Remove all enum-declarations from the "tablesorter" module (#35624)

This commit is contained in:
Manuel Thalmann 2019-05-21 22:04:38 +02:00 committed by Ryan Cavanaugh
parent f35549183f
commit f106c413ce
20 changed files with 130 additions and 147 deletions

View File

@ -1,59 +1,58 @@
/**
* Defines a theme.
*/
export enum CoreTheme {
export type CoreTheme =
/**
* Indicates the `Default`-theme.
*/
Default = "default",
"default" |
/**
* Indicates the `Bootstrap`-theme.
*/
Bootstrap = "bootstrap",
"bootstrap" |
/**
* Indicates the `Dropbox`-theme.
*/
Dropbox = "dropbox",
"dropbox" |
/**
* Indicates the `jQuery UI`-theme.
*/
JUI = "jui",
"jui" |
/**
* Indicates the `Metro Dark`-theme.
*/
MetroDark = "metro-dark",
"metro-dark" |
/**
* Indicates the `Blackice`-theme.
*/
Blackice = "blackice",
"blackice" |
/**
* Indicates the `Blue`-theme.
*/
Blue = "blue",
"blue" |
/**
* Indicates the `Dark`-theme.
*/
Dark = "dark",
"dark" |
/**
* Indicates the `Green`-theme.
*/
Green = "green",
"green" |
/**
* Indicates the `Grey`-theme.
*/
Grey = "grey",
"grey" |
/**
* Indicates the `Ice`-theme.
*/
Ice = "ice"
}
"ice";

View File

@ -1,19 +1,18 @@
/**
* Defines a concept for filtering.
*/
export enum ColumnFilter {
export type ColumnFilter =
/**
* Indicates disabled filtering.
*/
None = "false",
"false" |
/**
* Indicates filtering on parsed data.
*/
Parsed = "parsed",
"parsed" |
/**
* Indicates filtering on raw data.
*/
Default = "default"
}
"default";

View File

@ -1,24 +1,23 @@
/**
* Represents a filter-box.
*/
export enum FilterBox {
export type FilterBox =
/**
* Indicates an ordinary text-box.
*/
TextBox = "search",
"search" |
/**
* Indicates a dropdown.
*/
Dropdown = "select",
"select" |
/**
* Indicates the textbox for the start of a date-range.
*/
DateFrom = "from",
"from" |
/**
* Indicates the textbox for the end of a date-range.
*/
DateTo = "to"
}
"to";

View File

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

View File

@ -1,29 +1,28 @@
/**
* Represents an event which uses pager-settings for processing.
*/
export enum PagerEventMap {
export type PagerEventMap =
/**
* Indicates the `pagerInitialized`-event.
*/
"pagerInitialized",
"pagerInitialized" |
/**
* Indicates the `pageMoved`-event.
*/
"pageMoved",
"pageMoved" |
/**
* Indicates the `pagerChange`-event.
*/
"pagerChange",
"pagerChange" |
/**
* Indicates the `pagerComplete`-event.
*/
"pagerComplete",
"pagerComplete" |
/**
* Indicates the `pagerBeforeInitialized`-event.
*/
"pagerBeforeInitialized",
}
"pagerBeforeInitialized";

View File

@ -1,14 +1,13 @@
/**
* Represents a parser-type.
*/
export enum ParserType {
export type ParserType =
/**
* Indicates the default parser-type.
*/
Default = "text",
"text" |
/**
* Indicates a decimal parser-type.
*/
Decimal = "numeric"
}
"numeric";

View File

@ -1,29 +1,28 @@
/**
* Defines a sort-order for empty cells.
*/
export enum EmptySorting {
export type EmptySorting =
/**
* Indicates that the cells are pinned to the top.
*/
Top = "top",
"top" |
/**
* Indicates that the cells are pinned to the bottom.
*/
Bottom = "bottom",
"bottom" |
/**
* Indicates that the cells are treated like a value lesser than the minimal numeric value.
*/
Min = "emptyMin",
"emptyMin" |
/**
* Indicates that the cells are treated like a value greater than the maximal numeric value.
*/
Max = "emptyMax",
"emptyMax" |
/**
* Indicates that the cells are treated like a value equal to `0`.
*/
Zero = "zero"
}
"zero";

View File

@ -1,24 +1,23 @@
/**
* Defines a relative sorting.
*/
export enum RelativeSorting {
export type RelativeSorting =
/**
* Indicates an ascending sorting.
*/
Ascending = "a",
"a" |
/**
* Indicates a descending sorting.
*/
Descending = "d",
"d" |
/**
* Indicates the same sorting like the other column.
*/
Same = "s",
"s" |
/**
* Indicates the opposite sorting of the other column.
*/
Opposite = "o"
}
"o";

View File

@ -1,19 +1,18 @@
/**
* Defines a sort-order.
*/
export enum SortDefinitionOrder {
export type SortDefinitionOrder =
/**
* Indicates no sorting.
*/
None = 2,
2 |
/**
* Indicates ascending sorting.
*/
Ascending = 0,
0 |
/**
* Indicates descending sorting.
*/
Descending = 1
}
1;

View File

@ -1,29 +1,28 @@
/**
* Represents a sort-initiator.
*/
export enum SortInitiator {
export type SortInitiator =
/**
* Indicates the user.
*/
User = "user",
"user" |
/**
* Indicates the `sort`-event.
*/
SortEvent = "sort",
"sort" |
/**
* Indicates the `sorton`-method.
*/
SortOnMethod = "sorton",
"sorton" |
/**
* Indicates the `sortAppend`-configuration.
*/
SotAppend = "sortAppend",
"sortAppend" |
/**
* Indicates the `sortForce`-configuration.
*/
SortForce = "sortForce"
}
"sortForce";

View File

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

View File

@ -1,29 +1,28 @@
/**
* Defines a sort-order for text-cells.
*/
export enum StringSorting {
export type StringSorting =
/**
* Indicates that the cells are pinned to the top.
*/
Top = "top",
"top" |
/**
* Indicates that the cells are pinned to the bottom.
*/
Bottom = "bottom",
"bottom" |
/**
* Indicates that the cells are treated like a value lesser than the minimal numeric value.
*/
Min = "min",
"min" |
/**
* Indicates that the cells are treated like a value greater than the maximal numeric value.
*/
Max = "max",
"max" |
/**
* Indicates that the cells are treated like a value equal to `0`.
*/
Zero = "zero"
}
"zero";

View File

@ -1,19 +1,18 @@
/**
* Represents a storage type.
*/
export enum StorageType {
export type StorageType =
/**
* Indicates the default local storage.
*/
Default = "d",
"d" |
/**
* Indicates the session-storage.
*/
Session = "s",
"s" |
/**
* Indicates cookies.
*/
Cookie = "s"
}
"c";

View File

@ -1,14 +1,13 @@
/**
* Represents an event which uses the `TablesorterConfigurationStore` for processing.
*/
export enum ConfigEventMap {
export type ConfigEventMap =
/**
* Indicates the `filterInit`-event.
*/
"filterInit",
"filterInit" |
/**
* Indicates the `filterEnd`-event.
*/
"filterEnd"
}
"filterEnd";

View File

@ -1,44 +1,43 @@
/**
* Represents an event.
*/
export enum EventMap {
export type EventMap =
/**
* Indicates the `tablesorter-initialized`-event.
*/
"tablesorter-initialized",
"tablesorter-initialized" |
/**
* Indicates the `tablesorter-ready`-event.
*/
"tablesorter-ready",
"tablesorter-ready" |
/**
* Indicates the `refreshComplete`-event.
*/
"refreshComplete",
"refreshComplete" |
/**
* Indicates the `updateComplete`-event.
*/
"updateComplete",
"updateComplete" |
/**
* Indicates the `widgetRemoveEnd`-event.
*/
"widgetRemoveEnd",
"widgetRemoveEnd" |
/**
* Indicates the `sortStart`-event.
*/
"sortStart",
"sortStart" |
/**
* Indicates the `sortBegin`-event.
*/
"sortBegin",
"sortBegin" |
/**
* Indicates the `sortEnd`-event.
*/
"sortEnd"
}
"sortEnd";

View File

@ -1,99 +1,98 @@
/**
* Represents a parameterless trigger.
*/
export enum ParameterlessTriggerNameMap {
export type ParameterlessTriggerNameMap =
/**
* Indicates the `sort`-trigger.
*/
"sort",
"sort" |
/**
* Indicates the `applyWidgets`-trigger.
*/
"applyWidgets",
"applyWidgets" |
/**
* Indicates the `appendCache`-trigger.
*/
"appendCache",
"appendCache" |
/**
* Indicates the `update`-trigger.
*/
"update",
"update" |
/**
* Indicates the `updateRows`-trigger.
*/
"updateRows",
"updateRows" |
/**
* Indicates the `updateCache`-trigger.
*/
"updateCache",
"updateCache" |
/**
* Indicates the `updateHeaders`-trigger.
*/
"updateHeaders",
"updateHeaders" |
/**
* Indicates the `updateAll`-trigger.
*/
"updateAll",
"updateAll" |
/**
* Indicates the `search`-trigger.
*/
"search",
"search" |
/**
* Indicates the `resetToLoadState`-trigger.
*/
"resetToLoadState",
"resetToLoadState" |
/**
* Indicates the `destroy`-trigger.
*/
"destroy",
"destroy" |
/**
* Indicates the `filterReset`-trigger.
*/
"filterReset",
"filterReset" |
/**
* Indicates the `filterResetSaved`-trigger.
*/
"filterResetSaved",
"filterResetSaved" |
/**
* Indicates the `filterAndSortReset`-trigger.
*/
"filterAndSortReset",
"filterAndSortReset" |
/**
* Indicates the `saveSortReset`-trigger.
*/
"saveSortReset",
"saveSortReset" |
/**
* Indicates the `enablePager`-trigger.
*/
"enablePager",
"enablePager" |
/**
* Indicates the `disablePager`-trigger.
*/
"disablePager",
"disablePager" |
/**
* Indicates the `pagerUpdate`-trigger.
*/
"pagerUpdate",
"pagerUpdate" |
/**
* Indicates the `destroyPager`-trigger.
*/
"destroyPager"
}
"destroyPager";

View File

@ -233,12 +233,12 @@ declare global {
trigger<T extends keyof TriggerNameMap<TElement>>(name: T, extraParameters: TriggerNameMap<TElement>[T]): this;
trigger(name: keyof typeof ParameterlessTriggerNameMap): this;
trigger(name: ParameterlessTriggerNameMap): this;
bind(name: keyof typeof EventMap, callback: TablesorterEventHandler<TElement>): this;
bind(name: keyof typeof ConfigEventMap, callback: ConfigEventHandler<TElement>): this;
bind(name: EventMap, callback: TablesorterEventHandler<TElement>): this;
bind(name: ConfigEventMap, callback: ConfigEventHandler<TElement>): this;
bind(name: "filterStart", callback: FilterEventHandler<TElement>): this;
bind(name: keyof typeof PagerEventMap, callback: PagerEventHandler<TElement>): this;
bind(name: PagerEventMap, callback: PagerEventHandler<TElement>): this;
bind(name: "stickyHeadersInit", callback: CommonEventHandler<TElement>): this;
}
}

View File

@ -15,19 +15,19 @@ export class TestMethods<T extends HTMLElement> {
/**
* A set of sort-definitions for testing.
*/
protected sorting: ReadonlyArray<SortDefinition> = [[0, SortDefinitionOrder.Ascending], [1, 0]];
protected sorting: ReadonlyArray<SortDefinition> = [[0, 1], [1, 0]];
/**
* A set of relative sort-definitions for testing.
*/
protected relativeSorting: ReadonlyArray<RelativeSortDefinition> = [[0, RelativeSorting.Opposite], [1, RelativeSorting.Same]];
protected relativeSorting: ReadonlyArray<RelativeSortDefinition> = [[0, "o"], [1, "s"]];
/**
* A set of mixed sort-definitions for testing.
*/
protected mixedSorting: ReadonlyArray<SortDefinition | RelativeSortDefinition> = [
[0, SortDefinitionOrder.Descending],
[1, RelativeSorting.Opposite]];
[0, "d"],
[1, "o"]];
/**
* A trigger-callback for testing.
@ -53,7 +53,7 @@ export class TestMethods<T extends HTMLElement> {
group: "",
id: "",
page: "",
storageType: StorageType.Cookie,
storageType: "c",
url: ""
};
@ -161,9 +161,9 @@ export class TestMethods<T extends HTMLElement> {
$.tablesorter.getData($(), config.headers[0], "sorter");
// $ExpectType string | boolean | undefined
$.tablesorter.getData($()[0], config.headers[0], "sorter");
// $ExpectType StringSorting | undefined
// $ExpectType "top" | "bottom" | "zero" | "min" | "max" | undefined
$.tablesorter.getData($(), config.headers[0], "string");
// $ExpectType StringSorting | undefined
// $ExpectType "top" | "bottom" | "zero" | "min" | "max" | undefined
$.tablesorter.getData($()[0], config.headers[0], "string");
// $ExpectType string[]

View File

@ -51,18 +51,18 @@ export class TestSettings<T extends HTMLElement> {
debug: true,
delayInit: true,
duplicateSpan: true,
emptyTo: EmptySorting.Top,
emptyTo: "top",
headers: {
0: {
dateFormat: "yyyy-mm-dd",
empty: EmptySorting.Max,
filter: ColumnFilter.Parsed,
lockedOrder: SortOrder.Ascending,
empty: "emptyMax",
filter: "parsed",
lockedOrder: "asc",
parser: "date",
resizable: true,
sortInitialOrder: SortOrder.Ascending,
sortInitialOrder: "asc",
sorter: "date",
string: StringSorting.Zero
string: "zero"
},
3: {
parser: "ipAddress",
@ -117,17 +117,17 @@ export class TestSettings<T extends HTMLElement> {
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]],
sortAppend: [[1, 0], [2, 1]],
sortForce: [[0, 1], [1, 1]],
sortInitialOrder: "asc",
sortList: [[0, 1], [1, 1]],
sortLocaleCompare: true,
sortMultiSortKey: "bubbles",
sortReset: true,
sortResetKey: "shiftKey",
sortRestart: true,
sortStable: true,
stringTo: StringSorting.Max,
stringTo: "top",
tabIndex: true,
tableClass: "tablesorter-table",
textAttribute: "data-text",
@ -145,7 +145,7 @@ export class TestSettings<T extends HTMLElement> {
table;
return x.localeCompare(y);
},
theme: CoreTheme.Bootstrap,
theme: "bootstrap",
usNumberFormat: true,
widgetClass: "pleas-load-me-the-widget-named-{name}",
widgetOptions,
@ -173,8 +173,8 @@ export class TestSettings<T extends HTMLElement> {
* Sorting relatively
*/
settings.sortAppend = {
0: [[1, RelativeSorting.Opposite]],
1: [[2, RelativeSorting.Descending]]
0: [[1, "o"]],
1: [[2, "d"]]
};
/**
@ -273,8 +273,8 @@ export class TestSettings<T extends HTMLElement> {
filter_ignoreCase: true,
filter_liveSearch: true,
filter_matchType: {
input: MatchType.Wildcard,
select: MatchType.Exact
input: "exact",
select: "match"
},
filter_onlyAvail: "filter-onlyAvail",
filter_placeholder: {
@ -316,7 +316,7 @@ export class TestSettings<T extends HTMLElement> {
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_storageType: "c",
storage_tableId: "myAwesomeTable",
zebra: ["even", "odd"]
};

View File

@ -3,7 +3,6 @@ import "./Methods";
import "./Triggers";
import "./Events";
import "./Variables";
import { SortDefinitionOrder } from "tablesorter";
/**
* Basic usage
@ -12,8 +11,8 @@ $("#").tablesorter();
$("#").tablesorter({
sortList: [
[0, 0],
[1, SortDefinitionOrder.Descending],
[2, SortDefinitionOrder.None],
[3, SortDefinitionOrder.Ascending]
[1, 1],
[2, 2],
[3, 0]
]
});