fix: update form

This commit is contained in:
2025-06-16 16:26:23 +03:00
parent d53c5606ff
commit 39d4c3c362
30 changed files with 653 additions and 125 deletions

View File

@@ -0,0 +1 @@
export { useClickOutside } from './useClickOutside';

View File

@@ -0,0 +1,28 @@
import { RefObject, useEffect } from 'react';
export function useClickOutside(
ref: RefObject<HTMLDivElement | null>,
fn: (event: Event) => void,
) {
useEffect(() => {
const handleClickOutside = (event: Event) => {
const el = ref?.current;
if (event instanceof MouseEvent && window !== undefined) {
const x = event?.offsetX || 0;
const width = window?.innerWidth - 18;
if (x >= width) {
return;
}
}
if (!el || el.contains((event?.target as Node) || null)) {
return;
}
fn(event);
};
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [ref, fn]);
}

View File

@@ -0,0 +1,15 @@
function detectIOS() {
const iosQuirkPresent = () => {
const audio = new Audio();
audio.volume = 0.5;
return audio.volume === 1; // volume cannot be changed from "1" on iOS 12 and below
};
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
const isAppleDevice = navigator.userAgent.includes('Macintosh');
const isTouchScreen = navigator.maxTouchPoints >= 1; // true for iOS 13 (and hopefully beyond)
return isIOS || (isAppleDevice && (isTouchScreen || iosQuirkPresent()));
}
export { detectIOS };

View File

@@ -0,0 +1 @@
export { detectIOS } from './detectIOS';

2
src/shared/lib/index.ts Normal file
View File

@@ -0,0 +1,2 @@
export { useClickOutside } from './clickOutside';
export { detectIOS } from './detectIOS';