@arex95/vue-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/dist/composables/axios/axiosFetch.d.ts +10 -0
  4. package/dist/composables/axios/createFetch.d.ts +10 -0
  5. package/dist/composables/axios/index.d.ts +3 -0
  6. package/dist/composables/axios/useVueQuery.d.ts +192 -0
  7. package/dist/composables/breakpoints/index.d.ts +1 -0
  8. package/dist/composables/breakpoints/useBreakpoint.d.ts +62 -0
  9. package/dist/composables/filters/index.d.ts +1 -0
  10. package/dist/composables/filters/useFilter.d.ts +16 -0
  11. package/dist/composables/index.d.ts +5 -0
  12. package/dist/composables/paginators/index.d.ts +1 -0
  13. package/dist/composables/paginators/usePaginator.d.ts +14 -0
  14. package/dist/composables/sorters/index.d.ts +1 -0
  15. package/dist/composables/sorters/useSorter.d.ts +14 -0
  16. package/dist/config/axios/axiosConfig.d.ts +47 -0
  17. package/dist/config/axios/index.d.ts +2 -0
  18. package/dist/config/index.d.ts +1 -0
  19. package/dist/constants/breakpointEnum.d.ts +31 -0
  20. package/dist/constants/exceptionEnum.d.ts +30 -0
  21. package/dist/constants/fileTypesEnum.d.ts +25 -0
  22. package/dist/constants/httpEnum.d.ts +21 -0
  23. package/dist/constants/index.d.ts +6 -0
  24. package/dist/constants/keyCodeEnum.d.ts +10 -0
  25. package/dist/constants/storageEnum.d.ts +50 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/rest/RestStd.d.ts +70 -0
  28. package/dist/rest/index.d.ts +1 -0
  29. package/dist/types/AxiosOptionsParameter.d.ts +31 -0
  30. package/dist/types/ExtendedQueryOptions.d.ts +6 -0
  31. package/dist/types/index.d.ts +2 -0
  32. package/dist/utils/browser.d.ts +30 -0
  33. package/dist/utils/dates.d.ts +71 -0
  34. package/dist/utils/debounces.d.ts +57 -0
  35. package/dist/utils/exports.d.ts +34 -0
  36. package/dist/utils/files.d.ts +46 -0
  37. package/dist/utils/index.d.ts +9 -0
  38. package/dist/utils/io.d.ts +168 -0
  39. package/dist/utils/objects.d.ts +109 -0
  40. package/dist/utils/strings.d.ts +63 -0
  41. package/dist/utils/validations.d.ts +114 -0
  42. package/dist/vue-core.cjs.js +2118 -0
  43. package/dist/vue-core.esm.js +1993 -0
  44. package/package.json +45 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * A standard REST API interface for handling basic CRUD operations.
3
+ * This class can be instantiated with a resource endpoint and a fetch composable for API requests.
4
+ */
5
+ export default class RestStd {
6
+ static resource: string;
7
+ static fetchComposable: Function;
8
+ /**
9
+ * Fetch a list of items from the server.
10
+ *
11
+ * @param params Query parameters for filtering the results.
12
+ * @param options Additional options for the fetch composable.
13
+ * @returns The result of the fetch composable (typically a promise).
14
+ */
15
+ static getMany<T>(params?: Record<string, any>, options?: object): any;
16
+ /**
17
+ * Fetch a single item by ID from the server.
18
+ *
19
+ * @param id The ID of the item to fetch.
20
+ * @param params Additional query parameters for the request.
21
+ * @param options Additional options for the fetch composable.
22
+ * @returns The result of the fetch composable (typically a promise).
23
+ */
24
+ static getOne<T>(id: string | number, params?: Record<string, any>, options?: object): any;
25
+ /**
26
+ * Create a new item on the server.
27
+ *
28
+ * @param data The data for the new item to create.
29
+ * @param options Additional options for the fetch composable.
30
+ * @returns The result of the fetch composable (typically a promise).
31
+ */
32
+ static create<T>(data: any, options?: object): any;
33
+ /**
34
+ * Update an existing item on the server.
35
+ *
36
+ * @param id The ID of the item to update.
37
+ * @param data The updated data for the item.
38
+ * @param options Additional options for the fetch composable.
39
+ * @returns The result of the fetch composable (typically a promise).
40
+ */
41
+ static update<T>(id: string | number, data: any, options?: object): any;
42
+ /**
43
+ * Partially update an existing item on the server.
44
+ *
45
+ * @param id The ID of the item to update.
46
+ * @param data The updated data for the item.
47
+ * @param options Additional options for the fetch composable.
48
+ * @returns The result of the fetch composable (typically a promise).
49
+ */
50
+ static patch<T>(id: string | number, data: any, options?: object): any;
51
+ /**
52
+ * Delete an item from the server.
53
+ *
54
+ * @param id The ID of the item to delete.
55
+ * @param options Additional options for the fetch composable.
56
+ * @returns The result of the fetch composable (typically a promise).
57
+ */
58
+ static delete<T>(id: string | number, options?: object): any;
59
+ /**
60
+ * Custom request method for more flexibility.
61
+ *
62
+ * @param method HTTP method (GET, POST, etc.).
63
+ * @param params Query parameters.
64
+ * @param data Request body data.
65
+ * @param token Authorization token (optional).
66
+ * @param options Additional options for the fetch composable.
67
+ * @returns The result of the fetch composable (typically a promise).
68
+ */
69
+ static customRequest<T>(method: string, params?: Record<string, any>, data?: any, options?: object): any;
70
+ }
@@ -0,0 +1 @@
1
+ export * from './RestStd';
@@ -0,0 +1,31 @@
1
+ import { MaybeRef } from 'vue';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ /**
4
+ * Type for options passed to an Axios fetch request.
5
+ */
6
+ export type AxiosOptionsParameter<T = any> = {
7
+ /**
8
+ * A boolean or a reactive reference to a boolean indicating if the request is enabled by default.
9
+ */
10
+ immediate?: MaybeRef<boolean>;
11
+ /**
12
+ * A default value to be used if the request does not return data.
13
+ */
14
+ defaultValue?: T;
15
+ /**
16
+ * Axios configuration options for the request.
17
+ */
18
+ axiosOptionFetch?: AxiosRequestConfig;
19
+ /**
20
+ * Delay in milliseconds to debounce the request.
21
+ */
22
+ debounce?: number;
23
+ /**
24
+ * Maximum number of retries for the request on failure.
25
+ */
26
+ maxRetries?: number;
27
+ /**
28
+ * Delay in milliseconds between retry attempts.
29
+ */
30
+ retryDelay?: number;
31
+ };
@@ -0,0 +1,6 @@
1
+ import { UseQueryOptions } from '@tanstack/vue-query';
2
+ export type ExtendedQueryOptions = {
3
+ options?: UseQueryOptions;
4
+ server?: boolean;
5
+ queryKey?: string;
6
+ };
@@ -0,0 +1,2 @@
1
+ export * from './AxiosOptionsParameter';
2
+ export * from './ExtendedQueryOptions';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Opens a new window with the specified URL and options.
3
+ * @param {string} url The URL to open.
4
+ * @param {Object} [opt] Options for the new window.
5
+ * @param {string} [opt.target='__blank'] The target window name.
6
+ * @param {boolean} [opt.noopener=true] Whether to add 'noopener' attribute.
7
+ * @param {boolean} [opt.noreferrer=true] Whether to add 'noreferrer' attribute.
8
+ */
9
+ export declare function openWindow(url: string, opt?: {
10
+ target?: string;
11
+ noopener?: boolean;
12
+ noreferrer?: boolean;
13
+ }): void;
14
+ /**
15
+ * Copies text to the clipboard.
16
+ * @param {string} text The text to copy.
17
+ * @returns {Promise<void>} A promise that resolves when the text has been copied.
18
+ */
19
+ export declare function copyToClipboard(text: string): Promise<void>;
20
+ /**
21
+ * Scrolls the window to the top smoothly.
22
+ * @param {number} [duration=300] Duration of the scroll animation in milliseconds.
23
+ */
24
+ export declare function scrollToTop(duration?: number): void;
25
+ /**
26
+ * Gets the value of a query parameter from the URL.
27
+ * @param {string} paramName The name of the query parameter.
28
+ * @returns {string | null} The value of the query parameter, or null if it does not exist.
29
+ */
30
+ export declare function getQueryParam(paramName: string): string | null;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Parses a date string into a Date object.
3
+ * @param {string} dateString The date string in 'YYYY-MM-DD' format.
4
+ * @returns {Date | null} The parsed Date object or null if the format is invalid.
5
+ */
6
+ export declare function parseDate(dateString: string): Date | null;
7
+ /**
8
+ * Formats a Date object into a string.
9
+ * @param {Date} date The date to format.
10
+ * @param {string} format The format string (e.g., 'YYYY-MM-DD').
11
+ * @returns {string} The formatted date string.
12
+ */
13
+ export declare function formatDate(date: Date, format: string): string;
14
+ /**
15
+ * Calculates the number of days between two dates.
16
+ * @param {Date} startDate The start date.
17
+ * @param {Date} endDate The end date.
18
+ * @returns {number} The number of days between the two dates.
19
+ */
20
+ export declare function daysBetween(startDate: Date, endDate: Date): number;
21
+ /**
22
+ * Adds a specified number of days to a date.
23
+ * @param {Date} date The date to modify.
24
+ * @param {number} days The number of days to add.
25
+ * @returns {Date} The new date with days added.
26
+ */
27
+ export declare function addDays(date: Date, days: number): Date;
28
+ /**
29
+ * Subtracts a specified number of days from a date.
30
+ * @param {Date} date The date to modify.
31
+ * @param {number} days The number of days to subtract.
32
+ * @returns {Date} The new date with days subtracted.
33
+ */
34
+ export declare function subtractDays(date: Date, days: number): Date;
35
+ /**
36
+ * Determines if a year is a leap year.
37
+ * @param {number} year The year to check.
38
+ * @returns {boolean} True if the year is a leap year, false otherwise.
39
+ */
40
+ export declare function isLeapYear(year: number): boolean;
41
+ /**
42
+ * Gets the first day of the month for a given date.
43
+ * @param {Date} date The date to use.
44
+ * @returns {Date} The first day of the month.
45
+ */
46
+ export declare function getStartOfMonth(date: Date): Date;
47
+ /**
48
+ * Gets the last day of the month for a given date.
49
+ * @param {Date} date The date to use.
50
+ * @returns {Date} The last day of the month.
51
+ */
52
+ export declare function getEndOfMonth(date: Date): Date;
53
+ /**
54
+ * Calculates age from a given birth date.
55
+ * @param {Date} birthDate The birth date.
56
+ * @returns {number} The calculated age.
57
+ */
58
+ export declare function calculateAge(birthDate: Date): number;
59
+ /**
60
+ * Calculates the number of days until the next birthday.
61
+ * @param {Date} birthDate The birth date.
62
+ * @returns {number} The number of days until the next birthday.
63
+ */
64
+ export declare function daysToNextBirthday(birthDate: Date): number;
65
+ /**
66
+ * Calculates the age at a specific date.
67
+ * @param {Date} birthDate The birth date.
68
+ * @param {Date} atDate The date to calculate the age at.
69
+ * @returns {number} The calculated age.
70
+ */
71
+ export declare function ageAtDate(birthDate: Date, atDate: Date): number;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Creates a debounced asynchronous validator function.
3
+ *
4
+ * @param validator - The async validator function to debounce.
5
+ * @param delay - The debounce delay in milliseconds.
6
+ * @returns A debounced version of the validator function.
7
+ */
8
+ export declare function debounceAsyncValidator(validator: (value: any, debounce: () => Promise<void>) => Promise<void>, delay: number): (value: any) => Promise<void>;
9
+ /**
10
+ * Creates a debounced version of an asynchronous function.
11
+ * @param {Function} func The asynchronous function to debounce.
12
+ * @param {number} wait The number of milliseconds to wait before invoking the function.
13
+ * @returns {Function} The debounced function.
14
+ */
15
+ export declare function debounceAsync<T extends (...args: any[]) => Promise<any>>(func: T, wait: number): (...args: Parameters<T>) => Promise<ReturnType<T>>;
16
+ /**
17
+ * Creates a debounced asynchronous function that executes immediately on the first call.
18
+ * @param {Function} func The asynchronous function to debounce.
19
+ * @param {number} wait The number of milliseconds to wait before invoking the function.
20
+ * @returns {Function} The debounced function with immediate execution on the first call.
21
+ */
22
+ export declare function debounceAsyncWithImmediate<T extends (...args: any[]) => Promise<any>>(func: T, wait: number): (...args: Parameters<T>) => Promise<ReturnType<T>>;
23
+ /**
24
+ * Creates a debounced version of a function that executes on the leading edge.
25
+ * @param {Function} func The function to debounce.
26
+ * @param {number} wait The number of milliseconds to wait before invoking the function.
27
+ * @returns {Function} The debounced function.
28
+ */
29
+ export declare function debounceLeading<T extends (...args: any[]) => void>(func: T, wait: number): T;
30
+ /**
31
+ * Creates a debounced version of a function that executes on the trailing edge.
32
+ * @param {Function} func The function to debounce.
33
+ * @param {number} wait The number of milliseconds to wait before invoking the function.
34
+ * @returns {Function} The debounced function.
35
+ */
36
+ export declare function debounceTrailing<T extends (...args: any[]) => void>(func: T, wait: number): T;
37
+ /**
38
+ * Creates a debounced version of a function that executes on both leading and trailing edges.
39
+ * @param {Function} func The function to debounce.
40
+ * @param {number} wait The number of milliseconds to wait before invoking the function.
41
+ * @returns {Function} The debounced function.
42
+ */
43
+ export declare function debounceLeadingTrailing<T extends (...args: any[]) => void>(func: T, wait: number): T;
44
+ /**
45
+ * Creates a debounced version of a function.
46
+ * @param {Function} func The function to debounce.
47
+ * @param {number} wait The number of milliseconds to wait before invoking the function.
48
+ * @returns {Function} The debounced function.
49
+ */
50
+ export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number): T;
51
+ /**
52
+ * Creates a throttled version of a function.
53
+ * @param {Function} func The function to throttle.
54
+ * @param {number} limit The number of milliseconds to wait between function calls.
55
+ * @returns {Function} The throttled function.
56
+ */
57
+ export declare function throttle<T extends (...args: any[]) => void>(func: T, limit: number): T;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Exports data to a CSV file.
3
+ * @param {string[]} headers The headers for the CSV.
4
+ * @param {any[][]} data The data to export, as an array of arrays.
5
+ * @param {string} fileName The name of the file to create.
6
+ */
7
+ export declare function exportToCSV(headers: string[], data: any[][], fileName: string): void;
8
+ /**
9
+ * Exports data to an Excel file (.xls) using HTML table.
10
+ * @param {string[]} headers The headers for the Excel file.
11
+ * @param {any[][]} data The data to export, as an array of arrays.
12
+ * @param {string} fileName The name of the file to create.
13
+ */
14
+ export declare function exportToExcel(headers: string[], data: any[][], fileName: string): void;
15
+ /**
16
+ * Exports data to a JSON file.
17
+ * @param {any[]} data The data to export.
18
+ * @param {string} fileName The name of the file to create.
19
+ */
20
+ export declare function exportToJSON(data: any[], fileName: string): void;
21
+ /**
22
+ * Exports data to an XML file.
23
+ * @param {string[]} headers The headers for the XML.
24
+ * @param {any[][]} data The data to export, as an array of arrays.
25
+ * @param {string} fileName The name of the file to create.
26
+ */
27
+ export declare function exportToXML(headers: string[], data: any[][], fileName: string): void;
28
+ /**
29
+ * Exports data to a plain text file.
30
+ * @param {string[]} headers The headers for the text file.
31
+ * @param {any[][]} data The data to export, as an array of arrays.
32
+ * @param {string} fileName The name of the file to create.
33
+ */
34
+ export declare function exportToText(headers: string[], data: any[][], fileName: string): void;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Converts a FormData object to a plain JavaScript object.
3
+ * @param {FormData} formData The FormData object to convert.
4
+ * @returns {Record<string, any>} The plain JavaScript object.
5
+ */
6
+ export declare function formDataToObject(formData: FormData): Record<string, any>;
7
+ /**
8
+ * Reads a file as text.
9
+ * @param {File} file The file to read.
10
+ * @returns {Promise<string>} A promise that resolves with the file content.
11
+ */
12
+ export declare function readFileAsText(file: File): Promise<string>;
13
+ /**
14
+ * Reads a file as a Data URL.
15
+ * @param {File} file The file to read.
16
+ * @returns {Promise<string>} A promise that resolves with the Data URL.
17
+ */
18
+ export declare function readFileAsDataURL(file: File): Promise<string>;
19
+ /**
20
+ * Creates a Blob from a string.
21
+ * @param {string} content The string content for the Blob.
22
+ * @param {string} [type='text/plain'] The MIME type of the Blob.
23
+ * @returns {Blob} The Blob object.
24
+ */
25
+ export declare function stringToBlob(content: string, type?: string): Blob;
26
+ /**
27
+ * Creates a Blob from an ArrayBuffer.
28
+ * @param {ArrayBuffer} buffer The ArrayBuffer to convert.
29
+ * @param {string} [type='application/octet-stream'] The MIME type of the Blob.
30
+ * @returns {Blob} The Blob object.
31
+ */
32
+ export declare function bufferToBlob(buffer: ArrayBuffer, type?: string): Blob;
33
+ /**
34
+ * Creates and downloads a file from Blob data.
35
+ * @param {Blob} blob The Blob containing the file data.
36
+ * @param {string} fileName The name of the file to create.
37
+ */
38
+ export declare function downloadBlob(blob: Blob, fileName: string): void;
39
+ /**
40
+ * Creates a FormData object containing a Blob.
41
+ * @param {Blob} blob The Blob to include in the FormData.
42
+ * @param {string} name The name of the form field.
43
+ * @param {string} [fileName='file'] The file name for the Blob.
44
+ * @returns {FormData} The FormData object.
45
+ */
46
+ export declare function blobToFormData(blob: Blob, name: string, fileName?: string): FormData;
@@ -0,0 +1,9 @@
1
+ export * from './exports';
2
+ export * from './browser';
3
+ export * from './io';
4
+ export * from './dates';
5
+ export * from './debounces';
6
+ export * from './files';
7
+ export * from './objects';
8
+ export * from './strings';
9
+ export * from './validations';
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Disables the right-click context menu on the window.
3
+ */
4
+ export declare function disableRightClick(): void;
5
+ export declare namespace disableRightClick {
6
+ var handler: any;
7
+ }
8
+ /**
9
+ * Enables the right-click context menu on the window.
10
+ */
11
+ export declare function enableRightClick(): void;
12
+ /**
13
+ * Disables specific mouse buttons.
14
+ * @param {Array<number>} buttons Array of mouse button codes to disable (0 for left, 1 for middle, 2 for right).
15
+ */
16
+ export declare function disableMouseButtons(buttons: number[]): void;
17
+ export declare namespace disableMouseButtons {
18
+ var handlers: ((event: MouseEvent) => void)[];
19
+ }
20
+ /**
21
+ * Enables all previously disabled mouse buttons.
22
+ */
23
+ export declare function enableMouseButtons(): void;
24
+ /**
25
+ * Adds a double-click event listener to a specific element.
26
+ * @param {HTMLElement} element The target element.
27
+ * @param {(event: MouseEvent) => void} callback The callback function to execute on double click.
28
+ */
29
+ export declare function addDoubleClickListener(element: HTMLElement, callback: (event: MouseEvent) => void): void;
30
+ /**
31
+ * Removes a double-click event listener from a specific element.
32
+ * @param {HTMLElement} element The target element.
33
+ * @param {(event: MouseEvent) => void} callback The callback function to remove.
34
+ */
35
+ export declare function removeDoubleClickListener(element: HTMLElement, callback: (event: MouseEvent) => void): void;
36
+ /**
37
+ * Detects a click outside a specific element and triggers a callback.
38
+ * @param {HTMLElement} element The element to detect clicks outside of.
39
+ * @param {() => void} callback The callback function to execute when a click outside is detected.
40
+ */
41
+ export declare function clickOutside(element: HTMLElement, callback: () => void): void;
42
+ export declare namespace clickOutside {
43
+ var handlers: {
44
+ element: HTMLElement;
45
+ handler: (event: MouseEvent) => void;
46
+ }[];
47
+ }
48
+ /**
49
+ * Removes the click outside listener for a specific element.
50
+ * @param {HTMLElement} element The element to stop detecting clicks outside of.
51
+ */
52
+ export declare function removeClickOutside(element: HTMLElement): void;
53
+ /**
54
+ * Disables the F12 key and certain key combinations for developer tools.
55
+ */
56
+ export declare function disableF12Key(): void;
57
+ /**
58
+ * Enables or disables the tab navigation (Tab key) on the page.
59
+ * @param {boolean} enable Whether to enable or disable tab navigation.
60
+ */
61
+ export declare function toggleTabNavigation(enable: boolean): void;
62
+ /**
63
+ * Disables the copy (Ctrl + C) functionality on the page.
64
+ */
65
+ export declare function disableCopy(): void;
66
+ /**
67
+ * Adds a custom keyboard shortcut to execute a given callback function.
68
+ * @param {string} key The key to trigger the callback.
69
+ * @param {Function} callback The function to execute on the key press.
70
+ * @param {boolean} [ctrlKey=false] Whether Ctrl key should be pressed.
71
+ * @param {boolean} [shiftKey=false] Whether Shift key should be pressed.
72
+ */
73
+ export declare function addCustomKeyboardShortcut(key: string, callback: () => void, ctrlKey?: boolean, shiftKey?: boolean): void;
74
+ /**
75
+ * Removes a custom keyboard shortcut by key and modifiers.
76
+ * @param {string} key The key to trigger the callback.
77
+ * @param {boolean} [ctrlKey=false] Whether Ctrl key should be pressed.
78
+ * @param {boolean} [shiftKey=false] Whether Shift key should be pressed.
79
+ */
80
+ export declare function removeCustomKeyboardShortcut(key: string, ctrlKey?: boolean, shiftKey?: boolean): void;
81
+ /**
82
+ * Disables specific keys or key combinations.
83
+ * @param {Array<string>} keys Array of key names to disable (e.g., ['F1', 'F5', 'Control+S']).
84
+ */
85
+ export declare function disableSpecificKeys(keys: string[]): void;
86
+ export declare namespace disableSpecificKeys {
87
+ var handlers: ((event: KeyboardEvent) => void)[];
88
+ }
89
+ /**
90
+ * Enables keys that were previously disabled using disableSpecificKeys.
91
+ */
92
+ export declare function enableSpecificKeys(): void;
93
+ /**
94
+ * Registers multiple keyboard shortcuts with their respective callback functions.
95
+ * @param {Array<{ key: string, ctrlKey?: boolean, shiftKey?: boolean, altKey?: boolean, callback: Function }>} shortcuts Array of shortcut objects.
96
+ */
97
+ export declare function registerKeyboardShortcuts(shortcuts: {
98
+ key: string;
99
+ ctrlKey?: boolean;
100
+ shiftKey?: boolean;
101
+ altKey?: boolean;
102
+ callback: () => void;
103
+ }[]): void;
104
+ export declare namespace registerKeyboardShortcuts {
105
+ var handlers: ((event: KeyboardEvent) => void)[];
106
+ }
107
+ /**
108
+ * Unregisters all keyboard shortcuts that were registered with registerKeyboardShortcuts.
109
+ */
110
+ export declare function unregisterKeyboardShortcuts(): void;
111
+ /**
112
+ * Adds a listener for a specific key to trigger a custom event.
113
+ * @param {string} key The key to listen for (e.g., 'Enter', 'Escape').
114
+ * @param {Function} callback The function to execute when the key is pressed.
115
+ */
116
+ export declare function addKeyListener(key: string, callback: () => void): void;
117
+ export declare namespace addKeyListener {
118
+ var handlers: ((event: KeyboardEvent) => void)[];
119
+ }
120
+ /**
121
+ * Removes all custom key listeners added by addKeyListener.
122
+ */
123
+ export declare function removeKeyListeners(): void;
124
+ /**
125
+ * Detects if a specific key is held down.
126
+ * @param {string} key The key to detect (e.g., 'Shift', 'Control', 'Alt', 'a').
127
+ * @param {Function} onHold Callback function to execute while the key is held down.
128
+ */
129
+ export declare function detectKeyHold(key: string, onHold: () => void): void;
130
+ export declare namespace detectKeyHold {
131
+ var handlers: ((event: KeyboardEvent) => void)[];
132
+ }
133
+ /**
134
+ * Stops detecting if a specific key is held down.
135
+ */
136
+ export declare function stopDetectingKeyHold(): void;
137
+ /**
138
+ * Tracks currently pressed keys and provides a map of active keys.
139
+ * @returns {Set<string>} A set of currently pressed keys.
140
+ */
141
+ export declare function createKeyMap(): Set<string>;
142
+ export declare namespace createKeyMap {
143
+ var clearListeners: () => void;
144
+ }
145
+ /**
146
+ * Sets up custom keyboard shortcuts with flexible order.
147
+ * @param {Array<string>} keys The combination of keys for the shortcut.
148
+ * @param {Function} callback The callback function to execute when the combination is detected.
149
+ */
150
+ export declare function customShortcut(keys: string[], callback: () => void): void;
151
+ export declare namespace customShortcut {
152
+ var handlers: {
153
+ keyDownHandler: (event: KeyboardEvent) => void;
154
+ keyUpHandler: (event: KeyboardEvent) => void;
155
+ }[];
156
+ }
157
+ /**
158
+ * Removes all custom keyboard shortcuts added by customShortcut.
159
+ */
160
+ export declare function removeCustomShortcuts(): void;
161
+ /**
162
+ * Simulates a key press event.
163
+ * @param {string} key The key to simulate (e.g., 'Enter', 'a').
164
+ * @param {boolean} ctrlKey If true, include Ctrl key in the event.
165
+ * @param {boolean} shiftKey If true, include Shift key in the event.
166
+ * @param {boolean} altKey If true, include Alt key in the event.
167
+ */
168
+ export declare function simulateKeyPress(key: string, ctrlKey?: boolean, shiftKey?: boolean, altKey?: boolean): void;
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Converts a Proxy object to a plain object.
3
+ * @param {ProxyConstructor} proxy The Proxy object to convert.
4
+ * @returns {Object} The plain object.
5
+ */
6
+ export declare function proxyToPlainObject(proxy: ProxyConstructor): any;
7
+ /**
8
+ * Compares two objects to check if they have the same keys.
9
+ * @param {Object} object1 The first object to compare.
10
+ * @param {Object} object2 The second object to compare.
11
+ * @returns {boolean} True if the objects have the same keys, otherwise false.
12
+ */
13
+ export declare function compareObject(object1: Record<string, any>, object2: Record<string, any>): boolean;
14
+ /**
15
+ * Deeply compares two objects to check if they are equal.
16
+ * @param {Object} object1 The first object to compare.
17
+ * @param {Object} object2 The second object to compare.
18
+ * @returns {boolean} True if the objects are deeply equal, otherwise false.
19
+ */
20
+ export declare function deepEqual(object1: Record<string, any>, object2: Record<string, any>): boolean;
21
+ /**
22
+ * Deeply clones an object.
23
+ * @param {Object} obj The object to clone.
24
+ * @returns {Object} The cloned object.
25
+ */
26
+ export declare function deepClone<T>(obj: T): T;
27
+ /**
28
+ * Converts an object to a query string.
29
+ * @param {Object} obj The object to convert.
30
+ * @returns {string} The query string.
31
+ */
32
+ export declare function objectToQueryString(obj: Record<string, any>): string;
33
+ /**
34
+ * Gets the differences between two objects.
35
+ * @param {Object} object1 The first object.
36
+ * @param {Object} object2 The second object.
37
+ * @returns {Object} An object containing the differences.
38
+ */
39
+ export declare function getObjectDifferences(object1: Record<string, any>, object2: Record<string, any>): Record<string, any>;
40
+ /**
41
+ * Filters an object by a list of keys.
42
+ * @param {Object} obj The object to filter.
43
+ * @param {Array<string>} keys The keys to keep.
44
+ * @returns {Object} The filtered object.
45
+ */
46
+ export declare function filterObjectByKeys(obj: Record<string, any>, keys: string[]): Record<string, any>;
47
+ /**
48
+ * Deeply merges two objects.
49
+ * @param {Object} target The target object to merge into.
50
+ * @param {Object} source The source object to merge from.
51
+ * @returns {Object} The merged object.
52
+ */
53
+ export declare function deepMerge<T>(target: T, source: Partial<T>): T;
54
+ /**
55
+ * Checks if an object is empty.
56
+ * @param {Object} obj The object to check.
57
+ * @returns {boolean} True if the object is empty, otherwise false.
58
+ */
59
+ export declare function isEmptyObject(obj: Record<string, any>): boolean;
60
+ /**
61
+ * Safely accesses nested properties in an object.
62
+ * @param {Object} obj The object to access.
63
+ * @param {Array<string>} keys The array of keys representing the path.
64
+ * @returns {any} The value at the nested path, or undefined if not found.
65
+ */
66
+ export declare function safeGet(obj: Record<string, any>, keys: string[]): any;
67
+ /**
68
+ * Removes empty properties (null, undefined, or empty string) from an object.
69
+ * @param {Object} obj The object to clean.
70
+ * @returns {Object} A new object without empty properties.
71
+ */
72
+ export declare function removeEmptyProperties(obj: Record<string, any>): Record<string, any>;
73
+ /**
74
+ * Retrieves all keys of an object as an array.
75
+ * @param {Object} obj The object to retrieve keys from.
76
+ * @returns {Array<string>} The array of keys.
77
+ */
78
+ export declare function getObjectKeys(obj: Record<string, any>): string[];
79
+ /**
80
+ * Checks if an object has nested properties.
81
+ * @param {Object} obj The object to check.
82
+ * @returns {boolean} True if there are nested properties, false otherwise.
83
+ */
84
+ export declare function hasNestedProperties(obj: Record<string, any>): boolean;
85
+ /**
86
+ * Converts an object to FormData, handling nested objects.
87
+ * @param {Object} obj The object to convert.
88
+ * @param {FormData} [formData] The FormData object to append to.
89
+ * @param {string} [parentKey] The parent key for nested objects.
90
+ * @returns {FormData} The FormData object.
91
+ */
92
+ export declare function objectToFormDataEnhanced(obj: Record<string, any>, formData?: FormData, parentKey?: string): FormData;
93
+ /**
94
+ * Converts a JavaScript object into FormData.
95
+ *
96
+ * @param obj - The object to be converted.
97
+ * @param form - An optional FormData instance to use.
98
+ * @param namespace - An optional namespace to use for nested objects.
99
+ * @returns The FormData instance with the object's key-value pairs.
100
+ */
101
+ export declare const objectToFormData: (obj: any, form?: FormData, namespace?: string) => FormData;
102
+ /**
103
+ * Flattens a nested object, bringing all properties to the top level.
104
+ * @param {Object} obj The object to flatten.
105
+ * @param {string} [parentKey] The parent key for nested properties.
106
+ * @param {Object} [result] The resulting flattened object.
107
+ * @returns {Object} The flattened object.
108
+ */
109
+ export declare function flattenObject(obj: Record<string, any>, parentKey?: string, result?: Record<string, any>): Record<string, any>;