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
This commit is contained in:
Manuel Thalmann
2019-05-15 18:25:27 +02:00
committed by Nathan Shively-Sanders
parent b6fc18280b
commit 3daa0d2fd3
117 changed files with 6086 additions and 0 deletions

59
types/tablesorter/Design/CoreTheme.d.ts vendored Normal file
View File

@@ -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"
}

79
types/tablesorter/Design/Theme.d.ts vendored Normal file
View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -0,0 +1,9 @@
/**
* Provides the functionality to handle filtering-events of the `tablesorter`.
*/
export interface FilterEventHandler<TElement = HTMLElement> {
/**
* Handles filtering-events of the `tablesorter`.
*/
(eventArgs: JQuery.TriggeredEvent<TElement, null, TElement, TElement>, filters: string[]): void;
}

View File

@@ -0,0 +1,30 @@
import "jquery";
import { TablesorterConfigurationStore } from "../System/TablesorterConfigurationStore";
/**
* Represents a function for filtering.
*/
export interface FilterFunction<TElement = HTMLElement> {
/**
* 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<TElement>, data: object): boolean;
}

View File

@@ -0,0 +1,11 @@
import { FilterFunction } from "./FilterFunction";
/**
* A collection of filter-functions.
*/
export interface FilterFunctionCollection<TElement = HTMLElement> {
/**
* The display-name of the filter-function and the `FilterFunction` itself.
*/
[displayName: string]: FilterFunction<TElement> | true;
}

View File

@@ -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;
};

View File

@@ -0,0 +1,88 @@
import "jquery";
import { ParsedOption } from "../Parsing/ParsedOption";
/**
* Represents the static instance of the `filter`-widget.
*/
export interface FilterStatic<TElement = HTMLElement> {
/**
* 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> | 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> | TElement, column: number, options: ReadonlyArray<any> | 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> | 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> | 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> | TElement, column: number | null | undefined, options: ReadonlyArray<any>): string[];
}

View File

@@ -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;
}

View File

@@ -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 { }

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
/**
* Provides options for comparable controls.
*/
export interface ComparableOptions {
/**
* The compare-operators supported by the control.
*/
compare?: string | string[];
}

View File

@@ -0,0 +1,9 @@
/**
* Provides options for filter-controls.
*/
export interface ControlOptions {
/**
* The label of the control.
*/
cellText?: string;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
/**
* Provides options for a control which has a default value.
*/
export interface DefaultValueOptions<T> {
/**
* The default value of the control.
*/
value?: T;
}

View File

@@ -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;
}

View File

@@ -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<string>,
ToggleableOptions,
StrictOptions,
PreviewableOptions,
TestableOptions { }

View File

@@ -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<number>,
ComparableOptions,
ToggleableOptions,
DelayableOptions,
StrictOptions,
TestableOptions { }

View File

@@ -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<number>,
ComparableOptions,
StrictOptions,
PreviewableOptions,
DelayableOptions,
TestableOptions { }

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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<string> { }

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
/**
* Provides settings for testable filter-controls.
*/
export interface TestableOptions {
/**
* A value indicating whether tests should be skipped.
*/
skipTest?: boolean;
}

View File

@@ -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;
}

View File

@@ -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 { }

View File

@@ -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;
}

View File

@@ -0,0 +1,6 @@
import { Omit } from "../../../Omit";
/**
* Provides a base for ui-options.
*/
export type UIOptionsBase<T extends { min?: any, max?: any, step?: any }> = Omit<T, "min" | "max" | "step">;

View File

@@ -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<UIOptionsBase<JQueryUI.SliderOptions>, "value">,
NumericOptions,
DelayableOptions,
PreviewableOptions { }

View File

@@ -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<UIOptionsBase<JQueryUI.SliderOptions>, "values">,
RangeOptions,
ControlOptions,
DefaultValueOptions<number>,
ComparableOptions,
PreviewableOptions,
DelayableOptions,
StrictOptions { }

View File

@@ -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<JQueryUI.SpinnerOptions>,
IntervalOptions,
ControlOptions,
DefaultValueOptions<number>,
ToggleableOptions,
ComparableOptions,
DelayableOptions,
StrictOptions { }

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,20 @@
import { ValidSelectSources } from "./ValidSelectSources";
/**
* Represents a function for generating select-sources.
*/
export interface FunctionSelectSource<TElement = HTMLElement> {
/**
* 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;
}

View File

@@ -0,0 +1,14 @@
/**
* Represents a match-type.
*/
export enum MatchType {
/**
* Indicates an exact match.
*/
Exact = "exact",
/**
* Indicates a wildcard-match.
*/
Wildcard = "match"
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,7 @@
import { FunctionSelectSource } from "./FunctionSelectSource";
import { ValidSelectSources } from "./ValidSelectSources";
/**
* Represents types for specifying select-sources.
*/
export type SelectSources<TElement = HTMLElement> = FunctionSelectSource<TElement> | ValidSelectSources;

View File

@@ -0,0 +1,6 @@
import { SelectSource } from "./SelectSource";
/**
* Represents a valid select-source.
*/
export type ValidSelectSources = string | null | Array<string | SelectSource>;

View File

@@ -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;
}

4
types/tablesorter/Omit.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
/**
* Exclude all keys `K` from type `T`.
*/
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

View File

@@ -0,0 +1,24 @@
import "jquery";
import { PagerDataPart } from "./PagerDataPart";
/**
* Provides the functionality to process data for the `pager`-widget.
*/
export interface AjaxDataProcessor<TElement = HTMLElement> {
/**
* 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<TElement> | [number] | [number, JQuery | any[][], string[]?];
}

View File

@@ -0,0 +1,27 @@
import "jquery";
import { TablesorterConfigurationStore } from "../System/TablesorterConfigurationStore";
/**
* Provides the functionality to handle errors caused by `ajax`.
*/
export interface AjaxErrorHandler<TElement = HTMLElement> {
/**
* 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<TElement>, request: JQuery.jqXHR, ajaxSettings: JQuery.AjaxSettings, thrownError: string): string;
}

View File

@@ -0,0 +1,18 @@
/**
* Provides the functionality to customize the url for querying a page.
*/
export interface AjaxUrlProcessor<TElement = HTMLElement> {
/**
* 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;
}

View File

@@ -0,0 +1,4 @@
/**
* Represents a page-size.
*/
export type PageSize = number | "all";

View File

@@ -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;
}

View File

@@ -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<TElement = HTMLElement> {
/**
* 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<TElement>;
/**
* The settings for the api-interaction of the pager.
*/
ajaxObject?: JQueryAjaxSettings;
/**
* Handles errors caused by an ajax-request.
*/
ajaxError?: AjaxErrorHandler<TElement>;
/**
* 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<TElement>;
/**
* 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<TElement>;
/**
* 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;
}

View File

@@ -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<TElement = HTMLElement> extends PagerConfiguration<TElement> {
page: number;
size: number;
/**
* The initial settings of the pager.
*/
settings: PagerConfiguration<TElement>;
/**
* 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<any>;
/**
* The result of the ajax-request.
*/
ajaxData: PagerDataPart<TElement> | [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;
}

View File

@@ -0,0 +1,46 @@
import { PagerOutputProcessor } from "./PagerOutputProcessor";
/**
* Represents a part of table-data for the `pager`-widget.
*/
export interface PagerDataPart<TElement = HTMLElement> {
/**
* 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<TElement>;
/**
* 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;
}

View File

@@ -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<TElement = HTMLElement> {
/**
* 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<TElement, null, TElement, TElement>, options: TablesorterConfigurationStore<TElement> | PagerConfigurationStore<TElement>): void;
}

View File

@@ -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",
}

View File

@@ -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;
}

View File

@@ -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[];
}

View File

@@ -0,0 +1,18 @@
/**
* Provides the functionality to generate output for the `pager`-plugin.
*/
export interface PagerOutputProcessor<TElement = HTMLElement> {
/**
* 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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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[];
}

View File

@@ -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;
}

46
types/tablesorter/Parsing/Parser.d.ts vendored Normal file
View File

@@ -0,0 +1,46 @@
import { ParserType } from "./ParserType";
/**
* Represents a parser.
*/
export interface Parser<TElement = HTMLElement> {
/**
* 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;
}

View File

@@ -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"
}

View File

@@ -0,0 +1,18 @@
/**
* Provides the functionality to extract the text from a cell.
*/
export interface TextExtractor<TElement> {
/**
* 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;
}

View File

@@ -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"
}

View File

@@ -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;
}

View File

@@ -0,0 +1,6 @@
import { RelativeSorting } from "./RelativeSorting";
/**
* Represents a definition of a relative sorting.
*/
export type RelativeSortDefinition = [number, RelativeSorting];

View File

@@ -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"
}

View File

@@ -0,0 +1,6 @@
import { SortDefinitionOrder } from "./SortDefinitionOrder";
/**
* Represents a definition of a sorting.
*/
export type SortDefinition = [number, SortDefinitionOrder];

View File

@@ -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
}

View File

@@ -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"
}

View File

@@ -0,0 +1,14 @@
/**
* Defines a sort-order.
*/
export enum SortOrder {
/**
* Indicates ascending sorting.
*/
Ascending = "asc",
/**
* Indicates descending sorting.
*/
Descending = "desc"
}

View File

@@ -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"
}

View File

@@ -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;
}

View File

@@ -0,0 +1,30 @@
/**
* Provides the functionality to compare text.
*/
export interface TextSorter<TElement = HTMLElement> {
/**
* 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;
}

View File

@@ -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;
}

View File

@@ -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"
}

View File

@@ -0,0 +1,14 @@
import "jquery";
/**
* Provides the functionality to handle common events of the `tablesorter`.
*/
export interface CommonEventHandler<TElement = HTMLElement> {
/**
* Handles common events of the `tablesorter`.
*
* @param eventArgs
* An object that contains event data.
*/
(eventArgs: JQuery.TriggeredEvent<TElement, null, TElement, TElement>): void;
}

View File

@@ -0,0 +1,18 @@
import "jquery";
import { TablesorterConfigurationStore } from "./TablesorterConfigurationStore";
/**
* Provides the functionality to handle config-events of the `tablesorter`.
*/
export interface ConfigEventHandler<TElement = HTMLElement> {
/**
* 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<TElement, null, TElement, TElement>, config: TablesorterConfigurationStore<TElement>): void;
}

View File

@@ -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"
}

44
types/tablesorter/System/EventMap.d.ts vendored Normal file
View File

@@ -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"
}

View File

@@ -0,0 +1,9 @@
/**
* Provides options for handling `HeaderResize`-events.
*/
export interface HeaderResizeOptions {
/**
* The interval to look for header-changes in miliseconds.
*/
timer: number;
}

View File

@@ -0,0 +1,12 @@
/**
* Provides the functionality to handle the `Initialized`-event.
*/
export interface InitializationEventHandler<TElement> {
/**
* Handles the `Initialized`-event.
*
* @param table
* The initialized table.
*/
(table: TElement): void;
}

39
types/tablesorter/System/Locale.d.ts vendored Normal file
View File

@@ -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;
}

View File

@@ -0,0 +1,14 @@
/**
* Represents settings mapped to columns.
*/
export interface MappedSettings<T> {
/**
* The jquery-selector and their settings.
*/
[selector: string]: T;
/**
* The column-index and its settings.
*/
[index: number]: T;
}

View File

@@ -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"
}

View File

@@ -0,0 +1,21 @@
import "jquery";
import { TablesorterConfigurationStore } from "./TablesorterConfigurationStore";
/**
* Provides the functionality to handle the `RenderHeader`-event.
*/
export interface RenderHeaderEventHandler<TElement = HTMLElement> {
/**
* 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<TElement>, table: JQuery<TElement>): void;
}

View File

@@ -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;
}

View File

@@ -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[];
}

View File

@@ -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;
}

View File

@@ -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<TElement = HTMLElement> 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<TElement> | MappedSettings<"basic" | TextExtractor<TElement>>;
/**
* 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<TElement>;
/**
* 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<TElement>;
/**
* The text-sorting to apply.
*/
textSorter?: TextSorter<TElement> | MappedSettings<TextSorter<TElement>>;
/**
* 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<TElement>;
/**
* 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;
}

View File

@@ -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<TElement = HTMLElement> extends Required<TablesorterConfiguration<TElement>> {
/**
* 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<TElement>;
/**
* 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<Parser<TElement>>;
/**
* The sortings of the tablesorter.
*/
sortVars: TableSorting[];
widgetOptions: WidgetOptionStore<TElement>;
/**
* Provides methods and settings for the `pager`-widget.
*/
pager: PagerConfigurationStore<TElement>;
}

View File

@@ -0,0 +1,17 @@
import "jquery";
/**
* Provides the functionality to handle events of the `tablesorter`.
*/
export interface TablesorterEventHandler<TElement = HTMLElement> {
/**
* 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<TElement, null, TElement, TElement>, table: TElement): void;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
/**
* Provides the functionality to handle trigger-callbacks.
*/
export interface TriggerCallbackHandler<TElement = HTMLElement> {
/**
* Handles a trigger-callback.
*/
(table: TElement): void;
}

View File

@@ -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<TElement = HTMLElement> {
/**
* Applies a sort to the table.
*/
sorton: [ReadonlyArray<(SortDefinition | RelativeSortDefinition)>, TriggerCallbackHandler<TElement>?];
/**
* Resets the sorting.
*/
sortReset: [TriggerCallbackHandler<TElement>?];
/**
* Adds rows to the table.
*/
addRows: [JQuery | string, boolean, TriggerCallbackHandler<TElement>?];
/**
* Removes the tablesorter from the table.
*/
destroy: [boolean, TriggerCallbackHandler<TElement>?];
/**
* Applies the widget to the table.
*/
applyWidgetId: string;
/**
* Applies the configured widgets to the table.
*/
applyWidgets: TriggerCallbackHandler<TElement>;
/**
* Refreshes the widgets.
*/
refreshWidgets: [boolean?, boolean?];
/**
* Removes widgets.
*/
removeWidget: string | ReadonlyArray<string> | boolean;
/**
* Updates the data of the table-body.
*/
update: [boolean | ReadonlyArray<SortDefinition>, TriggerCallbackHandler<TElement>?];
/**
* Updates the data of the table-body.
*/
updateRows: [boolean | ReadonlyArray<SortDefinition>, TriggerCallbackHandler<TElement>?];
/**
* Updates the cache and optionally adds new `tbody`s.
*/
updateCache: [TriggerCallbackHandler<TElement>?, JQuery?];
/**
* Updates the cell of the table.
*/
updateCell: [JQuery, (boolean | ReadonlyArray<SortDefinition>)?, TriggerCallbackHandler<TElement>?];
/**
* Updates the table-headers.
*/
updateHeaders: TriggerCallbackHandler<TElement>;
/**
* Updates the data of the whole table.
*/
updateAll: [(boolean | ReadonlyArray<SortDefinition>)?, TriggerCallbackHandler<TElement>?];
/**
* Performs a search.
*/
search: [ReadonlyArray<string>?] | 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;
}

654
types/tablesorter/Tablesorter.d.ts vendored Normal file
View File

@@ -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<TElement = HTMLElement> {
/**
* The default settings.
*/
defaults: TablesorterConfiguration<TElement>;
/**
* 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<Parser<TElement>>;
/**
* The widgets of the tablesorter.
*/
widgets: Array<Widget<TElement>>;
/**
* Provides methods for the `filter`-widget.
*/
filter: FilterStatic<TElement>;
/**
* 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> | 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> | TElement, filter: ReadonlyArray<string>, 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<TElement>): void;
/**
* Adds a widget to the tablesorter.
*
* @param widget
* The widget to add.
*/
addWidget(widget: Widget<TElement>): 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> | 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<TElement>;
/**
* 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<TElement>;
/**
* 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> | 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> | 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<TElement>, sort: ReadonlyArray<(SortDefinition | RelativeSortDefinition)>, callback?: TriggerCallbackHandler<TElement>): void;
/**
* Resets the sorting.
*
* @param config
* The configuration of the table-sorter.
*
* @param callback
* A callback for post-processing the table.
*/
sortReset(config: TablesorterConfigurationStore<TElement>, callback?: TriggerCallbackHandler<TElement>): 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<TElement>, rows: JQuery | string, resort: boolean | ReadonlyArray<SortDefinition>, callback?: TriggerCallbackHandler<TElement>): void;
/**
* Clears all table-bodies inside the specified `table`.
*
* @param table
* The table which is being processed.
*/
clearTableBody(table: JQuery<TElement> | 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> | TElement, initialize?: boolean, callback?: TriggerCallbackHandler<TElement>): 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> | 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> | TElement, id: string | ReadonlyArray<string> | 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> | 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<TElement>): 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<TElement>, sorting?: boolean | ReadonlyArray<SortDefinition>, callback?: TriggerCallbackHandler<TElement>): 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<TElement>, sorting?: boolean | ReadonlyArray<SortDefinition>, callback?: TriggerCallbackHandler<TElement>): 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<TElement>, callback?: TriggerCallbackHandler<TElement>, 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<TElement>, cell: JQuery, sorting?: boolean | ReadonlyArray<SortDefinition>, callback?: TriggerCallbackHandler<TElement>): 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<TElement>, callback?: TriggerCallbackHandler<TElement>): 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<TElement>, sorting?: boolean | ReadonlyArray<SortDefinition>, callback?: TriggerCallbackHandler<TElement>): void;
/**
* Restores the headers of a table.
*
* @param table
* The table to process.
*/
restoreHeaders(table: JQuery<TElement> | 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<TElement>): void;
/**
* Adds a `colgroup`-element to the specified `table`.
*
* @param table
* The table to add the fixed columns to.
*/
fixColumnWidth(table: JQuery<TElement> | 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<T extends keyof TablesorterHeading>(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<T>(table: JQuery<TElement> | TElement, object: MappedSettings<T>, 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> | TElement,
column: number | "all",
callback?: (cell: ParsedCell) => void,
rowFilter?: JQuery.Selector | JQuery.TypeOrArray<Element> | 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> | 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> | 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> | 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> | 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> | 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> | TElement, removeClasses?: boolean, callback?: TriggerCallbackHandler<TElement>): 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> | TElement, tbody: JQuery, detach: true): JQuery;
processTbody(table: JQuery<TElement> | 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> | TElement, keepLocalSettings?: boolean): void;
}

View File

@@ -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;
}

View File

@@ -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<TElement = HTMLElement> {
/**
* 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<TElement>) => boolean);
/**
* The default filters to apply.
*/
filter_defaultFilter?: MappedSettings<string>;
/**
* A set of filters to prevent.
*/
filter_excludeFilter?: MappedSettings<string>;
/**
* The jQuery-selector for querying the external search-box.
*/
filter_external?: JQuery.Selector;
/**
* The filter-controls to apply.
*/
filter_formatter?: MappedSettings<FilterControlFactory>;
/**
* 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<FilterFunctionCollection<TElement> | FilterFunction<TElement>>;
/**
* 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<TElement> | MappedSettings<SelectSources<TElement>>;
/**
* 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;
}

Some files were not shown because too many files have changed in this diff Show More