From 832d728940be054a79047407da4a1abbdb9a0733 Mon Sep 17 00:00:00 2001 From: martin <74269598+martabal@users.noreply.github.com> Date: Thu, 23 May 2024 19:56:48 +0200 Subject: [PATCH] refactor(web): svelte actions (#9701) --- web/src/lib/{utils => actions}/autogrow.ts | 0 web/src/lib/{utils => actions}/click-outside.ts | 2 +- web/src/lib/{utils => actions}/focus-outside.ts | 0 web/src/lib/actions/focus.ts | 3 +++ web/src/lib/{utils => actions}/list-navigation.ts | 2 +- web/src/lib/{utils => actions}/shortcut.ts | 0 web/src/lib/components/album-page/album-description.svelte | 4 ++-- web/src/lib/components/album-page/album-title.svelte | 2 +- web/src/lib/components/album-page/album-viewer.svelte | 2 +- web/src/lib/components/asset-viewer/activity-viewer.svelte | 6 +++--- .../lib/components/asset-viewer/asset-viewer-nav-bar.svelte | 2 +- web/src/lib/components/asset-viewer/asset-viewer.svelte | 2 +- web/src/lib/components/asset-viewer/detail-panel.svelte | 6 +++--- web/src/lib/components/asset-viewer/photo-viewer.svelte | 2 +- web/src/lib/components/assets/thumbnail/thumbnail.svelte | 2 +- web/src/lib/components/elements/dropdown.svelte | 2 +- web/src/lib/components/faces-page/people-search.svelte | 5 +---- web/src/lib/components/memory-page/memory-viewer.svelte | 2 +- web/src/lib/components/photos-page/asset-grid.svelte | 2 +- .../components/photos-page/asset-select-context-menu.svelte | 2 +- .../shared-components/album-selection-modal.svelte | 2 ++ .../lib/components/shared-components/change-location.svelte | 4 ++-- web/src/lib/components/shared-components/combobox.svelte | 6 +++--- .../shared-components/context-menu/context-menu.svelte | 2 +- web/src/lib/components/shared-components/focus-trap.svelte | 2 +- .../components/shared-components/full-screen-modal.svelte | 2 +- .../shared-components/navigation-bar/navigation-bar.svelte | 2 +- .../shared-components/search-bar/search-bar.svelte | 6 +++--- .../[[photos=photos]]/[[assetId=id]]/+page.svelte | 2 +- web/src/routes/(user)/people/+page.svelte | 2 +- .../[[photos=photos]]/[[assetId=id]]/+page.svelte | 4 ++-- .../search/[[photos=photos]]/[[assetId=id]]/+page.svelte | 2 +- 32 files changed, 43 insertions(+), 41 deletions(-) rename web/src/lib/{utils => actions}/autogrow.ts (100%) rename web/src/lib/{utils => actions}/click-outside.ts (95%) rename web/src/lib/{utils => actions}/focus-outside.ts (100%) create mode 100644 web/src/lib/actions/focus.ts rename web/src/lib/{utils => actions}/list-navigation.ts (95%) rename web/src/lib/{utils => actions}/shortcut.ts (100%) diff --git a/web/src/lib/utils/autogrow.ts b/web/src/lib/actions/autogrow.ts similarity index 100% rename from web/src/lib/utils/autogrow.ts rename to web/src/lib/actions/autogrow.ts diff --git a/web/src/lib/utils/click-outside.ts b/web/src/lib/actions/click-outside.ts similarity index 95% rename from web/src/lib/utils/click-outside.ts rename to web/src/lib/actions/click-outside.ts index e04bc11fdf..ddb648a4f2 100644 --- a/web/src/lib/utils/click-outside.ts +++ b/web/src/lib/actions/click-outside.ts @@ -1,5 +1,5 @@ +import { matchesShortcut } from '$lib/actions/shortcut'; import type { ActionReturn } from 'svelte/action'; -import { matchesShortcut } from './shortcut'; interface Attributes { /** @deprecated */ diff --git a/web/src/lib/utils/focus-outside.ts b/web/src/lib/actions/focus-outside.ts similarity index 100% rename from web/src/lib/utils/focus-outside.ts rename to web/src/lib/actions/focus-outside.ts diff --git a/web/src/lib/actions/focus.ts b/web/src/lib/actions/focus.ts new file mode 100644 index 0000000000..81185625f7 --- /dev/null +++ b/web/src/lib/actions/focus.ts @@ -0,0 +1,3 @@ +export const initInput = (element: HTMLInputElement) => { + element.focus(); +}; diff --git a/web/src/lib/utils/list-navigation.ts b/web/src/lib/actions/list-navigation.ts similarity index 95% rename from web/src/lib/utils/list-navigation.ts rename to web/src/lib/actions/list-navigation.ts index dff958d757..b981f67521 100644 --- a/web/src/lib/utils/list-navigation.ts +++ b/web/src/lib/actions/list-navigation.ts @@ -1,5 +1,5 @@ +import { shortcuts } from '$lib/actions/shortcut'; import type { Action } from 'svelte/action'; -import { shortcuts } from './shortcut'; export const listNavigation: Action = (node, container: HTMLElement) => { const moveFocus = (direction: 'up' | 'down') => { diff --git a/web/src/lib/utils/shortcut.ts b/web/src/lib/actions/shortcut.ts similarity index 100% rename from web/src/lib/utils/shortcut.ts rename to web/src/lib/actions/shortcut.ts diff --git a/web/src/lib/components/album-page/album-description.svelte b/web/src/lib/components/album-page/album-description.svelte index 28e726593d..1d7add6883 100644 --- a/web/src/lib/components/album-page/album-description.svelte +++ b/web/src/lib/components/album-page/album-description.svelte @@ -1,8 +1,8 @@