@immich/ui 0.41.0 → 0.42.0
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.
|
@@ -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,32 @@
|
|
|
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">
|
|
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
|
+
<div class="flex items-center gap-2">
|
|
77
|
+
{#if renderedShortcuts.length > 0}
|
|
78
|
+
<div class="mt-2 flex w-3/4 flex-wrap justify-end gap-1">
|
|
79
|
+
{#each renderedShortcuts[0] as key (key)}
|
|
80
|
+
<Kbd>
|
|
81
|
+
{key}
|
|
82
|
+
</Kbd>
|
|
83
|
+
{/each}
|
|
84
|
+
</div>
|
|
85
|
+
{/if}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
69
88
|
</div>
|
|
70
89
|
</Button>
|
|
71
90
|
</div>
|
package/dist/index.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ export { default as ToastContainer } from './components/Toast/ToastContainer.sve
|
|
|
68
68
|
export { default as ToastContent } from './components/Toast/ToastContent.svelte';
|
|
69
69
|
export { default as ToastPanel } from './components/Toast/ToastPanel.svelte';
|
|
70
70
|
export * from './services/command-palette-manager.svelte.js';
|
|
71
|
+
export * from './services/menu-manager.svelte.js';
|
|
71
72
|
export * from './services/modal-manager.svelte.js';
|
|
72
73
|
export * from './services/theme.svelte.js';
|
|
73
74
|
export * from './services/toast-manager.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ export { default as ToastContent } from './components/Toast/ToastContent.svelte'
|
|
|
71
71
|
export { default as ToastPanel } from './components/Toast/ToastPanel.svelte';
|
|
72
72
|
// helpers
|
|
73
73
|
export * from './services/command-palette-manager.svelte.js';
|
|
74
|
+
export * from './services/menu-manager.svelte.js';
|
|
74
75
|
export * from './services/modal-manager.svelte.js';
|
|
75
76
|
export * from './services/theme.svelte.js';
|
|
76
77
|
export * from './services/toast-manager.svelte.js';
|