* chore: `npm audit fix --force` * feat: Update sidebar toggle to use Logo * refactor: Clean up favicon SVG * feat: Refactor logo component and implement theme-aware favicon generation * feat: Add configurable padding to generated PWA assets * test: Add unit tests for writeThemeFavicons * refactor: Componentization * feat: WIP * feat: WIP * feat: WIP * feat: Mobile UI * feat: add SEARCH route constant * feat: create SidebarNavigationSearchResults component * refactor: use SidebarNavigationSearchResults in conversation list * feat: enable mobile search navigation in sidebar actions * feat: add mobile search route and page * fix: prevent sidebar overflow on mobile viewports * fix: Mobile sidebar * feat: Mobile Search WIP * feat: Mobile WIP * feat: Add PWA standalone detection and refine mobile UI * feat: Improve mobile layout, sidebar handling, and chat scrolling * feat: Improve mobile sidebar visibility and iOS Safari chat spacing * fix: Disable auto-scroll on mobile * chore: Linting * fix: Wrong condition * feat: Mobile chat scroll * refactor: WIP * fix: Desktop initial scroll always working again * fix: Partial fix for mobile auto-scroll / initial scroll * fix: Desktop auto-scroll on initial load and during streaming * fix: Mobile scrolling logic * refactor: Clean up * feat: Improve start UI * feat: Add `delay` to `fadeInView` * feat: Auto-scroll button * refactor: Cleanup * refactor: Extract chat dialogs and alerts into dedicated component * refactor: Reorganize ChatScreen component structure and initialization * feat: Improve auto-scroll after sending message * feat: UI improvements * fix: Settings link * feat: UI improvements * fix: better UI spacing * fix: Remove unneeded logic * fix: Chat Processing Info UI rendering * feat: Improve mobile UI * feat: UI improvement * fix: Conditional transition delay for Chat Messages based on route from * fix: Delay mobile sidebar collapse for smoother transitions * fix: Mobile scroll down button + sidebar pointer events * fix: Mobile UI * fix: Auto scrolling * fix: Implement dynamic height calculations for chat auto-scroll positioning and UI elements * fix: Retrieve `autofocus` for Chat Form textarea * fix: Use proper class Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * refactor: extract scroll-to-bottom logic and fix message send flow * fix: update viewport store usage and remove conflicting autofocus * feat: add accessibility labels to scroll down button * fix: correct HTML structure in sidebar empty states * fix: dynamically toggle processing info visibility * chore: remove commented exports and fix formatting * fix * fix: Mobile Chat Form Add Action Sheet interactions --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
73 lines
1.6 KiB
TypeScript
73 lines
1.6 KiB
TypeScript
/**
|
|
* Drag-and-drop state machine for the ChatScreen.
|
|
*
|
|
* Tracks pointer enter/leave nesting so the overlay stays visible while the
|
|
* cursor traverses child elements, then routes the dropped files either to
|
|
* the active message-edit handler (if a message is being edited) or to the
|
|
* caller's onDrop callback.
|
|
*/
|
|
|
|
import { getAddFilesHandler, isEditing } from '$lib/stores/chat.svelte';
|
|
|
|
interface UseChatScreenDragAndDropOptions {
|
|
/** Called when the user drops files and no message is being edited. */
|
|
onDrop: (files: File[]) => void;
|
|
}
|
|
|
|
export function useChatScreenDragAndDrop(options: UseChatScreenDragAndDropOptions) {
|
|
let dragCounter = $state(0);
|
|
let isDragOver = $state(false);
|
|
|
|
function handleDragEnter(event: DragEvent) {
|
|
event.preventDefault();
|
|
dragCounter++;
|
|
if (event.dataTransfer?.types.includes('Files')) {
|
|
isDragOver = true;
|
|
}
|
|
}
|
|
|
|
function handleDragLeave(event: DragEvent) {
|
|
event.preventDefault();
|
|
dragCounter--;
|
|
if (dragCounter === 0) {
|
|
isDragOver = false;
|
|
}
|
|
}
|
|
|
|
function handleDragOver(event: DragEvent) {
|
|
event.preventDefault();
|
|
}
|
|
|
|
async function handleDrop(event: DragEvent) {
|
|
event.preventDefault();
|
|
isDragOver = false;
|
|
dragCounter = 0;
|
|
|
|
if (!event.dataTransfer?.files) return;
|
|
|
|
const files = Array.from(event.dataTransfer.files);
|
|
|
|
if (isEditing()) {
|
|
const handler = getAddFilesHandler();
|
|
if (handler) {
|
|
handler(files);
|
|
return;
|
|
}
|
|
}
|
|
|
|
options.onDrop(files);
|
|
}
|
|
|
|
return {
|
|
get isDragOver() {
|
|
return isDragOver;
|
|
},
|
|
dragHandlers: {
|
|
dragenter: handleDragEnter,
|
|
dragleave: handleDragLeave,
|
|
dragover: handleDragOver,
|
|
drop: handleDrop
|
|
}
|
|
};
|
|
}
|