Add type definitions for jQuery plugins

616fc34826978b44619992de98ba1e6dab0a653f

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +51 -379Showing whitespace changes
package-lock.json+44 -0
@@ -88,6 +88,9 @@
88 "@types/deno": "^2.0.0",88 "@types/deno": "^2.0.0",
89 "@types/express": "^4.17.21",89 "@types/express": "^4.17.21",
90 "@types/jquery": "^3.5.29",90 "@types/jquery": "^3.5.29",
91 "@types/jquery-cropper": "^1.0.4",
92 "@types/jquery.transit": "^0.9.33",
93 "@types/jqueryui": "^1.12.23",
91 "@types/lodash": "^4.17.10",94 "@types/lodash": "^4.17.10",
92 "@types/mime-types": "^2.1.4",95 "@types/mime-types": "^2.1.4",
93 "@types/multer": "^1.4.12",96 "@types/multer": "^1.4.12",
@@ -97,6 +100,7 @@
97 "@types/png-chunks-encode": "^1.0.2",100 "@types/png-chunks-encode": "^1.0.2",
98 "@types/png-chunks-extract": "^1.0.2",101 "@types/png-chunks-extract": "^1.0.2",
99 "@types/response-time": "^2.3.8",102 "@types/response-time": "^2.3.8",
103 "@types/select2": "^4.0.63",
100 "@types/toastr": "^2.1.43",104 "@types/toastr": "^2.1.43",
101 "@types/write-file-atomic": "^4.0.3",105 "@types/write-file-atomic": "^4.0.3",
102 "@types/yargs": "^17.0.33",106 "@types/yargs": "^17.0.33",
@@ -1228,6 +1232,36 @@
1228 "@types/sizzle": "*"1232 "@types/sizzle": "*"
1229 }1233 }
1230 },1234 },
1235 "node_modules/@types/jquery-cropper": {
1236 "version": "1.0.4",
1237 "resolved": "https://registry.npmjs.org/@types/jquery-cropper/-/jquery-cropper-1.0.4.tgz",
1238 "integrity": "sha512-YMyUoY+rhB8yc3xM1B/daNaSq5+q93rzvRx6HP8K9mmvXEviTH3/rldlYNCGd0TmE/kLlZYJsruYhu9wY350PA==",
1239 "dev": true,
1240 "license": "MIT",
1241 "dependencies": {
1242 "@types/jquery": "*"
1243 }
1244 },
1245 "node_modules/@types/jquery.transit": {
1246 "version": "0.9.33",
1247 "resolved": "https://registry.npmjs.org/@types/jquery.transit/-/jquery.transit-0.9.33.tgz",
1248 "integrity": "sha512-gEDi1Lw7qfHFxtcnm2dg0F3Z5yG+84Sn0gDpGbd+u+r2RxsCcdQzfUmFKzHGBjWflZ9CXOZiAkenKOSvwLITrg==",
1249 "dev": true,
1250 "license": "MIT",
1251 "dependencies": {
1252 "@types/jquery": "*"
1253 }
1254 },
1255 "node_modules/@types/jqueryui": {
1256 "version": "1.12.23",
1257 "resolved": "https://registry.npmjs.org/@types/jqueryui/-/jqueryui-1.12.23.tgz",
1258 "integrity": "sha512-pm1yVNVI29B9IGw41anCEzA5eR2r1pYc7flqD471ZT7B0yUXIY7YNe/zq7LGpihIGXNzWyG+Q4YQSzv2AF3fNA==",
1259 "dev": true,
1260 "license": "MIT",
1261 "dependencies": {
1262 "@types/jquery": "*"
1263 }
1264 },
1231 "node_modules/@types/json-schema": {1265 "node_modules/@types/json-schema": {
1232 "version": "7.0.15",1266 "version": "7.0.15",
1233 "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",1267 "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
@@ -1379,6 +1413,16 @@
1379 "@types/node": "*"1413 "@types/node": "*"
1380 }1414 }
1381 },1415 },
1416 "node_modules/@types/select2": {
1417 "version": "4.0.63",
1418 "resolved": "https://registry.npmjs.org/@types/select2/-/select2-4.0.63.tgz",
1419 "integrity": "sha512-/DXUfPSj3iVTGlRYRYPCFKKSogAGP/j+Z0fIMXbBiBtmmZj0WH7vnfNuckafq9C43KnqPPQW2TI/Rj/vTSGnQQ==",
1420 "dev": true,
1421 "license": "MIT",
1422 "dependencies": {
1423 "@types/jquery": "*"
1424 }
1425 },
1382 "node_modules/@types/send": {1426 "node_modules/@types/send": {
1383 "version": "0.17.4",1427 "version": "0.17.4",
1384 "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",1428 "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",
package.json+4 -0
@@ -116,6 +116,9 @@
116 "@types/deno": "^2.0.0",116 "@types/deno": "^2.0.0",
117 "@types/express": "^4.17.21",117 "@types/express": "^4.17.21",
118 "@types/jquery": "^3.5.29",118 "@types/jquery": "^3.5.29",
119 "@types/jquery-cropper": "^1.0.4",
120 "@types/jquery.transit": "^0.9.33",
121 "@types/jqueryui": "^1.12.23",
119 "@types/lodash": "^4.17.10",122 "@types/lodash": "^4.17.10",
120 "@types/mime-types": "^2.1.4",123 "@types/mime-types": "^2.1.4",
121 "@types/multer": "^1.4.12",124 "@types/multer": "^1.4.12",
@@ -125,6 +128,7 @@
125 "@types/png-chunks-encode": "^1.0.2",128 "@types/png-chunks-encode": "^1.0.2",
126 "@types/png-chunks-extract": "^1.0.2",129 "@types/png-chunks-extract": "^1.0.2",
127 "@types/response-time": "^2.3.8",130 "@types/response-time": "^2.3.8",
131 "@types/select2": "^4.0.63",
128 "@types/toastr": "^2.1.43",132 "@types/toastr": "^2.1.43",
129 "@types/write-file-atomic": "^4.0.3",133 "@types/write-file-atomic": "^4.0.3",
130 "@types/yargs": "^17.0.33",134 "@types/yargs": "^17.0.33",
public/global.d.ts+3 -379
@@ -20,321 +20,11 @@ declare global {
20 pagination(method: 'getCurrentPageNum'): number;20 pagination(method: 'getCurrentPageNum'): number;
21 pagination(method: string, options?: any): JQuery;21 pagination(method: string, options?: any): JQuery;
22 pagination(options?: any): JQuery;22 pagination(options?: any): JQuery;
23 transition(options?: any, complete?: function): JQuery;
24 autocomplete(options?: any): JQuery;
25 autocomplete(method: string, options?: any): JQuery;
26 slider(options?: any): JQuery;
27 slider(method: string, func: string, options?: any): JQuery;
28 cropper(options?: any): JQuery;
29 izoomify(options?: any): JQuery;23 izoomify(options?: any): JQuery;
30
31 //#region select2
32
33 /**
34 * Initializes or modifies a select2 instance with provided options
35 *
36 * @param options - Configuration options for the select2 instance
37 * @returns The jQuery object for chaining
38 */
39 select2(options?: Select2Options): JQuery;
40
41 /**
42 * Retrieves data currently selected in the select2 instance
43 *
44 * @param field - A string specifying the 'data' method
45 * @returns An array of selected items
46 */
47 select2(field: 'data'): any[];
48
49 /**
50 * Calls the specified select2 method
51 *
52 * @param method - The name of the select2 method to invoke
53 * @returns The jQuery object for chaining
54 */
55 select2(method: 'open' | 'close' | 'destroy' | 'focus' | 'val', value?: any): JQuery;
56
57 //#endregion
58
59 //#region sortable
60
61 /**
62 * Initializes or updates a sortable instance with the provided options
63 *
64 * @param options - Configuration options for the sortable instance
65 * @returns The jQuery object for chaining
66 */
67 sortable(options?: SortableOptions): JQuery;
68
69 /**
70 * Calls a sortable method to perform actions on the instance
71 *
72 * @param method - The name of the sortable method to invoke
73 * @returns The jQuery object for chaining
74 */
75 sortable(method: 'destroy' | 'disable' | 'enable' | 'refresh' | 'toArray'): JQuery;
76
77 /**
78 * Retrieves the sortable's instance object. If the element does not have an associated instance, undefined is returned.
79 *
80 * @returns The instance of the sortable object
81 */
82 sortable(method: 'instance'): object;
83
84 /**
85 * Retrieves the current option value for the specified option
86 *
87 * @param method - The string 'option' to retrieve an option value
88 * @param optionName - The name of the option to retrieve
89 * @returns The value of the specified option
90 */
91 sortable(method: 'option', optionName: string): any;
92
93 /**
94 * Sets the value of the specified option
95 *
96 * @param method - The string 'option' to set an option value
97 * @param optionName - The name of the option to set
98 * @param value - The value to assign to the option
99 * @returns The jQuery object for chaining
100 */
101 sortable(method: 'option', optionName: string, value: any): JQuery;
102
103 /**
104 * Sets multiple options using an object
105 *
106 * @param method - The string 'option' to set options
107 * @param options - An object containing multiple option key-value pairs
108 * @returns The jQuery object for chaining
109 */
110 sortable(method: 'option', options: SortableOptions): JQuery;
111
112 //#endregion
113 }24 }
114}
115
116//#region select2
117
118/** Options for configuring a select2 instance */
119interface Select2Options {
120 /**
121 * Provides support for ajax data sources
122 * @param params - Parameters including the search term
123 * @param callback - A callback function to handle the results
124 * @default null
125 */
126 ajax?: {
127 url: string;
128 dataType?: string;
129 delay?: number;
130 data?: (params: any) => any;
131 processResults?: (data: any, params: any) => any;
132 } | { transport: (params, success, failure) => any };
133
134 /**
135 * Provides support for clearable selections
136 * @default false
137 */
138 allowClear?: boolean;
139
140 /**
141 * See Using Select2 with AMD or CommonJS loaders
142 * @default './i18n/'
143 */
144 amdLanguageBase?: string;
145
146 /**
147 * Controls whether the dropdown is closed after a selection is made
148 * @default true
149 */
150 closeOnSelect?: boolean;
151
152 /**
153 * Allows rendering dropdown options from an array
154 * @default null
155 */
156 data?: object[];
157
158 /**
159 * Used to override the built-in DataAdapter
160 * @default SelectAdapter
161 */
162 dataAdapter?: SelectAdapter;
163
164 /**
165 * Enable debugging messages in the browser console
166 * @default false
167 */
168 debug?: boolean;
169
170 /**
171 * Sets the dir attribute on the selection and dropdown containers to indicate the direction of the text
172 * @default 'ltr'
173 */
174 dir?: string;
175
176 /**
177 * When set to true, the select control will be disabled
178 * @default false
179 */
180 disabled?: boolean;
181
182 /**
183 * Used to override the built-in DropdownAdapter
184 * @default DropdownAdapter
185 */
186 dropdownAdapter?: DropdownAdapter;
187
188 /**
189 * @default false
190 */
191 dropdownAutoWidth?: boolean;
192
193 /**
194 * Adds additional CSS classes to the dropdown container. The helper :all: can be used to add all CSS classes present on the original <select> element.
195 * @default ''
196 */
197 dropdownCssClass?: string;
198
199 /**
200 * Allows you to customize placement of the dropdown
201 * @default $(document.body)
202 */
203 dropdownParent?: JQuery | HTMLElement;
204
205 /**
206 * Handles automatic escaping of content rendered by custom templates
207 * @default Utils.escapeMarkup
208 */
209 escapeMarkup?: function;
210
211 /**
212 * Specify the language used for Select2 messages
213 * @default EnglishTranslation
214 */
215 language?: string | object;
216
217 /**
218 * Handles custom search matching
219 * @default null
220 */
221 matcher?: (searchParams: object, data: object) => boolean;
222
223 /**
224 * Maximum number of characters that may be provided for a search term
225 * @default 0
226 */
227 maximumInputLength?: number;
228
229 /**
230 * The maximum number of items that may be selected in a multi-select control. If the value of this option is less than 1, the number of selected items will not be limited.
231 * @default 0
232 */
233 maximumSelectionLength?: number;
234
235 /**
236 * Minimum number of characters required to start a search
237 * @default 0
238 */
239 minimumInputLength?: number;
240
241 /**
242 * The minimum number of results required to display the search box
243 * @default 0
244 */
245 minimumResultsForSearch?: number;
246
247 /**
248 * This option enables multi-select (pillbox) mode. Select2 will automatically map the value of the multiple HTML attribute to this option during initialization.
249 * @default false
250 */
251 multiple?: boolean;
252
253 /**
254 * Specifies the placeholder for the control
255 * @default null
256 */
257 placeholder?: string;
258
259 /**
260 * Used to override the built-in ResultsAdapter
261 * @default ResultsAdapter
262 */
263 resultsAdapter?: ResultsAdapter;
264
265 /**
266 * Used to override the built-in SelectionAdapter
267 * @default SingleSelection | MultipleSelection
268 */
269 selectionAdapter?: SingleSelection | MultipleSelection;
270
271 /**
272 * Adds additional CSS classes to the selection container. The helper :all: can be used to add all CSS classes present on the original <select> element
273 * @default ''
274 */
275 selectionCssClass?: string;
276
277 /**
278 * Implements automatic selection when the dropdown is closed
279 * @default false
280 */
281 selectOnClose?: boolean;
282
283 sorter?: function;
284
285 /**
286 * When set to `true`, allows the user to create new tags that aren't pre-populated
287 * Used to enable free text responses
288 * @default false
289 */
290 tags?: boolean | object[];
291
292 /**
293 * Customizes the way that search results are rendered
294 * @param item - The item object to format
295 * @returns The formatted representation
296 * @default null
297 */
298 templateResult?: (item: any) => JQuery | string;
299
300 /**
301 * Customizes the way that selections are rendered
302 * @param item - The selected item object to format
303 * @returns The formatted representation
304 * @default null
305 */
306 templateSelection?: (item: any) => JQuery | string;
307
308 /**
309 * Allows you to set the theme
310 * @default 'default'
311 */
312 theme?: string;
313
314 /**
315 * A callback that handles automatic tokenization of free-text entry
316 * @default null
317 */
318 tokenizer?: (input: { _type: string, term: string }, selection: { options: object }, callback: (Select2Option) => any) => { term: string };
319
320 /**
321 * The list of characters that should be used as token separators
322 * @default null
323 */
324 tokenSeparators?: string[];
325
326 /**
327 * Supports customization of the container width
328 * @default 'resolve'
329 */
330 width?: string;
331
332 /**
333 * If true, resolves issue for multiselects using closeOnSelect: false that caused the list of results to scroll to the first selection after each select/unselect
334 * @default false
335 */
336 scrollAfterSelect?: boolean;
33725
26 namespace Select2 {
27 interface Options<Result = DataFormat | GroupedDataFormat, RemoteResult = any> {
338 /**28 /**
339 * Extends Select2 v4 plugin by adding an option to set a placeholder for the 'search' input field29 * Extends Select2 v4 plugin by adding an option to set a placeholder for the 'search' input field
340 * [Custom Field]30 * [Custom Field]
@@ -343,77 +33,11 @@ interface Select2Options {
343 searchInputPlaceholder?: string;33 searchInputPlaceholder?: string;
34434
345 /**35 /**
346 * Extends select2 plugin by adding a custom css class for the 'searcH' input field36 * Extends select2 plugin by adding a custom css class for the 'search' input field
347 * [Custom Field]37 * [Custom Field]
348 * @default ''38 * @default ''
349 */39 */
350 searchInputCssClass?: string;40 searchInputCssClass?: string;
351 }41 }
352
353//#endregion
354
355//#region sortable
356
357/** Options for configuring a sortable instance */
358interface SortableOptions {
359 /**
360 * When set, prevents the sortable items from being dragged unless clicked with a delay
361 * @default 0
362 */
363 delay?: number;
364
365 /**
366 * Class name for elements to handle sorting. Elements with this class can be dragged to sort.
367 * @default ''
368 */
369 handle?: string;
370
371 /**
372 * Whether to allow sorting between different connected lists
373 * @default false
374 */
375 connectWith?: string | boolean;
376
377 /**
378 * Function called when sorting starts
379 * @param event - The event object
380 * @param ui - The UI object containing the helper and position information
381 */
382 start?: (event: Event, ui: SortableUI) => void;
383
384 /**
385 * Function called when sorting stops
386 * @param event - The event object
387 * @param ui - The UI object containing the helper and position information
388 */
389 stop?: (event: Event, ui: SortableUI) => void;
390
391 /**
392 * Function called when sorting updates
393 * @param event - The event object
394 * @param ui - The UI object containing the helper and position information
395 */
396 update?: (event: Event, ui: SortableUI) => void;
397
398 /**
399 * Specifies which items inside the element should be sortable
400 * @default '> *'
401 */
402 items?: string;
403 }42 }
404
405/** UI object passed to sortable event handlers */
406interface SortableUI {
407 /** jQuery object representing the helper element */
408 helper: JQuery;
409 /** The current position of the helper element */
410 position: { top: number; left: number };
411 /** Original position of the helper element */
412 originalPosition: { top: number; left: number };
413 /** jQuery object representing the item being sorted */
414 item: JQuery;
415 /** The placeholder element used during sorting */
416 placeholder: JQuery;
417}43}
418
419//#endregion