mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-30 20:06:30 +01:00
# Description of Changes - added tooltips to ocr and compress - added the tooltip component which can be used either directly, or through the toolstep component --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
/**
|
|
* DOM utility functions for common operations
|
|
*/
|
|
|
|
/**
|
|
* Clamps a value between a minimum and maximum
|
|
* @param value - The value to clamp
|
|
* @param min - The minimum allowed value
|
|
* @param max - The maximum allowed value
|
|
* @returns The clamped value
|
|
*/
|
|
export function clamp(value: number, min: number, max: number): number {
|
|
return Math.min(Math.max(value, min), max);
|
|
}
|
|
|
|
/**
|
|
* Safely adds an event listener with proper cleanup
|
|
* @param target - The target element or window/document
|
|
* @param event - The event type
|
|
* @param handler - The event handler function
|
|
* @param options - Event listener options
|
|
* @returns A cleanup function to remove the listener
|
|
*/
|
|
export function addEventListenerWithCleanup(
|
|
target: EventTarget,
|
|
event: string,
|
|
handler: EventListener,
|
|
options?: boolean | AddEventListenerOptions
|
|
): () => void {
|
|
target.addEventListener(event, handler, options);
|
|
return () => target.removeEventListener(event, handler, options);
|
|
}
|
|
|
|
/**
|
|
* Checks if a click event occurred outside of a specified element
|
|
* @param event - The click event
|
|
* @param element - The element to check against
|
|
* @returns True if the click was outside the element
|
|
*/
|
|
export function isClickOutside(event: MouseEvent, element: HTMLElement | null): boolean {
|
|
return element ? !element.contains(event.target as Node) : true;
|
|
}
|