@immich/ui 0.42.3 → 0.44.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/common/context.svelte.d.ts +1 -0
- package/dist/common/context.svelte.js +2 -2
- package/dist/components/ContextMenu/ContextMenu.svelte +9 -4
- package/dist/components/Label/Label.svelte +11 -5
- package/dist/internal/Button.svelte +1 -1
- 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 +8 -3
- package/dist/utilities/internal.d.ts +2 -1
- package/dist/utilities/internal.js +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,6 @@ const fieldKey = Symbol(withPrefix('field'));
|
|
|
4
4
|
export const setFieldContext = (field) => setContext(fieldKey, field);
|
|
5
5
|
export const hasFieldContext = () => hasContext(fieldKey);
|
|
6
6
|
export const getFieldContext = () => {
|
|
7
|
-
const { label, color = 'secondary', invalid = false, readOnly = false, required = false, disabled = false, description, } = getContext(fieldKey) || {};
|
|
8
|
-
return { label, description, color, invalid, readOnly, required, disabled };
|
|
7
|
+
const { label, color = 'secondary', invalid = false, readOnly = false, required = false, requiredIndicator = false, disabled = false, description, } = getContext(fieldKey) || {};
|
|
8
|
+
return { label, description, color, invalid, readOnly, required, requiredIndicator, disabled };
|
|
9
9
|
};
|
|
@@ -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
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { cleanClass } from '../../utilities/internal.js';
|
|
5
5
|
import { tv } from 'tailwind-variants';
|
|
6
6
|
|
|
7
|
-
const { label, size, color, class: className, children, ...restProps }: LabelProps = $props();
|
|
7
|
+
const { label, size, color, class: className, children, requiredIndicator, ...restProps }: LabelProps = $props();
|
|
8
8
|
|
|
9
9
|
const styles = tv({
|
|
10
10
|
base: '',
|
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
});
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
|
-
<
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
<div class="inline-block">
|
|
19
|
+
<label class={cleanClass(styles({ size, color }), className)} {...restProps}>
|
|
20
|
+
{#if label}{label}{/if}
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</label>
|
|
23
|
+
|
|
24
|
+
{#if requiredIndicator}
|
|
25
|
+
<span aria-hidden="true" class="text-danger">*</span>
|
|
26
|
+
{/if}
|
|
27
|
+
</div>
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
const disabled = $derived((restProps as HTMLButtonAttributes).disabled || loading);
|
|
37
37
|
|
|
38
38
|
const buttonVariants = tv({
|
|
39
|
-
base: 'ring-offset-background focus-visible:ring-ring flex items-center justify-center gap-1 rounded-md text-sm font-medium
|
|
39
|
+
base: 'ring-offset-background focus-visible:ring-ring flex items-center justify-center gap-1 rounded-md text-sm font-medium transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none',
|
|
40
40
|
variants: {
|
|
41
41
|
disabled: {
|
|
42
42
|
true: 'disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50',
|
|
@@ -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
|
@@ -96,6 +96,7 @@ export type LabelProps = {
|
|
|
96
96
|
class?: string;
|
|
97
97
|
size?: Size;
|
|
98
98
|
color?: TextColor;
|
|
99
|
+
requiredIndicator?: boolean;
|
|
99
100
|
children?: Snippet;
|
|
100
101
|
} & HTMLLabelAttributes;
|
|
101
102
|
export type FieldContext = {
|
|
@@ -104,6 +105,7 @@ export type FieldContext = {
|
|
|
104
105
|
invalid?: boolean;
|
|
105
106
|
disabled?: boolean;
|
|
106
107
|
required?: boolean;
|
|
108
|
+
requiredIndicator?: boolean;
|
|
107
109
|
readOnly?: boolean;
|
|
108
110
|
} & LabelProps;
|
|
109
111
|
type BaseInputProps<T> = {
|
|
@@ -213,14 +215,14 @@ export type MenuItem = {
|
|
|
213
215
|
icon: IconLike;
|
|
214
216
|
color?: Color;
|
|
215
217
|
onSelect?: MenuSelectHandler;
|
|
216
|
-
};
|
|
218
|
+
} & IfLike;
|
|
217
219
|
export declare enum MenuItemType {
|
|
218
220
|
Divider = "divider"
|
|
219
221
|
}
|
|
220
|
-
export type MenuItems = Array<MenuItem | MenuItemType>;
|
|
222
|
+
export type MenuItems = Array<MenuItem | MenuItemType | undefined>;
|
|
221
223
|
export type MenuProps = {
|
|
222
224
|
items: MenuItems;
|
|
223
|
-
bottomItems?: MenuItem[];
|
|
225
|
+
bottomItems?: (MenuItem | undefined)[];
|
|
224
226
|
size?: MenuSize;
|
|
225
227
|
} & HTMLAttributes<HTMLDivElement>;
|
|
226
228
|
export type ContextMenuPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
@@ -231,4 +233,7 @@ export type ContextMenuBaseProps = MenuProps & {
|
|
|
231
233
|
export type ContextMenuProps = ContextMenuBaseProps & {
|
|
232
234
|
onClose: () => void;
|
|
233
235
|
};
|
|
236
|
+
export type IfLike = {
|
|
237
|
+
$if?: () => boolean;
|
|
238
|
+
};
|
|
234
239
|
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;
|