@shival99/z-ui-svelte 0.1.14 → 0.1.15
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/z-gallery/ZGalleryPreview.svelte +1 -4
- package/dist/components/z-gallery/ZGalleryPreview.svelte.d.ts +0 -2
- package/dist/components/z-gallery/ZGalleryPreviewStage.svelte +1 -9
- package/dist/components/z-gallery/ZGalleryPreviewStage.svelte.d.ts +0 -2
- package/dist/components/z-tabs/z-tabs.util.js +3 -3
- package/package.json +1 -1
- package/dist/components/z-gallery/ZGalleryOfficeHtml.svelte +0 -44
- package/dist/components/z-gallery/ZGalleryOfficeHtml.svelte.d.ts +0 -10
|
@@ -23,8 +23,6 @@
|
|
|
23
23
|
zPdfViewerConfig?: ZGalleryPdfViewerConfig;
|
|
24
24
|
/** Extra origins (besides the page's own) PDFs may be loaded from. */
|
|
25
25
|
zTrustedResourceOrigins?: string[];
|
|
26
|
-
/** Renders a Word, Excel or PowerPoint file as HTML, shown in a sandboxed frame instead of the built-in renderers. */
|
|
27
|
-
zOfficeHtml?: (file: ZGalleryFile) => Promise<string>;
|
|
28
26
|
onClose?: () => void;
|
|
29
27
|
onDownload?: (file: ZGalleryFile) => void;
|
|
30
28
|
onNavigate?: (file: ZGalleryFile) => void;
|
|
@@ -38,7 +36,6 @@
|
|
|
38
36
|
zShowToolbar = true,
|
|
39
37
|
zPdfViewerConfig = {},
|
|
40
38
|
zTrustedResourceOrigins = [],
|
|
41
|
-
zOfficeHtml,
|
|
42
39
|
onClose,
|
|
43
40
|
onDownload,
|
|
44
41
|
onNavigate,
|
|
@@ -260,7 +257,7 @@
|
|
|
260
257
|
data-dismiss
|
|
261
258
|
>
|
|
262
259
|
{#key shown.id}
|
|
263
|
-
<ZGalleryPreviewStage file={shown} {rotation} bind:zoomed {zPdfViewerConfig} {zTrustedResourceOrigins}
|
|
260
|
+
<ZGalleryPreviewStage file={shown} {rotation} bind:zoomed {zPdfViewerConfig} {zTrustedResourceOrigins} />
|
|
264
261
|
{/key}
|
|
265
262
|
</div>
|
|
266
263
|
</div>
|
|
@@ -13,8 +13,6 @@ interface Props {
|
|
|
13
13
|
zPdfViewerConfig?: ZGalleryPdfViewerConfig;
|
|
14
14
|
/** Extra origins (besides the page's own) PDFs may be loaded from. */
|
|
15
15
|
zTrustedResourceOrigins?: string[];
|
|
16
|
-
/** Renders a Word, Excel or PowerPoint file as HTML, shown in a sandboxed frame instead of the built-in renderers. */
|
|
17
|
-
zOfficeHtml?: (file: ZGalleryFile) => Promise<string>;
|
|
18
16
|
onClose?: () => void;
|
|
19
17
|
onDownload?: (file: ZGalleryFile) => void;
|
|
20
18
|
onNavigate?: (file: ZGalleryFile) => void;
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import ZIcon from '../z-icon/ZIcon.svelte';
|
|
5
5
|
import type { ZIcon as ZIconName } from '../z-icon/z-icon.types';
|
|
6
6
|
import ZSkeleton from '../z-skeleton/ZSkeleton.svelte';
|
|
7
|
-
import ZGalleryOfficeHtml from './ZGalleryOfficeHtml.svelte';
|
|
8
7
|
import ZGalleryOfficePreview from './ZGalleryOfficePreview.svelte';
|
|
9
8
|
import ZGalleryPdfViewer from './ZGalleryPdfViewer.svelte';
|
|
10
9
|
import ZGalleryTextPreview from './ZGalleryTextPreview.svelte';
|
|
@@ -26,8 +25,6 @@
|
|
|
26
25
|
zoomed?: boolean;
|
|
27
26
|
zPdfViewerConfig?: ZGalleryPdfViewerConfig;
|
|
28
27
|
zTrustedResourceOrigins?: string[];
|
|
29
|
-
/** Renders an Office file as HTML (see ZGalleryOfficeHtml). Without it the built-in renderers are used. */
|
|
30
|
-
zOfficeHtml?: (file: ZGalleryFile) => Promise<string>;
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
let {
|
|
@@ -36,7 +33,6 @@
|
|
|
36
33
|
zoomed = $bindable(false),
|
|
37
34
|
zPdfViewerConfig = {},
|
|
38
35
|
zTrustedResourceOrigins = [],
|
|
39
|
-
zOfficeHtml,
|
|
40
36
|
}: Props = $props();
|
|
41
37
|
|
|
42
38
|
// The lightbox keys this component by file id, so state starts fresh for every file.
|
|
@@ -218,11 +214,7 @@
|
|
|
218
214
|
{#if loading}
|
|
219
215
|
{@render loadingState()}
|
|
220
216
|
{/if}
|
|
221
|
-
{
|
|
222
|
-
<ZGalleryOfficeHtml {file} {zOfficeHtml} onLoaded={done} onError={officeFailed} />
|
|
223
|
-
{:else}
|
|
224
|
-
<ZGalleryOfficePreview kind={officeKind} url={mediaUrl} name={file.name} onLoaded={done} onError={officeFailed} />
|
|
225
|
-
{/if}
|
|
217
|
+
<ZGalleryOfficePreview kind={officeKind} url={mediaUrl} name={file.name} onLoaded={done} onError={officeFailed} />
|
|
226
218
|
{/if}
|
|
227
219
|
</div>
|
|
228
220
|
{:else if isTextual}
|
|
@@ -5,8 +5,6 @@ interface Props {
|
|
|
5
5
|
zoomed?: boolean;
|
|
6
6
|
zPdfViewerConfig?: ZGalleryPdfViewerConfig;
|
|
7
7
|
zTrustedResourceOrigins?: string[];
|
|
8
|
-
/** Renders an Office file as HTML (see ZGalleryOfficeHtml). Without it the built-in renderers are used. */
|
|
9
|
-
zOfficeHtml?: (file: ZGalleryFile) => Promise<string>;
|
|
10
8
|
}
|
|
11
9
|
declare const ZGalleryPreviewStage: import("svelte").Component<Props, {}, "zoomed">;
|
|
12
10
|
type ZGalleryPreviewStage = ReturnType<typeof ZGalleryPreviewStage>;
|
|
@@ -42,9 +42,9 @@ export function zTabsMeasure(button) {
|
|
|
42
42
|
if (!container) {
|
|
43
43
|
return { x: button.offsetLeft, y: button.offsetTop, w: button.offsetWidth, h: button.offsetHeight };
|
|
44
44
|
}
|
|
45
|
-
// Screen rects follow transforms: a strip inside a panel that is still scaling in measured smaller, and the
|
|
46
|
-
// stayed off until a later resize. Dividing by the container's own scale (its drawn width over its layout
|
|
47
|
-
// the layout geometry back, with the fractional part kept.
|
|
45
|
+
// Screen rects follow transforms: a strip inside a panel that is still scaling in measured smaller, and the
|
|
46
|
+
// indicator stayed off until a later resize. Dividing by the container's own scale (its drawn width over its layout
|
|
47
|
+
// width) gives the layout geometry back, with the fractional part kept.
|
|
48
48
|
const buttonRect = button.getBoundingClientRect();
|
|
49
49
|
const containerRect = container.getBoundingClientRect();
|
|
50
50
|
const scaleX = container.offsetWidth ? containerRect.width / container.offsetWidth : 1;
|
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { zTranslate } from '../../i18n/translate.svelte';
|
|
3
|
-
import type { ZGalleryFile } from './z-gallery.types';
|
|
4
|
-
|
|
5
|
-
// A Word, Excel or PowerPoint file shown as the HTML the app renders for it (`zOfficeHtml`). The HTML runs in a sandboxed
|
|
6
|
-
// frame without the page's origin: its own scripts (sheet tabs, slide arrows) work, and it cannot reach the app.
|
|
7
|
-
interface Props {
|
|
8
|
-
file: ZGalleryFile;
|
|
9
|
-
zOfficeHtml: (file: ZGalleryFile) => Promise<string>;
|
|
10
|
-
onLoaded?: () => void;
|
|
11
|
-
onError?: (message: string) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let { file, zOfficeHtml, onLoaded, onError }: Props = $props();
|
|
15
|
-
|
|
16
|
-
let srcdoc = $state<string | null>(null);
|
|
17
|
-
|
|
18
|
-
$effect(() => {
|
|
19
|
-
const target = file;
|
|
20
|
-
let stale = false;
|
|
21
|
-
srcdoc = null;
|
|
22
|
-
zOfficeHtml(target)
|
|
23
|
-
.then((html) => {
|
|
24
|
-
if (stale) return;
|
|
25
|
-
srcdoc = html;
|
|
26
|
-
})
|
|
27
|
-
.catch((error: unknown) => {
|
|
28
|
-
if (!stale) onError?.(error instanceof Error ? error.message : zTranslate('i18n_z_ui_gallery_preview_load_error'));
|
|
29
|
-
});
|
|
30
|
-
return () => {
|
|
31
|
-
stale = true;
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
{#if srcdoc !== null}
|
|
37
|
-
<iframe
|
|
38
|
-
title={file.name}
|
|
39
|
-
class="bg-card size-full border-0 transition-opacity duration-300 motion-reduce:transition-none"
|
|
40
|
-
sandbox="allow-scripts"
|
|
41
|
-
srcdoc={srcdoc}
|
|
42
|
-
onload={() => onLoaded?.()}
|
|
43
|
-
></iframe>
|
|
44
|
-
{/if}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ZGalleryFile } from './z-gallery.types';
|
|
2
|
-
interface Props {
|
|
3
|
-
file: ZGalleryFile;
|
|
4
|
-
zOfficeHtml: (file: ZGalleryFile) => Promise<string>;
|
|
5
|
-
onLoaded?: () => void;
|
|
6
|
-
onError?: (message: string) => void;
|
|
7
|
-
}
|
|
8
|
-
declare const ZGalleryOfficeHtml: import("svelte").Component<Props, {}, "">;
|
|
9
|
-
type ZGalleryOfficeHtml = ReturnType<typeof ZGalleryOfficeHtml>;
|
|
10
|
-
export default ZGalleryOfficeHtml;
|