From 3daa0d2fd31eec148aaf4e11b4872b3b466eb0ab Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 15 May 2019 18:25:27 +0200 Subject: [PATCH] Add types for tablesorter (#35488) * Add type-declarations for the tablesorter * Adjust types for readonly-arrays * Move the test-scripts to a separate directory * Add strict null-checks --- types/tablesorter/Design/CoreTheme.d.ts | 59 ++ types/tablesorter/Design/Theme.d.ts | 79 ++ types/tablesorter/Design/ThemeCollection.d.ts | 11 + types/tablesorter/Filtering/ColumnFilter.d.ts | 19 + types/tablesorter/Filtering/FilterBox.d.ts | 24 + .../Filtering/FilterEventHandler.d.ts | 9 + .../tablesorter/Filtering/FilterFunction.d.ts | 30 + .../Filtering/FilterFunctionCollection.d.ts | 11 + .../Filtering/FilterPlaceholders.d.ts | 11 + types/tablesorter/Filtering/FilterStatic.d.ts | 88 ++ .../Formatter/FilterControlFactory.d.ts | 20 + .../Filtering/Formatter/FilterFormatter.d.ts | 11 + .../Filtering/Formatter/Html5Formatter.d.ts | 60 ++ .../Formatter/Options/ComparableOptions.d.ts | 9 + .../Formatter/Options/ControlOptions.d.ts | 9 + .../Formatter/Options/DateOptions.d.ts | 9 + .../Options/DefaultValueOptions.d.ts | 9 + .../Formatter/Options/DelayableOptions.d.ts | 9 + .../Formatter/Options/Html5ColorOptions.d.ts | 15 + .../Formatter/Options/Html5NumberOptions.d.ts | 21 + .../Formatter/Options/Html5RangeOptions.d.ts | 21 + .../Formatter/Options/IntervalOptions.d.ts | 11 + .../Formatter/Options/NumericOptions.d.ts | 14 + .../Formatter/Options/PreviewableOptions.d.ts | 9 + .../Formatter/Options/RangeOptions.d.ts | 11 + .../Formatter/Options/Select2Options.d.ts | 13 + .../Formatter/Options/StrictOptions.d.ts | 9 + .../Formatter/Options/TestableOptions.d.ts | 9 + .../Formatter/Options/ToggleableOptions.d.ts | 14 + .../Options/UIDateCompareOptions.d.ts | 13 + .../Formatter/Options/UIDateRangeOptions.d.ts | 29 + .../Formatter/Options/UIOptionsBase.d.ts | 6 + .../Formatter/Options/UIRangeOptions.d.ts | 14 + .../Formatter/Options/UISliderOptions.d.ts | 23 + .../Formatter/Options/UISpinnerOptions.d.ts | 22 + .../Filtering/Formatter/Select2Formatter.d.ts | 24 + .../Filtering/Formatter/UIFormatter.d.ts | 96 ++ .../Filtering/FunctionSelectSource.d.ts | 20 + types/tablesorter/Filtering/MatchType.d.ts | 14 + .../Filtering/MatchTypeSettings.d.ts | 16 + types/tablesorter/Filtering/SelectSource.d.ts | 19 + .../tablesorter/Filtering/SelectSources.d.ts | 7 + .../Filtering/ValidSelectSources.d.ts | 6 + .../Globalization/GlobalizeSettings.d.ts | 17 + types/tablesorter/Omit.d.ts | 4 + .../tablesorter/Paging/AjaxDataProcessor.d.ts | 24 + .../tablesorter/Paging/AjaxErrorHandler.d.ts | 27 + .../tablesorter/Paging/AjaxUrlProcessor.d.ts | 18 + types/tablesorter/Paging/PageSize.d.ts | 4 + types/tablesorter/Paging/PagerClasses.d.ts | 19 + .../Paging/PagerConfiguration.d.ts | 184 ++++ .../Paging/PagerConfigurationStore.d.ts | 139 +++ types/tablesorter/Paging/PagerDataPart.d.ts | 46 + .../tablesorter/Paging/PagerEventHandler.d.ts | 19 + types/tablesorter/Paging/PagerEventMap.d.ts | 29 + .../tablesorter/Paging/PagerInitialRows.d.ts | 14 + types/tablesorter/Paging/PagerMemory.d.ts | 31 + .../Paging/PagerOutputProcessor.d.ts | 18 + types/tablesorter/Paging/PagerSelectors.d.ts | 46 + types/tablesorter/Parsing/ParsedCell.d.ts | 27 + types/tablesorter/Parsing/ParsedData.d.ts | 21 + types/tablesorter/Parsing/ParsedOption.d.ts | 14 + types/tablesorter/Parsing/Parser.d.ts | 46 + types/tablesorter/Parsing/ParserType.d.ts | 14 + types/tablesorter/Parsing/TextExtractor.d.ts | 18 + types/tablesorter/Sorting/EmptySorting.d.ts | 29 + types/tablesorter/Sorting/NumberSorter.d.ts | 27 + .../Sorting/RelativeSortDefinition.d.ts | 6 + .../tablesorter/Sorting/RelativeSorting.d.ts | 24 + types/tablesorter/Sorting/SortDefinition.d.ts | 6 + .../Sorting/SortDefinitionOrder.d.ts | 19 + types/tablesorter/Sorting/SortInitiator.d.ts | 29 + types/tablesorter/Sorting/SortOrder.d.ts | 14 + types/tablesorter/Sorting/StringSorting.d.ts | 29 + types/tablesorter/Sorting/TableSorting.d.ts | 27 + types/tablesorter/Sorting/TextSorter.d.ts | 30 + .../Storage/StorageConfiguration.d.ts | 31 + types/tablesorter/Storage/StorageType.d.ts | 19 + .../System/CommonEventHandler.d.ts | 14 + .../System/ConfigEventHandler.d.ts | 18 + types/tablesorter/System/ConfigEventMap.d.ts | 14 + types/tablesorter/System/EventMap.d.ts | 44 + .../System/HeaderResizeOptions.d.ts | 9 + .../System/InitializationEventHandler.d.ts | 12 + types/tablesorter/System/Locale.d.ts | 39 + types/tablesorter/System/MappedSettings.d.ts | 14 + .../System/ParameterlessTriggerNameMap.d.ts | 99 ++ .../System/RenderHeaderEventHandler.d.ts | 21 + .../System/RenderTemplateEventHandler.d.ts | 18 + .../tablesorter/System/TablesorterCache.d.ts | 14 + .../System/TablesorterConfigBase.d.ts | 16 + .../System/TablesorterConfiguration.d.ts | 384 ++++++++ .../System/TablesorterConfigurationStore.d.ts | 89 ++ .../System/TablesorterEventHandler.d.ts | 17 + .../System/TablesorterHeading.d.ts | 45 + .../System/TriggerCallbackHandler.d.ts | 9 + types/tablesorter/System/TriggerNameMap.d.ts | 104 ++ types/tablesorter/Tablesorter.d.ts | 654 +++++++++++++ .../Widgets/ColumnWidgetOptions.d.ts | 19 + types/tablesorter/Widgets/FilterOptions.d.ts | 174 ++++ types/tablesorter/Widgets/PagerOptions.d.ts | 146 +++ .../tablesorter/Widgets/ResizingOptions.d.ts | 34 + .../tablesorter/Widgets/SaveSortOptions.d.ts | 36 + .../Widgets/StickyHeaderOptions.d.ts | 61 ++ types/tablesorter/Widgets/Widget.d.ts | 73 ++ .../Widgets/WidgetOptionStore.d.ts | 26 + types/tablesorter/Widgets/WidgetOptions.d.ts | 21 + types/tablesorter/Widgets/ZebraOptions.d.ts | 9 + types/tablesorter/index.d.ts | 244 +++++ types/tablesorter/test/Events.ts | 66 ++ types/tablesorter/test/Methods.ts | 351 +++++++ types/tablesorter/test/Settings.ts | 910 ++++++++++++++++++ types/tablesorter/test/Triggers.ts | 118 +++ types/tablesorter/test/Variables.ts | 113 +++ types/tablesorter/test/main.ts | 19 + types/tablesorter/tsconfig.json | 29 + types/tablesorter/tslint.json | 1 + 117 files changed, 6086 insertions(+) create mode 100644 types/tablesorter/Design/CoreTheme.d.ts create mode 100644 types/tablesorter/Design/Theme.d.ts create mode 100644 types/tablesorter/Design/ThemeCollection.d.ts create mode 100644 types/tablesorter/Filtering/ColumnFilter.d.ts create mode 100644 types/tablesorter/Filtering/FilterBox.d.ts create mode 100644 types/tablesorter/Filtering/FilterEventHandler.d.ts create mode 100644 types/tablesorter/Filtering/FilterFunction.d.ts create mode 100644 types/tablesorter/Filtering/FilterFunctionCollection.d.ts create mode 100644 types/tablesorter/Filtering/FilterPlaceholders.d.ts create mode 100644 types/tablesorter/Filtering/FilterStatic.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/FilterControlFactory.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/FilterFormatter.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Html5Formatter.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/ComparableOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/ControlOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/DateOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/DefaultValueOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/DelayableOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/Html5ColorOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/Html5NumberOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/Html5RangeOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/IntervalOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/NumericOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/PreviewableOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/RangeOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/Select2Options.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/StrictOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/TestableOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/ToggleableOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/UIDateCompareOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/UIDateRangeOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/UIOptionsBase.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/UIRangeOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/UISliderOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Options/UISpinnerOptions.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/Select2Formatter.d.ts create mode 100644 types/tablesorter/Filtering/Formatter/UIFormatter.d.ts create mode 100644 types/tablesorter/Filtering/FunctionSelectSource.d.ts create mode 100644 types/tablesorter/Filtering/MatchType.d.ts create mode 100644 types/tablesorter/Filtering/MatchTypeSettings.d.ts create mode 100644 types/tablesorter/Filtering/SelectSource.d.ts create mode 100644 types/tablesorter/Filtering/SelectSources.d.ts create mode 100644 types/tablesorter/Filtering/ValidSelectSources.d.ts create mode 100644 types/tablesorter/Globalization/GlobalizeSettings.d.ts create mode 100644 types/tablesorter/Omit.d.ts create mode 100644 types/tablesorter/Paging/AjaxDataProcessor.d.ts create mode 100644 types/tablesorter/Paging/AjaxErrorHandler.d.ts create mode 100644 types/tablesorter/Paging/AjaxUrlProcessor.d.ts create mode 100644 types/tablesorter/Paging/PageSize.d.ts create mode 100644 types/tablesorter/Paging/PagerClasses.d.ts create mode 100644 types/tablesorter/Paging/PagerConfiguration.d.ts create mode 100644 types/tablesorter/Paging/PagerConfigurationStore.d.ts create mode 100644 types/tablesorter/Paging/PagerDataPart.d.ts create mode 100644 types/tablesorter/Paging/PagerEventHandler.d.ts create mode 100644 types/tablesorter/Paging/PagerEventMap.d.ts create mode 100644 types/tablesorter/Paging/PagerInitialRows.d.ts create mode 100644 types/tablesorter/Paging/PagerMemory.d.ts create mode 100644 types/tablesorter/Paging/PagerOutputProcessor.d.ts create mode 100644 types/tablesorter/Paging/PagerSelectors.d.ts create mode 100644 types/tablesorter/Parsing/ParsedCell.d.ts create mode 100644 types/tablesorter/Parsing/ParsedData.d.ts create mode 100644 types/tablesorter/Parsing/ParsedOption.d.ts create mode 100644 types/tablesorter/Parsing/Parser.d.ts create mode 100644 types/tablesorter/Parsing/ParserType.d.ts create mode 100644 types/tablesorter/Parsing/TextExtractor.d.ts create mode 100644 types/tablesorter/Sorting/EmptySorting.d.ts create mode 100644 types/tablesorter/Sorting/NumberSorter.d.ts create mode 100644 types/tablesorter/Sorting/RelativeSortDefinition.d.ts create mode 100644 types/tablesorter/Sorting/RelativeSorting.d.ts create mode 100644 types/tablesorter/Sorting/SortDefinition.d.ts create mode 100644 types/tablesorter/Sorting/SortDefinitionOrder.d.ts create mode 100644 types/tablesorter/Sorting/SortInitiator.d.ts create mode 100644 types/tablesorter/Sorting/SortOrder.d.ts create mode 100644 types/tablesorter/Sorting/StringSorting.d.ts create mode 100644 types/tablesorter/Sorting/TableSorting.d.ts create mode 100644 types/tablesorter/Sorting/TextSorter.d.ts create mode 100644 types/tablesorter/Storage/StorageConfiguration.d.ts create mode 100644 types/tablesorter/Storage/StorageType.d.ts create mode 100644 types/tablesorter/System/CommonEventHandler.d.ts create mode 100644 types/tablesorter/System/ConfigEventHandler.d.ts create mode 100644 types/tablesorter/System/ConfigEventMap.d.ts create mode 100644 types/tablesorter/System/EventMap.d.ts create mode 100644 types/tablesorter/System/HeaderResizeOptions.d.ts create mode 100644 types/tablesorter/System/InitializationEventHandler.d.ts create mode 100644 types/tablesorter/System/Locale.d.ts create mode 100644 types/tablesorter/System/MappedSettings.d.ts create mode 100644 types/tablesorter/System/ParameterlessTriggerNameMap.d.ts create mode 100644 types/tablesorter/System/RenderHeaderEventHandler.d.ts create mode 100644 types/tablesorter/System/RenderTemplateEventHandler.d.ts create mode 100644 types/tablesorter/System/TablesorterCache.d.ts create mode 100644 types/tablesorter/System/TablesorterConfigBase.d.ts create mode 100644 types/tablesorter/System/TablesorterConfiguration.d.ts create mode 100644 types/tablesorter/System/TablesorterConfigurationStore.d.ts create mode 100644 types/tablesorter/System/TablesorterEventHandler.d.ts create mode 100644 types/tablesorter/System/TablesorterHeading.d.ts create mode 100644 types/tablesorter/System/TriggerCallbackHandler.d.ts create mode 100644 types/tablesorter/System/TriggerNameMap.d.ts create mode 100644 types/tablesorter/Tablesorter.d.ts create mode 100644 types/tablesorter/Widgets/ColumnWidgetOptions.d.ts create mode 100644 types/tablesorter/Widgets/FilterOptions.d.ts create mode 100644 types/tablesorter/Widgets/PagerOptions.d.ts create mode 100644 types/tablesorter/Widgets/ResizingOptions.d.ts create mode 100644 types/tablesorter/Widgets/SaveSortOptions.d.ts create mode 100644 types/tablesorter/Widgets/StickyHeaderOptions.d.ts create mode 100644 types/tablesorter/Widgets/Widget.d.ts create mode 100644 types/tablesorter/Widgets/WidgetOptionStore.d.ts create mode 100644 types/tablesorter/Widgets/WidgetOptions.d.ts create mode 100644 types/tablesorter/Widgets/ZebraOptions.d.ts create mode 100644 types/tablesorter/index.d.ts create mode 100644 types/tablesorter/test/Events.ts create mode 100644 types/tablesorter/test/Methods.ts create mode 100644 types/tablesorter/test/Settings.ts create mode 100644 types/tablesorter/test/Triggers.ts create mode 100644 types/tablesorter/test/Variables.ts create mode 100644 types/tablesorter/test/main.ts create mode 100644 types/tablesorter/tsconfig.json create mode 100644 types/tablesorter/tslint.json diff --git a/types/tablesorter/Design/CoreTheme.d.ts b/types/tablesorter/Design/CoreTheme.d.ts new file mode 100644 index 0000000000..9040b2fa52 --- /dev/null +++ b/types/tablesorter/Design/CoreTheme.d.ts @@ -0,0 +1,59 @@ +/** + * Defines a theme. + */ +export enum CoreTheme { + /** + * Indicates the `Default`-theme. + */ + Default = "default", + + /** + * Indicates the `Bootstrap`-theme. + */ + Bootstrap = "bootstrap", + + /** + * Indicates the `Dropbox`-theme. + */ + Dropbox = "dropbox", + + /** + * Indicates the `jQuery UI`-theme. + */ + JUI = "jui", + + /** + * Indicates the `Metro Dark`-theme. + */ + MetroDark = "metro-dark", + + /** + * Indicates the `Blackice`-theme. + */ + Blackice = "blackice", + + /** + * Indicates the `Blue`-theme. + */ + Blue = "blue", + + /** + * Indicates the `Dark`-theme. + */ + Dark = "dark", + + /** + * Indicates the `Green`-theme. + */ + Green = "green", + + /** + * Indicates the `Grey`-theme. + */ + Grey = "grey", + + /** + * Indicates the `Ice`-theme. + */ + Ice = "ice" +} diff --git a/types/tablesorter/Design/Theme.d.ts b/types/tablesorter/Design/Theme.d.ts new file mode 100644 index 0000000000..50d3dfb4a6 --- /dev/null +++ b/types/tablesorter/Design/Theme.d.ts @@ -0,0 +1,79 @@ +/** + * Represents a theme. + */ +export class Theme { + /** + * A set of classes to apply to the table. + */ + table: string; + + /** + * A set of classes to apply to the caption. + */ + caption: string; + + /** + * A set of classes to apply to the header. + */ + header: string; + + /** + * A set of classes to apply to unsorted headers. + */ + sortNone: string; + + /** + * A set of classes to apply to ascending sorted headers. + */ + sortAsc: string; + + /** + * A set of classes to apply to descending sorted headers. + */ + sortDesc: string; + + /** + * A set of classes to apply to cells inside the active column. + */ + active: string; + + /** + * A set of classes to apply to hovered cells. + */ + hover: string; + + /** + * A set of classes to apply to icons. + */ + icons: string; + + /** + * A set of classes to apply to icons for unsorted headers. + */ + iconSortNone: string; + + /** + * A set of classes to apply to icons for ascending sorted headers. + */ + iconSortAsc: string; + + /** + * A set of classes to apply to icons for descending sorted headers. + */ + iconSortDesc: string; + + /** + * A set of classes to apply to the filter-row. + */ + filterRow: string; + + /** + * A set of classes to apply to even rows. + */ + even: string; + + /** + * A set of classes to apply to odd rows. + */ + odd: string; +} diff --git a/types/tablesorter/Design/ThemeCollection.d.ts b/types/tablesorter/Design/ThemeCollection.d.ts new file mode 100644 index 0000000000..5460ae70c8 --- /dev/null +++ b/types/tablesorter/Design/ThemeCollection.d.ts @@ -0,0 +1,11 @@ +import { Theme } from "./Theme"; + +/** + * Represents a collection of themes. + */ +export interface ThemeCollection { + /** + * The name of the theme and the `Theme` itself. + */ + [themeName: string]: Theme; +} diff --git a/types/tablesorter/Filtering/ColumnFilter.d.ts b/types/tablesorter/Filtering/ColumnFilter.d.ts new file mode 100644 index 0000000000..90ba1f4062 --- /dev/null +++ b/types/tablesorter/Filtering/ColumnFilter.d.ts @@ -0,0 +1,19 @@ +/** + * Defines a concept for filtering. + */ +export enum ColumnFilter { + /** + * Indicates disabled filtering. + */ + None = "false", + + /** + * Indicates filtering on parsed data. + */ + Parsed = "parsed", + + /** + * Indicates filtering on raw data. + */ + Default = "default" +} diff --git a/types/tablesorter/Filtering/FilterBox.d.ts b/types/tablesorter/Filtering/FilterBox.d.ts new file mode 100644 index 0000000000..d92d09c678 --- /dev/null +++ b/types/tablesorter/Filtering/FilterBox.d.ts @@ -0,0 +1,24 @@ +/** + * Represents a filter-box. + */ +export enum FilterBox { + /** + * Indicates an ordinary text-box. + */ + TextBox = "search", + + /** + * Indicates a dropdown. + */ + Dropdown = "select", + + /** + * Indicates the textbox for the start of a date-range. + */ + DateFrom = "from", + + /** + * Indicates the textbox for the end of a date-range. + */ + DateTo = "to" +} diff --git a/types/tablesorter/Filtering/FilterEventHandler.d.ts b/types/tablesorter/Filtering/FilterEventHandler.d.ts new file mode 100644 index 0000000000..ea50c445aa --- /dev/null +++ b/types/tablesorter/Filtering/FilterEventHandler.d.ts @@ -0,0 +1,9 @@ +/** + * Provides the functionality to handle filtering-events of the `tablesorter`. + */ +export interface FilterEventHandler { + /** + * Handles filtering-events of the `tablesorter`. + */ + (eventArgs: JQuery.TriggeredEvent, filters: string[]): void; +} diff --git a/types/tablesorter/Filtering/FilterFunction.d.ts b/types/tablesorter/Filtering/FilterFunction.d.ts new file mode 100644 index 0000000000..781966aae5 --- /dev/null +++ b/types/tablesorter/Filtering/FilterFunction.d.ts @@ -0,0 +1,30 @@ +import "jquery"; +import { TablesorterConfigurationStore } from "../System/TablesorterConfigurationStore"; + +/** + * Represents a function for filtering. + */ +export interface FilterFunction { + /** + * A function for determining whether to include a row. + * + * @param originalContent + * The original content of the cell. + * + * @param normalizedText + * The normalized content of the cell. + * + * @param filterInput + * The currently applied filter. + * + * @param index + * The index of the column. + * + * @param row + * The row of the cell being filtered. + * + * @return + * A value indicating whether the row should be included. + */ + (originalContent: string, normalizedText: string, filterInput: string, index: number, row: JQuery, config: TablesorterConfigurationStore, data: object): boolean; +} diff --git a/types/tablesorter/Filtering/FilterFunctionCollection.d.ts b/types/tablesorter/Filtering/FilterFunctionCollection.d.ts new file mode 100644 index 0000000000..c3dd6a4ed4 --- /dev/null +++ b/types/tablesorter/Filtering/FilterFunctionCollection.d.ts @@ -0,0 +1,11 @@ +import { FilterFunction } from "./FilterFunction"; + +/** + * A collection of filter-functions. + */ +export interface FilterFunctionCollection { + /** + * The display-name of the filter-function and the `FilterFunction` itself. + */ + [displayName: string]: FilterFunction | true; +} diff --git a/types/tablesorter/Filtering/FilterPlaceholders.d.ts b/types/tablesorter/Filtering/FilterPlaceholders.d.ts new file mode 100644 index 0000000000..1db712d10f --- /dev/null +++ b/types/tablesorter/Filtering/FilterPlaceholders.d.ts @@ -0,0 +1,11 @@ +import { FilterBox } from "./FilterBox"; + +/** + * Provides place-holders for different kinds of filter-boxes. + */ +export type FilterPlaceholders = { + /** + * A filter-box and the placeholder to apply. + */ + [name in FilterBox]?: string; +}; diff --git a/types/tablesorter/Filtering/FilterStatic.d.ts b/types/tablesorter/Filtering/FilterStatic.d.ts new file mode 100644 index 0000000000..06dfe83429 --- /dev/null +++ b/types/tablesorter/Filtering/FilterStatic.d.ts @@ -0,0 +1,88 @@ +import "jquery"; +import { ParsedOption } from "../Parsing/ParsedOption"; + +/** + * Represents the static instance of the `filter`-widget. + */ +export interface FilterStatic { + /** + * Adds new controls to the tablesorter as external search-filters. + * + * @param table + * The table to add the external search to. + * @param controls + * The controls to bind as external search-controls. + * + * @param forceStart + * A value indicating whether a new search should be performed after adding the controls. + */ + bindSearch(table: JQuery | TElement, controls: JQuery, forceStart: boolean): void; + + /** + * Updates a select-control. + * + * @param table + * The table to build the selec-control for. + * + * @param column + * The index of the column to build the select-control for. + * + * @param options + * The options to display in the select-control. + * + * @param replace + * A value indicating whether to replace the current options with the new options. + * + * @param visibleOnly + * A value indicating whether the new options should only include visible row-values if no `options` are defined. + */ + buildSelect(table: JQuery | TElement, column: number, options: ReadonlyArray | string | JQuery, replace: boolean, visibleOnly?: boolean): void; + + /** + * Gets all available column-values of a column. + * + * @param table + * The table to get the options from. + * + * @param column + * The index of the column to get the options from. + * + * @param visibleOnly + * A value indicating whether only visible column-values should be included. + * + * @return + * The values which appear in the column. + */ + getOptionSource(table: JQuery | TElement, column: number, visibleOnly?: boolean): ParsedOption[]; + + /** + * Gets all available column-values of a column. + * + * @param table + * The table to get the options from. + * + * @param column + * The index of the column to get the options from. + * + * @param visibleOnly + * A value indicating whether only visible column-values should be included. + * + * @return + * The values which appear in the column. + */ + getOptions(table: JQuery | TElement, column: number, visibleOnly?: boolean): string[]; + + /** + * Processes and sorts the options according to the options of the specified `column`. + * + * @param table + * The table to process the options for. + * + * @param column + * The column to add the options to. + * + * @param options + * The options to add. + */ + processOptions(table: JQuery | TElement, column: number | null | undefined, options: ReadonlyArray): string[]; +} diff --git a/types/tablesorter/Filtering/Formatter/FilterControlFactory.d.ts b/types/tablesorter/Filtering/Formatter/FilterControlFactory.d.ts new file mode 100644 index 0000000000..bb266ff6aa --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/FilterControlFactory.d.ts @@ -0,0 +1,20 @@ +import "jquery"; + +/** + * Provides the functionality to create filter-controls. + */ +export interface FilterControlFactory { + /** + * Creates a filter-control. + * + * @param cell + * The cell to add the filter to. + * + * @param index + * The index of the cell. + * + * @return + * The jQuery-object of the control. + */ + (cell: JQuery, index: number): JQuery; +} diff --git a/types/tablesorter/Filtering/Formatter/FilterFormatter.d.ts b/types/tablesorter/Filtering/Formatter/FilterFormatter.d.ts new file mode 100644 index 0000000000..f7b262c434 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/FilterFormatter.d.ts @@ -0,0 +1,11 @@ +import { Html5Formatter } from "./Html5Formatter"; +import { UIFormatter } from "./UIFormatter"; +import { Select2Formatter } from "./Select2Formatter"; + +/** + * Provides the functionality to generate filter-controls. + */ +export interface FilterFormatter extends + Html5Formatter, + UIFormatter, + Select2Formatter { } diff --git a/types/tablesorter/Filtering/Formatter/Html5Formatter.d.ts b/types/tablesorter/Filtering/Formatter/Html5Formatter.d.ts new file mode 100644 index 0000000000..e55a7188f3 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Html5Formatter.d.ts @@ -0,0 +1,60 @@ +import "jquery"; +import { Html5ColorOptions } from "./Options/Html5ColorOptions"; +import { Html5NumberOptions } from "./Options/Html5NumberOptions"; +import { Html5RangeOptions } from "./Options/Html5RangeOptions"; + +/** + * Provides the functionality to generate html5-controls. + */ +export interface Html5Formatter { + /** + * Creates an html5 number-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + html5Number(cell: JQuery, index: number, options?: Html5NumberOptions): JQuery; + + /** + * Creates an html5 range-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + html5Range(cell: JQuery, index: number, options?: Html5RangeOptions): JQuery; + + /** + * Creates an html5 color-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + html5Color(cell: JQuery, index: number, options?: Html5ColorOptions): JQuery; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/ComparableOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/ComparableOptions.d.ts new file mode 100644 index 0000000000..37bbfa76a9 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/ComparableOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for comparable controls. + */ +export interface ComparableOptions { + /** + * The compare-operators supported by the control. + */ + compare?: string | string[]; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/ControlOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/ControlOptions.d.ts new file mode 100644 index 0000000000..b8c5dcadea --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/ControlOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for filter-controls. + */ +export interface ControlOptions { + /** + * The label of the control. + */ + cellText?: string; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/DateOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/DateOptions.d.ts new file mode 100644 index 0000000000..aecb60112f --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/DateOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for date-related controls. + */ +export interface DateOptions { + /** + * A value indicating whether the filter's time-value should be set to the end of the day. + */ + endOfDay?: boolean; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/DefaultValueOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/DefaultValueOptions.d.ts new file mode 100644 index 0000000000..532e03e310 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/DefaultValueOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for a control which has a default value. + */ +export interface DefaultValueOptions { + /** + * The default value of the control. + */ + value?: T; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/DelayableOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/DelayableOptions.d.ts new file mode 100644 index 0000000000..06ac1522e9 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/DelayableOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for delayable controls. + */ +export interface DelayableOptions { + /** + * A value indicating whether the value of the filter should be set delayed. + */ + delayed?: boolean; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/Html5ColorOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/Html5ColorOptions.d.ts new file mode 100644 index 0000000000..849ef86e7e --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/Html5ColorOptions.d.ts @@ -0,0 +1,15 @@ +import { DefaultValueOptions } from "./DefaultValueOptions"; +import { PreviewableOptions } from "./PreviewableOptions"; +import { StrictOptions } from "./StrictOptions"; +import { TestableOptions } from "./TestableOptions"; +import { ToggleableOptions } from "./ToggleableOptions"; + +/** + * Provides options for the html5 color control. + */ +export interface Html5ColorOptions extends + DefaultValueOptions, + ToggleableOptions, + StrictOptions, + PreviewableOptions, + TestableOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Options/Html5NumberOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/Html5NumberOptions.d.ts new file mode 100644 index 0000000000..8a2714980a --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/Html5NumberOptions.d.ts @@ -0,0 +1,21 @@ +import { ControlOptions } from "./ControlOptions"; +import { ComparableOptions } from "./ComparableOptions"; +import { DefaultValueOptions } from "./DefaultValueOptions"; +import { DelayableOptions } from "./DelayableOptions"; +import { IntervalOptions } from "./IntervalOptions"; +import { StrictOptions } from "./StrictOptions"; +import { TestableOptions } from "./TestableOptions"; +import { ToggleableOptions } from "./ToggleableOptions"; + +/** + * Provides options for the html5 number control. + */ +export interface Html5NumberOptions extends + IntervalOptions, + ControlOptions, + DefaultValueOptions, + ComparableOptions, + ToggleableOptions, + DelayableOptions, + StrictOptions, + TestableOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Options/Html5RangeOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/Html5RangeOptions.d.ts new file mode 100644 index 0000000000..9692b75490 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/Html5RangeOptions.d.ts @@ -0,0 +1,21 @@ +import { ComparableOptions } from "./ComparableOptions"; +import { ControlOptions } from "./ControlOptions"; +import { DefaultValueOptions } from "./DefaultValueOptions"; +import { DelayableOptions } from "./DelayableOptions"; +import { PreviewableOptions } from "./PreviewableOptions"; +import { RangeOptions } from "./RangeOptions"; +import { StrictOptions } from "./StrictOptions"; +import { TestableOptions } from "./TestableOptions"; + +/** + * Provides options for the html5 range control. + */ +export interface Html5RangeOptions extends + RangeOptions, + ControlOptions, + DefaultValueOptions, + ComparableOptions, + StrictOptions, + PreviewableOptions, + DelayableOptions, + TestableOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Options/IntervalOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/IntervalOptions.d.ts new file mode 100644 index 0000000000..02723edb28 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/IntervalOptions.d.ts @@ -0,0 +1,11 @@ +import { NumericOptions } from "./NumericOptions"; + +/** + * Provides options for interval filter-controls. + */ +export interface IntervalOptions extends NumericOptions { + /** + * The interval of the control. + */ + step?: number; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/NumericOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/NumericOptions.d.ts new file mode 100644 index 0000000000..a0b681aefb --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/NumericOptions.d.ts @@ -0,0 +1,14 @@ +/** + * Provides settings for numeric controls. + */ +export interface NumericOptions { + /** + * The minimum value of the control. + */ + min?: number; + + /** + * The maximum value of the control. + */ + max?: number; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/PreviewableOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/PreviewableOptions.d.ts new file mode 100644 index 0000000000..73ef6cd48b --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/PreviewableOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for previewable controls. + */ +export interface PreviewableOptions { + /** + * A value indicating whether the value should be visible in the table header. + */ + valueToHeader?: boolean; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/RangeOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/RangeOptions.d.ts new file mode 100644 index 0000000000..3bd3317b4e --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/RangeOptions.d.ts @@ -0,0 +1,11 @@ +import { IntervalOptions } from "./IntervalOptions"; + +/** + * Provides options for range-controls. + */ +export interface RangeOptions extends IntervalOptions { + /** + * The text indicating the whole range. + */ + allText?: string; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/Select2Options.d.ts b/types/tablesorter/Filtering/Formatter/Options/Select2Options.d.ts new file mode 100644 index 0000000000..ebf86bb44b --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/Select2Options.d.ts @@ -0,0 +1,13 @@ +import { Options } from "select2"; +import { ControlOptions } from "./ControlOptions"; +import { DefaultValueOptions } from "./DefaultValueOptions"; +import { StrictOptions } from "./StrictOptions"; + +/** + * Provides options for the select2-control. + */ +export interface Select2Options extends + Options, + ControlOptions, + StrictOptions, + DefaultValueOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Options/StrictOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/StrictOptions.d.ts new file mode 100644 index 0000000000..920ed7969a --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/StrictOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for strict filter-controls. + */ +export interface StrictOptions { + /** + * A value indicatin whether only exact matching values should be included. + */ + exactMatch?: boolean; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/TestableOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/TestableOptions.d.ts new file mode 100644 index 0000000000..a1522023d7 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/TestableOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides settings for testable filter-controls. + */ +export interface TestableOptions { + /** + * A value indicating whether tests should be skipped. + */ + skipTest?: boolean; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/ToggleableOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/ToggleableOptions.d.ts new file mode 100644 index 0000000000..6c9a252ab0 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/ToggleableOptions.d.ts @@ -0,0 +1,14 @@ +/** + * Provides options for toggleable controls. + */ +export interface ToggleableOptions { + /** + * A value indicating whether the control is initially disabled. + */ + disabled?: boolean; + + /** + * A value indicating whether to add a box for enabling/disabling the control. + */ + addToggle?: boolean; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/UIDateCompareOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/UIDateCompareOptions.d.ts new file mode 100644 index 0000000000..a51f391212 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/UIDateCompareOptions.d.ts @@ -0,0 +1,13 @@ +import "jqueryui"; +import { ControlOptions } from "./ControlOptions"; +import { ComparableOptions } from "./ComparableOptions"; +import { DateOptions } from "./DateOptions"; + +/** + * Provides options for the date-comparsion control. + */ +export interface UIDateCompareOptions extends + JQueryUI.DatepickerOptions, + DateOptions, + ControlOptions, + ComparableOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Options/UIDateRangeOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/UIDateRangeOptions.d.ts new file mode 100644 index 0000000000..ece2791db9 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/UIDateRangeOptions.d.ts @@ -0,0 +1,29 @@ +import "jqueryui"; +import { DateOptions } from "./DateOptions"; + +/** + * Provides settings for the date-range control. + */ +export interface UIDateRangeOptions extends + JQueryUI.DatepickerOptions, + DateOptions { + /** + * The label of the "from"-input. + */ + textFrom?: string; + + /** + * The label of the "to"-input. + */ + textTo?: string; + + /** + * The default `from`-value. + */ + from?: Date; + + /** + * The default `to`-value. + */ + to?: Date; +} diff --git a/types/tablesorter/Filtering/Formatter/Options/UIOptionsBase.d.ts b/types/tablesorter/Filtering/Formatter/Options/UIOptionsBase.d.ts new file mode 100644 index 0000000000..cfa5e37201 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/UIOptionsBase.d.ts @@ -0,0 +1,6 @@ +import { Omit } from "../../../Omit"; + +/** + * Provides a base for ui-options. + */ +export type UIOptionsBase = Omit; diff --git a/types/tablesorter/Filtering/Formatter/Options/UIRangeOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/UIRangeOptions.d.ts new file mode 100644 index 0000000000..5f15957b9b --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/UIRangeOptions.d.ts @@ -0,0 +1,14 @@ +import { NumericOptions } from "./NumericOptions"; +import { DelayableOptions } from "./DelayableOptions"; +import { PreviewableOptions } from "./PreviewableOptions"; +import { Omit } from "../../../Omit"; +import { UIOptionsBase } from "./UIOptionsBase"; + +/** + * Provides options for the ui-range control. + */ +export interface UIRangeOptions extends + Omit, "value">, + NumericOptions, + DelayableOptions, + PreviewableOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Options/UISliderOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/UISliderOptions.d.ts new file mode 100644 index 0000000000..ecc74b3afe --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/UISliderOptions.d.ts @@ -0,0 +1,23 @@ +import "jqueryui"; +import { ComparableOptions } from "./ComparableOptions"; +import { ControlOptions } from "./ControlOptions"; +import { DefaultValueOptions } from "./DefaultValueOptions"; +import { DelayableOptions } from "./DelayableOptions"; +import { PreviewableOptions } from "./PreviewableOptions"; +import { RangeOptions } from "./RangeOptions"; +import { StrictOptions } from "./StrictOptions"; +import { UIOptionsBase } from "./UIOptionsBase"; +import { Omit } from "../../../Omit"; + +/** + * Provides options for the ui-slider control. + */ +export interface UISliderOptions extends + Omit, "values">, + RangeOptions, + ControlOptions, + DefaultValueOptions, + ComparableOptions, + PreviewableOptions, + DelayableOptions, + StrictOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Options/UISpinnerOptions.d.ts b/types/tablesorter/Filtering/Formatter/Options/UISpinnerOptions.d.ts new file mode 100644 index 0000000000..8b81d3b0a4 --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Options/UISpinnerOptions.d.ts @@ -0,0 +1,22 @@ +import "jqueryui"; +import { ComparableOptions } from "./ComparableOptions"; +import { ControlOptions } from "./ControlOptions"; +import { DefaultValueOptions } from "./DefaultValueOptions"; +import { DelayableOptions } from "./DelayableOptions"; +import { IntervalOptions } from "./IntervalOptions"; +import { StrictOptions } from "./StrictOptions"; +import { ToggleableOptions } from "./ToggleableOptions"; +import { UIOptionsBase } from "./UIOptionsBase"; + +/** + * Provides options for the ui-slider control. + */ +export interface UISpinnerOptions extends + UIOptionsBase, + IntervalOptions, + ControlOptions, + DefaultValueOptions, + ToggleableOptions, + ComparableOptions, + DelayableOptions, + StrictOptions { } diff --git a/types/tablesorter/Filtering/Formatter/Select2Formatter.d.ts b/types/tablesorter/Filtering/Formatter/Select2Formatter.d.ts new file mode 100644 index 0000000000..9c5799704d --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/Select2Formatter.d.ts @@ -0,0 +1,24 @@ +import "jquery"; +import { Select2Options } from "./Options/Select2Options"; + +/** + * Provides the functionality to generate select2-controls. + */ +export interface Select2Formatter { + /** + * Creates a select2-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + select2(cell: JQuery, index: number, options?: Select2Options): JQuery; +} diff --git a/types/tablesorter/Filtering/Formatter/UIFormatter.d.ts b/types/tablesorter/Filtering/Formatter/UIFormatter.d.ts new file mode 100644 index 0000000000..cd0d80512e --- /dev/null +++ b/types/tablesorter/Filtering/Formatter/UIFormatter.d.ts @@ -0,0 +1,96 @@ +import "jquery"; +import { UIDateCompareOptions } from "./Options/UIDateCompareOptions"; +import { UIDateRangeOptions } from "./Options/UIDateRangeOptions"; +import { UIRangeOptions } from "./Options/UIRangeOptions"; +import { UISliderOptions } from "./Options/UISliderOptions"; +import { UISpinnerOptions } from "./Options/UISpinnerOptions"; + +/** + * Provides the functionality to generate html5-controls. + */ +export interface UIFormatter { + /** + * Creates a jQueryUI spinner-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + uiSpinner(cell: JQuery, index: number, options?: UISpinnerOptions): JQuery; + + /** + * Creates a jQueryUI slider-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + uiSlider(cell: JQuery, index: number, options?: UISliderOptions): JQuery; + + /** + * Creates a jQueryUI range-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + uiRange(cell: JQuery, index: number, options?: UIRangeOptions): JQuery; + + /** + * Creates a jQueryUI date-comparsion control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + uiDateCompare(cell: JQuery, index: number, options?: UIDateCompareOptions): JQuery; + + /** + * Creates a jQueryUI datepicker-control. + * + * @param cell + * The jQuery-object of the cell the control is added to. + * + * @param index + * The column-index of the cell the control is added to. + * + * @param options + * The options for the control-creation. + * + * @return + * The jQuery-object of the created control. + */ + uiDatepicker(cell: JQuery, index: number, options?: UIDateRangeOptions): JQuery; +} diff --git a/types/tablesorter/Filtering/FunctionSelectSource.d.ts b/types/tablesorter/Filtering/FunctionSelectSource.d.ts new file mode 100644 index 0000000000..1e4def1c3c --- /dev/null +++ b/types/tablesorter/Filtering/FunctionSelectSource.d.ts @@ -0,0 +1,20 @@ +import { ValidSelectSources } from "./ValidSelectSources"; + +/** + * Represents a function for generating select-sources. + */ +export interface FunctionSelectSource { + /** + * Generates a set of select-sources. + * + * @param table + * The table which is being filtered. + * + * @param index + * The index of the column to filter. + * + * @param onlyAvail + * A value indicating whether only visible rows should be displayed. + */ + (table: TElement, index: number, onlyAvail: boolean): ValidSelectSources; +} diff --git a/types/tablesorter/Filtering/MatchType.d.ts b/types/tablesorter/Filtering/MatchType.d.ts new file mode 100644 index 0000000000..69047da96c --- /dev/null +++ b/types/tablesorter/Filtering/MatchType.d.ts @@ -0,0 +1,14 @@ +/** + * Represents a match-type. + */ +export enum MatchType { + /** + * Indicates an exact match. + */ + Exact = "exact", + + /** + * Indicates a wildcard-match. + */ + Wildcard = "match" +} diff --git a/types/tablesorter/Filtering/MatchTypeSettings.d.ts b/types/tablesorter/Filtering/MatchTypeSettings.d.ts new file mode 100644 index 0000000000..1b179e463e --- /dev/null +++ b/types/tablesorter/Filtering/MatchTypeSettings.d.ts @@ -0,0 +1,16 @@ +import { MatchType } from "./MatchType"; + +/** + * Provides match-type settings. + */ +export interface MatchTypeSettings { + /** + * The match-type for `input`-controls. + */ + input?: MatchType; + + /** + * The match-type for `select`-controls. + */ + select?: MatchType; +} diff --git a/types/tablesorter/Filtering/SelectSource.d.ts b/types/tablesorter/Filtering/SelectSource.d.ts new file mode 100644 index 0000000000..5e1e664fc8 --- /dev/null +++ b/types/tablesorter/Filtering/SelectSource.d.ts @@ -0,0 +1,19 @@ +/** + * Represents a filter-source. + */ +export interface SelectSource { + /** + * The display-name of the filter source. + */ + text: string; + + /** + * The filter-value. + */ + value?: string; + + /** + * Classes to add to the dropdown-entries. + */ + "data-class"?: string; +} diff --git a/types/tablesorter/Filtering/SelectSources.d.ts b/types/tablesorter/Filtering/SelectSources.d.ts new file mode 100644 index 0000000000..a16b72a871 --- /dev/null +++ b/types/tablesorter/Filtering/SelectSources.d.ts @@ -0,0 +1,7 @@ +import { FunctionSelectSource } from "./FunctionSelectSource"; +import { ValidSelectSources } from "./ValidSelectSources"; + +/** + * Represents types for specifying select-sources. + */ +export type SelectSources = FunctionSelectSource | ValidSelectSources; diff --git a/types/tablesorter/Filtering/ValidSelectSources.d.ts b/types/tablesorter/Filtering/ValidSelectSources.d.ts new file mode 100644 index 0000000000..16c9a92275 --- /dev/null +++ b/types/tablesorter/Filtering/ValidSelectSources.d.ts @@ -0,0 +1,6 @@ +import { SelectSource } from "./SelectSource"; + +/** + * Represents a valid select-source. + */ +export type ValidSelectSources = string | null | Array; diff --git a/types/tablesorter/Globalization/GlobalizeSettings.d.ts b/types/tablesorter/Globalization/GlobalizeSettings.d.ts new file mode 100644 index 0000000000..c90f08de72 --- /dev/null +++ b/types/tablesorter/Globalization/GlobalizeSettings.d.ts @@ -0,0 +1,17 @@ +import Globalize = require("globalize"); +import { DateFormatterOptions } from "globalize"; + +/** + * Provides settings for `Globalize`. + */ +export interface GlobalizeSettings extends DateFormatterOptions { + /** + * The language to localize the dates to. + */ + lang: string; + + /** + * The `Globalize`-object to use for localization. + */ + Globalize: Globalize; +} diff --git a/types/tablesorter/Omit.d.ts b/types/tablesorter/Omit.d.ts new file mode 100644 index 0000000000..4cfea35495 --- /dev/null +++ b/types/tablesorter/Omit.d.ts @@ -0,0 +1,4 @@ +/** + * Exclude all keys `K` from type `T`. + */ +export type Omit = Pick>; diff --git a/types/tablesorter/Paging/AjaxDataProcessor.d.ts b/types/tablesorter/Paging/AjaxDataProcessor.d.ts new file mode 100644 index 0000000000..677cb499af --- /dev/null +++ b/types/tablesorter/Paging/AjaxDataProcessor.d.ts @@ -0,0 +1,24 @@ +import "jquery"; +import { PagerDataPart } from "./PagerDataPart"; + +/** + * Provides the functionality to process data for the `pager`-widget. + */ +export interface AjaxDataProcessor { + /** + * Processes the ajax-result for the `pager`-widget. + * + * @param data + * The result of ajax. + * + * @param table + * The table which is being processed. + * + * @param request + * The ajax-request which processed the `data`. + * + * @return + * The data for the pager to show. + */ + (data: any, table: TElement, request: JQuery.jqXHR): PagerDataPart | [number] | [number, JQuery | any[][], string[]?]; +} diff --git a/types/tablesorter/Paging/AjaxErrorHandler.d.ts b/types/tablesorter/Paging/AjaxErrorHandler.d.ts new file mode 100644 index 0000000000..5464730b5f --- /dev/null +++ b/types/tablesorter/Paging/AjaxErrorHandler.d.ts @@ -0,0 +1,27 @@ +import "jquery"; +import { TablesorterConfigurationStore } from "../System/TablesorterConfigurationStore"; + +/** + * Provides the functionality to handle errors caused by `ajax`. + */ +export interface AjaxErrorHandler { + /** + * Handles errors caused by an ajax-request. + * + * @param config + * The configuration of the `tablesorter`. + * + * @param request + * The request which caused an error. + * + * @param ajaxSettings + * The settings for the request. + * + * @param thrownError + * The error which occurred. + * + * @return + * The error-message to display in the table-head. + */ + (config: TablesorterConfigurationStore, request: JQuery.jqXHR, ajaxSettings: JQuery.AjaxSettings, thrownError: string): string; +} diff --git a/types/tablesorter/Paging/AjaxUrlProcessor.d.ts b/types/tablesorter/Paging/AjaxUrlProcessor.d.ts new file mode 100644 index 0000000000..5cf8da9939 --- /dev/null +++ b/types/tablesorter/Paging/AjaxUrlProcessor.d.ts @@ -0,0 +1,18 @@ +/** + * Provides the functionality to customize the url for querying a page. + */ +export interface AjaxUrlProcessor { + /** + * Processes the url for `ajax` to query data. + * + * @param table + * The table to process data for. + * + * @param url + * The formatted url to query data from. + * + * @return + * The manipulated url to query data from. + */ + (table: TElement, url: string): string; +} diff --git a/types/tablesorter/Paging/PageSize.d.ts b/types/tablesorter/Paging/PageSize.d.ts new file mode 100644 index 0000000000..729a12323f --- /dev/null +++ b/types/tablesorter/Paging/PageSize.d.ts @@ -0,0 +1,4 @@ +/** + * Represents a page-size. + */ +export type PageSize = number | "all"; diff --git a/types/tablesorter/Paging/PagerClasses.d.ts b/types/tablesorter/Paging/PagerClasses.d.ts new file mode 100644 index 0000000000..51fdcf6d53 --- /dev/null +++ b/types/tablesorter/Paging/PagerClasses.d.ts @@ -0,0 +1,19 @@ +/** + * Provides css-classes to apply to pager-controls. + */ +export interface PagerClasses { + /** + * A set of css-classes to apply to the container. + */ + container?: string; + + /** + * The css-class to apply to disabled pager-controls. + */ + disabled?: string; + + /** + * The css-class to apply to the table-row which displays the error-message in case of an ajax-error. + */ + errorRow?: string; +} diff --git a/types/tablesorter/Paging/PagerConfiguration.d.ts b/types/tablesorter/Paging/PagerConfiguration.d.ts new file mode 100644 index 0000000000..acefd17f55 --- /dev/null +++ b/types/tablesorter/Paging/PagerConfiguration.d.ts @@ -0,0 +1,184 @@ +import "jquery"; +import { AjaxDataProcessor } from "./AjaxDataProcessor"; +import { AjaxErrorHandler } from "./AjaxErrorHandler"; +import { AjaxUrlProcessor } from "./AjaxUrlProcessor"; +import { PagerInitialRows } from "./PagerInitialRows"; +import { PagerOutputProcessor } from "./PagerOutputProcessor"; +import { PageSize } from "./PageSize"; + +/** + * Provides options for the pager. + */ +export interface PagerConfiguration { + /** + * The url to query data from. + * + * Following portions of text are substituted: + * + * | Tag | Replacement | + * |----------------------------------------|------------------------------------------------------------------------| + * | `{page}` | The zero-based index of the page to show. | + * | `{page+n}` | The zero-based index of the page added to `n`. | + * | `{size}` | The number of rows to fetch. | + * | `{sortList:name}` or `{sort:name}` | A GET-variable called `name` containing the current sorting. | + * | `{filterList:name}` or `{filter:name}` | A GET-variable called `name` containing all currently applied filters. | + */ + ajaxUrl?: string; + + /** + * Pre-processes the url for `ajax`. + */ + customAjaxUrl?: AjaxUrlProcessor; + + /** + * The settings for the api-interaction of the pager. + */ + ajaxObject?: JQueryAjaxSettings; + + /** + * Handles errors caused by an ajax-request. + */ + ajaxError?: AjaxErrorHandler; + + /** + * Processes the ajax-result for the `pager`-widget. + * + * @param data + * The result of ajax. + * + * @param table + * The table which is being processed. + * + * @param request + * The ajax-request which processed the `data`. + * + * @return + * The data for the pager to show. + */ + ajaxProcessing?: AjaxDataProcessor; + + /** + * The output to display in the output-area. + * + * Following portions of text are substituted: + * + * | Tag | Replacement | + * |--------------------|----------------------------------------------| + * | `{size}` | The current page size. | + * | `{page}` | The current page. | + * | `{page:input}` | The page inputted by the user. | + * | `{totalPages}` | The total amount of pages. | + * | `{filteredPages}` | The filtered number of pages. | + * | `{startRow}` | The number of the first row being displayed. | + * | `{startRow:input}` | The start-row inputted by the user. | + * | `{endRow}` | The number of the last row being displayed. | + * | `{filteredRows}` | The amount of filtered rows. | + * | `{totalRows}` | The total amount of rows. | + */ + output?: string | PagerOutputProcessor; + + /** + * The number of the first page to show. + */ + page?: number; + + /** + * The number of the first page to show after applying a filter. + */ + pageReset?: number | boolean; + + /** + * The initial page-size. + */ + size?: PageSize; + + /** + * A value indicating whether to split child-rows on page-breaks. + */ + countChildRows?: boolean; + + /** + * A value indicating whether an ajax-request should be executed after the initialization of the table. + */ + processAjaxOnInit?: boolean; + + /** + * The initial amount of rows to show. + */ + initialRows?: PagerInitialRows; + + /** + * A value indicating whether to remove the rows while performing sortings for speed up. + */ + removeRows?: boolean; + + /** + * The key to of the local storage to save data to. + */ + storageKey?: string; + + /** + * A value indicating whether to save the current page locally. + */ + savePages?: boolean; + + /** + * The selector for querying the pager-container. + */ + container?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the first page. + */ + cssFirst?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the previous page. + */ + cssPrev?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the next page. + */ + cssNext?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the last page. + */ + cssLast?: JQuery.Selector | JQuery; + + /** + * The selector for querying the dropdown-control to jump to a specific page. + */ + cssGoto?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to set the page-size. + */ + cssPageSize?: JQuery.Selector | JQuery; + + /** + * The selector for querying the container to print the output to. + */ + cssPageDisplay?: JQuery.Selector | JQuery; + + /** + * A value indicating whether the table should always have the same number of rows even if there is a lesser number of records to show. + */ + fixedHeight?: boolean; + + /** + * A value indicating whether the `cssDisabled` class should be applied to non-applicable buttons. + */ + updateArrows?: boolean; + + /** + * The css-class to apply to disabled pager-controls. + */ + cssDisabled?: string; + + /** + * The css-class to apply to the table-row which displays the error-message in case of an ajax-error. + */ + cssErrorRow?: string; +} diff --git a/types/tablesorter/Paging/PagerConfigurationStore.d.ts b/types/tablesorter/Paging/PagerConfigurationStore.d.ts new file mode 100644 index 0000000000..6802e46c3f --- /dev/null +++ b/types/tablesorter/Paging/PagerConfigurationStore.d.ts @@ -0,0 +1,139 @@ +import "jquery"; +import { SortDefinition } from "../Sorting/SortDefinition"; +import { PagerConfiguration } from "./PagerConfiguration"; +import { PagerDataPart } from "./PagerDataPart"; +import { PagerMemory } from "./PagerMemory"; + +/** + * Represents the configuration-store of the `pager` addon. + */ +export interface PagerConfigurationStore extends PagerConfiguration { + page: number; + + size: number; + + /** + * The initial settings of the pager. + */ + settings: PagerConfiguration; + + /** + * A value indicating whether ajax is enabled. + */ + ajax: boolean; + + /** + * The url to query data from. + */ + ajaxUrl: string; + + /** + * The optional url to query data from. + */ + optAjaxUrl: string; + + /** + * The number of performed ajax-request. + */ + ajaxCounter: number; + + /** + * The old success-callback of the ajax-settings. + */ + oldAjaxSuccess: JQuery.Ajax.SuccessCallback; + + /** + * The result of the ajax-request. + */ + ajaxData: PagerDataPart | [number] | [number, JQuery | any[][], string[]?]; + + /** + * The index of the cached rows which are being displayed. + */ + cachedIndex: number[]; + + /** + * A value indicating whether the pager is disabled. + */ + isDisabled: boolean; + + /** + * A value indicating whether the pager is initializing. + */ + initializing: boolean; + + /** + * A value indicating whether the pager is initialized. + */ + initialized: boolean; + + /** + * The last memorized settings of the `pager`. + */ + last: PagerMemory; + + /** + * The number of the first row being displayed. + */ + startRow: number; + + /** + * The number of the last row being displayed. + */ + endRow: number; + + /** + * The amount of filtered rows. + */ + filteredRows: number; + + /** + * The total amount of rows. + */ + totalRows: number; + + /** + * The amount of filtered pages. + */ + filteredPages: number; + + /** + * The total amount of pages. + */ + totalPages: number; + + /** + * The regex for identifying rows. + */ + regexRows: RegExp; + + /** + * The regex for identifying filtered rows. + */ + regexFiltered: RegExp; + + /** + * The applied filters. + */ + currentFilters: string[]; + + /** + * The sorting to apply. + */ + sortList: SortDefinition[]; + + /** + * The jQuery-object which contains the container-control. + */ + $container: JQuery; + + /** + * The jQuery-object which contains the control for jumping to pages. + */ + $goto: JQuery; + + /** + * The jQuery-object which contains the size-control. + */ + $size: JQuery; +} diff --git a/types/tablesorter/Paging/PagerDataPart.d.ts b/types/tablesorter/Paging/PagerDataPart.d.ts new file mode 100644 index 0000000000..4f1c48bfec --- /dev/null +++ b/types/tablesorter/Paging/PagerDataPart.d.ts @@ -0,0 +1,46 @@ +import { PagerOutputProcessor } from "./PagerOutputProcessor"; + +/** + * Represents a part of table-data for the `pager`-widget. + */ +export interface PagerDataPart { + /** + * The output to display in the output-area. + * + * Following portions of text are substituted: + * + * | Tag | Replacement | + * |--------------------|----------------------------------------------| + * | `{size}` | The current page size. | + * | `{page}` | The current page. | + * | `{page:input}` | The page inputted by the user. | + * | `{totalPages}` | The total amount of pages. | + * | `{filteredPages}` | The filtered number of pages. | + * | `{startRow}` | The number of the first row being displayed. | + * | `{startRow:input}` | The start-row inputted by the user. | + * | `{endRow}` | The number of the last row being displayed. | + * | `{filteredRows}` | The amount of filtered rows. | + * | `{totalRows}` | The total amount of rows. | + */ + output?: string | PagerOutputProcessor; + + /** + * The number of total rows. + */ + total: number; + + /** + * The number of filtered rows. + */ + filteredRows?: number; + + /** + * The column-names of the table. + */ + headers?: string[]; + + /** + * The data to show. + */ + rows?: any[][] | JQuery; +} diff --git a/types/tablesorter/Paging/PagerEventHandler.d.ts b/types/tablesorter/Paging/PagerEventHandler.d.ts new file mode 100644 index 0000000000..189b2e24c5 --- /dev/null +++ b/types/tablesorter/Paging/PagerEventHandler.d.ts @@ -0,0 +1,19 @@ +import "jquery"; +import { TablesorterConfigurationStore } from "../System/TablesorterConfigurationStore"; +import { PagerConfigurationStore } from "./PagerConfigurationStore"; + +/** + * Provides the functionality to handle pager-events of the `tablesorter`. + */ +export interface PagerEventHandler { + /** + * Handles pager-events of the `tablesorter`. + * + * @param eventArgs + * An object that contains event data. + * + * @param options + * Either the options of the configuration of the tablesorter or the configuration of the pager-widget. + */ + (eventArgs: JQuery.TriggeredEvent, options: TablesorterConfigurationStore | PagerConfigurationStore): void; +} diff --git a/types/tablesorter/Paging/PagerEventMap.d.ts b/types/tablesorter/Paging/PagerEventMap.d.ts new file mode 100644 index 0000000000..bfda115361 --- /dev/null +++ b/types/tablesorter/Paging/PagerEventMap.d.ts @@ -0,0 +1,29 @@ +/** + * Represents an event which uses pager-settings for processing. + */ +export enum PagerEventMap { + /** + * Indicates the `pagerInitialized`-event. + */ + "pagerInitialized", + + /** + * Indicates the `pageMoved`-event. + */ + "pageMoved", + + /** + * Indicates the `pagerChange`-event. + */ + "pagerChange", + + /** + * Indicates the `pagerComplete`-event. + */ + "pagerComplete", + + /** + * Indicates the `pagerBeforeInitialized`-event. + */ + "pagerBeforeInitialized", +} diff --git a/types/tablesorter/Paging/PagerInitialRows.d.ts b/types/tablesorter/Paging/PagerInitialRows.d.ts new file mode 100644 index 0000000000..bb05d59996 --- /dev/null +++ b/types/tablesorter/Paging/PagerInitialRows.d.ts @@ -0,0 +1,14 @@ +/** + * Provides an intitial amount of rows and filtered rows to display. + */ +export interface PagerInitialRows { + /** + * The total number of rows. + */ + total?: number; + + /** + * The filtered number of rows. + */ + filtered?: number; +} diff --git a/types/tablesorter/Paging/PagerMemory.d.ts b/types/tablesorter/Paging/PagerMemory.d.ts new file mode 100644 index 0000000000..44e6d9075c --- /dev/null +++ b/types/tablesorter/Paging/PagerMemory.d.ts @@ -0,0 +1,31 @@ +import { SortDefinition } from "../Sorting/SortDefinition"; + +/** + * The memorized settings of the `pager`. + */ +export interface PagerMemory { + /** + * The page-number. + */ + page: number; + + /** + * The size of a page. + */ + size: number; + + /** + * The sorting. + */ + sortList: SortDefinition[]; + + /** + * The total amount of rows. + */ + totalRows: number; + + /** + * The currently applied filters. + */ + currentFilters: string[]; +} diff --git a/types/tablesorter/Paging/PagerOutputProcessor.d.ts b/types/tablesorter/Paging/PagerOutputProcessor.d.ts new file mode 100644 index 0000000000..3a9b209957 --- /dev/null +++ b/types/tablesorter/Paging/PagerOutputProcessor.d.ts @@ -0,0 +1,18 @@ +/** + * Provides the functionality to generate output for the `pager`-plugin. + */ +export interface PagerOutputProcessor { + /** + * Generates an output for the `pager`-plugin. + * + * @param table + * The table which is being processed. + * + * @param pager + * The representation of the pager. + * + * @return + * The output for the `pager`-plugin. + */ + (table: TElement, pager: any): string; +} diff --git a/types/tablesorter/Paging/PagerSelectors.d.ts b/types/tablesorter/Paging/PagerSelectors.d.ts new file mode 100644 index 0000000000..3ea57f0bf1 --- /dev/null +++ b/types/tablesorter/Paging/PagerSelectors.d.ts @@ -0,0 +1,46 @@ +import "jquery"; + +/** + * Provides selectors for the `pager`-widget. + */ +export interface PagerSelectors { + /** + * The selector for querying the pager-container. + */ + container?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the first page. + */ + first?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the previous page. + */ + prev?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the next page. + */ + next?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to jump to the last page. + */ + last?: JQuery.Selector | JQuery; + + /** + * The selector for querying the dropdown-control to jump to a specific page. + */ + gotoPage?: JQuery.Selector | JQuery; + + /** + * The selector for querying the control to set the page-size. + */ + pageSize?: JQuery.Selector | JQuery; + + /** + * The selector for querying the container to print the output to. + */ + pageDisplay?: JQuery.Selector | JQuery; +} diff --git a/types/tablesorter/Parsing/ParsedCell.d.ts b/types/tablesorter/Parsing/ParsedCell.d.ts new file mode 100644 index 0000000000..10cfdf3ca4 --- /dev/null +++ b/types/tablesorter/Parsing/ParsedCell.d.ts @@ -0,0 +1,27 @@ +import "jquery"; +import { ParsedOption } from "./ParsedOption"; + +/** + * Represents a parsed row. + */ +export interface ParsedCell extends ParsedOption { + /** + * The index of the row. + */ + rowIndex: number; + + /** + * The index of the `tbody` of the row. + */ + tbodyIndex: number; + + /** + * The jQuery-object which contains the row. + */ + $row: JQuery; + + /** + * The jQuery-object which contains the cell. + */ + $cell: JQuery; +} diff --git a/types/tablesorter/Parsing/ParsedData.d.ts b/types/tablesorter/Parsing/ParsedData.d.ts new file mode 100644 index 0000000000..55f37641c7 --- /dev/null +++ b/types/tablesorter/Parsing/ParsedData.d.ts @@ -0,0 +1,21 @@ +import "jquery"; + +/** + * Represents parsed data. + */ +export interface ParsedData { + /** + * The raw values of the rows. + */ + raw: string[]; + + /** + * The parsed values of the rows. + */ + parsed: any[]; + + /** + * The jQuery-objects containing the cells of the rows. + */ + $cells: JQuery[]; +} diff --git a/types/tablesorter/Parsing/ParsedOption.d.ts b/types/tablesorter/Parsing/ParsedOption.d.ts new file mode 100644 index 0000000000..8c1e212c7d --- /dev/null +++ b/types/tablesorter/Parsing/ParsedOption.d.ts @@ -0,0 +1,14 @@ +/** + * Represents a parsed option. + */ +export interface ParsedOption { + /** + * The unparsed text of the cell. + */ + raw: string; + + /** + * The parsed value of the cell. + */ + parsed: any; +} diff --git a/types/tablesorter/Parsing/Parser.d.ts b/types/tablesorter/Parsing/Parser.d.ts new file mode 100644 index 0000000000..8a3f6291b7 --- /dev/null +++ b/types/tablesorter/Parsing/Parser.d.ts @@ -0,0 +1,46 @@ +import { ParserType } from "./ParserType"; + +/** + * Represents a parser. + */ +export interface Parser { + /** + * The id of the parser. + */ + id: string; + + /** + * The type of the parser. + */ + type: ParserType; + + /** + * A value indicating whether the tablesorter should use parsed text for searching. + */ + parsed: boolean; + + /** + * Checks whether a text is applicable to the parser. + * + * @param text + * The text to check. + * + * @returns + * A value indicating whether the parser is applicable to the `text`. + */ + is(text: string): boolean; + + /** + * Formats the text of a cell. + * + * @param text + * The text to format. + * + * @param table + * The table which is being processed. + * + * @return + * The formatted text. + */ + format(text: string, table: TElement): string; +} diff --git a/types/tablesorter/Parsing/ParserType.d.ts b/types/tablesorter/Parsing/ParserType.d.ts new file mode 100644 index 0000000000..15810f97b1 --- /dev/null +++ b/types/tablesorter/Parsing/ParserType.d.ts @@ -0,0 +1,14 @@ +/** + * Represents a parser-type. + */ +export enum ParserType { + /** + * Indicates the default parser-type. + */ + Default = "text", + + /** + * Indicates a decimal parser-type. + */ + Decimal = "numeric" +} diff --git a/types/tablesorter/Parsing/TextExtractor.d.ts b/types/tablesorter/Parsing/TextExtractor.d.ts new file mode 100644 index 0000000000..be170bbaed --- /dev/null +++ b/types/tablesorter/Parsing/TextExtractor.d.ts @@ -0,0 +1,18 @@ +/** + * Provides the functionality to extract the text from a cell. + */ +export interface TextExtractor { + /** + * Extracts the text from a cell. + * + * @param cell + * The cell whose text is being extracted. + * + * @param table + * The table of the cell. + * + * @param index + * The index of the cell. + */ + (cell: Element, table: TElement, index: number): string; +} diff --git a/types/tablesorter/Sorting/EmptySorting.d.ts b/types/tablesorter/Sorting/EmptySorting.d.ts new file mode 100644 index 0000000000..0e1ddc34a8 --- /dev/null +++ b/types/tablesorter/Sorting/EmptySorting.d.ts @@ -0,0 +1,29 @@ +/** + * Defines a sort-order for empty cells. + */ +export enum EmptySorting { + /** + * Indicates that the cells are pinned to the top. + */ + Top = "top", + + /** + * Indicates that the cells are pinned to the bottom. + */ + Bottom = "bottom", + + /** + * Indicates that the cells are treated like a value lesser than the minimal numeric value. + */ + Min = "emptyMin", + + /** + * Indicates that the cells are treated like a value greater than the maximal numeric value. + */ + Max = "emptyMax", + + /** + * Indicates that the cells are treated like a value equal to `0`. + */ + Zero = "zero" +} diff --git a/types/tablesorter/Sorting/NumberSorter.d.ts b/types/tablesorter/Sorting/NumberSorter.d.ts new file mode 100644 index 0000000000..418b5d93be --- /dev/null +++ b/types/tablesorter/Sorting/NumberSorter.d.ts @@ -0,0 +1,27 @@ +/** + * Provides the functionality to sort numbers. + */ +export interface NumberSorter { + /** + * Compares the `x` and `y` number. + * + * @param x + * The first number to compare. + * + * @param y + * The second number to compare. + * + * @param ascending + * A value indicating whether an ascending sort is performed. + * + * @param maxValue + * The maximum value in the column. + * + * @return + * An integer that indicated the relative values of `x` and `y`: + * - If less than 0, `x` is less than `y`. + * - If `0`, `x` equals `y`. + * - If greater than 0, `x` is greater than `y`. + */ + (x: number, y: number, ascending: boolean, maxValue: number): number; +} diff --git a/types/tablesorter/Sorting/RelativeSortDefinition.d.ts b/types/tablesorter/Sorting/RelativeSortDefinition.d.ts new file mode 100644 index 0000000000..3ffc8c23f2 --- /dev/null +++ b/types/tablesorter/Sorting/RelativeSortDefinition.d.ts @@ -0,0 +1,6 @@ +import { RelativeSorting } from "./RelativeSorting"; + +/** + * Represents a definition of a relative sorting. + */ +export type RelativeSortDefinition = [number, RelativeSorting]; diff --git a/types/tablesorter/Sorting/RelativeSorting.d.ts b/types/tablesorter/Sorting/RelativeSorting.d.ts new file mode 100644 index 0000000000..5d70ee4070 --- /dev/null +++ b/types/tablesorter/Sorting/RelativeSorting.d.ts @@ -0,0 +1,24 @@ +/** + * Defines a relative sorting. + */ +export enum RelativeSorting { + /** + * Indicates an ascending sorting. + */ + Ascending = "a", + + /** + * Indicates a descending sorting. + */ + Descending = "d", + + /** + * Indicates the same sorting like the other column. + */ + Same = "s", + + /** + * Indicates the opposite sorting of the other column. + */ + Opposite = "o" +} diff --git a/types/tablesorter/Sorting/SortDefinition.d.ts b/types/tablesorter/Sorting/SortDefinition.d.ts new file mode 100644 index 0000000000..b478474144 --- /dev/null +++ b/types/tablesorter/Sorting/SortDefinition.d.ts @@ -0,0 +1,6 @@ +import { SortDefinitionOrder } from "./SortDefinitionOrder"; + +/** + * Represents a definition of a sorting. + */ +export type SortDefinition = [number, SortDefinitionOrder]; diff --git a/types/tablesorter/Sorting/SortDefinitionOrder.d.ts b/types/tablesorter/Sorting/SortDefinitionOrder.d.ts new file mode 100644 index 0000000000..cb844d58d8 --- /dev/null +++ b/types/tablesorter/Sorting/SortDefinitionOrder.d.ts @@ -0,0 +1,19 @@ +/** + * Defines a sort-order. + */ +export enum SortDefinitionOrder { + /** + * Indicates no sorting. + */ + None = 2, + + /** + * Indicates ascending sorting. + */ + Ascending = 0, + + /** + * Indicates descending sorting. + */ + Descending = 1 +} diff --git a/types/tablesorter/Sorting/SortInitiator.d.ts b/types/tablesorter/Sorting/SortInitiator.d.ts new file mode 100644 index 0000000000..f6093f3614 --- /dev/null +++ b/types/tablesorter/Sorting/SortInitiator.d.ts @@ -0,0 +1,29 @@ +/** + * Represents a sort-initiator. + */ +export enum SortInitiator { + /** + * Indicates the user. + */ + User = "user", + + /** + * Indicates the `sort`-event. + */ + SortEvent = "sort", + + /** + * Indicates the `sorton`-method. + */ + SortOnMethod = "sorton", + + /** + * Indicates the `sortAppend`-configuration. + */ + SotAppend = "sortAppend", + + /** + * Indicates the `sortForce`-configuration. + */ + SortForce = "sortForce" +} diff --git a/types/tablesorter/Sorting/SortOrder.d.ts b/types/tablesorter/Sorting/SortOrder.d.ts new file mode 100644 index 0000000000..160c0c7253 --- /dev/null +++ b/types/tablesorter/Sorting/SortOrder.d.ts @@ -0,0 +1,14 @@ +/** + * Defines a sort-order. + */ +export enum SortOrder { + /** + * Indicates ascending sorting. + */ + Ascending = "asc", + + /** + * Indicates descending sorting. + */ + Descending = "desc" +} diff --git a/types/tablesorter/Sorting/StringSorting.d.ts b/types/tablesorter/Sorting/StringSorting.d.ts new file mode 100644 index 0000000000..20c3002504 --- /dev/null +++ b/types/tablesorter/Sorting/StringSorting.d.ts @@ -0,0 +1,29 @@ +/** + * Defines a sort-order for text-cells. + */ +export enum StringSorting { + /** + * Indicates that the cells are pinned to the top. + */ + Top = "top", + + /** + * Indicates that the cells are pinned to the bottom. + */ + Bottom = "bottom", + + /** + * Indicates that the cells are treated like a value lesser than the minimal numeric value. + */ + Min = "min", + + /** + * Indicates that the cells are treated like a value greater than the maximal numeric value. + */ + Max = "max", + + /** + * Indicates that the cells are treated like a value equal to `0`. + */ + Zero = "zero" +} diff --git a/types/tablesorter/Sorting/TableSorting.d.ts b/types/tablesorter/Sorting/TableSorting.d.ts new file mode 100644 index 0000000000..8f04bc6362 --- /dev/null +++ b/types/tablesorter/Sorting/TableSorting.d.ts @@ -0,0 +1,27 @@ +import { SortDefinitionOrder } from "./SortDefinitionOrder"; +import { SortInitiator } from "./SortInitiator"; + +/** + * Represents a sorting for a table. + */ +export interface TableSorting { + /** + * The number of times the sorting has been applied. + */ + count: number; + + /** + * The order to apply the sorting. + */ + order: SortDefinitionOrder[]; + + /** + * A value indicating whether the order is locked. + */ + lockedOrder: boolean; + + /** + * The initiator of the sorting. + */ + sortedBy: SortInitiator; +} diff --git a/types/tablesorter/Sorting/TextSorter.d.ts b/types/tablesorter/Sorting/TextSorter.d.ts new file mode 100644 index 0000000000..d45f233f7c --- /dev/null +++ b/types/tablesorter/Sorting/TextSorter.d.ts @@ -0,0 +1,30 @@ +/** + * Provides the functionality to compare text. + */ +export interface TextSorter { + /** + * Compares two strings and returns a value indicating whether one is less than, equal to or greater than the other. + * + * @param x + * The first string to compare. + * + * @param y + * The second string to compare. + * + * @param ascending + * A value indicating whether an ascending sort is being performed. + * + * @param index + * The index of the column which is being sorted. + * + * @param table + * The table which is being sorted. + * + * @return + * An integer that indicated the relative values of `x` and `y`: + * - If less than 0, `x` is less than `y`. + * - If `0`, `x` equals `y`. + * - If greater than 0, `x` is greater than `y`. + */ + (x: string, y: string, ascending: boolean, index: number, table: TElement): number; +} diff --git a/types/tablesorter/Storage/StorageConfiguration.d.ts b/types/tablesorter/Storage/StorageConfiguration.d.ts new file mode 100644 index 0000000000..2464e96457 --- /dev/null +++ b/types/tablesorter/Storage/StorageConfiguration.d.ts @@ -0,0 +1,31 @@ +import { StorageType } from "./StorageType"; + +/** + * Provides settings for saving data to the storage. + */ +export interface StorageConfiguration { + /** + * The id of the storage to save to. + */ + id?: string; + + /** + * The `data-attribute`-name to automatically get the id of the table from. + */ + group?: string; + + /** + * The url to save the storage to. + */ + url?: string; + + /** + * The `data-attribute`-name to automatically get the url of the table from. + */ + page?: string; + + /** + * The medium to save the storage to. + */ + storageType?: StorageType; +} diff --git a/types/tablesorter/Storage/StorageType.d.ts b/types/tablesorter/Storage/StorageType.d.ts new file mode 100644 index 0000000000..09dc14a5c2 --- /dev/null +++ b/types/tablesorter/Storage/StorageType.d.ts @@ -0,0 +1,19 @@ +/** + * Represents a storage type. + */ +export enum StorageType { + /** + * Indicates the default local storage. + */ + Default = "d", + + /** + * Indicates the session-storage. + */ + Session = "s", + + /** + * Indicates cookies. + */ + Cookie = "s" +} diff --git a/types/tablesorter/System/CommonEventHandler.d.ts b/types/tablesorter/System/CommonEventHandler.d.ts new file mode 100644 index 0000000000..c7f9fa5236 --- /dev/null +++ b/types/tablesorter/System/CommonEventHandler.d.ts @@ -0,0 +1,14 @@ +import "jquery"; + +/** + * Provides the functionality to handle common events of the `tablesorter`. + */ +export interface CommonEventHandler { + /** + * Handles common events of the `tablesorter`. + * + * @param eventArgs + * An object that contains event data. + */ + (eventArgs: JQuery.TriggeredEvent): void; +} diff --git a/types/tablesorter/System/ConfigEventHandler.d.ts b/types/tablesorter/System/ConfigEventHandler.d.ts new file mode 100644 index 0000000000..77c3214605 --- /dev/null +++ b/types/tablesorter/System/ConfigEventHandler.d.ts @@ -0,0 +1,18 @@ +import "jquery"; +import { TablesorterConfigurationStore } from "./TablesorterConfigurationStore"; + +/** + * Provides the functionality to handle config-events of the `tablesorter`. + */ +export interface ConfigEventHandler { + /** + * Handles config-events of the `tablesorter`. + * + * @param eventArgs + * An object that contains event data. + * + * @param config + * The configuration of the table processed by the `tablesorter`. + */ + (eventArgs: JQuery.TriggeredEvent, config: TablesorterConfigurationStore): void; +} diff --git a/types/tablesorter/System/ConfigEventMap.d.ts b/types/tablesorter/System/ConfigEventMap.d.ts new file mode 100644 index 0000000000..064c1379f0 --- /dev/null +++ b/types/tablesorter/System/ConfigEventMap.d.ts @@ -0,0 +1,14 @@ +/** + * Represents an event which uses the `TablesorterConfigurationStore` for processing. + */ +export enum ConfigEventMap { + /** + * Indicates the `filterInit`-event. + */ + "filterInit", + + /** + * Indicates the `filterEnd`-event. + */ + "filterEnd" +} diff --git a/types/tablesorter/System/EventMap.d.ts b/types/tablesorter/System/EventMap.d.ts new file mode 100644 index 0000000000..824fc948de --- /dev/null +++ b/types/tablesorter/System/EventMap.d.ts @@ -0,0 +1,44 @@ +/** + * Represents an event. + */ +export enum EventMap { + /** + * Indicates the `tablesorter-initialized`-event. + */ + "tablesorter-initialized", + + /** + * Indicates the `tablesorter-ready`-event. + */ + "tablesorter-ready", + + /** + * Indicates the `refreshComplete`-event. + */ + "refreshComplete", + + /** + * Indicates the `updateComplete`-event. + */ + "updateComplete", + + /** + * Indicates the `widgetRemoveEnd`-event. + */ + "widgetRemoveEnd", + + /** + * Indicates the `sortStart`-event. + */ + "sortStart", + + /** + * Indicates the `sortBegin`-event. + */ + "sortBegin", + + /** + * Indicates the `sortEnd`-event. + */ + "sortEnd" +} diff --git a/types/tablesorter/System/HeaderResizeOptions.d.ts b/types/tablesorter/System/HeaderResizeOptions.d.ts new file mode 100644 index 0000000000..3450d495ec --- /dev/null +++ b/types/tablesorter/System/HeaderResizeOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides options for handling `HeaderResize`-events. + */ +export interface HeaderResizeOptions { + /** + * The interval to look for header-changes in miliseconds. + */ + timer: number; +} diff --git a/types/tablesorter/System/InitializationEventHandler.d.ts b/types/tablesorter/System/InitializationEventHandler.d.ts new file mode 100644 index 0000000000..b7aa93c8f6 --- /dev/null +++ b/types/tablesorter/System/InitializationEventHandler.d.ts @@ -0,0 +1,12 @@ +/** + * Provides the functionality to handle the `Initialized`-event. + */ +export interface InitializationEventHandler { + /** + * Handles the `Initialized`-event. + * + * @param table + * The initialized table. + */ + (table: TElement): void; +} diff --git a/types/tablesorter/System/Locale.d.ts b/types/tablesorter/System/Locale.d.ts new file mode 100644 index 0000000000..5dd2d25838 --- /dev/null +++ b/types/tablesorter/System/Locale.d.ts @@ -0,0 +1,39 @@ +/** + * Provides localized strings. + */ +export interface Locale { + /** + * The text to show for ascending sorting. + */ + sortAsc: string; + + /** + * The text to show for descending sorting. + */ + sortDesc: string; + + /** + * The text to show for non-sorted columns. + */ + sortNone: string; + + /** + * The text to show for disabled sorting. + */ + sortDisabled: string; + + /** + * The text to show for applying ascending sorting. + */ + nextAsc: string; + + /** + * The text to show for applying descending sorting. + */ + nextDesc: string; + + /** + * The text to show for disabling sorting. + */ + nextNone: string; +} diff --git a/types/tablesorter/System/MappedSettings.d.ts b/types/tablesorter/System/MappedSettings.d.ts new file mode 100644 index 0000000000..d4b9ece6a2 --- /dev/null +++ b/types/tablesorter/System/MappedSettings.d.ts @@ -0,0 +1,14 @@ +/** + * Represents settings mapped to columns. + */ +export interface MappedSettings { + /** + * The jquery-selector and their settings. + */ + [selector: string]: T; + + /** + * The column-index and its settings. + */ + [index: number]: T; +} diff --git a/types/tablesorter/System/ParameterlessTriggerNameMap.d.ts b/types/tablesorter/System/ParameterlessTriggerNameMap.d.ts new file mode 100644 index 0000000000..4c8164d199 --- /dev/null +++ b/types/tablesorter/System/ParameterlessTriggerNameMap.d.ts @@ -0,0 +1,99 @@ +/** + * Represents a parameterless trigger. + */ +export enum ParameterlessTriggerNameMap { + /** + * Indicates the `sort`-trigger. + */ + "sort", + + /** + * Indicates the `applyWidgets`-trigger. + */ + "applyWidgets", + + /** + * Indicates the `appendCache`-trigger. + */ + "appendCache", + + /** + * Indicates the `update`-trigger. + */ + "update", + + /** + * Indicates the `updateRows`-trigger. + */ + "updateRows", + + /** + * Indicates the `updateCache`-trigger. + */ + "updateCache", + + /** + * Indicates the `updateHeaders`-trigger. + */ + "updateHeaders", + + /** + * Indicates the `updateAll`-trigger. + */ + "updateAll", + + /** + * Indicates the `search`-trigger. + */ + "search", + + /** + * Indicates the `resetToLoadState`-trigger. + */ + "resetToLoadState", + + /** + * Indicates the `destroy`-trigger. + */ + "destroy", + + /** + * Indicates the `filterReset`-trigger. + */ + "filterReset", + + /** + * Indicates the `filterResetSaved`-trigger. + */ + "filterResetSaved", + + /** + * Indicates the `filterAndSortReset`-trigger. + */ + "filterAndSortReset", + + /** + * Indicates the `saveSortReset`-trigger. + */ + "saveSortReset", + + /** + * Indicates the `enablePager`-trigger. + */ + "enablePager", + + /** + * Indicates the `disablePager`-trigger. + */ + "disablePager", + + /** + * Indicates the `pagerUpdate`-trigger. + */ + "pagerUpdate", + + /** + * Indicates the `destroyPager`-trigger. + */ + "destroyPager" +} diff --git a/types/tablesorter/System/RenderHeaderEventHandler.d.ts b/types/tablesorter/System/RenderHeaderEventHandler.d.ts new file mode 100644 index 0000000000..c3aba85641 --- /dev/null +++ b/types/tablesorter/System/RenderHeaderEventHandler.d.ts @@ -0,0 +1,21 @@ +import "jquery"; +import { TablesorterConfigurationStore } from "./TablesorterConfigurationStore"; + +/** + * Provides the functionality to handle the `RenderHeader`-event. + */ +export interface RenderHeaderEventHandler { + /** + * Handles the `RenderHeader`-event. + * + * @param index + * The zero-based index of the current table header cell. + * + * @param config + * The current configuration of the table. + * + * @param table + * The jQuery-object of the table. + */ + (index: number, config: TablesorterConfigurationStore, table: JQuery): void; +} diff --git a/types/tablesorter/System/RenderTemplateEventHandler.d.ts b/types/tablesorter/System/RenderTemplateEventHandler.d.ts new file mode 100644 index 0000000000..fcd080c29a --- /dev/null +++ b/types/tablesorter/System/RenderTemplateEventHandler.d.ts @@ -0,0 +1,18 @@ +/** + * Provides the functionality to handle the `RenderTemplate`-event. + */ +export interface RenderTemplateEventHandler { + /** + * Handles the `RenderTemplate`-event. + * + * @param index + * The index of the header. + * + * @param template + * The rendered content of the header. + * + * @return + * A manipulated version of the content of the header. + */ + (index: number, template: string): string; +} diff --git a/types/tablesorter/System/TablesorterCache.d.ts b/types/tablesorter/System/TablesorterCache.d.ts new file mode 100644 index 0000000000..655dc34583 --- /dev/null +++ b/types/tablesorter/System/TablesorterCache.d.ts @@ -0,0 +1,14 @@ +/** + * Represents the cache of the tablesorter. + */ +export interface TablesorterCache { + /** + * The maximal values of the columns. + */ + colMax: any[]; + + /** + * The normalized data. + */ + normalized: any[]; +} diff --git a/types/tablesorter/System/TablesorterConfigBase.d.ts b/types/tablesorter/System/TablesorterConfigBase.d.ts new file mode 100644 index 0000000000..b25c948975 --- /dev/null +++ b/types/tablesorter/System/TablesorterConfigBase.d.ts @@ -0,0 +1,16 @@ +import { SortOrder } from "../Sorting/SortOrder"; + +/** + * I don't fucking know what this is supposed to be... + */ +export interface TablesorterConfigBase { + /** + * The date-format for dates inside the table. + */ + dateFormat?: string; + + /** + * The order which will be applied when clicking on the heading the first time. + */ + sortInitialOrder?: SortOrder; +} diff --git a/types/tablesorter/System/TablesorterConfiguration.d.ts b/types/tablesorter/System/TablesorterConfiguration.d.ts new file mode 100644 index 0000000000..55005eefe3 --- /dev/null +++ b/types/tablesorter/System/TablesorterConfiguration.d.ts @@ -0,0 +1,384 @@ +import "jquery"; +import { CoreTheme } from "../Design/CoreTheme"; +import { GlobalizeSettings } from "../Globalization/GlobalizeSettings"; +import { TextExtractor } from "../Parsing/TextExtractor"; +import { EmptySorting } from "../Sorting/EmptySorting"; +import { NumberSorter } from "../Sorting/NumberSorter"; +import { RelativeSortDefinition } from "../Sorting/RelativeSortDefinition"; +import { SortDefinition } from "../Sorting/SortDefinition"; +import { SortOrder } from "../Sorting/SortOrder"; +import { StringSorting } from "../Sorting/StringSorting"; +import { TextSorter } from "../Sorting/TextSorter"; +import { WidgetOptions } from "../Widgets/WidgetOptions"; +import { InitializationEventHandler } from "./InitializationEventHandler"; +import { MappedSettings } from "./MappedSettings"; +import { RenderHeaderEventHandler } from "./RenderHeaderEventHandler"; +import { RenderTemplateEventHandler } from "./RenderTemplateEventHandler"; +import { TablesorterConfigBase } from "./TablesorterConfigBase"; +import { TablesorterHeading } from "./TablesorterHeading"; + +/** + * Represents settings for the `tablesorter`. + */ +export interface TablesorterConfiguration extends TablesorterConfigBase { + /** + * The namespace of the table. + */ + namespace?: string; + + /** + * The initial sorting after the initialization of the table. + */ + sortList?: SortDefinition[]; + + /** + * A value indicating whether sortings other than the ones in the `sortList` should be prevented. + */ + sortRestart?: boolean; + + /** + * A value indicating whether to apply the original sorting when two cells have the same value. + */ + sortStable?: boolean; + + /** + * The key which is used for selecting multiple columns. + */ + sortMultiSortKey?: keyof MouseEvent; + + /** + * The key to hold while clicking on a heading for reseting the sorting for the whole table. + */ + sortResetKey?: keyof MouseEvent; + + /** + * A value indicating whether the user can reset a sorting of a column by clicking on it a third time. + */ + sortReset?: boolean; + + /** + * Sortings to prepend to the current sorting. + */ + sortForce?: SortDefinition[]; + + /** + * Sortings to append to the current sorting. + */ + sortAppend?: SortDefinition[] | { [index: number]: RelativeSortDefinition[] }; + + /** + * A value indicating whether accent character should be converted to their equivalent characters during sort. + */ + sortLocaleCompare?: boolean; + + /** + * The order which will be applied when clicking on a heading the first time. + */ + sortInitialOrder?: SortOrder; + + /** + * A value indicating whether tabbing through table headings is enabled. + */ + tabIndex?: boolean; + + /** + * The sorting to apply for empty cells. + */ + emptyTo?: EmptySorting; + + /** + * The sorting to apply to text cells in numeric columns. + */ + stringTo?: StringSorting; + + /** + * A value indicating whether letter-case should be considered while sorting. + */ + ignoreCase?: boolean; + + /** + * A value indicating whether the sorting should be reapplied after an update of the table-data. + */ + resort?: boolean; + + /** + * A value indicating whether the selection of the text in the table headers should be disabled. + */ + cancelSelection?: boolean; + + /** + * A value indicating whether the width of the columns should be fixed. + */ + widthFixed?: boolean; + + /** + * A value indicating whether the table should be initialized upon the initial sort-action. + */ + delayInit?: boolean; + + /** + * A value indicating whether widgets should be initialized. + */ + initWidgets?: boolean; + + /** + * A value indicating whether contents of spanned cells should be sortable and filterable in all table headers. + */ + duplicateSpan?: boolean; + + /** + * Specific configurations for separate headers. + */ + headers?: { [index: number]: TablesorterHeading }; + + /** + * A template for generating headers. + * + * ***Note:*** + * * `{content}` is replaced by the actual content of the header + * * If `cssIcon` is set, `{icon}` is replaced by a tag for the icon + * + * This template may also contain html-code. + */ + headerTemplate?: string; + + /** + * One or more events which should be considered as a `mousedown`-event. + */ + pointerDown?: string; + + /** + * One or more events which should be considered as a `mouseup`-event. + */ + pointerUp?: string; + + /** + * One or more events which should be considered as a `click`-event. + */ + pointerClick?: string; + + /** + * The `data-attribute` to automatically read text from cells. + */ + textAttribute?: string; + + /** + * The methods for extracting text from cells. + */ + textExtraction?: "basic" | TextExtractor | MappedSettings<"basic" | TextExtractor>; + + /** + * The attribute to read the text-value from `img`-tags. + */ + imgAttr?: string; + + /** + * Either global `Globalize`-settings or per-column `Globalize`-settings to apply. + */ + globalize?: GlobalizeSettings | {[index: number]: GlobalizeSettings}; + + /** + * A value indicating whether changes to child-rows are ignored by the table-sorter. + */ + ignoreChildRow?: boolean; + + /** + * The widgets to initialize. + */ + widgets?: string[]; + + /** + * The options for the widgets. + */ + widgetOptions?: WidgetOptions; + + /** + * The format of the class-names for automatically loading the widget with the id `{name}`. + * + * The default setting is `widget-{name}`. + */ + widgetClass?: string; + + /** + * A class to add to checked rows. + */ + checkboxClass?: string; + + /** + * A value indicating whether only visible rows should be affected by the checkbox located in the header. + */ + cehckboxVisible?: boolean; + + /** + * The storage for the `build-table` widget. + */ + data?: object | any[][]; + + /** + * The date-range for two-digit years. + */ + dateRange?: number; + + /** + * Either value indicating whether debug-information should be printed or a set of plugin-names to print debug-information from. + */ + debug?: boolean | string; + + /** + * A value indicating whether the sorting is performed by the server. + */ + serverSideSorting?: boolean; + + /** + * Processes the table after the initialization. + */ + initialized?: InitializationEventHandler; + + /** + * The text-sorting to apply. + */ + textSorter?: TextSorter | MappedSettings>; + + /** + * The number-sorting to apply. + */ + numberSorter?: NumberSorter; + + /** + * A function for processing the header. + * + * @param index + * The zero-based index of the header. + * + * @param template + * The rendered content of the header. + * + * @return + * A manipulated version of the content of the header. + */ + onRenderTemplate?: RenderTemplateEventHandler; + + /** + * A function to execute after the content of the header is processed. + * + * @param index + * The zero-based index of the current table header cell. + * + * @param config + * The current configuration of the table. + * + * @param table + * The jQuery-object of the table. + */ + onRenderHeader?: RenderHeaderEventHandler; + + /** + * A value indicating whether a timer icon should be shown while applying sorting and filtering. + */ + showProcessing?: boolean; + + /** + * A value indicating whether to use `en-US`-flavored numbers. + */ + usNumberFormat?: boolean; + + /** + * The theme to use. + */ + theme?: CoreTheme | string; + + /** + * A class to add to the table. + */ + tableClass?: string; + + /** + * A class to add to headers when no sort is applied. + */ + cssNone?: string; + + /** + * A class for indicating elements which don't cause a sort when clicking on them. + */ + cssNoSort?: string; + + /** + * A class to add to the header-row while applying a processing the table. + */ + cssProcessing?: string; + + /** + * A class to add to the header-row. + */ + cssHeaderRow?: string; + + /** + * A class to add to the table headers. + */ + cssHeader?: string; + + /** + * A class to add to table headers with ascending sort. + */ + cssAsc?: string; + + /** + * A class to add to table headers with descending sort. + */ + cssDesc?: string; + + /** + * A class for indicating rows which should be attached to the above row. + */ + cssChildRow?: string; + + /** + * A class to add to the sort-icons. + */ + cssIcon?: string; + + /** + * A class to add to sort-icons for with ascending sorting. + */ + cssIconAsc?: string; + + /** + * A class to add to sort-icons with descending sorting. + */ + cssIconDesc?: string; + + /** + * A class to add to sort-icons with disabled sorting. + */ + cssIconDisabled?: string; + + /** + * A class to add to sort-icons without sorting. + */ + cssIconNone?: string; + + /** + * A class for indicating rows which should be ignored. + */ + cssIgnoreRow?: string; + + /** + * A class for indicating `tbody`s which should not be sortable. + */ + cssInfoBlock?: string; + + /** + * A jQuery-selector for finding cells in the header-row. + */ + selectorHeaders?: JQuery.Selector; + + /** + * A jQuery-selector for finding rows to remove prior to a table-update. + */ + selectorRemove?: JQuery.Selector; + + /** + * A jQuery-selector to find clickable elements inside the result of `selectorHeaders` for triggering a sort. + */ + selectorSort?: JQuery.Selector; +} diff --git a/types/tablesorter/System/TablesorterConfigurationStore.d.ts b/types/tablesorter/System/TablesorterConfigurationStore.d.ts new file mode 100644 index 0000000000..d5f60c3b2c --- /dev/null +++ b/types/tablesorter/System/TablesorterConfigurationStore.d.ts @@ -0,0 +1,89 @@ +import "jquery"; +import { PagerConfigurationStore } from "../Paging/PagerConfigurationStore"; +import { Parser } from "../Parsing/Parser"; +import { TableSorting } from "../Sorting/TableSorting"; +import { WidgetOptionStore } from "../Widgets/WidgetOptionStore"; +import { TablesorterCache } from "./TablesorterCache"; +import { TablesorterConfiguration } from "./TablesorterConfiguration"; + +/** + * Represents the configuration-store of the `tablesorter`. + */ +export interface TablesorterConfigurationStore extends Required> { + /** + * A jQuery-object containing all headers of the table. + */ + $headers: JQuery; + + /** + * The headers of the table. + */ + $headerIndexed: JQuery[]; + + /** + * A jQuery-object which contains all filter-cells. + */ + $filters: JQuery; + + /** + * A jQuery-object containing the table itself. + */ + $table: JQuery; + + /** + * The html-representation of the table. + */ + table: TElement; + + /** + * A jQuery-object containing all sortable table-bodies. + */ + $tbodies: JQuery; + + /** + * The number of columns of the table. + */ + columns: number; + + /** + * The initial content of the headers. + */ + headerContent: string[]; + + /** + * The headers of the table. + */ + headerList: HTMLElement[]; + + /** + * The total amount of rows. + */ + totalRows: number; + + /** + * The amount of filtered rows. + */ + filteredRows: number; + + /** + * The cache of the tablesorter. + */ + cache: TablesorterCache; + + /** + * The parsers of the table. + */ + parsers: Array>; + + /** + * The sortings of the tablesorter. + */ + sortVars: TableSorting[]; + + widgetOptions: WidgetOptionStore; + + /** + * Provides methods and settings for the `pager`-widget. + */ + pager: PagerConfigurationStore; +} diff --git a/types/tablesorter/System/TablesorterEventHandler.d.ts b/types/tablesorter/System/TablesorterEventHandler.d.ts new file mode 100644 index 0000000000..ef68f557ca --- /dev/null +++ b/types/tablesorter/System/TablesorterEventHandler.d.ts @@ -0,0 +1,17 @@ +import "jquery"; + +/** + * Provides the functionality to handle events of the `tablesorter`. + */ +export interface TablesorterEventHandler { + /** + * Handles events of the `tablesorter`. + * + * @param eventArgs + * An object that contains event data. + * + * @param table + * The table which is processed by the `tablesorter`. + */ + (eventArgs: JQuery.TriggeredEvent, table: TElement): void; +} diff --git a/types/tablesorter/System/TablesorterHeading.d.ts b/types/tablesorter/System/TablesorterHeading.d.ts new file mode 100644 index 0000000000..a21b10bb61 --- /dev/null +++ b/types/tablesorter/System/TablesorterHeading.d.ts @@ -0,0 +1,45 @@ +import { ColumnFilter } from "../Filtering/ColumnFilter"; +import { EmptySorting } from "../Sorting/EmptySorting"; +import { SortOrder } from "../Sorting/SortOrder"; +import { StringSorting } from "../Sorting/StringSorting"; +import { TablesorterConfigBase } from "../System/TablesorterConfigBase"; + +/** + * Represents settings for a table header generated using `tablesorter`. + */ +export interface TablesorterHeading extends TablesorterConfigBase { + /** + * Either the name of the parser to use for sorting or a value indicating whether sorting is enabled. + */ + sorter?: string | boolean; + + /** + * Either the name of the parser to use for text-extraction or a value indicating whether text-extraction is enabled. + */ + parser?: string | boolean; + + /** + * A value indicating whether the column should be resizable. + */ + resizable?: boolean; + + /** + * The sorting to apply for empty cells. + */ + empty?: EmptySorting; + + /** + * The sorting to apply for text-cells. + */ + string?: StringSorting; + + /** + * The filter-concept for the column. + */ + filter?: ColumnFilter; + + /** + * The locked sort-order of the heading. + */ + lockedOrder?: SortOrder; +} diff --git a/types/tablesorter/System/TriggerCallbackHandler.d.ts b/types/tablesorter/System/TriggerCallbackHandler.d.ts new file mode 100644 index 0000000000..5cb4ec7384 --- /dev/null +++ b/types/tablesorter/System/TriggerCallbackHandler.d.ts @@ -0,0 +1,9 @@ +/** + * Provides the functionality to handle trigger-callbacks. + */ +export interface TriggerCallbackHandler { + /** + * Handles a trigger-callback. + */ + (table: TElement): void; +} diff --git a/types/tablesorter/System/TriggerNameMap.d.ts b/types/tablesorter/System/TriggerNameMap.d.ts new file mode 100644 index 0000000000..18b7c98061 --- /dev/null +++ b/types/tablesorter/System/TriggerNameMap.d.ts @@ -0,0 +1,104 @@ +import "jquery"; +import { RelativeSortDefinition } from "../Sorting/RelativeSortDefinition"; +import { SortDefinition } from "../Sorting/SortDefinition"; +import { TriggerCallbackHandler } from "./TriggerCallbackHandler"; + +/** + * The names and the data-types of the trigger. + */ +export interface TriggerNameMap { + /** + * Applies a sort to the table. + */ + sorton: [ReadonlyArray<(SortDefinition | RelativeSortDefinition)>, TriggerCallbackHandler?]; + + /** + * Resets the sorting. + */ + sortReset: [TriggerCallbackHandler?]; + + /** + * Adds rows to the table. + */ + addRows: [JQuery | string, boolean, TriggerCallbackHandler?]; + + /** + * Removes the tablesorter from the table. + */ + destroy: [boolean, TriggerCallbackHandler?]; + + /** + * Applies the widget to the table. + */ + applyWidgetId: string; + + /** + * Applies the configured widgets to the table. + */ + applyWidgets: TriggerCallbackHandler; + + /** + * Refreshes the widgets. + */ + refreshWidgets: [boolean?, boolean?]; + + /** + * Removes widgets. + */ + removeWidget: string | ReadonlyArray | boolean; + + /** + * Updates the data of the table-body. + */ + update: [boolean | ReadonlyArray, TriggerCallbackHandler?]; + + /** + * Updates the data of the table-body. + */ + updateRows: [boolean | ReadonlyArray, TriggerCallbackHandler?]; + + /** + * Updates the cache and optionally adds new `tbody`s. + */ + updateCache: [TriggerCallbackHandler?, JQuery?]; + + /** + * Updates the cell of the table. + */ + updateCell: [JQuery, (boolean | ReadonlyArray)?, TriggerCallbackHandler?]; + + /** + * Updates the table-headers. + */ + updateHeaders: TriggerCallbackHandler; + + /** + * Updates the data of the whole table. + */ + updateAll: [(boolean | ReadonlyArray)?, TriggerCallbackHandler?]; + + /** + * Performs a search. + */ + search: [ReadonlyArray?] | boolean; + + /** + * Opens the specified page. + */ + pageSet: number; + + /** + * Sets the specified size for the page. + */ + pageSize: number; + + /** + * Opens the specified page with the specified size. + */ + pageAndSize: [number, number]; + + /** + * Updates the pager and opens the specified page. + */ + pagerUpdate: number; +} diff --git a/types/tablesorter/Tablesorter.d.ts b/types/tablesorter/Tablesorter.d.ts new file mode 100644 index 0000000000..e07acadd96 --- /dev/null +++ b/types/tablesorter/Tablesorter.d.ts @@ -0,0 +1,654 @@ +import { ThemeCollection } from "./Design/ThemeCollection"; +import { FilterStatic } from "./Filtering/FilterStatic"; +import { FilterFormatter } from "./Filtering/Formatter/FilterFormatter"; +import { ParsedCell } from "./Parsing/ParsedCell"; +import { ParsedData } from "./Parsing/ParsedData"; +import { Parser } from "./Parsing/Parser"; +import { Locale } from "./System/Locale"; +import { TablesorterConfiguration } from "./System/TablesorterConfiguration"; +import { SortDefinition } from "./Sorting/SortDefinition"; +import { TablesorterConfigurationStore } from "./System/TablesorterConfigurationStore"; +import { RelativeSortDefinition } from "./Sorting/RelativeSortDefinition"; +import { TriggerCallbackHandler } from "./System/TriggerCallbackHandler"; +import { Widget } from "./Widgets/Widget"; +import { StorageConfiguration } from "./Storage/StorageConfiguration"; +import { MappedSettings } from "./System/MappedSettings"; +import { TablesorterHeading } from "./System/TablesorterHeading"; +import { HeaderResizeOptions } from "./System/HeaderResizeOptions"; +import { ParsedOption } from "./Parsing/ParsedOption"; + +/** + * Represents the tablesorter. + */ +export interface Tablesorter { + /** + * The default settings. + */ + defaults: TablesorterConfiguration; + + /** + * The settings of the themes. + */ + themes: ThemeCollection; + + /** + * The localized text for the tablesorter. + */ + language: Locale; + + /** + * The custom instance-methods added to the tablesorter. + */ + instanceMethods: { [name: string]: () => any }; + + /** + * The parsers of the tablesorter. + */ + parsers: Array>; + + /** + * The widgets of the tablesorter. + */ + widgets: Array>; + + /** + * Provides methods for the `filter`-widget. + */ + filter: FilterStatic; + + /** + * Provides methods for creating filter-controls. + */ + filterFormatter: FilterFormatter; + + /** + * Fetches all filters from the tablesorter. + * + * @param table + * The table to get the filters from. + * + * @return + * The filters applied to the `table`. + */ + getFilters(table: JQuery | TElement, cached?: boolean): string[]; + + /** + * Sets the filter-text of the tablesorter. + * + * @param table + * The table to set the filter-text for. + * + * @param filter + * The filter-text to set. + * + * @param apply + * A value indicating whether to apply the filter after setting the filter-text. + */ + setFilters(table: JQuery | TElement, filter: ReadonlyArray, apply?: boolean): void; + + /** + * Adds instance-methods to the tablesorter. + * + * @param methods + * The methods to add. + */ + addInstanceMethods(methods: { [name: string]: () => any }): void; + + /** + * Adds a parser to the tablesorter. + * + * @param parser + * The parser to add. + */ + addParser(parser: Parser): void; + + /** + * Adds a widget to the tablesorter. + * + * @param widget + * The widget to add. + */ + addWidget(widget: Widget): void; + + /** + * Verifies whether the specified `table` has a widget with the specified `id`. + * + * @param table + * The table to check. + * + * @param id + * The id of the widget to verify. + * + * @return + * A value indicating whether a widget with the specified `id` is loaded for the specified `table`. + */ + hasWidget(table: JQuery | TElement, id: string): boolean; + + /** + * Gets a parser of the tablesorter. + * + * @param id + * The id of the parser to get. + * + * @return + * The parser with the specified `id`. + */ + getParserById(id: string): Parser; + + /** + * Gets a widget of the tablesorter. + * + * @param id + * The id of the widget to get. + * + * @return + * The widget with the specified `id`. + */ + getWidgetById(id: string): Widget; + + /** + * Pins an error-message to the table. + * + * @param table + * The table to pin the error-message to. + * + * @param request + * The request which caused an error. + * + * @param settings + * The ajax-settings of the `request`. + * + * @param message + * A message which describes the error. + */ + showError(table: JQuery | TElement, request: string | JQuery.jqXHR, settings: JQueryAjaxSettings, message: string): void; + + /** + * Verifies whether the specified `text` is a digit. + * + * @param text + * The text to check. + * + * @return + * A value indicating whether the specified `text` is a digit. + */ + isDigit(text: string): boolean; + + /** + * Formats a text containing a number according to the correct format. + * + * @param text + * The text to format. + * + * @param table + * The table which is being processed. + */ + formatFloat(text: string, table: JQuery | TElement): void; + + /** + * Applies a sort to the table. + * + * @param config + * The configuration of the table-sorter. + * + * @param sort + * The sort to apply. + * + * @param callback + * A callback for post-processing the table. + */ + sortOn(config: TablesorterConfigurationStore, sort: ReadonlyArray<(SortDefinition | RelativeSortDefinition)>, callback?: TriggerCallbackHandler): void; + + /** + * Resets the sorting. + * + * @param config + * The configuration of the table-sorter. + * + * @param callback + * A callback for post-processing the table. + */ + sortReset(config: TablesorterConfigurationStore, callback?: TriggerCallbackHandler): void; + + /** + * Compares two strings and returns a value indicating whether one is less than, equal to or greater than the other. + * + * @param x + * The first string to compare. + * + * @param y + * The second string to compare. + * + * @param ascending + * A value indicating whether an ascending sort is being performed. + * + * @param index + * The index of the column which is being sorted. + * + * @param table + * The table which is being sorted. + * + * @return + * An integer that indicated the relative values of `x` and `y`: + * - If less than 0, `x` is less than `y`. + * - If `0`, `x` equals `y`. + * - If greater than 0, `x` is greater than `y`. + */ + sortNatural(x: string, y: string): number; + + /** + * Compares two strings and returns a value indicating whether one is less than, equal to or greater than the other. + * + * @param x + * The first string to compare. + * + * @param y + * The second string to compare. + * + * @param ascending + * A value indicating whether an ascending sort is being performed. + * + * @param index + * The index of the column which is being sorted. + * + * @param table + * The table which is being sorted. + * + * @return + * An integer that indicated the relative values of `x` and `y`: + * - If less than 0, `x` is less than `y`. + * - If `0`, `x` equals `y`. + * - If greater than 0, `x` is greater than `y`. + */ + sortText(x: string, y: string): number; + + /** + * Adds rows to the table. + * + * @param config + * The configuration of the table-sorter. + * + * @param rows + * The rows to add. + * + * @param resort + * Either a value indicating whether to resort the table or a new sort-definition to apply. + * + * @param callback + * A callback for post-processing the table. + */ + addRows(config: TablesorterConfigurationStore, rows: JQuery | string, resort: boolean | ReadonlyArray, callback?: TriggerCallbackHandler): void; + + /** + * Clears all table-bodies inside the specified `table`. + * + * @param table + * The table which is being processed. + */ + clearTableBody(table: JQuery | TElement): void; + + /** + * Refreshes all currently loaded widgets. + * + * @param table + * The table which is being processed. + * + * @param initialize + * A value indicating whether the widgets should be initialized. + * + * @param callback + * A callback for post-processing the table. + */ + applyWidget(table: JQuery | TElement, initialize?: boolean, callback?: TriggerCallbackHandler): void; + + /** + * Applies the widget to the specified `table`. + * + * @param table + * The table to apply the widget to. + * + * @param id + * The id of the widget to apply. + */ + applyWidgetId(table: JQuery | TElement, id: string): void; + + /** + * Removes widgets from the specified `table`. + * + * @param table + * The table to remove the widget from. + * + * @param id + * Either the id of the widget to remove or a value indicating whether to remove all widgets. + * + * @param refreshing + * A value indicating whether to keep the id of the widget in the `widgets`-option. + */ + removeWidget(table: JQuery | TElement, id: string | ReadonlyArray | boolean, refreshing?: boolean): void; + + /** + * Refreshes the widgets. + * + * @param table + * The table which is being processed. + * + * @param removeAll + * A value indicating whether the widgets should be removed from the table. + * + * @param reapply + * A value indicating whether the widgets should be reapplied after removing them. + */ + refreshWidgets(table: JQuery | TElement, removeAll?: boolean, reapply?: boolean): void; + + /** + * Adds all cached table-rows back into the table. + * + * @param config + * The configuration of the table-sorter. + */ + appendCache(config: TablesorterConfigurationStore): void; + + /** + * Updates the data of the table-body. + * + * @param config + * The configuration of the table-sorter. + * + * @param callback + * A callback for post-processing the table. + */ + update(config: TablesorterConfigurationStore, sorting?: boolean | ReadonlyArray, callback?: TriggerCallbackHandler): void; + + /** + * Updates the data of the table-body. + * + * @param config + * The configuration of the table-sorter. + * + * @param callback + * A callback for post-processing the table. + */ + updateRows(config: TablesorterConfigurationStore, sorting?: boolean | ReadonlyArray, callback?: TriggerCallbackHandler): void; + + /** + * Updates the cache and optionally adds new `tbody`s. + * + * @param config + * The configuration of the table-sorter. + * + * @param callback + * A callback for post-processing the table. + * + * @param tbodies + * The `tbody`s to add. + */ + updateCache(config: TablesorterConfigurationStore, callback?: TriggerCallbackHandler, tbodies?: JQuery): void; + + /** + * Updates the cell of the table. + * + * @param config + * The configuration of the table-sorter. + * + * @param cell + * The cell to update. + * + * @param sorting + * Either a new sorting to apply or a value indicating whether the current sorting should be re-applied. + * + * @param callback + * A callback for post-processing the table. + */ + updateCell(config: TablesorterConfigurationStore, cell: JQuery, sorting?: boolean | ReadonlyArray, callback?: TriggerCallbackHandler): void; + + /** + * Updates the table-headers. + * + * @param config + * The configuration of the table-sorter. + * + * @param callback + * A callback for post-processing the table. + */ + updateHeaders(config: TablesorterConfigurationStore, callback?: TriggerCallbackHandler): void; + + /** + * Updates the data of the whole table. + * + * @param config + * The configuration of the table-sorter. + * + * @param sorting + * Either a new sorting to apply or a value indicating whether the current sorting should be re-applied. + * + * @param callback + * A callback for post-processing the table. + */ + updateAll(config: TablesorterConfigurationStore, sorting?: boolean | ReadonlyArray, callback?: TriggerCallbackHandler): void; + + /** + * Restores the headers of a table. + * + * @param table + * The table to process. + */ + restoreHeaders(table: JQuery | TElement): void; + + /** + * Re-calculates the `data-column`-attribute of the cells inside the rows. + * + * If a `config` is passed, the `data-column`-attributes will be removed for cells whose index matches its actual position. + * + * @param rows + * The rows to compute. + * + * @param config + * The tablesorter-configuration. + */ + computeColumnIndex(rows: JQuery, config?: TablesorterConfigurationStore): void; + + /** + * Adds a `colgroup`-element to the specified `table`. + * + * @param table + * The table to add the fixed columns to. + */ + fixColumnWidth(table: JQuery | TElement): void; + + /** + * Identifies the correct setting for a header. + * + * @param header + * The header-cell to get the data from. + * + * @param headerConfig + * The configuration of the header to get the data from. + * + * @param option + * The name of the option to get. + * + * @return + * The correct `option` for the specified `header`. + */ + getData(header: JQuery | HTMLElement, headerConfig: TablesorterHeading, option: T): TablesorterHeading[T]; + + /** + * Identifies the correct settings for the specified column `key` in the per-column settings `object`. + * + * @param table + * The table which is being processed. + * + * @param object + * The object which contains column-specific values. + * + * @param key + * The column-index or the class-name of the collumn to get the settings from. + * + * @return + * The settings inside the settings-`object` for the column with the specified `key`. + */ + getColumnData(table: JQuery | TElement, object: MappedSettings, key: string | number): T; + + /** + * Parses the text of a column. + * + * @param table + * The table which is being processed. + * + * @param column + * The index of the column to get the text from. + * + * @param callback + * A callback for processing the cell-text. + * + * @param rowFilter + * An object for filtering the rows to process. + * + * @return + * The parsed data of the column. + */ + getColumnText( + table: JQuery | TElement, + column: number | "all", + callback?: (cell: ParsedCell) => void, + rowFilter?: JQuery.Selector | JQuery.TypeOrArray | JQuery | ((this: HTMLElement, index: number, element: HTMLElement) => boolean)): ParsedData; + + /** + * Binds the header-events to the specified `elements`. + * + * @param table + * The table which is being processed. + * + * @param elements + * The jQuery-object containing the elements to bind the header-events to. + */ + bindEvents(table: JQuery | TElement, elements: JQuery): void; + + /** + * Adds an event-handler to the `resize`-event for the sticky headers. + * + * @param table + * The table to add the event to. + * + * @param disable + * A value indicating whether the event-handler should be disabled. + * + * @param options + * Options for the event-handler. + */ + addHeaderResizeEvent(table: JQuery | TElement, disable: boolean, options?: HeaderResizeOptions): void; + + /** + * Adds a processing-icon to headers. + * + * @param table + * The table to apply the processing-icons to. + * + * @param state + * A valud indicating whether the headers are processing. + * + * @param headers + * A jQuery-object containing the objects to apply the processing-icons to. + */ + isProcessing(table: JQuery | TElement, state: boolean, headers?: JQuery): void; + + /** + * Checks whether a `SortDefinition` for the specified `column` exists. + * + * @param column + * The column-index to check. + * + * @param array + * The sort-definitions to browse. + * + * @return + * A value indicating whether a `SortDefinition` for the specified `column` exists. + */ + isValueInArray(value: number, array: ReadonlyArray<[number, any]>): boolean; + + /** + * Replaces all accent characters in the `text`. + * + * @param text + * The text to process. + * + * @return + * The processed text. + */ + replaceAccents(text: string): string; + + /** + * Saves data to the storage. + * + * @param table + * The table to store data for. + * + * @param key + * The name of the option to save. + * + * @param value + * The value of the option to save. + * + * @param options + * The options for customizing the way to save the data to the storage. + */ + storage(table: JQuery | TElement, key: string, value: any, options?: StorageConfiguration): void; + + /** + * Saves data to the storage. + * + * @param table + * The table to store data for. + * + * @param key + * The name of the option to save. + * + * @param value + * The value of the option to save. + * + * @param options + * The options for customizing the way to save the data to the storage. + */ + storage(table: JQuery | TElement, key: string, value?: null, options?: StorageConfiguration): any; + + /** + * Removes the `tablesorter` from a table. + * + * @param table + * The table to destroy. + * + * @param removeClasses + * A value indicating whether the classes added by tablesorter should be removed. + * + * @param callback + * A callback for post-processing the table. + */ + destroy(table: JQuery | TElement, removeClasses?: boolean, callback?: TriggerCallbackHandler): void; + + /** + * Provides the functionality to process the `tbody`. + * + * @param table + * The table the `tbody` belongs to. + * + * @param tbody + * The `tbody` to process. + * + * @param detach + * A value indicating whether the `tbody` should be detached. + */ + processTbody(table: JQuery | TElement, tbody: JQuery, detach: true): JQuery; + + processTbody(table: JQuery | TElement, tbody: JQuery, detach?: false): void; + + /** + * Resets the column-widths and optionally clears the locally stored column-widths. + * + * @param table + * The table to reset the resizable settings for. + * + * @param keepLocalSettings + * A value indicating whether local settings should not be cleared. + */ + resizableReset(table: JQuery | TElement, keepLocalSettings?: boolean): void; +} diff --git a/types/tablesorter/Widgets/ColumnWidgetOptions.d.ts b/types/tablesorter/Widgets/ColumnWidgetOptions.d.ts new file mode 100644 index 0000000000..ca71e0b27c --- /dev/null +++ b/types/tablesorter/Widgets/ColumnWidgetOptions.d.ts @@ -0,0 +1,19 @@ +/** + * Represents options for the `column`-widget. + */ +export interface ColumnOptions { + /** + * The names of the classes to apply when sorting in chronological order. + */ + columns?: string[]; + + /** + * A value indicating whether the class specified in `columns` should also be applied to the table-head. + */ + columns_thead?: boolean; + + /** + * A value indicating whether the class specified in `columns` should also be applied to the table-foot. + */ + columns_tfoot?: boolean; +} diff --git a/types/tablesorter/Widgets/FilterOptions.d.ts b/types/tablesorter/Widgets/FilterOptions.d.ts new file mode 100644 index 0000000000..0224ccf1f3 --- /dev/null +++ b/types/tablesorter/Widgets/FilterOptions.d.ts @@ -0,0 +1,174 @@ +import "jquery"; +import { FilterControlFactory } from "../Filtering/Formatter/FilterControlFactory"; +import { FilterFunction } from "../Filtering/FilterFunction"; +import { FilterFunctionCollection } from "../Filtering/FilterFunctionCollection"; +import { FilterPlaceholders } from "../Filtering/FilterPlaceholders"; +import { MatchTypeSettings } from "../Filtering/MatchTypeSettings"; +import { SelectSources } from "../Filtering/SelectSources"; +import { MappedSettings } from "../System/MappedSettings"; +import { TablesorterConfigurationStore } from "../System/TablesorterConfigurationStore"; + +/** + * Represents options for the `filter`-widget. + */ +export interface FilterOptions { + /** + * A value indicating whether filtering is enabled. + */ + filter_columnFilters?: boolean; + + /** + * A value indicating whether the letter-case should be ignored. + */ + filter_ignoreCase?: boolean; + + /** + * A value indicating whether the filters should be saved to the client. + */ + filter_saveFilters?: boolean; + + /** + * A value indicating whether a search should be performed without having to hit `Enter`. + */ + filter_liveSearch?: (boolean | number) | MappedSettings<(boolean | number)>; + + /** + * A value indicating whether only filtered rows should be considered while searching. + */ + filter_searchFiltered?: boolean; + + /** + * A jQuery-selector for querying the button for resetting the filter. + */ + filter_reset?: JQuery.Selector | JQuery; + + /** + * A value indicating whether the filter should be resetted when `ESC` is hit. + */ + filter_resetOnEsc?: boolean; + + /** + * A value indicating whether the filter-controls should be hidden when the table is empty. + */ + filter_hideEmpty?: boolean; + + /** + * A value indicating whether the filter should hide automatically. + */ + filter_hideFilters?: boolean | ((config: TablesorterConfigurationStore) => boolean); + + /** + * The default filters to apply. + */ + filter_defaultFilter?: MappedSettings; + + /** + * A set of filters to prevent. + */ + filter_excludeFilter?: MappedSettings; + + /** + * The jQuery-selector for querying the external search-box. + */ + filter_external?: JQuery.Selector; + + /** + * The filter-controls to apply. + */ + filter_formatter?: MappedSettings; + + /** + * A value indicating whether searches using the `{index}:{query}` in the anyMatch-textbox is allowed. + */ + filter_columnAnyMatch?: boolean; + + /** + * A set of classes to apply to the filter-cells. + */ + filter_cellFilter?: string | string[]; + + /** + * A value indicating whether child-rows should be considered when filtering. + */ + filter_childRows?: boolean; + + /** + * A value indicating whether only the filtered column of child-rows should be considered when filtering. + */ + filter_childByColumn?: boolean; + + /** + * A value indicating whether siblings should be displayed when filtering. + */ + filter_childWithSibs?: boolean; + + /** + * The attribute-name which is used for querying the default filter-value. + */ + filter_defaultAttrib?: string; + + /** + * The template for generating the ARIA-label of the filter-control. + */ + filter_filterLabel?: string; + + /** + * A set of filter-functions to apply for the columns. + */ + filter_functions?: MappedSettings | FilterFunction>; + + /** + * The match-types to apply to the controls. + */ + filter_matchType?: MatchTypeSettings; + + /** + * A value indicating whether searches should be performed with the `starts with`-logic. + */ + filter_startsWith?: boolean; + + /** + * A class for indicating whether only visible entries should be available in `select`-controls. + */ + filter_onlyAvail?: string; + + /** + * The placeholders to set initially. + */ + filter_placeholder?: FilterPlaceholders; + + /** + * The sources for the select-controls. + */ + filter_selectSource?: SelectSources | MappedSettings>; + + /** + * The character for separating display-name and value inside the `filter_selectSource`. + */ + filter_selectSourceSeparator?: string; + + /** + * A value indicating whether filtering is performed server-side. + */ + filter_serversideFiltering?: boolean; + + /** + * The number of miliseconds to wait before performing a search. + */ + filter_searchDelay?: number; + + /** + * A value indicating whether filtering should be perormed using parsed data. + */ + filter_useParsedData?: boolean; + + /** + * A CSS class which is applied to each filter-cell. + */ + filter_cssFilter?: string | string[]; + + /** + * A CSS class which is applied for each cel which is filtered. + */ + filter_filteredRow?: string; +} diff --git a/types/tablesorter/Widgets/PagerOptions.d.ts b/types/tablesorter/Widgets/PagerOptions.d.ts new file mode 100644 index 0000000000..27d87700b4 --- /dev/null +++ b/types/tablesorter/Widgets/PagerOptions.d.ts @@ -0,0 +1,146 @@ +import "jquery"; +import { AjaxDataProcessor } from "../Paging/AjaxDataProcessor"; +import { AjaxErrorHandler } from "../Paging/AjaxErrorHandler"; +import { AjaxUrlProcessor } from "../Paging/AjaxUrlProcessor"; +import { PagerClasses } from "../Paging/PagerClasses"; +import { PagerInitialRows } from "../Paging/PagerInitialRows"; +import { PagerOutputProcessor } from "../Paging/PagerOutputProcessor"; +import { PagerSelectors } from "../Paging/PagerSelectors"; +import { PageSize } from "../Paging/PageSize"; + +/** + * Provides options for the `pager`-widget. + */ +export interface PagerOptions { + /** + * The url to query data from. + * + * Following portions of text are substituted: + * + * | Tag | Replacement | + * |----------------------------------------|------------------------------------------------------------------------| + * | `{page}` | The zero-based index of the page to show. | + * | `{page+n}` | The zero-based index of the page added to `n`. | + * | `{size}` | The number of rows to fetch. | + * | `{sortList:name}` or `{sort:name}` | A GET-variable called `name` containing the current sorting. | + * | `{filterList:name}` or `{filter:name}` | A GET-variable called `name` containing all currently applied filters. | + */ + pager_ajaxUrl?: string; + + /** + * Pre-processes the url for `ajax`. + */ + pager_customAjaxUrl?: AjaxUrlProcessor; + + /** + * The settings for the api-interaction of the pager. + */ + pager_ajaxObject?: JQueryAjaxSettings; + + /** + * Handles errors caused by an ajax-request. + */ + pager_ajaxError?: AjaxErrorHandler; + + /** + * Processes the ajax-result for the `pager`-widget. + * + * @param data + * The result of ajax. + * + * @param table + * The table which is being processed. + * + * @param request + * The ajax-request which processed the `data`. + * + * @return + * The data for the pager to show. + */ + pager_ajaxProcessing?: AjaxDataProcessor; + + /** + * The output to display in the output-area. + * + * Following portions of text are substituted: + * + * | Tag | Replacement | + * |--------------------|----------------------------------------------| + * | `{size}` | The current page size. | + * | `{page}` | The current page. | + * | `{page:input}` | The page inputted by the user. | + * | `{totalPages}` | The total amount of pages. | + * | `{filteredPages}` | The filtered number of pages. | + * | `{startRow}` | The number of the first row being displayed. | + * | `{startRow:input}` | The start-row inputted by the user. | + * | `{endRow}` | The number of the last row being displayed. | + * | `{filteredRows}` | The amount of filtered rows. | + * | `{totalRows}` | The total amount of rows. | + */ + pager_output?: string | PagerOutputProcessor; + + /** + * The number of the first page to show. + */ + pager_startPage?: number; + + /** + * The number of the first page to show after applying a filter. + */ + pager_pageReset?: number | boolean; + + /** + * The initial page-size. + */ + pager_size?: PageSize; + + /** + * A value indicating whether to split child-rows on page-breaks. + */ + pager_countChildRows?: boolean; + + /** + * A value indicating whether an ajax-request should be executed after the initialization of the table. + */ + pager_processAjaxOnInit?: boolean; + + /** + * The initial amount of rows to show. + */ + pager_initialRows?: PagerInitialRows; + + /** + * The key to of the local storage to save data to. + */ + pager_storageKey?: string; + + /** + * A value indicating whether to save the current page locally. + */ + pager_savePages?: boolean; + + /** + * A value indicating whether to remove the rows while performing sortings for speed up. + */ + pager_removeRows?: boolean; + + /** + * The selectors for for handling click-events. + */ + pager_selectors?: PagerSelectors; + + /** + * The css-classes to apply to the pager-controls. + */ + pager_css?: PagerClasses; + + /** + * A value indicating whether the table should always have the same number of rows even if there is a lesser number of records to show. + */ + pager_fixedHeight?: boolean; + + /** + * A value indicating whether the `pager_css.disabled` class should be applied to non-applicable buttons. + */ + pager_updateArrows?: boolean; +} diff --git a/types/tablesorter/Widgets/ResizingOptions.d.ts b/types/tablesorter/Widgets/ResizingOptions.d.ts new file mode 100644 index 0000000000..cb9a727236 --- /dev/null +++ b/types/tablesorter/Widgets/ResizingOptions.d.ts @@ -0,0 +1,34 @@ +/** + * Provides options for the `resizable`-widget. + */ +export interface ResizingOptions { + /** + * A value indicating whether column widths are saved locally. + */ + resizable?: boolean; + + /** + * A value indicating whether the last column should have a resize-handle. + */ + resizable_addLastColumn?: boolean; + + /** + * A value indicating whether the user can resize the columns inside the footer. + */ + resizable_includeFooter?: boolean; + + /** + * A value indicating whether always the last column should shrink when resizing. + */ + resizable_targetLast?: boolean; + + /** + * The number of milliseconds to wait before raising the `mousemove`-event. + */ + resizable_throttle?: boolean | number; + + /** + * The initial widths of the columns. + */ + resizable_widths?: string[]; +} diff --git a/types/tablesorter/Widgets/SaveSortOptions.d.ts b/types/tablesorter/Widgets/SaveSortOptions.d.ts new file mode 100644 index 0000000000..d81fdca971 --- /dev/null +++ b/types/tablesorter/Widgets/SaveSortOptions.d.ts @@ -0,0 +1,36 @@ +import { StorageType } from "../Storage/StorageType"; + +/** + * Provides options for the `saveSort`-widget. + */ +export interface SaveSortOptions { + /** + * A value indicating whether the sorting should be saved locally. + */ + saveSort?: boolean; + + /** + * The id of the `saveSort`-settings. + */ + storage_tableId?: string; + + /** + * A url to a table for grouping settings together. + */ + storage_fixedUrl?: string; + + /** + * The name of the data-attribute to obtain an id for the table which allows grouping multiple tables together. + */ + storage_group?: string; + + /** + * The name of the data-attribute to obtain a table url which allows grouping tables together across pages. + */ + storage_page?: string; + + /** + * The storage-type to use. + */ + storage_storageType?: StorageType; +} diff --git a/types/tablesorter/Widgets/StickyHeaderOptions.d.ts b/types/tablesorter/Widgets/StickyHeaderOptions.d.ts new file mode 100644 index 0000000000..d7a86d0fb0 --- /dev/null +++ b/types/tablesorter/Widgets/StickyHeaderOptions.d.ts @@ -0,0 +1,61 @@ +import "jquery"; + +/** + * Provides options for the `stickyHeaders`-widget. + */ +export interface StickyHeaderOptions { + /** + * A set of classes to add to the sticky header. + */ + stickyHeaders?: string; + + /** + * A value indicating whether the table should be resized automatically when data is added to or removed from the table. + */ + stickyHeaders_addResizeEvent?: boolean; + + /** + * A value indicating whether the caption should be included in the sticky header. + */ + stickyHeaders_includeCaption?: boolean; + + /** + * A jQuery-selector to get an element to append the sticky header to. + */ + stickyHeaders_appendTo?: JQuery.Selector | JQuery; + + /** + * A jQuery-selector to get an element to attach the sticky header to. + */ + stickyHeaders_attachTo?: JQuery.Selector | JQuery; + + /** + * A string to append to the table-id for the cloned sticky table. + */ + stickyHeaders_cloneId?: string; + + /** + * A value indicating whether the filter should be scrolled into view when inputing a filter. + */ + stickyHeaders_filteredToTop?: boolean; + + /** + * Either a number of the offset to the top of the browser-window or a jQuery-selector or -object for the elemtn which represents the offset. + */ + stickyHeaders_offset?: number | JQuery.Selector | JQuery; + + /** + * The jQuery-selector or -object to monitor for horizontal scrolling. + */ + stickyHeaders_xScroll?: JQuery.Selector | JQuery; + + /** + * The jQuery-selector or -object to monitor for vertical scrolling. + */ + stickyHeaders_yScroll?: JQuery.Selector | JQuery; + + /** + * The z-index of the sticky header. + */ + stickyHeaders_zindex?: number; +} diff --git a/types/tablesorter/Widgets/Widget.d.ts b/types/tablesorter/Widgets/Widget.d.ts new file mode 100644 index 0000000000..747602ea14 --- /dev/null +++ b/types/tablesorter/Widgets/Widget.d.ts @@ -0,0 +1,73 @@ +import { TablesorterConfigurationStore } from "../System/TablesorterConfigurationStore"; +import { WidgetOptions } from "./WidgetOptions"; + +/** + * Represents a widget. + */ +export interface Widget { + /** + * The identification of the widget. + */ + id: string; + + /** + * The priority of the widget. + */ + priority: number; + + /** + * The default options of the widget. + */ + options: { [name: string]: any }; + + /** + * Initializes the widget. + * + * @param table + * The table which is being processed. + * + * @param thisWidget + * This instance of the widget. + * + * @param config + * The configuration of the tablesorter. + * + * @param widgetOptions + * The widget-options of the tablesorter. + */ + init(table: TElement, thisWidget: this, config: TablesorterConfigurationStore, widgetOptions: { [name: string]: any }): void; + + /** + * Pre-processes the table after applying a sort. + * + * @param table + * The table which is being processed. + * + * @param config + * The configuration of the tablesorter. + * + * @param widgetOptions + * The widget-options of the tablesorter. + * + * @param initializing + * A value indicating whether the widget is being initialized. + */ + format(table: TElement, config: TablesorterConfigurationStore, widgetOptions: { [name: string]: any }, initializing: boolean): void; + + /** + * Removes the widget from the table. + * + * @param table + * The table which is being processed. + * + * @param config + * The configuration of the tablesorter. + * + * @param widgetOptions + * The widget-options of the tablesorter. + * + * @param refreshing + * A value indicating whether the widgets are being refreshed. + */ + remove(table: TElement, config: TablesorterConfigurationStore, widgetOptions: { [name: string]: any }, refreshing: boolean): void; +} diff --git a/types/tablesorter/Widgets/WidgetOptionStore.d.ts b/types/tablesorter/Widgets/WidgetOptionStore.d.ts new file mode 100644 index 0000000000..be87d8fa80 --- /dev/null +++ b/types/tablesorter/Widgets/WidgetOptionStore.d.ts @@ -0,0 +1,26 @@ +import { WidgetOptions } from "./WidgetOptions"; + +/** + * Represents the configuration-store of the widgets. + */ +export interface WidgetOptionStore extends WidgetOptions { + /** + * A value indicating whether the filters have initialized. + */ + filter_initialized: boolean; + + /** + * The jQuery-object containing the cloned table for the sticky headers. + */ + $sticky: JQuery; + + /** + * A jQuery-object containing all external filters. + */ + filter_$externalFilters: JQuery; + + /** + * A jQuery-object containing all filters which are bound to all columns. + */ + filter_$anyMatch: JQuery; +} diff --git a/types/tablesorter/Widgets/WidgetOptions.d.ts b/types/tablesorter/Widgets/WidgetOptions.d.ts new file mode 100644 index 0000000000..0689cfcd12 --- /dev/null +++ b/types/tablesorter/Widgets/WidgetOptions.d.ts @@ -0,0 +1,21 @@ +import { ColumnOptions } from "./ColumnWidgetOptions"; +import { FilterOptions } from "./FilterOptions"; +import { ResizingOptions } from "./ResizingOptions"; +import { SaveSortOptions } from "./SaveSortOptions"; +import { StickyHeaderOptions } from "./StickyHeaderOptions"; +import { PagerOptions } from "./PagerOptions"; +import { ZebraOptions } from "./ZebraOptions"; + +/** + * Represents options for the widgets. + */ +export interface WidgetOptions extends + ColumnOptions, + FilterOptions, + ResizingOptions, + SaveSortOptions, + StickyHeaderOptions, + PagerOptions, + ZebraOptions { + [option: string]: any; +} diff --git a/types/tablesorter/Widgets/ZebraOptions.d.ts b/types/tablesorter/Widgets/ZebraOptions.d.ts new file mode 100644 index 0000000000..77cac66113 --- /dev/null +++ b/types/tablesorter/Widgets/ZebraOptions.d.ts @@ -0,0 +1,9 @@ +/** + * Provides settings of the `zebra`-widget. + */ +export interface ZebraOptions { + /** + * The classes to add to even and odd rows. + */ + zebra?: [string, string]; +} diff --git a/types/tablesorter/index.d.ts b/types/tablesorter/index.d.ts new file mode 100644 index 0000000000..0541d7ced8 --- /dev/null +++ b/types/tablesorter/index.d.ts @@ -0,0 +1,244 @@ +// Type definitions for tablesorter 2.31 +// Project: https://mottie.github.io/tablesorter/ +// Definitions by: Manuel Thalmann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 + +import "jqueryui"; +import { CoreTheme } from "./Design/CoreTheme"; +import { Theme } from "./Design/Theme"; +import { ThemeCollection } from "./Design/ThemeCollection"; +import { ColumnFilter } from "./Filtering/ColumnFilter"; +import { FilterBox } from "./Filtering/FilterBox"; +import { FilterEventHandler } from "./Filtering/FilterEventHandler"; +import { FilterFunction } from "./Filtering/FilterFunction"; +import { FilterFunctionCollection } from "./Filtering/FilterFunctionCollection"; +import { FilterPlaceholders } from "./Filtering/FilterPlaceholders"; +import { FilterStatic } from "./Filtering/FilterStatic"; +import { FilterControlFactory } from "./Filtering/Formatter/FilterControlFactory"; +import { FilterFormatter } from "./Filtering/Formatter/FilterFormatter"; +import { ComparableOptions } from "./Filtering/Formatter/Options/ComparableOptions"; +import { ControlOptions } from "./Filtering/Formatter/Options/ControlOptions"; +import { DateOptions } from "./Filtering/Formatter/Options/DateOptions"; +import { DefaultValueOptions } from "./Filtering/Formatter/Options/DefaultValueOptions"; +import { DelayableOptions } from "./Filtering/Formatter/Options/DelayableOptions"; +import { Html5ColorOptions } from "./Filtering/Formatter/Options/Html5ColorOptions"; +import { Html5NumberOptions } from "./Filtering/Formatter/Options/Html5NumberOptions"; +import { Html5RangeOptions } from "./Filtering/Formatter/Options/Html5RangeOptions"; +import { IntervalOptions } from "./Filtering/Formatter/Options/IntervalOptions"; +import { NumericOptions } from "./Filtering/Formatter/Options/NumericOptions"; +import { PreviewableOptions } from "./Filtering/Formatter/Options/PreviewableOptions"; +import { RangeOptions } from "./Filtering/Formatter/Options/RangeOptions"; +import { Select2Options } from "./Filtering/Formatter/Options/Select2Options"; +import { StrictOptions } from "./Filtering/Formatter/Options/StrictOptions"; +import { TestableOptions } from "./Filtering/Formatter/Options/TestableOptions"; +import { ToggleableOptions } from "./Filtering/Formatter/Options/ToggleableOptions"; +import { UIDateCompareOptions } from "./Filtering/Formatter/Options/UIDateCompareOptions"; +import { UIDateRangeOptions } from "./Filtering/Formatter/Options/UIDateRangeOptions"; +import { UIRangeOptions } from "./Filtering/Formatter/Options/UIRangeOptions"; +import { UISliderOptions } from "./Filtering/Formatter/Options/UISliderOptions"; +import { UISpinnerOptions } from "./Filtering/Formatter/Options/UISpinnerOptions"; +import { FunctionSelectSource } from "./Filtering/FunctionSelectSource"; +import { MatchType } from "./Filtering/MatchType"; +import { MatchTypeSettings } from "./Filtering/MatchTypeSettings"; +import { SelectSource } from "./Filtering/SelectSource"; +import { SelectSources } from "./Filtering/SelectSources"; +import { GlobalizeSettings } from "./Globalization/GlobalizeSettings"; +import { AjaxDataProcessor } from "./Paging/AjaxDataProcessor"; +import { AjaxErrorHandler } from "./Paging/AjaxErrorHandler"; +import { AjaxUrlProcessor } from "./Paging/AjaxUrlProcessor"; +import { PagerClasses } from "./Paging/PagerClasses"; +import { PagerConfiguration } from "./Paging/PagerConfiguration"; +import { PagerConfigurationStore } from "./Paging/PagerConfigurationStore"; +import { PagerDataPart } from "./Paging/PagerDataPart"; +import { PagerEventHandler } from "./Paging/PagerEventHandler"; +import { PagerEventMap } from "./Paging/PagerEventMap"; +import { PagerInitialRows } from "./Paging/PagerInitialRows"; +import { PagerMemory } from "./Paging/PagerMemory"; +import { PagerOutputProcessor } from "./Paging/PagerOutputProcessor"; +import { PagerSelectors } from "./Paging/PagerSelectors"; +import { PageSize } from "./Paging/PageSize"; +import { ParsedCell } from "./Parsing/ParsedCell"; +import { ParsedData } from "./Parsing/ParsedData"; +import { ParsedOption } from "./Parsing/ParsedOption"; +import { Parser } from "./Parsing/Parser"; +import { ParserType } from "./Parsing/ParserType"; +import { TextExtractor } from "./Parsing/TextExtractor"; +import { EmptySorting } from "./Sorting/EmptySorting"; +import { NumberSorter } from "./Sorting/NumberSorter"; +import { RelativeSortDefinition } from "./Sorting/RelativeSortDefinition"; +import { RelativeSorting } from "./Sorting/RelativeSorting"; +import { SortDefinition } from "./Sorting/SortDefinition"; +import { SortDefinitionOrder } from "./Sorting/SortDefinitionOrder"; +import { SortInitiator } from "./Sorting/SortInitiator"; +import { SortOrder } from "./Sorting/SortOrder"; +import { StringSorting } from "./Sorting/StringSorting"; +import { TableSorting } from "./Sorting/TableSorting"; +import { TextSorter } from "./Sorting/TextSorter"; +import { StorageConfiguration } from "./Storage/StorageConfiguration"; +import { StorageType } from "./Storage/StorageType"; +import { CommonEventHandler } from "./System/CommonEventHandler"; +import { ConfigEventHandler } from "./System/ConfigEventHandler"; +import { ConfigEventMap } from "./System/ConfigEventMap"; +import { EventMap } from "./System/EventMap"; +import { HeaderResizeOptions } from "./System/HeaderResizeOptions"; +import { InitializationEventHandler } from "./System/InitializationEventHandler"; +import { Locale } from "./System/Locale"; +import { MappedSettings } from "./System/MappedSettings"; +import { ParameterlessTriggerNameMap } from "./System/ParameterlessTriggerNameMap"; +import { RenderHeaderEventHandler } from "./System/RenderHeaderEventHandler"; +import { RenderTemplateEventHandler } from "./System/RenderTemplateEventHandler"; +import { TablesorterCache } from "./System/TablesorterCache"; +import { TablesorterConfiguration } from "./System/TablesorterConfiguration"; +import { TablesorterConfigurationStore } from "./System/TablesorterConfigurationStore"; +import { TablesorterEventHandler } from "./System/TablesorterEventHandler"; +import { TablesorterHeading } from "./System/TablesorterHeading"; +import { TriggerCallbackHandler } from "./System/TriggerCallbackHandler"; +import { TriggerNameMap } from "./System/TriggerNameMap"; +import { Tablesorter } from "./Tablesorter"; +import { Widget } from "./Widgets/Widget"; +import { WidgetOptions } from "./Widgets/WidgetOptions"; +import { WidgetOptionStore } from "./Widgets/WidgetOptionStore"; + +export { + CoreTheme, + Theme, + ThemeCollection, + ColumnFilter, + FilterBox, + FilterFunction, + FilterEventHandler, + FilterFunctionCollection, + FilterPlaceholders, + FilterStatic, + FilterControlFactory, + FilterFormatter, + ComparableOptions, + ControlOptions, + DateOptions, + DefaultValueOptions, + DelayableOptions, + Html5ColorOptions, + Html5NumberOptions, + Html5RangeOptions, + IntervalOptions, + NumericOptions, + PreviewableOptions, + RangeOptions, + Select2Options, + StrictOptions, + TestableOptions, + ToggleableOptions, + UIDateCompareOptions, + UIDateRangeOptions, + UIRangeOptions, + UISliderOptions, + UISpinnerOptions, + FunctionSelectSource, + MatchType, + MatchTypeSettings, + SelectSource, + SelectSources, + GlobalizeSettings, + AjaxDataProcessor, + AjaxErrorHandler, + AjaxUrlProcessor, + PagerClasses, + PagerConfiguration, + PagerConfigurationStore, + PagerDataPart, + PagerEventHandler, + PagerEventMap, + PagerInitialRows, + PagerMemory, + PagerOutputProcessor, + PagerSelectors, + PageSize, + ParsedCell, + ParsedData, + ParsedOption, + Parser, + ParserType, + TextExtractor, + EmptySorting, + NumberSorter, + RelativeSortDefinition, + RelativeSorting, + SortDefinition, + SortDefinitionOrder, + SortInitiator, + SortOrder, + StringSorting, + TableSorting, + TextSorter, + StorageConfiguration, + StorageType, + CommonEventHandler, + ConfigEventHandler, + ConfigEventMap, + EventMap, + HeaderResizeOptions, + InitializationEventHandler, + Locale, + MappedSettings, + ParameterlessTriggerNameMap, + RenderHeaderEventHandler, + RenderTemplateEventHandler, + TablesorterCache, + TablesorterConfiguration, + TablesorterConfigurationStore, + TablesorterEventHandler, + TablesorterHeading, + TriggerCallbackHandler, + TriggerNameMap, + Tablesorter, + Widget, + WidgetOptions, + WidgetOptionStore +}; + +declare global { + interface HTMLElement { + /** + * A value indicating whether the tablesorter has initialized. + */ + hasInitialized: boolean; + + /** + * The configuration of the tablesorter. + */ + config: TablesorterConfigurationStore; + } + + interface JQueryStatic { + /** + * The tablesorter. + */ + tablesorter: Tablesorter; + } + + interface JQuery { + /** + * Initializes a new `tablesorter`. + * + * @param options + * The options for the tablesorter. + */ + tablesorter(options?: TablesorterConfiguration): this; + + /** + * Initializes a pager for a tablesorter. + */ + tablesorterPager(options?: PagerConfiguration): this; + + trigger>(name: T, extraParameters: TriggerNameMap[T]): this; + + trigger(name: keyof typeof ParameterlessTriggerNameMap): this; + + bind(name: keyof typeof EventMap, callback: TablesorterEventHandler): this; + bind(name: keyof typeof ConfigEventMap, callback: ConfigEventHandler): this; + bind(name: "filterStart", callback: FilterEventHandler): this; + bind(name: keyof typeof PagerEventMap, callback: PagerEventHandler): this; + bind(name: "stickyHeadersInit", callback: CommonEventHandler): this; + } +} diff --git a/types/tablesorter/test/Events.ts b/types/tablesorter/test/Events.ts new file mode 100644 index 0000000000..412ff6b0fa --- /dev/null +++ b/types/tablesorter/test/Events.ts @@ -0,0 +1,66 @@ +import { TablesorterEventHandler, ConfigEventHandler, FilterEventHandler, CommonEventHandler, PagerEventHandler } from "tablesorter"; + +/** + * Provides tests for the events. + */ +export class TestEvents { + /** + * Tests for the events. + */ + Test() { + const table = $("#myTable"); + const eventHandler: TablesorterEventHandler = (eventArgs, table) => { + // $ExpectType TriggeredEvent + eventArgs; + // $ExpectType T + table; + }; + + const configEventHandler: ConfigEventHandler = (eventArgs, config) => { + // $ExpectType TriggeredEvent + eventArgs; + // $ExpectType TablesorterConfigurationStore + config; + }; + + const filterEventHandler: FilterEventHandler = (eventArgs, filters) => { + // $ExpectType TriggeredEvent + eventArgs; + // $ExpectType string[] + filters; + }; + + const commonEventHandler: CommonEventHandler = (eventArgs) => { + // $ExpectType TriggeredEvent + eventArgs; + }; + + const pagerEventHandler: PagerEventHandler = (eventArgs, options) => { + // $ExpectType TriggeredEvent + eventArgs; + // $ExpectType TablesorterConfigurationStore | PagerConfigurationStore + options; + }; + + /** + * Binding to events + */ + table.bind("refreshComplete", eventHandler); + table.bind("sortBegin", eventHandler); + table.bind("sortEnd", eventHandler); + table.bind("sortStart", eventHandler); + table.bind("tablesorter-initialized", eventHandler); + table.bind("tablesorter-ready", eventHandler); + table.bind("updateComplete", eventHandler); + table.bind("filterEnd", configEventHandler); + table.bind("filterInit", configEventHandler); + table.bind("filterStart", filterEventHandler); + table.bind("stickyHeadersInit", commonEventHandler); + table.bind("widgetRemoveEnd", eventHandler); + table.bind("pageMoved", pagerEventHandler); + table.bind("pagerBeforeInitialized", pagerEventHandler); + table.bind("pagerChange", pagerEventHandler); + table.bind("pagerComplete", pagerEventHandler); + table.bind("pagerInitialized", pagerEventHandler); + } +} diff --git a/types/tablesorter/test/Methods.ts b/types/tablesorter/test/Methods.ts new file mode 100644 index 0000000000..cfe22ca51c --- /dev/null +++ b/types/tablesorter/test/Methods.ts @@ -0,0 +1,351 @@ +import "./Tests"; +import { SortDefinitionOrder, TriggerCallbackHandler, SortDefinition, RelativeSortDefinition, Parser, Widget, ParsedCell, TablesorterHeading, StorageConfiguration } from "tablesorter"; +import { RelativeSorting } from "tablesorter/Sorting/RelativeSorting"; +import { StorageType } from "tablesorter/Storage/StorageType"; + +/** + * Provides tests for the methods. + */ +export class TestMethods { + /** + * A jQuery-object for testing. + */ + protected table = $(""); + + /** + * A set of sort-definitions for testing. + */ + protected sorting: ReadonlyArray = [[0, SortDefinitionOrder.Ascending], [1, 0]]; + + /** + * A set of relative sort-definitions for testing. + */ + protected relativeSorting: ReadonlyArray = [[0, RelativeSorting.Opposite], [1, RelativeSorting.Same]]; + + /** + * A set of mixed sort-definitions for testing. + */ + protected mixedSorting: ReadonlyArray = [ + [0, SortDefinitionOrder.Descending], + [1, RelativeSorting.Opposite]]; + + /** + * A trigger-callback for testing. + */ + protected triggerCallback: TriggerCallbackHandler = (table) => { + // $ExpectType T + table; + } + + /** + * Tests for the methods. + */ + Test() { + const $: JQueryStatic = {} as any; + const tableElement = this.table[0]; + const config = this.table[0].config; + const parser: Parser = {} as any; + const widget: Widget = {} as any; + const parsedCellCallback = (cell: ParsedCell): void => { }; + const ajaxSettings: JQuery.AjaxSettings = {} as any; + const request: JQuery.jqXHR = {} as any; + const storageConfig: StorageConfiguration = { + group: "", + id: "", + page: "", + storageType: StorageType.Cookie, + url: "" + }; + + /** + * Methods + * Invoking methods directly + */ + $.tablesorter.addHeaderResizeEvent(this.table, true); + $.tablesorter.addHeaderResizeEvent(this.table, true, { timer: 20 }); + $.tablesorter.addHeaderResizeEvent(tableElement, true); + $.tablesorter.addHeaderResizeEvent(tableElement, true, { timer: 20 }); + + $.tablesorter.addRows(config, $(), true); + $.tablesorter.addRows(config, $(), true, this.triggerCallback); + $.tablesorter.addRows(config, $(), this.sorting); + $.tablesorter.addRows(config, $(), this.sorting, this.triggerCallback); + $.tablesorter.addRows(config, "", true); + $.tablesorter.addRows(config, "", true, this.triggerCallback); + $.tablesorter.addRows(config, "", this.sorting); + $.tablesorter.addRows(config, "", this.sorting, this.triggerCallback); + + $.tablesorter.addInstanceMethods({ hello: () => null }); + $.tablesorter.addInstanceMethods({ world() { } }); + + $.tablesorter.addParser(parser); + + $.tablesorter.addWidget(widget); + + $.tablesorter.appendCache(config); + + $.tablesorter.applyWidget(this.table); + $.tablesorter.applyWidget(this.table, true); + $.tablesorter.applyWidget(this.table, true, this.triggerCallback); + $.tablesorter.applyWidget(tableElement); + $.tablesorter.applyWidget(tableElement, true); + $.tablesorter.applyWidget(tableElement, true, this.triggerCallback); + + $.tablesorter.applyWidgetId(this.table, "zebra"); + $.tablesorter.applyWidgetId(tableElement, "zebra"); + + $.tablesorter.bindEvents(this.table, $()); + $.tablesorter.bindEvents(tableElement, $()); + + $.tablesorter.clearTableBody(this.table); + $.tablesorter.clearTableBody(tableElement); + + $.tablesorter.computeColumnIndex($(), config); + + $.tablesorter.destroy(this.table); + $.tablesorter.destroy(this.table, true); + $.tablesorter.destroy(this.table, true, this.triggerCallback); + $.tablesorter.destroy(tableElement); + $.tablesorter.destroy(tableElement, true); + $.tablesorter.destroy(tableElement, true, this.triggerCallback); + + $.tablesorter.fixColumnWidth(this.table); + $.tablesorter.fixColumnWidth(tableElement); + + $.tablesorter.formatFloat("", this.table); + $.tablesorter.formatFloat("", tableElement); + + // $ExpectType Widget + $.tablesorter.getColumnData(this.table, { 0: widget, "*": widget }, 0); + // $ExpectType Widget + $.tablesorter.getColumnData(this.table, { 0: widget, "*": widget }, "*"); + // $ExpectType Widget + $.tablesorter.getColumnData(tableElement, { 0: widget, "*": widget }, 0); + // $ExpectType Widget + $.tablesorter.getColumnData(tableElement, { 0: widget, "*": widget }, "*"); + + $.tablesorter.getColumnText(this.table, 0); + $.tablesorter.getColumnText(this.table, 0, parsedCellCallback); + $.tablesorter.getColumnText(this.table, 0, parsedCellCallback, "*"); + $.tablesorter.getColumnText(this.table, 0, parsedCellCallback, $()); + $.tablesorter.getColumnText(this.table, 0, parsedCellCallback, $()[0]); + $.tablesorter.getColumnText( + this.table, + 0, + parsedCellCallback, + (index, element) => { + // $ExpectType number + index; + // $ExpectType HTMLElement + element; + return true; + }); + $.tablesorter.getColumnText(tableElement, 0); + $.tablesorter.getColumnText(tableElement, 0, parsedCellCallback); + $.tablesorter.getColumnText(tableElement, 0, parsedCellCallback, "*"); + $.tablesorter.getColumnText(tableElement, 0, parsedCellCallback, $()); + $.tablesorter.getColumnText(tableElement, 0, parsedCellCallback, $()[0]); + $.tablesorter.getColumnText( + tableElement, + 0, + parsedCellCallback, + (index, element) => { + // $ExpectType number + index; + // $ExpectType HTMLElement + element; + return true; + }); + + // $ExpectType string | boolean | undefined + $.tablesorter.getData($(), config.headers[0], "sorter"); + // $ExpectType string | boolean | undefined + $.tablesorter.getData($()[0], config.headers[0], "sorter"); + // $ExpectType StringSorting | undefined + $.tablesorter.getData($(), config.headers[0], "string"); + // $ExpectType StringSorting | undefined + $.tablesorter.getData($()[0], config.headers[0], "string"); + + // $ExpectType string[] + $.tablesorter.getFilters(this.table); + // $ExpectType string[] + $.tablesorter.getFilters(this.table, true); + // $ExpectType string[] + $.tablesorter.getFilters(tableElement); + // $ExpectType string[] + $.tablesorter.getFilters(tableElement, true); + + // $ExpectType Widget + $.tablesorter.getWidgetById(""); + + // $ExpectType boolean + $.tablesorter.hasWidget(this.table, ""); + // $ExpectType boolean + $.tablesorter.hasWidget(tableElement, ""); + + // $ExpectType boolean + $.tablesorter.isDigit(""); + + $.tablesorter.isProcessing(this.table, true); + $.tablesorter.isProcessing(this.table, true, $()); + $.tablesorter.isProcessing(tableElement, true); + $.tablesorter.isProcessing(tableElement, true, $()); + + // $ExpectType boolean + $.tablesorter.isValueInArray(2, this.sorting); + // $ExpectType boolean + $.tablesorter.isValueInArray(2, [[0, "this.table"], [1, 2102311923084], [3, {}]]); + + // $ExpectType void + $.tablesorter.processTbody(this.table, $()); + // $ExpectType void + $.tablesorter.processTbody(this.table, $(), false); + // $ExpectType JQuery + $.tablesorter.processTbody(this.table, $(), true); + // $ExpectType void + $.tablesorter.processTbody(tableElement, $()); + // $ExpectType void + $.tablesorter.processTbody(tableElement, $(), false); + // $ExpectType JQuery + $.tablesorter.processTbody(tableElement, $(), true); + + $.tablesorter.refreshWidgets(this.table); + $.tablesorter.refreshWidgets(this.table, true); + $.tablesorter.refreshWidgets(this.table, true, true); + $.tablesorter.refreshWidgets(tableElement); + $.tablesorter.refreshWidgets(tableElement, true); + $.tablesorter.refreshWidgets(tableElement, true, true); + + $.tablesorter.removeWidget(this.table, true); + $.tablesorter.removeWidget(this.table, true, true); + $.tablesorter.removeWidget(this.table, ""); + $.tablesorter.removeWidget(this.table, "", true); + $.tablesorter.removeWidget(this.table, ["", ""]); + $.tablesorter.removeWidget(this.table, ["", ""], true); + $.tablesorter.removeWidget(tableElement, true); + $.tablesorter.removeWidget(tableElement, true, true); + $.tablesorter.removeWidget(tableElement, ""); + $.tablesorter.removeWidget(tableElement, "", true); + $.tablesorter.removeWidget(tableElement, ["", ""]); + $.tablesorter.removeWidget(tableElement, ["", ""], true); + + // $ExpectType string + $.tablesorter.replaceAccents(""); + + $.tablesorter.resizableReset(this.table); + $.tablesorter.resizableReset(this.table, true); + $.tablesorter.resizableReset(tableElement); + $.tablesorter.resizableReset(tableElement, true); + + $.tablesorter.restoreHeaders(this.table); + $.tablesorter.restoreHeaders(tableElement); + + $.tablesorter.setFilters(this.table, [""]); + $.tablesorter.setFilters(this.table, [""], true); + $.tablesorter.setFilters(tableElement, [""]); + $.tablesorter.setFilters(tableElement, [""], true); + + $.tablesorter.showError(this.table, "", ajaxSettings, ""); + $.tablesorter.showError(this.table, request, ajaxSettings, ""); + $.tablesorter.showError(tableElement, "", ajaxSettings, ""); + $.tablesorter.showError(tableElement, request, ajaxSettings, ""); + + // $ExpectType number + $.tablesorter.sortNatural("", ""); + + // $ExpectType number + $.tablesorter.sortText("", ""); + + $.tablesorter.sortOn(config, this.sorting); + $.tablesorter.sortOn(config, this.sorting, this.triggerCallback); + $.tablesorter.sortOn(config, this.relativeSorting); + $.tablesorter.sortOn(config, this.relativeSorting, this.triggerCallback); + $.tablesorter.sortOn(config, this.mixedSorting); + $.tablesorter.sortOn(config, this.mixedSorting, this.triggerCallback); + + $.tablesorter.sortReset(config); + $.tablesorter.sortReset(config, this.triggerCallback); + + // $ExpectType any + $.tablesorter.storage(this.table, ""); + // $ExpectType void + $.tablesorter.storage(this.table, "", {}); + // $ExpectType void + $.tablesorter.storage(this.table, "", {}, storageConfig); + // $ExpectType any + $.tablesorter.storage(tableElement, ""); + // $ExpectType void + $.tablesorter.storage(tableElement, "", {}); + // $ExpectType void + $.tablesorter.storage(tableElement, "", {}, storageConfig); + + $.tablesorter.update(config); + $.tablesorter.update(config, true); + $.tablesorter.update(config, true, this.triggerCallback); + $.tablesorter.update(config, this.sorting); + $.tablesorter.update(config, this.sorting, this.triggerCallback); + $.tablesorter.updateRows(config); + $.tablesorter.updateRows(config, true); + $.tablesorter.updateRows(config, true, this.triggerCallback); + $.tablesorter.updateRows(config, this.sorting); + $.tablesorter.updateRows(config, this.sorting, this.triggerCallback); + + $.tablesorter.updateAll(config); + $.tablesorter.updateAll(config, true); + $.tablesorter.updateAll(config, true, this.triggerCallback); + $.tablesorter.updateAll(config, this.sorting); + $.tablesorter.updateAll(config, this.sorting, this.triggerCallback); + + $.tablesorter.updateCache(config); + $.tablesorter.updateCache(config, this.triggerCallback); + $.tablesorter.updateCache(config, this.triggerCallback, $()); + + $.tablesorter.updateCell(config, $()); + $.tablesorter.updateCell(config, $(), true); + $.tablesorter.updateCell(config, $(), true, this.triggerCallback); + $.tablesorter.updateCell(config, $(), this.sorting); + $.tablesorter.updateCell(config, $(), this.sorting, this.triggerCallback); + + $.tablesorter.updateHeaders(config); + $.tablesorter.updateHeaders(config, this.triggerCallback); + + $.tablesorter.filter.bindSearch(this.table, $(), true); + $.tablesorter.filter.bindSearch(tableElement, $(), true); + + $.tablesorter.filter.buildSelect(this.table, 0, [1, 2, 3, 4], true); + $.tablesorter.filter.buildSelect(this.table, 0, [1, 2, 3, 4], true, true); + $.tablesorter.filter.buildSelect(this.table, 0, "", true); + $.tablesorter.filter.buildSelect(this.table, 0, "", true, true); + $.tablesorter.filter.buildSelect(this.table, 0, $(), true); + $.tablesorter.filter.buildSelect(this.table, 0, $(), true, true); + $.tablesorter.filter.buildSelect(tableElement, 0, [1, 2, 3, 4], true); + $.tablesorter.filter.buildSelect(tableElement, 0, [1, 2, 3, 4], true, true); + $.tablesorter.filter.buildSelect(tableElement, 0, "", true); + $.tablesorter.filter.buildSelect(tableElement, 0, "", true, true); + $.tablesorter.filter.buildSelect(tableElement, 0, $(), true); + $.tablesorter.filter.buildSelect(tableElement, 0, $(), true, true); + + // $ExpectType string[] + $.tablesorter.filter.getOptions(this.table, 0); + // $ExpectType string[] + $.tablesorter.filter.getOptions(this.table, 0, true); + // $ExpectType string[] + $.tablesorter.filter.getOptions(tableElement, 0); + // $ExpectType string[] + $.tablesorter.filter.getOptions(tableElement, 0, true); + + // $ExpectType ParsedOption[] + $.tablesorter.filter.getOptionSource(this.table, 0); + // $ExpectType ParsedOption[] + $.tablesorter.filter.getOptionSource(this.table, 0, true); + // $ExpectType ParsedOption[] + $.tablesorter.filter.getOptionSource(tableElement, 0); + // $ExpectType ParsedOption[] + $.tablesorter.filter.getOptionSource(tableElement, 0, true); + + // $ExpectType string[] + $.tablesorter.filter.processOptions(this.table, 0, []); + // $ExpectType string[] + $.tablesorter.filter.processOptions(this.table, null, []); + } +} diff --git a/types/tablesorter/test/Settings.ts b/types/tablesorter/test/Settings.ts new file mode 100644 index 0000000000..eac6c07f6a --- /dev/null +++ b/types/tablesorter/test/Settings.ts @@ -0,0 +1,910 @@ +import * as Globalize from "globalize"; +import "jquery"; +import { + ColumnFilter, + CoreTheme, + EmptySorting, + MatchType, + PagerConfiguration, + RelativeSorting, + SortDefinitionOrder, + SortOrder, + StorageType, + StringSorting, + TablesorterConfiguration, + WidgetOptions +} from "tablesorter"; + +/** + * Provides tests for the settings. + */ +export class TestSettings { + /** + * Tests for the settings. + */ + Test() { + let settings: TablesorterConfiguration; + let widgetOptions: WidgetOptions = {}; + + /** + * Settings + * Legal settings + */ + settings = { + cancelSelection: true, + cssAsc: "asc", + cssChildRow: "childRow", + cssDesc: "desc", + cssHeader: "header", + cssHeaderRow: "headerRow", + cssIcon: "icon", + cssIconAsc: "icon-asc", + cssIconDesc: "icon-desc", + cssIconDisabled: "icon-disabled", + cssIconNone: "icon-none", + cssIgnoreRow: "ignored", + cssInfoBlock: "row-info", + cssNone: "no-sort", + cssNoSort: "no-sort-control", + cssProcessing: "loading-circle", + dateFormat: "dd.mm.yyyy", + debug: true, + delayInit: true, + duplicateSpan: true, + emptyTo: EmptySorting.Top, + headers: { + 0: { + dateFormat: "yyyy-mm-dd", + empty: EmptySorting.Max, + filter: ColumnFilter.Parsed, + lockedOrder: SortOrder.Ascending, + parser: "date", + resizable: true, + sortInitialOrder: SortOrder.Ascending, + sorter: "date", + string: StringSorting.Zero + }, + 3: { + parser: "ipAddress", + sorter: "ipAddress" + } + }, + headerTemplate: "{content} {icon}", + ignoreCase: true, + initialized(table) { + // $ExpectType T + table; + }, + initWidgets: true, + namespace: "my-awesome-tablesorter-namespace", + numberSorter(x, y, ascending, maxValue) { + // $ExpectType number + x; + // $ExpectType number + y; + // $ExpectType boolean + ascending; + // $ExpectType number + maxValue; + + if (x === y) { + return 0; + } else { + return x < y ? -1 : 1; + } + }, + onRenderHeader(index, config, table) { + // $ExpectType number + index; + // $ExpectType TablesorterConfigurationStore + config; + // $ExpectType JQuery + table; + }, + onRenderTemplate(index, text) { + // $ExpectType number + index; + // $ExpectType string + text; + return `Column #${index}`; + }, + pointerClick: "click", + pointerDown: "mousedown", + pointerUp: "mouseup", + resort: true, + selectorHeaders: "> thead th", + selectorRemove: ".remove-me", + selectorSort: "th, td", + serverSideSorting: true, + showProcessing: true, + sortAppend: [[1, 0], [2, SortDefinitionOrder.Descending]], + sortForce: [[0, SortDefinitionOrder.Descending], [1, SortDefinitionOrder.Ascending]], + sortInitialOrder: SortOrder.Ascending, + sortList: [[0, SortDefinitionOrder.Ascending], [1, SortDefinitionOrder.Ascending]], + sortLocaleCompare: true, + sortMultiSortKey: "bubbles", + sortReset: true, + sortResetKey: "shiftKey", + sortRestart: true, + sortStable: true, + stringTo: StringSorting.Max, + tabIndex: true, + tableClass: "tablesorter-table", + textAttribute: "data-text", + textExtraction: "basic", + textSorter(x, y, direction, index, table) { + // $ExpectType string + x; + // $ExpectType string + y; + // $ExpectType boolean + direction; + // $ExpectType number + index; + // $ExpectType T + table; + return x.localeCompare(y); + }, + theme: CoreTheme.Bootstrap, + usNumberFormat: true, + widgetClass: "pleas-load-me-the-widget-named-{name}", + widgetOptions, + widgets: ["zebra"], + widthFixed: true, + checkboxClass: "checked", + cehckboxVisible: true, + data: {}, + dateRange: 50, + globalize: { + lang: "de", + Globalize: Globalize("de"), + raw: "dd.mm.yyyy" + }, + ignoreChildRow: true, + imgAttr: "alt" + }; + + /** + * Debugging components + */ + settings.debug = "filter columnSelector"; + + /** + * Sorting relatively + */ + settings.sortAppend = { + 0: [[1, RelativeSorting.Opposite]], + 1: [[2, RelativeSorting.Descending]] + }; + + /** + * Text-extraction + * Root-level extraction + * Basic extraction + */ + settings.textExtraction = "basic"; + + /** + * Custom extraction + */ + settings.textExtraction = (node, table, index) => { + // $ExpectType Element + node; + // $ExpectType T + table; + // $ExpectType number + index; + return $(node).text(); + }; + + /** + * Root-level extraction + */ + settings.textExtraction = { + 0: "basic", + ".test"(node, table, index) { + // $ExpectType Element + node; + // $ExpectType T + table; + // $ExpectType number + index; + return $(node).text(); + } + }; + + /** + * Globalization + * Global settings + */ + settings.globalize = { + lang: "de", + Globalize: Globalize("de"), + raw: "dd.mm.yyyy" + }; + + /** + * Per-row settings + */ + settings.globalize = { + 0: { + lang: "de", + Globalize: Globalize("de"), + raw: "dd.mm.yyyy" + }, + 1: { + lang: "de", + Globalize: Globalize("de"), + raw: "dd.mm.yyyy" + } + }; + + /** + * Widget settings + * General settings + */ + widgetOptions = { + columns: ["pri", "sec", "ter"], + columns_tfoot: true, + columns_thead: true, + filter_cellFilter: "filter-control", + filter_childByColumn: true, + filter_childRows: false, + filter_childWithSibs: false, + filter_columnAnyMatch: true, + filter_columnFilters: true, + filter_cssFilter: "tablesorter-filter", + filter_defaultAttrib: "data-filter", + filter_defaultFilter: { + 0: "{q}=", + ".fuzzy": "~{q}" + }, + filter_excludeFilter: { + ".text": "range", + 2: "range, notMatch, exact" + }, + filter_external: ".external", + filter_filteredRow: "filtered", + filter_filterLabel: 'Filter "{{label}}" column by...', + filter_formatter: {}, + filter_functions: {}, + filter_hideEmpty: true, + filter_hideFilters: true, + filter_ignoreCase: true, + filter_liveSearch: true, + filter_matchType: { + input: MatchType.Wildcard, + select: MatchType.Exact + }, + filter_onlyAvail: "filter-onlyAvail", + filter_placeholder: { + from: "From", + to: "To", + search: "Type a text...", + select: "Select something" + }, + filter_reset: $("#reset"), + filter_resetOnEsc: true, + filter_saveFilters: true, + filter_searchDelay: 300, + filter_searchFiltered: true, + filter_selectSource: { + ".model-number": ["1|Awesome 1.x", "2|Awesome 2.x", "3|Awesome 3.x"] + }, + filter_selectSourceSeparator: "|", + filter_serversideFiltering: true, + filter_startsWith: true, + filter_useParsedData: true, + resizable: true, + resizable_addLastColumn: true, + resizable_includeFooter: true, + resizable_targetLast: true, + resizable_throttle: true, + resizable_widths: ["10%", "100%", "50px"], + saveSort: true, + stickyHeaders: "tablesorter-sticky", + stickyHeaders_addResizeEvent: true, + stickyHeaders_appendTo: ".wrapper", + stickyHeaders_attachTo: ".wrapper", + stickyHeaders_cloneId: "-sticky", + stickyHeaders_filteredToTop: true, + stickyHeaders_includeCaption: true, + stickyHeaders_offset: 10, + stickyHeaders_xScroll: ".wrapper", + stickyHeaders_yScroll: ".wrapper", + stickyHeaders_zindex: 10, + storage_fixedUrl: "/this/is/my/awesome/table/url", + storage_group: "data-awesome-table-group", + storage_page: "data-awesome-table-page", + storage_storageType: StorageType.Cookie, + storage_tableId: "myAwesomeTable", + zebra: ["even", "odd"] + }; + + /** + * Filter-settings + * Filter-cell classes + * Global filter-cell classes + */ + widgetOptions.filter_cellFilter = "filter-control"; + + /** + * Per-row filter-cell classes + */ + widgetOptions.filter_cellFilter = ["hidden", "", "hidden", ""]; + + /** + * Filter-classes + * Global filter-classes + */ + widgetOptions.filter_cssFilter = "tablesorter-filter"; + + /** + * Per-row filter-classes + */ + widgetOptions.filter_cssFilter = ["first-filter", "second-filter", "third-filter"]; + + /** + * Filter-formaters + * Creating filter-controls with all available options + */ + widgetOptions.filter_formatter = { + "*": (cell, index) => { + // $ExpectType JQuery + cell; + // $ExpectType number + index; + return $.tablesorter.filterFormatter.html5Number( + cell, + index, + { + addToggle: true, + cellText: "Age", + compare: ["<", ">", "="], + delayed: true, + disabled: true, + exactMatch: true, + min: 100, + max: 1000, + skipTest: true, + step: 10, + value: 110 + }); + }, + 1: (cell, index) => { + // $ExpectType JQuery + cell; + // $ExpectType number + index; + return $.tablesorter.filterFormatter.html5Range( + cell, + index, + { + allText: "all", + cellText: "Medals", + compare: "<", + delayed: false, + exactMatch: false, + min: 1, + max: 200, + skipTest: true, + step: 1, + value: 1, + valueToHeader: false + }); + }, + 2: (cell, index) => $.tablesorter.filterFormatter.html5Color( + cell, + index, + { + addToggle: true, + disabled: true, + exactMatch: true, + skipTest: true, + value: "#999999", + valueToHeader: true + }), + 3: (cell, index) => $.tablesorter.filterFormatter.uiSpinner( + cell, + index, + { + addToggle: true, + cellText: "Level", + compare: "=", + delayed: true, + disabled: true, + exactMatch: true, + min: 0, + max: 100, + step: 1, + value: 1, + culture: "de" + }), + 4: (cell, index) => $.tablesorter.filterFormatter.uiSlider( + cell, + index, + { + allText: "all", + cellText: "Height", + compare: ["<", ">"], + delayed: true, + exactMatch: true, + min: 0, + max: 3, + step: 0.01, + value: 1.60, + valueToHeader: true + }), + 5: (cell, index) => $.tablesorter.filterFormatter.uiRange( + cell, + index, + { + delayed: true, + min: 0, + max: 1000000, + valueToHeader: false + }), + 6: (cell, index) => $.tablesorter.filterFormatter.uiDateCompare( + cell, + index, + { + cellText: "Joindate", + compare: ["<", ">"], + endOfDay: true + }), + 7: (cell, index) => $.tablesorter.filterFormatter.uiDatepicker( + cell, + index, + { + endOfDay: true, + from: new Date(), + to: new Date(), + textFrom: "From", + textTo: "To", + maxDate: new Date(1989, 1, 1) + }), + 8: (cell, index) => $.tablesorter.filterFormatter.select2( + cell, + index, + { + cellText: "Gender", + exactMatch: true, + value: "other", + data: [ + { + id: "other", + text: "Other" + } + ] + }) + }; + + /** + * Creating filter-controls without options + */ + widgetOptions.filter_formatter = { + "*": (cell, index) => $.tablesorter.filterFormatter.select2(cell, index) + }; + + /** + * Creating custom filter-controls + */ + widgetOptions.filter_formatter = { + "*": () => $("input") + }; + + /** + * Filter-functions + */ + widgetOptions.filter_functions = { + "*": (o, n, f, i, r, c, d) => { + // $ExpectType string + o; + // $ExpectType string + n; + // $ExpectType string + f; + // $ExpectType number + i; + // $ExpectType JQuery + r; + // $ExpectType TablesorterConfigurationStore + c; + // $ExpectType object + d; + return false; + }, + 1: { + "A - D": (o, n, f, i, r, c, d) => { + // $ExpectType string + o; + // $ExpectType string + n; + // $ExpectType string + f; + // $ExpectType number + i; + // $ExpectType JQuery + r; + // $ExpectType TablesorterConfigurationStore + c; + // $ExpectType object + d; + return /^[A-D]/.test(o); + }, + "E - H": (e) => /^[E-H]/.test(e) + } + }; + + /** + * Hide-filters + * Hiding filters statically + */ + widgetOptions.filter_hideFilters = true; + + /** + * Hiding filters dynamicaly + */ + widgetOptions.filter_hideFilters = (config) => { + // $ExpectType TablesorterConfigurationStore + config; + const filters = $.tablesorter.getFilters(config.table); + return filters.join("") === ""; + }; + + /** + * Live-Search + * Setting live-features statically + */ + widgetOptions.filter_liveSearch = true; + + /** + * Setting live-features for a specific amount of characters + */ + widgetOptions.filter_liveSearch = 5; + + /** + * Setting live-features per-column + */ + widgetOptions.filter_liveSearch = { + 0: false, + "*": true, + ".fullname": 5 + }; + + /** + * Reset-button + * Setting the reset-button using a jQuery-object + */ + widgetOptions.filter_reset = $("#reset"); + + /** + * Setting the reset-button using a jQuery-selector + */ + widgetOptions.filter_reset = "#reset"; + + /** + * Select-source + * Setting a global select-source + */ + widgetOptions.filter_selectSource = (table, column, onlyAvail) => { + // $ExpectType T + table; + // $ExpectType number + column; + // $ExpectType boolean + onlyAvail; + const values = $.tablesorter.filter.getOptions(table, column, onlyAvail); + return values; + }; + + /** + * Setting per-column select-sources + */ + widgetOptions.filter_selectSource = { + "*": ["1", "2", "3"], + 0: [ + { + text: "JavaScript", + value: "*.js", + "data-class": "ui-icon-script" + } + ], + 1: (table, column, onlyAvail) => { + // $ExpectType T + table; + // $ExpectType number + column; + // $ExpectType boolean + onlyAvail; + return null; + } + }; + + /** + * Sticky-Headers settings + * Appending the sticky header + * Using a jQuery-object + */ + widgetOptions.stickyHeaders_appendTo = $(".wrapper"); + + /** + * Using a jQuery-selector + */ + widgetOptions.stickyHeaders_appendTo = ".wrapper"; + + /** + * Appending the sticky header + * Using a jQuery - object + */ + widgetOptions.stickyHeaders_appendTo = $(".wrapper"); + + /** + * Using a jQuery-selector + */ + widgetOptions.stickyHeaders_appendTo = ".wrapper"; + + /** + * Setting an offset + * Using a static number + */ + widgetOptions.stickyHeaders_offset = 10; + + /** + * Using a jQuery-selector + */ + widgetOptions.stickyHeaders_offset = ".navbar-fixed-top"; + + /** + * Using a jQuery-object + */ + widgetOptions.stickyHeaders_offset = $(".navbar-fixed-top"); + + /** + * Setting scroll-elements + * Using a jQuery-selector + */ + widgetOptions.stickyHeaders_xScroll = ".wrapper"; + widgetOptions.stickyHeaders_yScroll = ".wrapper"; + + /** + * Using a jQuery-object + */ + widgetOptions.stickyHeaders_xScroll = $(".wrapper"); + widgetOptions.stickyHeaders_yScroll = $(".wrapper"); + + /** + * Pager-settings + * Using widget-settings + */ + widgetOptions = { + pager_ajaxError: (config, request, settings, error) => { + // $ExpectType TablesorterConfigurationStore + config; + // $ExpectType jqXHR + request; + // $ExpectType AjaxSettings + settings; + // $ExpectType string + error; + return "What do you think you're doing!?"; + }, + pager_ajaxObject: { + dataType: "json" + }, + pager_ajaxProcessing: () => ({ total: 0 }), + pager_ajaxUrl: "https://go.com/download/my/stuff/?p={page}", + pager_selectors: { + container: $(".container"), + first: $(".first"), + gotoPage: $(".goto"), + last: $(".last"), + next: $(".next"), + pageDisplay: $(".display"), + pageSize: $(".size"), + prev: $(".prev") + }, + pager_countChildRows: true, + pager_css: { + disabled: "disabled", + container: "container", + errorRow: "error" + }, + pager_customAjaxUrl: (table, url) => { + // $ExpectType T + table; + // $ExpectType string + url; + return url; + }, + pager_fixedHeight: true, + pager_initialRows: { + total: 100, + filtered: 100 + }, + pager_output: "{startRow} to {endRow} of {totalRows} rows", + pager_startPage: 2, + pager_pageReset: true, + pager_processAjaxOnInit: true, + pager_removeRows: true, + pager_savePages: true, + pager_size: "all", + pager_storageKey: "tablesorter-pager", + pager_updateArrows: true + }; + + /** + * Using self-contained settings + */ + let pagerSettings: PagerConfiguration = { + ajaxError: () => { + return "What are you even trying to do!?"; + }, + ajaxObject: { + dataType: "csv" + }, + ajaxProcessing: () => ({ total: 1337 }), + ajaxUrl: "https://go.com/download/my/stuff/?p={page}", + container: $(".container"), + countChildRows: true, + cssDisabled: "disabled", + cssErrorRow: "error", + cssFirst: $(".first"), + cssGoto: $(".goto"), + cssLast: $(".last"), + cssNext: $(".next"), + cssPageDisplay: $(".display"), + cssPageSize: $(".size"), + cssPrev: $(".prev"), + customAjaxUrl: (table, url) => { + // $ExpectType T + table; + // $ExpectType string + url; + return url; + }, + fixedHeight: true, + initialRows: { + total: 100, + filtered: 100 + }, + output: "{startRow} to {endRow} of {totalRows} rows", + page: 2, + pageReset: true, + processAjaxOnInit: true, + removeRows: true, + savePages: true, + size: "all", + storageKey: "tablesorter-pager", + updateArrows: true + }; + + /** + * Setting an ajax data-processor + * Returning an object + * With all available options + */ + pagerSettings.ajaxProcessing = + widgetOptions.pager_ajaxProcessing = (data, table, request) => { + // $ExpectType any + data; + // $ExpectType T + table; + // $ExpectType jqXHR + request; + return ({ total: 1, filteredRows: 1, headers: ["ID"], output: "", rows: [["1"]] }); + }; + + /** + * With all required options + */ + pagerSettings.ajaxProcessing = + widgetOptions.pager_ajaxProcessing = () => { + return { + total: 1 + }; + }; + + /** + * Returning an array + * With the total amount of rows only + */ + pagerSettings.ajaxProcessing = + widgetOptions.pager_ajaxProcessing = () => [1]; + + /** + * With the rows as a jQuery-object + */ + pagerSettings.ajaxProcessing = + widgetOptions.pager_ajaxProcessing = (data) => [1, $(data.rows), ["ID", "Medals", "Exp"]]; + + /** + * With the records in an array + */ + pagerSettings.ajaxProcessing = + widgetOptions.pager_ajaxProcessing = () => [1, [[1, 1000, "John Doe"]], ["ID", "Medals", "Name"]]; + + /** + * Setting elements for the pager + * Using jQuery-selectors + */ + const selector = ".container"; + pagerSettings = { + container: selector, + cssFirst: selector, + cssGoto: selector, + cssLast: selector, + cssNext: selector, + cssPageDisplay: selector, + cssPageSize: selector, + cssPrev: selector + }; + + widgetOptions.pager_selectors = { + container: selector, + first: selector, + gotoPage: selector, + last: selector, + next: selector, + pageDisplay: selector, + pageSize: selector, + prev: selector + }; + + /** + * Using jQuery-objects + */ + const object = $(selector); + pagerSettings = { + container: object, + cssFirst: object, + cssGoto: object, + cssLast: object, + cssNext: object, + cssPageDisplay: object, + cssPageSize: object, + cssPrev: object + }; + + widgetOptions.pager_selectors = { + container: object, + first: object, + gotoPage: object, + last: object, + next: object, + pageDisplay: object, + pageSize: object, + prev: object + }; + + /** + * Setting a page-reset + * Using an exact number + */ + pagerSettings.pageReset = + widgetOptions.pager_pageReset = 3; + + /** + * Enabling/disabling page-reset + */ + pagerSettings.pageReset = + widgetOptions.pager_pageReset = true; + pagerSettings.pageReset = + widgetOptions.pager_pageReset = false; + + /** + * Setting the initial page-size + * Using an exact number + */ + pagerSettings.size = + widgetOptions.pager_size = 20; + + /** + * Using "all" + */ + pagerSettings.size = + widgetOptions.pager_size = "all"; + + $("#myTable").tablesorter(settings).tablesorterPager(pagerSettings); + } +} diff --git a/types/tablesorter/test/Triggers.ts b/types/tablesorter/test/Triggers.ts new file mode 100644 index 0000000000..ce32e59b57 --- /dev/null +++ b/types/tablesorter/test/Triggers.ts @@ -0,0 +1,118 @@ +import "jquery"; +import { TestMethods } from "./Methods"; + +/** + * Provides tests for the triggers. + */ +export class TestTriggers extends TestMethods { + /** + * Tests for the triggers. + */ + Test() { + /** + * Invoking Methods through events + */ + this.table.trigger("addRows", [$(), true]); + this.table.trigger("addRows", [$(), true, this.triggerCallback]); + this.table.trigger("addRows", [$(), this.sorting]); + this.table.trigger("addRows", [$(), this.sorting, this.triggerCallback]); + this.table.trigger("addRows", ["", true]); + this.table.trigger("addRows", ["", true, this.triggerCallback]); + this.table.trigger("addRows", ["", this.sorting]); + this.table.trigger("addRows", ["", this.sorting, this.triggerCallback]); + + this.table.trigger("appendCache"); + + this.table.trigger("applyWidgetId", "zebra"); + + this.table.trigger("applyWidgets"); + this.table.trigger("applyWidgets", this.triggerCallback); + + this.table.trigger("destroy"); + this.table.trigger("destroy", [true]); + this.table.trigger("destroy", [true, this.triggerCallback]); + + this.table.trigger("refreshWidgets"); + this.table.trigger("refreshWidgets", []); + this.table.trigger("refreshWidgets", [true]); + this.table.trigger("refreshWidgets", [true, true]); + + this.table.trigger("removeWidget", true); + this.table.trigger("removeWidget", "zebra"); + this.table.trigger("removeWidget", ["zebra", "filter"]); + + this.table.trigger("resetToLoadState"); + + this.table.find("th:eq(3)").trigger("sort"); + + this.table.trigger("sorton", [this.sorting]); + this.table.trigger("sorton", [this.sorting, this.triggerCallback]); + this.table.trigger("sorton", [this.relativeSorting]); + this.table.trigger("sorton", [this.relativeSorting, this.triggerCallback]); + this.table.trigger("sorton", [this.mixedSorting]); + this.table.trigger("sorton", [this.mixedSorting, this.triggerCallback]); + + this.table.trigger("sortReset"); + this.table.trigger("sortReset", []); + this.table.trigger("sortReset", [this.triggerCallback]); + + this.table.trigger("update"); + this.table.trigger("update", [true]); + this.table.trigger("update", [true, this.triggerCallback]); + this.table.trigger("update", [this.sorting]); + this.table.trigger("update", [this.sorting, this.triggerCallback]); + this.table.trigger("updateRows"); + this.table.trigger("updateRows", [true]); + this.table.trigger("updateRows", [true, this.triggerCallback]); + this.table.trigger("updateRows", [this.sorting]); + this.table.trigger("updateRows", [this.sorting, this.triggerCallback]); + + this.table.trigger("updateAll"); + this.table.trigger("updateAll", []); + this.table.trigger("updateAll", [true]); + this.table.trigger("updateAll", [true, this.triggerCallback]); + this.table.trigger("updateAll", [this.sorting]); + this.table.trigger("updateAll", [this.sorting, this.triggerCallback]); + + this.table.trigger("updateCache"); + this.table.trigger("updateCache", []); + this.table.trigger("updateCache", [this.triggerCallback]); + this.table.trigger("updateCache", [this.triggerCallback, $()]); + + this.table.trigger("updateCell", [$()]); + this.table.trigger("updateCell", [$(), true]); + this.table.trigger("updateCell", [$(), true, this.triggerCallback]); + this.table.trigger("updateCell", [$(), this.sorting]); + this.table.trigger("updateCell", [$(), this.sorting, this.triggerCallback]); + + this.table.trigger("updateHeaders"); + this.table.trigger("updateHeaders", this.triggerCallback); + + this.table.trigger("filterAndSortReset"); + + this.table.trigger("filterReset"); + + this.table.trigger("filterResetSaved"); + + this.table.trigger("saveSortReset"); + + this.table.trigger("search"); + this.table.trigger("search", true); + this.table.trigger("search", [["this", "is", "a", "test"]]); + + this.table.trigger("destroyPager"); + + this.table.trigger("disablePager"); + + this.table.trigger("enablePager"); + + this.table.trigger("pageAndSize", [3, 20]); + + this.table.trigger("pagerUpdate"); + this.table.trigger("pagerUpdate", 3); + + this.table.trigger("pageSet", 3); + + this.table.trigger("pageSize", 20); + } +} diff --git a/types/tablesorter/test/Variables.ts b/types/tablesorter/test/Variables.ts new file mode 100644 index 0000000000..d9e65bbd53 --- /dev/null +++ b/types/tablesorter/test/Variables.ts @@ -0,0 +1,113 @@ +import "jquery"; + +/** + * Provides tests for the variables. + */ +export class TestVariables { + /** + * Tests for the variables. + */ + Test() { + const $: JQueryStatic = {} as any; + const table = $()[0]; + const config = table.config; + const widgetOptions = config.widgetOptions; + const pager = config.pager; + + /** + * Table-variables + */ + // $ExpectType boolean + table.hasInitialized; + + /** + * Tablesorter-variables + */ + // $ExpectType TablesorterConfiguration + $.tablesorter.defaults; + // $ExpectType () => any + $.tablesorter.instanceMethods[""]; + // $ExpectType Locale + $.tablesorter.language; + // $ExpectType Parser[] + $.tablesorter.parsers; + // $ExpectType ThemeCollection + $.tablesorter.themes; + // $ExpectType Theme + $.tablesorter.themes[""]; + // $ExpectType Widget[] + $.tablesorter.widgets; + + /** + * config-store variables + */ + // $ExpectType JQuery[] + config.$headerIndexed; + // $ExpectType JQuery + config.$headers; + // $ExpectType JQuery + config.$table; + // $ExpectType JQuery + config.$tbodies; + // $ExpectType TablesorterCache + config.cache; + // $ExpectType number + config.columns; + // $ExpectType string[] + config.headerContent; + // $ExpectType HTMLElement[] + config.headerList; + // $ExpectType Parser[] + config.parsers; + // $ExpectType TableSorting[] + config.sortVars; + // $ExpectType T + config.table; + // $ExpectType number + config.totalRows; + // $ExpectType JQuery + config.$filters; + // $ExpectType number + config.filteredRows; + + /** + * Widget-config store + */ + // $ExpectType JQuery + widgetOptions.$sticky; + // $ExpectType JQuery + widgetOptions.filter_$anyMatch; + // $ExpectType JQuery + widgetOptions.filter_$externalFilters; + // $ExpectType boolean + widgetOptions.filter_initialized; + + /** + * Pager-config store + */ + // $ExpectType JQuery + pager.$container; + // $ExpectType JQuery + pager.$goto; + // $ExpectType JQuery + pager.$size; + // $ExpectType number[] + pager.cachedIndex; + // $ExpectType number + pager.endRow; + // $ExpectType number + pager.filteredPages; + // $ExpectType number + pager.filteredRows; + // $ExpectType number + pager.page; + // $ExpectType number + pager.size; + // $ExpectType number + pager.startRow; + // $ExpectType number + pager.totalPages; + // $ExpectType number + pager.totalRows; + } +} diff --git a/types/tablesorter/test/main.ts b/types/tablesorter/test/main.ts new file mode 100644 index 0000000000..1056224a17 --- /dev/null +++ b/types/tablesorter/test/main.ts @@ -0,0 +1,19 @@ +import "./Settings"; +import "./Methods"; +import "./Triggers"; +import "./Events"; +import "./Variables"; +import { SortDefinitionOrder } from "tablesorter"; + +/** + * Basic usage + */ +$("#").tablesorter(); +$("#").tablesorter({ + sortList: [ + [0, 0], + [1, SortDefinitionOrder.Descending], + [2, SortDefinitionOrder.None], + [3, SortDefinitionOrder.Ascending] + ] +}); diff --git a/types/tablesorter/tsconfig.json b/types/tablesorter/tsconfig.json new file mode 100644 index 0000000000..4fe7050692 --- /dev/null +++ b/types/tablesorter/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/main.ts", + "test/Events.ts", + "test/Methods.ts", + "test/Settings.ts", + "test/Triggers.ts", + "test/Variables.ts" + ] +} \ No newline at end of file diff --git a/types/tablesorter/tslint.json b/types/tablesorter/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/tablesorter/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }