Fix jquery plugins typedef

This commit is contained in:
Cohee
2024-10-31 21:05:22 +02:00
parent f4ef324203
commit 5fe1bc46e6

170
public/global.d.ts vendored
View File

@@ -11,103 +11,105 @@ declare var SillyTavern: {
libs: typeof libs; libs: typeof libs;
}; };
// Jquery plugins declare global {
interface JQuery { // Jquery plugins
nanogallery2(options?: any): JQuery; interface JQuery {
nanogallery2(method: string, options?: any): JQuery; nanogallery2(options?: any): JQuery;
pagination(method: 'getCurrentPageNum'): number; nanogallery2(method: string, options?: any): JQuery;
pagination(method: string, options?: any): JQuery; pagination(method: 'getCurrentPageNum'): number;
pagination(options?: any): JQuery; pagination(method: string, options?: any): JQuery;
transition(options?: any, complete?: function): JQuery; pagination(options?: any): JQuery;
autocomplete(options?: any): JQuery; transition(options?: any, complete?: function): JQuery;
autocomplete(method: string, options?: any): JQuery; autocomplete(options?: any): JQuery;
slider(options?: any): JQuery; autocomplete(method: string, options?: any): JQuery;
slider(method: string, func: string, options?: any): JQuery; slider(options?: any): JQuery;
cropper(options?: any): JQuery; slider(method: string, func: string, options?: any): JQuery;
izoomify(options?: any): JQuery; cropper(options?: any): JQuery;
izoomify(options?: any): JQuery;
//#region select2 //#region select2
/** /**
* Initializes or modifies a select2 instance with provided options * Initializes or modifies a select2 instance with provided options
* *
* @param options - Configuration options for the select2 instance * @param options - Configuration options for the select2 instance
* @returns The jQuery object for chaining * @returns The jQuery object for chaining
*/ */
select2(options?: Select2Options): JQuery; select2(options?: Select2Options): JQuery;
/** /**
* Retrieves data currently selected in the select2 instance * Retrieves data currently selected in the select2 instance
* *
* @param field - A string specifying the 'data' method * @param field - A string specifying the 'data' method
* @returns An array of selected items * @returns An array of selected items
*/ */
select2(field: 'data'): any[]; select2(field: 'data'): any[];
/** /**
* Calls the specified select2 method * Calls the specified select2 method
* *
* @param method - The name of the select2 method to invoke * @param method - The name of the select2 method to invoke
* @returns The jQuery object for chaining * @returns The jQuery object for chaining
*/ */
select2(method: 'open' | 'close' | 'destroy' | 'focus' | 'val', value?: any): JQuery; select2(method: 'open' | 'close' | 'destroy' | 'focus' | 'val', value?: any): JQuery;
//#endregion //#endregion
//#region sortable //#region sortable
/** /**
* Initializes or updates a sortable instance with the provided options * Initializes or updates a sortable instance with the provided options
* *
* @param options - Configuration options for the sortable instance * @param options - Configuration options for the sortable instance
* @returns The jQuery object for chaining * @returns The jQuery object for chaining
*/ */
sortable(options?: SortableOptions): JQuery; sortable(options?: SortableOptions): JQuery;
/** /**
* Calls a sortable method to perform actions on the instance * Calls a sortable method to perform actions on the instance
* *
* @param method - The name of the sortable method to invoke * @param method - The name of the sortable method to invoke
* @returns The jQuery object for chaining * @returns The jQuery object for chaining
*/ */
sortable(method: 'destroy' | 'disable' | 'enable' | 'refresh' | 'toArray'): JQuery; sortable(method: 'destroy' | 'disable' | 'enable' | 'refresh' | 'toArray'): JQuery;
/** /**
* Retrieves the sortable's instance object. If the element does not have an associated instance, undefined is returned. * Retrieves the sortable's instance object. If the element does not have an associated instance, undefined is returned.
* *
* @returns The instance of the sortable object * @returns The instance of the sortable object
*/ */
sortable(method: 'instance'): object; sortable(method: 'instance'): object;
/** /**
* Retrieves the current option value for the specified option * Retrieves the current option value for the specified option
* *
* @param method - The string 'option' to retrieve an option value * @param method - The string 'option' to retrieve an option value
* @param optionName - The name of the option to retrieve * @param optionName - The name of the option to retrieve
* @returns The value of the specified option * @returns The value of the specified option
*/ */
sortable(method: 'option', optionName: string): any; sortable(method: 'option', optionName: string): any;
/** /**
* Sets the value of the specified option * Sets the value of the specified option
* *
* @param method - The string 'option' to set an option value * @param method - The string 'option' to set an option value
* @param optionName - The name of the option to set * @param optionName - The name of the option to set
* @param value - The value to assign to the option * @param value - The value to assign to the option
* @returns The jQuery object for chaining * @returns The jQuery object for chaining
*/ */
sortable(method: 'option', optionName: string, value: any): JQuery; sortable(method: 'option', optionName: string, value: any): JQuery;
/** /**
* Sets multiple options using an object * Sets multiple options using an object
* *
* @param method - The string 'option' to set options * @param method - The string 'option' to set options
* @param options - An object containing multiple option key-value pairs * @param options - An object containing multiple option key-value pairs
* @returns The jQuery object for chaining * @returns The jQuery object for chaining
*/ */
sortable(method: 'option', options: SortableOptions): JQuery; sortable(method: 'option', options: SortableOptions): JQuery;
//#endregion //#endregion
}
} }
//#region select2 //#region select2