@marianmeres/stuic 2.42.1 → 2.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.
@@ -55,9 +55,14 @@
55
55
  }
56
56
 
57
57
  export interface Props {
58
- class?: string;
59
58
  assets: string[] | AssetPreview[];
60
59
  classControls?: string;
60
+ //
61
+ modalClassBackdrop?: string;
62
+ modalClassInner?: string;
63
+ modalClass?: string;
64
+ modalClassMain?: string;
65
+ //
61
66
  /** Optional translate function */
62
67
  t?: TranslateFn;
63
68
  /** Optional delete handler - receives the current asset and its index */
@@ -70,6 +75,8 @@
70
75
  ) => void;
71
76
  /** optional "do not display file name" switch flag */
72
77
  noName?: boolean;
78
+ /** When true (default), panning is clamped to keep image within bounds */
79
+ clampPan?: boolean;
73
80
  }
74
81
 
75
82
  export function getAssetIcon(ext?: string) {
@@ -167,12 +174,16 @@
167
174
  const clog = createClog("AssetsPreview", { color: "auto" });
168
175
 
169
176
  let {
170
- class: classProp = "",
177
+ modalClassBackdrop = "",
178
+ modalClassInner = "",
179
+ modalClass = "",
180
+ modalClassMain = "",
171
181
  assets: _assets,
172
182
  t = t_default,
173
183
  classControls = "",
174
184
  onDelete,
175
185
  noName,
186
+ clampPan = false,
176
187
  }: Props = $props();
177
188
 
178
189
  let assets: AssetPreviewNormalized[] = $derived(
@@ -248,7 +259,7 @@
248
259
  }
249
260
 
250
261
  // Clamp pan values to keep image within bounds
251
- function clampPan(newPanX: number, newPanY: number): { x: number; y: number } {
262
+ function getClampedPan(newPanX: number, newPanY: number): { x: number; y: number } {
252
263
  if (!imgEl || !containerEl) return { x: newPanX, y: newPanY };
253
264
 
254
265
  const imgRect = imgEl.getBoundingClientRect();
@@ -318,9 +329,14 @@
318
329
  const newPanX = startPanX + (clientX - startMouseX);
319
330
  const newPanY = startPanY + (clientY - startMouseY);
320
331
 
321
- const clamped = clampPan(newPanX, newPanY);
322
- panX = clamped.x;
323
- panY = clamped.y;
332
+ if (clampPan) {
333
+ const clamped = getClampedPan(newPanX, newPanY);
334
+ panX = clamped.x;
335
+ panY = clamped.y;
336
+ } else {
337
+ panX = newPanX;
338
+ panY = newPanY;
339
+ }
324
340
  }
325
341
 
326
342
  function panEnd() {
@@ -386,10 +402,10 @@
386
402
  <Modal
387
403
  bind:this={modal}
388
404
  onEscape={modal?.close}
389
- classBackdrop="p-4 md:p-4"
390
- classInner="max-w-full h-full"
391
- class="max-h-full md:max-h-full rounded-lg {classProp}"
392
- classMain="flex items-center justify-center relative stuic-assets-preview stuic-assets-preview-open"
405
+ classBackdrop="p-4 md:p-4 {modalClassBackdrop}"
406
+ classInner="max-w-full h-full {modalClassInner}"
407
+ class="max-h-full md:max-h-full rounded-lg {modalClass}"
408
+ classMain="flex items-center justify-center relative stuic-assets-preview stuic-assets-preview-open {modalClassMain}"
393
409
  >
394
410
  {@const previewAsset = assets?.[previewIdx]}
395
411
  {#if previewAsset}
@@ -10,9 +10,12 @@ export interface AssetPreview {
10
10
  type?: string;
11
11
  }
12
12
  export interface Props {
13
- class?: string;
14
13
  assets: string[] | AssetPreview[];
15
14
  classControls?: string;
15
+ modalClassBackdrop?: string;
16
+ modalClassInner?: string;
17
+ modalClass?: string;
18
+ modalClassMain?: string;
16
19
  /** Optional translate function */
17
20
  t?: TranslateFn;
18
21
  /** Optional delete handler - receives the current asset and its index */
@@ -21,6 +24,8 @@ export interface Props {
21
24
  }) => void;
22
25
  /** optional "do not display file name" switch flag */
23
26
  noName?: boolean;
27
+ /** When true (default), panning is clamped to keep image within bounds */
28
+ clampPan?: boolean;
24
29
  }
25
30
  export declare function getAssetIcon(ext?: string): CallableFunction;
26
31
  declare const AssetsPreview: import("svelte").Component<Props, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "2.42.1",
3
+ "version": "2.44.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",