@immich/ui 0.42.3 → 0.43.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.
- package/dist/components/ContextMenu/ContextMenu.svelte +9 -4
- package/dist/services/command-palette-manager.svelte.d.ts +2 -2
- package/dist/services/command-palette-manager.svelte.js +3 -3
- package/dist/types.d.ts +6 -3
- package/dist/utilities/internal.d.ts +2 -1
- package/dist/utilities/internal.js +1 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { zIndex } from '../../constants.js';
|
|
5
5
|
import { styleVariants } from '../../styles.js';
|
|
6
6
|
import { MenuItemType, type ContextMenuProps, type MenuItem } from '../../types.js';
|
|
7
|
-
import { cleanClass } from '../../utilities/internal.js';
|
|
7
|
+
import { cleanClass, isEnabled } from '../../utilities/internal.js';
|
|
8
8
|
import { DropdownMenu } from 'bits-ui';
|
|
9
9
|
import { fly } from 'svelte/transition';
|
|
10
10
|
import { tv } from 'tailwind-variants';
|
|
@@ -83,6 +83,11 @@
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
const filteredItems = $derived(
|
|
87
|
+
items.filter((item) => item !== undefined).filter((item) => isDivider(item) || isEnabled(item)),
|
|
88
|
+
);
|
|
89
|
+
const filteredBottomItems = $derived(bottomItems?.filter((item) => item !== undefined).filter(isEnabled));
|
|
90
|
+
|
|
86
91
|
const alignOffset = $derived(target.clientWidth / 2);
|
|
87
92
|
const sideOffset = $derived(-target.clientHeight / 2);
|
|
88
93
|
const { side, align } = $derived(getAlignment(position));
|
|
@@ -95,7 +100,7 @@
|
|
|
95
100
|
{#if open}
|
|
96
101
|
<div {...wrapperProps} class={zIndex.ContextMenu}>
|
|
97
102
|
<div {...props} {...restProps} class={cleanClass(wrapperStyles({ size }), className)} transition:fly>
|
|
98
|
-
{#each
|
|
103
|
+
{#each filteredItems as item, i (isDivider(item) ? i : item.title)}
|
|
99
104
|
{#if isDivider(item)}
|
|
100
105
|
<DropdownMenu.Separator class="my-0.5 border-t" />
|
|
101
106
|
{:else}
|
|
@@ -113,10 +118,10 @@
|
|
|
113
118
|
{/if}
|
|
114
119
|
{/each}
|
|
115
120
|
|
|
116
|
-
{#if
|
|
121
|
+
{#if filteredBottomItems}
|
|
117
122
|
<DropdownMenu.Separator class="my-0.5 border-t" />
|
|
118
123
|
<div class="flex gap-1 px-1">
|
|
119
|
-
{#each
|
|
124
|
+
{#each filteredBottomItems as item (item.title)}
|
|
120
125
|
<DropdownMenu.Item
|
|
121
126
|
textValue={item.title}
|
|
122
127
|
closeOnSelect
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Shortcut } from '../actions/shortcut.js';
|
|
2
|
-
import type { MaybeArray, TranslationProps } from '../types.js';
|
|
2
|
+
import type { IfLike, MaybeArray, TranslationProps } from '../types.js';
|
|
3
3
|
export type CommandItem = {
|
|
4
4
|
icon: string;
|
|
5
5
|
iconClass?: string;
|
|
@@ -12,7 +12,7 @@ export type CommandItem = {
|
|
|
12
12
|
ignoreInputFields?: boolean;
|
|
13
13
|
preventDefault?: boolean;
|
|
14
14
|
};
|
|
15
|
-
} & ({
|
|
15
|
+
} & IfLike & ({
|
|
16
16
|
href: string;
|
|
17
17
|
} | {
|
|
18
18
|
action: (command: CommandItem) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { goto } from '$app/navigation';
|
|
2
2
|
import { matchesShortcut, shortcuts, shouldIgnoreEvent } from '../actions/shortcut.js';
|
|
3
3
|
import CommandPaletteModal from '../internal/CommandPaletteModal.svelte';
|
|
4
|
-
import { generateId } from '../utilities/internal.js';
|
|
4
|
+
import { generateId, isEnabled } from '../utilities/internal.js';
|
|
5
5
|
import { modalManager } from './modal-manager.svelte.js';
|
|
6
6
|
export const asText = (...items) => {
|
|
7
7
|
return items
|
|
@@ -26,9 +26,9 @@ class CommandPaletteManager {
|
|
|
26
26
|
#isOpen = false;
|
|
27
27
|
#globalLayer = $state({ items: [], recentItems: [] });
|
|
28
28
|
#layers = $state([{ items: [], recentItems: [] }]);
|
|
29
|
-
items = $derived([...this.#globalLayer.items, ...this.#layers.at(-1).items]);
|
|
29
|
+
items = $derived([...this.#globalLayer.items, ...this.#layers.at(-1).items].filter(isEnabled));
|
|
30
30
|
filteredItems = $derived(this.items.filter((item) => isMatch(item, this.#normalizedQuery)).slice(0, 100));
|
|
31
|
-
recentItems = $derived([...this.#globalLayer.recentItems, ...this.#layers.at(-1).recentItems]);
|
|
31
|
+
recentItems = $derived([...this.#globalLayer.recentItems, ...this.#layers.at(-1).recentItems].filter(isEnabled));
|
|
32
32
|
results = $derived(this.query ? this.filteredItems : this.recentItems);
|
|
33
33
|
get isEnabled() {
|
|
34
34
|
return this.#isEnabled;
|
package/dist/types.d.ts
CHANGED
|
@@ -213,14 +213,14 @@ export type MenuItem = {
|
|
|
213
213
|
icon: IconLike;
|
|
214
214
|
color?: Color;
|
|
215
215
|
onSelect?: MenuSelectHandler;
|
|
216
|
-
};
|
|
216
|
+
} & IfLike;
|
|
217
217
|
export declare enum MenuItemType {
|
|
218
218
|
Divider = "divider"
|
|
219
219
|
}
|
|
220
|
-
export type MenuItems = Array<MenuItem | MenuItemType>;
|
|
220
|
+
export type MenuItems = Array<MenuItem | MenuItemType | undefined>;
|
|
221
221
|
export type MenuProps = {
|
|
222
222
|
items: MenuItems;
|
|
223
|
-
bottomItems?: MenuItem[];
|
|
223
|
+
bottomItems?: (MenuItem | undefined)[];
|
|
224
224
|
size?: MenuSize;
|
|
225
225
|
} & HTMLAttributes<HTMLDivElement>;
|
|
226
226
|
export type ContextMenuPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
@@ -231,4 +231,7 @@ export type ContextMenuBaseProps = MenuProps & {
|
|
|
231
231
|
export type ContextMenuProps = ContextMenuBaseProps & {
|
|
232
232
|
onClose: () => void;
|
|
233
233
|
};
|
|
234
|
+
export type IfLike = {
|
|
235
|
+
$if?: () => boolean;
|
|
236
|
+
};
|
|
234
237
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Color, IconLike, TextColor } from '../types.js';
|
|
1
|
+
import type { Color, IconLike, IfLike, TextColor } from '../types.js';
|
|
2
2
|
export declare const cleanClass: (...classNames: unknown[]) => string;
|
|
3
3
|
export declare const withPrefix: (key: string) => string;
|
|
4
4
|
export declare const generateId: () => string;
|
|
@@ -9,3 +9,4 @@ export declare const resolveIcon: ({ icons, color, override, fallback, }: {
|
|
|
9
9
|
override?: IconLike | false;
|
|
10
10
|
icons: Partial<Record<Color | TextColor, string>>;
|
|
11
11
|
}) => IconLike | undefined;
|
|
12
|
+
export declare const isEnabled: ({ $if }: IfLike) => boolean;
|