@immich/ui 0.34.0 → 0.34.2

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.
@@ -32,7 +32,7 @@
32
32
  }: Props = $props();
33
33
 
34
34
  const containerStyles = tv({
35
- base: 'w-full overflow-hidden shadow-sm',
35
+ base: 'flex w-full overflow-hidden shadow-sm',
36
36
  variants: {
37
37
  shape: {
38
38
  rectangle: '',
@@ -46,7 +46,7 @@
46
46
  });
47
47
 
48
48
  const cardStyles = tv({
49
- base: 'flex h-full w-full flex-col',
49
+ base: 'flex grow flex-col',
50
50
  variants: {
51
51
  color: {
52
52
  primary: 'bg-primary/25 dark:bg-primary/25',
@@ -25,11 +25,13 @@
25
25
  closeOnBackdropClick?: boolean;
26
26
  children: Snippet;
27
27
  onClose?: () => void;
28
+ onEscapeKeydown?: (event: KeyboardEvent) => void;
28
29
  };
29
30
 
30
31
  let {
31
32
  size = 'medium',
32
33
  onClose,
34
+ onEscapeKeydown,
33
35
  icon = true,
34
36
  title,
35
37
  class: className,
@@ -52,6 +54,20 @@
52
54
  },
53
55
  });
54
56
 
57
+ const modalContentStyles = tv({
58
+ base: 'fixed inset-0 m-auto flex max-h-dvh grow sm:p-4',
59
+ variants: {
60
+ size: {
61
+ tiny: 'sm:h-min md:max-w-sm',
62
+ small: 'sm:h-min md:max-w-md',
63
+ medium: 'sm:h-min md:max-w-(--breakpoint-sm)',
64
+ large: 'sm:h-min md:max-w-(--breakpoint-md)',
65
+ giant: 'sm:h-min md:max-w-(--breakpoint-lg)',
66
+ full: '',
67
+ },
68
+ },
69
+ });
70
+
55
71
  const { getChildren: getChildSnippet } = withChildrenSnippets(ChildKey.Modal);
56
72
  const headerChildren = $derived(getChildSnippet(ChildKey.ModalHeader));
57
73
  const bodyChildren = $derived(getChildSnippet(ChildKey.ModalBody));
@@ -67,32 +83,20 @@
67
83
 
68
84
  let cardRef = $state<HTMLElement | null>(null);
69
85
 
70
- const handleCloseOnClick = (event: Event) => {
71
- if (!closeOnBackdropClick || cardRef?.contains(event.target as Node)) {
72
- return;
73
- }
74
-
75
- onClose?.();
76
- };
86
+ const interactOutsideBehavior = $derived(closeOnBackdropClick ? 'close' : 'ignore');
87
+ const escapeKeydownBehavior = $derived(closeOnEsc ? 'close' : 'ignore');
77
88
  </script>
78
89
 
79
- <Dialog.Root open={true}>
90
+ <Dialog.Root open={true} onOpenChange={(isOpen: boolean) => !isOpen && handleClose()}>
80
91
  <Dialog.Portal>
81
- <Dialog.Overlay class="fixed start-0 top-0 flex h-dvh w-screen bg-black/30" />
92
+ <Dialog.Overlay class="fixed start-0 top-0 flex h-dvh max-h-dvh w-screen bg-black/30" />
82
93
  <Dialog.Content
83
- onkeydown={(e) => {
84
- if (e.key === 'Escape') {
85
- e.stopPropagation();
86
- e.preventDefault();
87
- if (closeOnEsc) {
88
- handleClose();
89
- }
90
- }
91
- }}
92
- onclick={handleCloseOnClick}
93
- class={cleanClass('fixed start-0 top-0 flex h-dvh w-screen items-center justify-center overflow-hidden sm:p-4')}
94
+ {onEscapeKeydown}
95
+ {escapeKeydownBehavior}
96
+ {interactOutsideBehavior}
97
+ class={cleanClass(modalContentStyles({ size }))}
94
98
  >
95
- <div class={cleanClass('flex h-full w-full flex-col items-center justify-center')}>
99
+ <div class={cleanClass('flex grow flex-col justify-center')}>
96
100
  <Card bind:ref={cardRef} class={cleanClass(modalStyles({ size }), className)}>
97
101
  <CardHeader class="border-b border-gray-200 px-5 py-3 dark:border-white/10">
98
102
  {#if headerChildren}
@@ -10,6 +10,7 @@ type Props = {
10
10
  closeOnBackdropClick?: boolean;
11
11
  children: Snippet;
12
12
  onClose?: () => void;
13
+ onEscapeKeydown?: (event: KeyboardEvent) => void;
13
14
  };
14
15
  declare const Modal: import("svelte").Component<Props, {}, "">;
15
16
  type Modal = ReturnType<typeof Modal>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immich/ui",
3
- "version": "0.34.0",
3
+ "version": "0.34.2",
4
4
  "license": "GNU Affero General Public License version 3",
5
5
  "scripts": {
6
6
  "create": "node scripts/create.js",
@@ -60,7 +60,6 @@
60
60
  "publint": "^0.3.0",
61
61
  "svelte": "^5.37.0",
62
62
  "svelte-check": "^4.0.0",
63
- "svelte-highlight": "^7.8.4",
64
63
  "tailwindcss": "^4.1.7",
65
64
  "typescript": "^5.0.0",
66
65
  "typescript-eslint": "^8.34.1",
@@ -68,6 +67,7 @@
68
67
  "vitest": "^3.0.0"
69
68
  },
70
69
  "dependencies": {
70
+ "svelte-highlight": "^7.8.4",
71
71
  "@mdi/js": "^7.4.47",
72
72
  "bits-ui": "^2.9.8",
73
73
  "luxon": "^3.7.2",
@@ -76,6 +76,6 @@
76
76
  "tailwind-variants": "^3.0.0"
77
77
  },
78
78
  "volta": {
79
- "node": "22.19.0"
79
+ "node": "22.20.0"
80
80
  }
81
81
  }