@immich/ui 0.41.1 → 0.42.1
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.
- package/dist/actions/shortcut.d.ts +1 -0
- package/dist/actions/shortcut.js +25 -0
- package/dist/components/CommandPalette/CommandPaletteItem.svelte +28 -13
- package/dist/components/Kbd/Kbd.svelte +2 -3
- package/dist/components/Kbd/Kbd.svelte.d.ts +1 -2
- package/dist/internal/CommandPaletteModal.svelte +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ export declare const shortcutLabel: (shortcut: Shortcut) => string;
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const shouldIgnoreEvent: (event: KeyboardEvent | ClipboardEvent) => boolean;
|
|
24
24
|
export declare const matchesShortcut: (event: KeyboardEvent, shortcut: Shortcut) => boolean;
|
|
25
|
+
export declare const renderShortcut: ({ alt, meta, ctrl, shift, key }: Shortcut) => string[];
|
|
25
26
|
/** Bind a single keyboard shortcut to node. */
|
|
26
27
|
export declare const shortcut: <T extends HTMLElement>(node: T, option: ShortcutOptions<T>) => ActionReturn<ShortcutOptions<T>>;
|
|
27
28
|
/** Binds multiple keyboard shortcuts to node */
|
package/dist/actions/shortcut.js
CHANGED
|
@@ -33,6 +33,31 @@ export const matchesShortcut = (event, shortcut) => {
|
|
|
33
33
|
Boolean(shortcut.shift) === event.shiftKey &&
|
|
34
34
|
Boolean(shortcut.meta) === event.metaKey);
|
|
35
35
|
};
|
|
36
|
+
const isMacOS = globalThis.navigator && /Mac(intosh|Intel)/.test(globalThis.navigator.userAgent);
|
|
37
|
+
const displayOverrides = {
|
|
38
|
+
ArrowDown: '↓',
|
|
39
|
+
ArrowLeft: '←',
|
|
40
|
+
ArrowRight: '→',
|
|
41
|
+
ArrowUp: '↑',
|
|
42
|
+
Delete: '⌦',
|
|
43
|
+
};
|
|
44
|
+
export const renderShortcut = ({ alt, meta, ctrl, shift, key }) => {
|
|
45
|
+
const result = [];
|
|
46
|
+
if (alt) {
|
|
47
|
+
result.push(isMacOS ? '⌥' : 'Alt');
|
|
48
|
+
}
|
|
49
|
+
if (meta) {
|
|
50
|
+
result.push(isMacOS ? '⌘' : '❖');
|
|
51
|
+
}
|
|
52
|
+
if (ctrl) {
|
|
53
|
+
result.push('Ctrl');
|
|
54
|
+
}
|
|
55
|
+
if (shift) {
|
|
56
|
+
result.push('⇧');
|
|
57
|
+
}
|
|
58
|
+
result.push(displayOverrides[key] ?? key.toUpperCase());
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
36
61
|
/** Bind a single keyboard shortcut to node. */
|
|
37
62
|
export const shortcut = (node, option) => {
|
|
38
63
|
const { update: shortcutsUpdate, destroy } = shortcuts(node, [option]);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { renderShortcut } from '../../actions/shortcut.js';
|
|
2
3
|
import Button from '../Button/Button.svelte';
|
|
3
4
|
import Icon from '../Icon/Icon.svelte';
|
|
4
5
|
import IconButton from '../IconButton/IconButton.svelte';
|
|
6
|
+
import Kbd from '../Kbd/Kbd.svelte';
|
|
5
7
|
import Text from '../Text/Text.svelte';
|
|
6
8
|
import type { CommandItem } from '../../services/command-palette-manager.svelte';
|
|
7
9
|
import { mdiClose } from '@mdi/js';
|
|
@@ -20,6 +22,10 @@
|
|
|
20
22
|
onRemove?.();
|
|
21
23
|
};
|
|
22
24
|
|
|
25
|
+
const shortcuts =
|
|
26
|
+
item.shortcuts === undefined ? [] : Array.isArray(item.shortcuts) ? item.shortcuts : [item.shortcuts];
|
|
27
|
+
const renderedShortcuts = shortcuts.map((shortcut) => renderShortcut(shortcut));
|
|
28
|
+
|
|
23
29
|
let ref = $state<HTMLElement | null>(null);
|
|
24
30
|
|
|
25
31
|
$effect(() => {
|
|
@@ -53,19 +59,28 @@
|
|
|
53
59
|
{/if}
|
|
54
60
|
</div>
|
|
55
61
|
</div>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
<div class="flex flex-col items-end gap-1">
|
|
63
|
+
{#if onRemove}
|
|
64
|
+
<IconButton
|
|
65
|
+
size="small"
|
|
66
|
+
onclick={handleRemove}
|
|
67
|
+
icon={mdiClose}
|
|
68
|
+
shape="round"
|
|
69
|
+
variant="ghost"
|
|
70
|
+
color="secondary"
|
|
71
|
+
aria-label="Remove"
|
|
72
|
+
/>
|
|
73
|
+
{:else}
|
|
74
|
+
<span class="shrink-0">[{item.type}]</span>
|
|
75
|
+
{/if}
|
|
76
|
+
{#if renderedShortcuts.length > 0}
|
|
77
|
+
<div class="flex justify-end gap-1">
|
|
78
|
+
{#each renderedShortcuts[0] as key (key)}
|
|
79
|
+
<Kbd size="small">{key}</Kbd>
|
|
80
|
+
{/each}
|
|
81
|
+
</div>
|
|
82
|
+
{/if}
|
|
83
|
+
</div>
|
|
69
84
|
</div>
|
|
70
85
|
</Button>
|
|
71
86
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Size } from '../../types.js';
|
|
3
3
|
import { cleanClass } from '../../utilities/internal.js';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
type Props = {
|
|
9
9
|
size?: Size;
|
|
10
|
-
color?: Color;
|
|
11
10
|
class?: string;
|
|
12
11
|
children?: Snippet;
|
|
13
12
|
} & HTMLAttributes<HTMLElement>;
|
|
@@ -15,7 +14,7 @@
|
|
|
15
14
|
const { class: className, size = 'small', children, ...restProps }: Props = $props();
|
|
16
15
|
|
|
17
16
|
const styles = tv({
|
|
18
|
-
base: 'bg-subtle
|
|
17
|
+
base: 'bg-subtle rounded-md border border-b-2 px-1 py-0.5 font-mono shadow',
|
|
19
18
|
variants: {
|
|
20
19
|
size: {
|
|
21
20
|
tiny: 'text-xs',
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Size } from '../../types.js';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
4
|
type Props = {
|
|
5
5
|
size?: Size;
|
|
6
|
-
color?: Color;
|
|
7
6
|
class?: string;
|
|
8
7
|
children?: Snippet;
|
|
9
8
|
} & HTMLAttributes<HTMLElement>;
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
|
|
90
90
|
{#if commandPaletteManager.results.length > 0}
|
|
91
91
|
<div class="flex flex-col">
|
|
92
|
-
{#each commandPaletteManager.results as item, i (
|
|
92
|
+
{#each commandPaletteManager.results as item, i (item.id)}
|
|
93
93
|
<CommandPaletteItem
|
|
94
94
|
{item}
|
|
95
95
|
selected={commandPaletteManager.selectedIndex === i}
|