@immich/ui 0.49.1 → 0.49.3
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/components/CommandPalette/CommandPaletteContext.svelte +6 -7
- package/dist/components/CommandPalette/CommandPaletteContext.svelte.d.ts +2 -3
- package/dist/components/CommandPalette/CommandPaletteItem.svelte +2 -2
- package/dist/components/CommandPalette/CommandPaletteItem.svelte.d.ts +2 -2
- package/dist/components/Toast/ToastPanel.svelte +15 -6
- package/dist/components/Toast/ToastPanel.svelte.d.ts +2 -5
- package/dist/services/command-palette-manager.svelte.d.ts +14 -31
- package/dist/services/command-palette-manager.svelte.js +11 -27
- package/dist/services/toast-manager.svelte.d.ts +3 -2
- package/dist/services/toast-manager.svelte.js +11 -8
- package/dist/site/constants.d.ts +2 -2
- package/dist/site/constants.js +3 -2
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { commandPaletteManager
|
|
2
|
+
import { commandPaletteManager } from '../../services/command-palette-manager.svelte';
|
|
3
|
+
import type { ActionItem } from '../../types.js';
|
|
3
4
|
import { untrack } from 'svelte';
|
|
4
5
|
|
|
5
6
|
type Props = {
|
|
6
|
-
commands?:
|
|
7
|
-
global?: boolean;
|
|
7
|
+
commands?: ActionItem[];
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const { commands = []
|
|
10
|
+
const { commands = [] }: Props = $props();
|
|
11
11
|
|
|
12
12
|
$effect(() => {
|
|
13
13
|
// prevent reactivity loop
|
|
14
|
-
const addCommands = (commands:
|
|
15
|
-
untrack(() => commandPaletteManager.addCommands(commands, { global }));
|
|
14
|
+
const addCommands = (commands: ActionItem[]) => untrack(() => commandPaletteManager.addCommands(commands));
|
|
16
15
|
|
|
17
|
-
return addCommands(commands
|
|
16
|
+
return addCommands(commands);
|
|
18
17
|
});
|
|
19
18
|
</script>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ActionItem } from '../../types.js';
|
|
2
2
|
type Props = {
|
|
3
|
-
commands?:
|
|
4
|
-
global?: boolean;
|
|
3
|
+
commands?: ActionItem[];
|
|
5
4
|
};
|
|
6
5
|
declare const CommandPaletteContext: import("svelte").Component<Props, {}, "">;
|
|
7
6
|
type CommandPaletteContext = ReturnType<typeof CommandPaletteContext>;
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
import IconButton from '../IconButton/IconButton.svelte';
|
|
7
7
|
import Kbd from '../Kbd/Kbd.svelte';
|
|
8
8
|
import Text from '../Text/Text.svelte';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ActionItem } from '../../types.js';
|
|
10
10
|
import { cleanClass } from '../../utilities/internal.js';
|
|
11
11
|
import { mdiClose } from '@mdi/js';
|
|
12
12
|
|
|
13
13
|
type Props = {
|
|
14
|
-
item:
|
|
14
|
+
item: ActionItem;
|
|
15
15
|
selected: boolean;
|
|
16
16
|
onSelect: () => void;
|
|
17
17
|
onRemove?: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ActionItem } from '../../types.js';
|
|
2
2
|
type Props = {
|
|
3
|
-
item:
|
|
3
|
+
item: ActionItem;
|
|
4
4
|
selected: boolean;
|
|
5
5
|
onSelect: () => void;
|
|
6
6
|
onRemove?: () => void;
|
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
import Toast from './Toast.svelte';
|
|
3
3
|
import { zIndex } from '../../constants.js';
|
|
4
4
|
import { isCustomToast } from '../../services/toast-manager.svelte.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ToastPanelProps } from '../../types.js';
|
|
6
|
+
import { cleanClass } from '../../utilities/internal.js';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
items: Array<ToastItem & ToastId>;
|
|
9
|
-
};
|
|
9
|
+
const { items, class: className, ...props }: ToastPanelProps = $props();
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const isEmpty = $derived(items.length === 0);
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
|
-
<div
|
|
14
|
+
<div
|
|
15
|
+
class={twMerge(
|
|
16
|
+
cleanClass(
|
|
17
|
+
isEmpty ? 'hidden' : 'absolute top-0 right-0 flex flex-col items-end justify-end gap-2 p-4',
|
|
18
|
+
zIndex.ToastPanel,
|
|
19
|
+
className,
|
|
20
|
+
),
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
15
24
|
{#each items as item (item.id)}
|
|
16
25
|
{#if isCustomToast(item)}
|
|
17
26
|
<item.component {...item.props} />
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
items: Array<ToastItem & ToastId>;
|
|
4
|
-
};
|
|
5
|
-
declare const ToastPanel: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ToastPanelProps } from '../../types.js';
|
|
2
|
+
declare const ToastPanel: import("svelte").Component<ToastPanelProps, {}, "">;
|
|
6
3
|
type ToastPanel = ReturnType<typeof ToastPanel>;
|
|
7
4
|
export default ToastPanel;
|
|
@@ -1,36 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { IfLike, MaybeArray, TranslationProps } from '../types.js';
|
|
3
|
-
export type CommandItem = {
|
|
4
|
-
icon: string;
|
|
5
|
-
iconClass?: string;
|
|
6
|
-
type: string;
|
|
7
|
-
title: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
text?: string;
|
|
10
|
-
shortcuts?: MaybeArray<Shortcut>;
|
|
11
|
-
shortcutOptions?: {
|
|
12
|
-
ignoreInputFields?: boolean;
|
|
13
|
-
preventDefault?: boolean;
|
|
14
|
-
};
|
|
15
|
-
id?: string;
|
|
16
|
-
} & IfLike & ({
|
|
17
|
-
href: string;
|
|
18
|
-
} | {
|
|
19
|
-
action: (command: CommandItemResponse) => void;
|
|
20
|
-
});
|
|
21
|
-
export type CommandItemResponse = CommandItem & {
|
|
22
|
-
id: string;
|
|
23
|
-
isGlobal: boolean;
|
|
24
|
-
};
|
|
1
|
+
import type { ActionItem, MaybeArray, TranslationProps } from '../types.js';
|
|
25
2
|
export type CommandPaletteTranslations = TranslationProps<'search_placeholder' | 'search_no_results' | 'search_recently_used' | 'command_palette_prompt_default' | 'command_palette_to_select' | 'command_palette_to_close' | 'command_palette_to_navigate' | 'command_palette_to_show_all' | 'global'>;
|
|
26
3
|
export declare const asText: (...items: unknown[]) => string;
|
|
27
4
|
declare class CommandPaletteManager {
|
|
28
5
|
#private;
|
|
29
6
|
selectedIndex: number;
|
|
30
|
-
items:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
items: (ActionItem & {
|
|
8
|
+
id: string;
|
|
9
|
+
})[];
|
|
10
|
+
filteredItems: (ActionItem & {
|
|
11
|
+
id: string;
|
|
12
|
+
})[];
|
|
13
|
+
recentItems: (ActionItem & {
|
|
14
|
+
id: string;
|
|
15
|
+
})[];
|
|
16
|
+
results: (ActionItem & {
|
|
17
|
+
id: string;
|
|
18
|
+
})[];
|
|
34
19
|
get isEnabled(): boolean;
|
|
35
20
|
enable(): void;
|
|
36
21
|
get query(): string;
|
|
@@ -47,9 +32,7 @@ declare class CommandPaletteManager {
|
|
|
47
32
|
up(): void;
|
|
48
33
|
down(): void;
|
|
49
34
|
reset(): void;
|
|
50
|
-
addCommands(itemOrItems: MaybeArray<
|
|
51
|
-
global: boolean;
|
|
52
|
-
}): () => void;
|
|
35
|
+
addCommands(itemOrItems: MaybeArray<ActionItem>): () => void;
|
|
53
36
|
removeCommands(itemOrItems: MaybeArray<{
|
|
54
37
|
id: string;
|
|
55
38
|
}>): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { goto } from '$app/navigation';
|
|
2
1
|
import { matchesShortcut, shortcuts, shouldIgnoreEvent } from '../actions/shortcut.js';
|
|
3
2
|
import CommandPaletteModal from '../internal/CommandPaletteModal.svelte';
|
|
4
3
|
import { generateId, isEnabled } from '../utilities/internal.js';
|
|
@@ -10,11 +9,11 @@ export const asText = (...items) => {
|
|
|
10
9
|
.join('|')
|
|
11
10
|
.toLowerCase();
|
|
12
11
|
};
|
|
13
|
-
const isMatch = ({ title, description, type,
|
|
12
|
+
const isMatch = ({ title, description, type, searchText = asText(title, description, type) }, query) => {
|
|
14
13
|
if (!query) {
|
|
15
14
|
return true;
|
|
16
15
|
}
|
|
17
|
-
return
|
|
16
|
+
return searchText.includes(query);
|
|
18
17
|
};
|
|
19
18
|
class CommandPaletteManager {
|
|
20
19
|
#query = $state('');
|
|
@@ -84,18 +83,7 @@ class CommandPaletteManager {
|
|
|
84
83
|
if (preventDefault) {
|
|
85
84
|
event.preventDefault();
|
|
86
85
|
}
|
|
87
|
-
await
|
|
88
|
-
}
|
|
89
|
-
async #executeCommand(command) {
|
|
90
|
-
if ('href' in command) {
|
|
91
|
-
if (!command.href.startsWith('/')) {
|
|
92
|
-
window.open(command.href, '_blank');
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
await goto(command.href);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
command.action(command);
|
|
86
|
+
await command.onAction(command);
|
|
99
87
|
}
|
|
100
88
|
setTranslations(translations = {}) {
|
|
101
89
|
this.#translations = translations;
|
|
@@ -143,8 +131,7 @@ class CommandPaletteManager {
|
|
|
143
131
|
if (!selected) {
|
|
144
132
|
return;
|
|
145
133
|
}
|
|
146
|
-
|
|
147
|
-
if (globalItem) {
|
|
134
|
+
if (selected.isGlobal) {
|
|
148
135
|
this.#globalLayer.recentItems = this.#globalLayer.recentItems.filter(({ id }) => id !== selected.id);
|
|
149
136
|
this.#globalLayer.recentItems.unshift(selected);
|
|
150
137
|
}
|
|
@@ -152,7 +139,7 @@ class CommandPaletteManager {
|
|
|
152
139
|
this.#layers.at(-1).recentItems = this.#layers.at(-1).recentItems.filter(({ id }) => id !== selected.id);
|
|
153
140
|
this.#layers.at(-1)?.recentItems.unshift(selected);
|
|
154
141
|
}
|
|
155
|
-
await
|
|
142
|
+
await selected.onAction(selected);
|
|
156
143
|
await this.close();
|
|
157
144
|
}
|
|
158
145
|
remove(index) {
|
|
@@ -178,19 +165,16 @@ class CommandPaletteManager {
|
|
|
178
165
|
this.#globalLayer = { items: [], recentItems: [] };
|
|
179
166
|
this.#query = '';
|
|
180
167
|
}
|
|
181
|
-
addCommands(itemOrItems
|
|
168
|
+
addCommands(itemOrItems) {
|
|
182
169
|
const items = Array.isArray(itemOrItems) ? itemOrItems : [itemOrItems];
|
|
183
170
|
const itemsWithId = items.map((item) => ({
|
|
184
171
|
...item,
|
|
185
|
-
id:
|
|
186
|
-
isGlobal: options.global,
|
|
172
|
+
id: generateId(),
|
|
187
173
|
}));
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
this.#layers.at(-1).items.push(...itemsWithId);
|
|
193
|
-
}
|
|
174
|
+
const globalItems = itemsWithId.filter(({ isGlobal }) => isGlobal);
|
|
175
|
+
const localItems = itemsWithId.filter(({ isGlobal }) => !isGlobal);
|
|
176
|
+
this.#globalLayer.items.push(...globalItems);
|
|
177
|
+
this.#layers.at(-1).items.push(...localItems);
|
|
194
178
|
return () => this.removeCommands(itemsWithId);
|
|
195
179
|
}
|
|
196
180
|
#removeCommands(layer, ids) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import type { ToastCustom, ToastItem, ToastOptions, ToastShow } from '../types.js';
|
|
1
|
+
import type { ToastCustom, ToastItem, ToastOptions, ToastPanelProps, ToastShow } from '../types.js';
|
|
2
2
|
export declare const isCustomToast: (item: ToastItem) => item is ToastCustom;
|
|
3
3
|
declare class ToastManager {
|
|
4
4
|
#private;
|
|
5
5
|
show(item: ToastShow, options?: ToastOptions): void;
|
|
6
6
|
custom(item: ToastCustom, options?: ToastOptions): void;
|
|
7
|
+
setOptions(options: Omit<ToastPanelProps, 'items'>): void;
|
|
7
8
|
open(item: ToastItem, options?: ToastOptions): void;
|
|
9
|
+
mount(): Promise<void>;
|
|
8
10
|
unmount(): Promise<void>;
|
|
9
11
|
success(item?: string | ToastShow, options?: ToastOptions): void;
|
|
10
12
|
info(item?: string | ToastShow, options?: ToastOptions): void;
|
|
11
13
|
warning(item?: string | ToastShow, options?: ToastOptions): void;
|
|
12
14
|
danger(item?: string | ToastShow, options?: ToastOptions): void;
|
|
13
|
-
mount(): Promise<void>;
|
|
14
15
|
private remove;
|
|
15
16
|
}
|
|
16
17
|
export declare const toastManager: ToastManager;
|
|
@@ -13,6 +13,9 @@ class ToastManager {
|
|
|
13
13
|
custom(item, options) {
|
|
14
14
|
return this.open(item, options);
|
|
15
15
|
}
|
|
16
|
+
setOptions(options) {
|
|
17
|
+
Object.assign(this.#props, options);
|
|
18
|
+
}
|
|
16
19
|
open(item, options) {
|
|
17
20
|
const { timeout = 3000, closable = true, id = generateId() } = options || {};
|
|
18
21
|
const toast = item;
|
|
@@ -32,6 +35,14 @@ class ToastManager {
|
|
|
32
35
|
setTimeout(() => this.remove(toast), timeout);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
38
|
+
async mount() {
|
|
39
|
+
if (!this.#ref) {
|
|
40
|
+
this.#ref = await mount(ToastPanel, {
|
|
41
|
+
target: document.body,
|
|
42
|
+
props: this.#props,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
35
46
|
async unmount() {
|
|
36
47
|
if (this.#ref) {
|
|
37
48
|
await unmount(this.#ref);
|
|
@@ -49,14 +60,6 @@ class ToastManager {
|
|
|
49
60
|
danger(item, options) {
|
|
50
61
|
this.show({ title: t('toast_danger_title'), color: 'danger', ...expand(item) }, options);
|
|
51
62
|
}
|
|
52
|
-
async mount() {
|
|
53
|
-
if (!this.#ref) {
|
|
54
|
-
this.#ref = await mount(ToastPanel, {
|
|
55
|
-
target: document.body,
|
|
56
|
-
props: this.#props,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
63
|
remove(target) {
|
|
61
64
|
this.#props.items = this.#props.items.filter((item) => item.id !== target.id);
|
|
62
65
|
}
|
package/dist/site/constants.d.ts
CHANGED
package/dist/site/constants.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { goto } from '$app/navigation';
|
|
1
2
|
import { asText } from '../services/command-palette-manager.svelte.js';
|
|
2
3
|
import { mdiOpenInNew } from '@mdi/js';
|
|
3
4
|
export const Constants = {
|
|
@@ -132,6 +133,6 @@ export const siteCommands = [
|
|
|
132
133
|
iconClass: 'text-indigo-700 dark:text-indigo-200',
|
|
133
134
|
title: site.title,
|
|
134
135
|
description: site.description,
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
onAction: () => goto(site.href),
|
|
137
|
+
searchText: asText('Site', 'Link', site.title, site.description, site.href),
|
|
137
138
|
}));
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Translations } from './services/translation.svelte.js';
|
|
|
2
2
|
import type { DateTime } from 'luxon';
|
|
3
3
|
import type { Component, Snippet } from 'svelte';
|
|
4
4
|
import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes, HTMLInputAttributes, HTMLLabelAttributes, HTMLTextareaAttributes } from 'svelte/elements';
|
|
5
|
+
import type { Shortcut } from './actions/shortcut.js';
|
|
5
6
|
export type Color = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
|
|
6
7
|
export type TextColor = Color | 'muted';
|
|
7
8
|
export type TextVariant = 'italic';
|
|
@@ -180,6 +181,9 @@ export type ToastContainerProps = ToastCommonProps & {
|
|
|
180
181
|
shape?: Shape;
|
|
181
182
|
size?: ContainerSize;
|
|
182
183
|
} & Omit<HTMLAttributes<HTMLElement>, 'title' | 'color' | 'size'>;
|
|
184
|
+
export type ToastPanelProps = {
|
|
185
|
+
items: Array<ToastItem & ToastId>;
|
|
186
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
183
187
|
export type ToastProps = ToastContentProps & ToastContainerProps;
|
|
184
188
|
type Closable = {
|
|
185
189
|
onClose: () => void;
|
|
@@ -242,10 +246,20 @@ export type IfLike = {
|
|
|
242
246
|
export type ActionItemHandler<T = never> = (item: ActionItem<T>) => void | Promise<void>;
|
|
243
247
|
export type ActionItem<T = never> = Omit<{
|
|
244
248
|
title: string;
|
|
249
|
+
description?: string;
|
|
250
|
+
type?: string;
|
|
251
|
+
searchText?: string;
|
|
245
252
|
icon: IconLike;
|
|
253
|
+
iconClass?: string;
|
|
246
254
|
color?: Color;
|
|
247
255
|
onAction: ActionItemHandler<T>;
|
|
248
256
|
data: T;
|
|
257
|
+
shortcuts?: MaybeArray<Shortcut>;
|
|
258
|
+
shortcutOptions?: {
|
|
259
|
+
ignoreInputFields?: boolean;
|
|
260
|
+
preventDefault?: boolean;
|
|
261
|
+
};
|
|
262
|
+
isGlobal?: boolean;
|
|
249
263
|
} & IfLike, [
|
|
250
264
|
T
|
|
251
265
|
] extends [never] ? 'data' : ''>;
|