From f106c413cef3a3eeaae1bfe116fc55ceb40e7796 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 21 May 2019 22:04:38 +0200 Subject: [PATCH] Remove all enum-declarations from the "tablesorter" module (#35624) --- types/tablesorter/Design/CoreTheme.d.ts | 25 ++++++----- types/tablesorter/Filtering/ColumnFilter.d.ts | 9 ++-- types/tablesorter/Filtering/FilterBox.d.ts | 11 +++-- types/tablesorter/Filtering/MatchType.d.ts | 7 ++-- types/tablesorter/Paging/PagerEventMap.d.ts | 13 +++--- types/tablesorter/Parsing/ParserType.d.ts | 7 ++-- types/tablesorter/Sorting/EmptySorting.d.ts | 13 +++--- .../tablesorter/Sorting/RelativeSorting.d.ts | 11 +++-- .../Sorting/SortDefinitionOrder.d.ts | 9 ++-- types/tablesorter/Sorting/SortInitiator.d.ts | 13 +++--- types/tablesorter/Sorting/SortOrder.d.ts | 7 ++-- types/tablesorter/Sorting/StringSorting.d.ts | 13 +++--- types/tablesorter/Storage/StorageType.d.ts | 9 ++-- types/tablesorter/System/ConfigEventMap.d.ts | 7 ++-- types/tablesorter/System/EventMap.d.ts | 19 ++++----- .../System/ParameterlessTriggerNameMap.d.ts | 41 +++++++++---------- types/tablesorter/index.d.ts | 8 ++-- types/tablesorter/test/Methods.ts | 14 +++---- types/tablesorter/test/Settings.ts | 34 +++++++-------- types/tablesorter/test/main.ts | 7 ++-- 20 files changed, 130 insertions(+), 147 deletions(-) diff --git a/types/tablesorter/Design/CoreTheme.d.ts b/types/tablesorter/Design/CoreTheme.d.ts index 9040b2fa52..c9ce3f40ca 100644 --- a/types/tablesorter/Design/CoreTheme.d.ts +++ b/types/tablesorter/Design/CoreTheme.d.ts @@ -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"; diff --git a/types/tablesorter/Filtering/ColumnFilter.d.ts b/types/tablesorter/Filtering/ColumnFilter.d.ts index 90ba1f4062..54dd269d2d 100644 --- a/types/tablesorter/Filtering/ColumnFilter.d.ts +++ b/types/tablesorter/Filtering/ColumnFilter.d.ts @@ -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"; diff --git a/types/tablesorter/Filtering/FilterBox.d.ts b/types/tablesorter/Filtering/FilterBox.d.ts index d92d09c678..24aba9100c 100644 --- a/types/tablesorter/Filtering/FilterBox.d.ts +++ b/types/tablesorter/Filtering/FilterBox.d.ts @@ -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"; diff --git a/types/tablesorter/Filtering/MatchType.d.ts b/types/tablesorter/Filtering/MatchType.d.ts index 69047da96c..13f3b04d15 100644 --- a/types/tablesorter/Filtering/MatchType.d.ts +++ b/types/tablesorter/Filtering/MatchType.d.ts @@ -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"; diff --git a/types/tablesorter/Paging/PagerEventMap.d.ts b/types/tablesorter/Paging/PagerEventMap.d.ts index bfda115361..70d2f684cf 100644 --- a/types/tablesorter/Paging/PagerEventMap.d.ts +++ b/types/tablesorter/Paging/PagerEventMap.d.ts @@ -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"; diff --git a/types/tablesorter/Parsing/ParserType.d.ts b/types/tablesorter/Parsing/ParserType.d.ts index 15810f97b1..171e310dd5 100644 --- a/types/tablesorter/Parsing/ParserType.d.ts +++ b/types/tablesorter/Parsing/ParserType.d.ts @@ -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"; diff --git a/types/tablesorter/Sorting/EmptySorting.d.ts b/types/tablesorter/Sorting/EmptySorting.d.ts index 0e1ddc34a8..f2c8e19a8b 100644 --- a/types/tablesorter/Sorting/EmptySorting.d.ts +++ b/types/tablesorter/Sorting/EmptySorting.d.ts @@ -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"; diff --git a/types/tablesorter/Sorting/RelativeSorting.d.ts b/types/tablesorter/Sorting/RelativeSorting.d.ts index 5d70ee4070..e06e9378ad 100644 --- a/types/tablesorter/Sorting/RelativeSorting.d.ts +++ b/types/tablesorter/Sorting/RelativeSorting.d.ts @@ -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"; diff --git a/types/tablesorter/Sorting/SortDefinitionOrder.d.ts b/types/tablesorter/Sorting/SortDefinitionOrder.d.ts index cb844d58d8..e9da8bff4f 100644 --- a/types/tablesorter/Sorting/SortDefinitionOrder.d.ts +++ b/types/tablesorter/Sorting/SortDefinitionOrder.d.ts @@ -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; diff --git a/types/tablesorter/Sorting/SortInitiator.d.ts b/types/tablesorter/Sorting/SortInitiator.d.ts index f6093f3614..2dfe0d0045 100644 --- a/types/tablesorter/Sorting/SortInitiator.d.ts +++ b/types/tablesorter/Sorting/SortInitiator.d.ts @@ -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"; diff --git a/types/tablesorter/Sorting/SortOrder.d.ts b/types/tablesorter/Sorting/SortOrder.d.ts index 160c0c7253..0f36103732 100644 --- a/types/tablesorter/Sorting/SortOrder.d.ts +++ b/types/tablesorter/Sorting/SortOrder.d.ts @@ -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"; diff --git a/types/tablesorter/Sorting/StringSorting.d.ts b/types/tablesorter/Sorting/StringSorting.d.ts index 20c3002504..e6e6e986a3 100644 --- a/types/tablesorter/Sorting/StringSorting.d.ts +++ b/types/tablesorter/Sorting/StringSorting.d.ts @@ -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"; diff --git a/types/tablesorter/Storage/StorageType.d.ts b/types/tablesorter/Storage/StorageType.d.ts index 09dc14a5c2..e1417d2930 100644 --- a/types/tablesorter/Storage/StorageType.d.ts +++ b/types/tablesorter/Storage/StorageType.d.ts @@ -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"; diff --git a/types/tablesorter/System/ConfigEventMap.d.ts b/types/tablesorter/System/ConfigEventMap.d.ts index 064c1379f0..36bb433100 100644 --- a/types/tablesorter/System/ConfigEventMap.d.ts +++ b/types/tablesorter/System/ConfigEventMap.d.ts @@ -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"; diff --git a/types/tablesorter/System/EventMap.d.ts b/types/tablesorter/System/EventMap.d.ts index 824fc948de..6c6fb5d369 100644 --- a/types/tablesorter/System/EventMap.d.ts +++ b/types/tablesorter/System/EventMap.d.ts @@ -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"; diff --git a/types/tablesorter/System/ParameterlessTriggerNameMap.d.ts b/types/tablesorter/System/ParameterlessTriggerNameMap.d.ts index 4c8164d199..031b4f5bb7 100644 --- a/types/tablesorter/System/ParameterlessTriggerNameMap.d.ts +++ b/types/tablesorter/System/ParameterlessTriggerNameMap.d.ts @@ -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"; diff --git a/types/tablesorter/index.d.ts b/types/tablesorter/index.d.ts index 0541d7ced8..77ef7e3aef 100644 --- a/types/tablesorter/index.d.ts +++ b/types/tablesorter/index.d.ts @@ -233,12 +233,12 @@ declare global { trigger>(name: T, extraParameters: TriggerNameMap[T]): this; - trigger(name: keyof typeof ParameterlessTriggerNameMap): this; + trigger(name: ParameterlessTriggerNameMap): this; - bind(name: keyof typeof EventMap, callback: TablesorterEventHandler): this; - bind(name: keyof typeof ConfigEventMap, callback: ConfigEventHandler): this; + bind(name: EventMap, callback: TablesorterEventHandler): this; + bind(name: ConfigEventMap, callback: ConfigEventHandler): this; bind(name: "filterStart", callback: FilterEventHandler): this; - bind(name: keyof typeof PagerEventMap, callback: PagerEventHandler): this; + bind(name: PagerEventMap, callback: PagerEventHandler): this; bind(name: "stickyHeadersInit", callback: CommonEventHandler): this; } } diff --git a/types/tablesorter/test/Methods.ts b/types/tablesorter/test/Methods.ts index cfe22ca51c..ac18a4ebb6 100644 --- a/types/tablesorter/test/Methods.ts +++ b/types/tablesorter/test/Methods.ts @@ -15,19 +15,19 @@ export class TestMethods { /** * A set of sort-definitions for testing. */ - protected sorting: ReadonlyArray = [[0, SortDefinitionOrder.Ascending], [1, 0]]; + protected sorting: ReadonlyArray = [[0, 1], [1, 0]]; /** * A set of relative sort-definitions for testing. */ - protected relativeSorting: ReadonlyArray = [[0, RelativeSorting.Opposite], [1, RelativeSorting.Same]]; + protected relativeSorting: ReadonlyArray = [[0, "o"], [1, "s"]]; /** * A set of mixed sort-definitions for testing. */ protected mixedSorting: ReadonlyArray = [ - [0, SortDefinitionOrder.Descending], - [1, RelativeSorting.Opposite]]; + [0, "d"], + [1, "o"]]; /** * A trigger-callback for testing. @@ -53,7 +53,7 @@ export class TestMethods { group: "", id: "", page: "", - storageType: StorageType.Cookie, + storageType: "c", url: "" }; @@ -161,9 +161,9 @@ export class TestMethods { $.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[] diff --git a/types/tablesorter/test/Settings.ts b/types/tablesorter/test/Settings.ts index eac6c07f6a..a2c65a7bbb 100644 --- a/types/tablesorter/test/Settings.ts +++ b/types/tablesorter/test/Settings.ts @@ -51,18 +51,18 @@ export class TestSettings { 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 { 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 { 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 { * 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 { 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 { 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"] }; diff --git a/types/tablesorter/test/main.ts b/types/tablesorter/test/main.ts index 1056224a17..2e41cf3618 100644 --- a/types/tablesorter/test/main.ts +++ b/types/tablesorter/test/main.ts @@ -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] ] });