Skip to content

Commit

Permalink
66747bd1e60e2043dd395c898152c2dbff448c13
Browse files Browse the repository at this point in the history
Sync to source repo @66747bd1e60e2043dd395c898152c2dbff448c13
  • Loading branch information
AllanJard committed Nov 8, 2022
1 parent 45e88ac commit d24da51
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 6 deletions.
5 changes: 3 additions & 2 deletions datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"types/types.d.ts"
],
"src-repo": "http://github.com/DataTables/StateRestore",
"last-tag": "1.1.1"
}
"last-tag": "1.1.1",
"last-sync": "66747bd1e60e2043dd395c898152c2dbff448c13"
}
145 changes: 141 additions & 4 deletions types/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,144 @@
// Type definitions for DataTables StateRestore
//
// Project: https://datatables.net/extensions/StateRestore/, https://datatables.net

// Dist-DataTables-StateRestore-jQueryUI integration with jQueryUI exports the DataTables API having
// set default values to complete the ingeration.
import Api from "datatables.net";
/// <reference types="jquery" />

export default Api;
import DataTables, {Api} from 'datatables.net';
import * as stateRestoreCollectionType from './StateRestoreCollection';
import * as stateRestoreType from './StateRestore';

export default DataTables;

type DeepPartial<T> = T extends object ? {
[P in keyof T]?: DeepPartial<T[P]>;
} : T;


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* DataTables' types integration
*/
declare module 'datatables.net' {
interface Config {
/**
* StateRestore extension options
*/
stateRestore?: boolean | string[] | ConfigStateRestore | ConfigStateRestore[];
}

interface ConfigLanguage {
/**
* StateRestore language options
*/
stateRestore?: ConfigStateRestoreLanguage;
}

interface Api<T> {
/**
* StateRestore API Methods
*/
stateRestore: ApiStateRestore<T>;
}

interface ApiStatic {
/**
* StateRestore class
*/
StateRestore: {
/**
* Create a new StateRestore instance for the target DataTable
*/
new (dt: Api<any>, settings: string[] | ConfigStateRestore | ConfigStateRestore[]);

/**
* StateRestore version
*/
version: string;

/**
* Default configuration values
*/
defaults: ConfigStateRestore;
}
}
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Options
*/
interface ConfigStateRestore extends Partial<stateRestoreCollectionType.IDefaults> {}

interface ConfigStateRestoreLanguage extends DeepPartial<stateRestoreCollectionType.II18n> {}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* API
*/

interface ApiStateRestore<T> {
/**
* Creates a new state, adding it to the collection.
*
* @param identifier The identifier that is to be used for the new state
*
* @returns DatatTables Api for chaining
*/
addState(identifier: string): void | Api<T>;

/**
* Retrieves a state from the collection.
*
* @param identifier The identifier of the state that is to be retrieved.
*
* @returns StateRestore instance, or further api methods.
*/
state(identifier: string): stateRestoreType.default | null | StateRestoreSubApi<T>;

/**
* Retrieves all of the states from the collection.
*
* @returns An array of the StateRestore instances,
* or further api methods that are applicable to multiple states.
*/
states(): stateRestoreType.default[] | StateRestoreMultiSubApi<T>;
}

interface StateRestoreSubApi<T> extends Api<T> {
/**
* Removes the state previously identified in the call to `state()`.
*
* @returns Datatables Api for chaining.
*/
remove(): Api<T>;

/**
* Loads the state previously identified in the call to `state()` into the table.
*
* @returns Datatables Api for chaining.
*/
load(): Api<T>;

/**
* Renames the state previously identified in the call to `state()`.
*
* @returns Datatables Api for chaining.
*/
rename(): Api<T>;

/**
* Saves the state previously identified in the call to `state()`.
*
* @returns Datatables Api for chaining.
*/
save(): Api<T>;
}

interface StateRestoreMultiSubApi<T> extends Api<T> {
/**
* Removes all of the states that were previously identified in the call to `states()`.
*
* @returns Datatables Api for chaining.
*/
remove(): Api<T>;
}

0 comments on commit d24da51

Please sign in to comment.