@dbx-tools/ui-mastra 0.9.188 → 0.9.190

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/index.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  // Hand edits are overwritten on the next watch; this file is read-only.
4
4
 
5
5
  export const PACKAGE_IDENTIFIER = "@dbx-tools/ui-mastra";
6
- export const PACKAGE_VERSION = "0.9.188";
6
+ export const PACKAGE_VERSION = "0.9.190";
package/package.json CHANGED
@@ -32,12 +32,12 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@databricks/appkit-ui": "0.81.0",
35
- "@dbx-tools/shared-auth": "^0.9.188",
36
- "@dbx-tools/shared-core": "^0.9.188",
37
- "@dbx-tools/shared-genie": "^0.9.188",
38
- "@dbx-tools/shared-mastra": "^0.9.188",
39
- "@dbx-tools/shared-model": "^0.9.188",
40
- "@dbx-tools/ui": "^0.9.188",
35
+ "@dbx-tools/shared-auth": "0.9.190",
36
+ "@dbx-tools/shared-core": "0.9.190",
37
+ "@dbx-tools/shared-genie": "0.9.190",
38
+ "@dbx-tools/shared-mastra": "0.9.190",
39
+ "@dbx-tools/shared-model": "0.9.190",
40
+ "@dbx-tools/ui": "0.9.190",
41
41
  "@mastra/client-js": "1.50.0",
42
42
  "@mastra/core": "1.71.0",
43
43
  "@tanstack/react-table": "^8.21.3",
@@ -55,7 +55,7 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "version": "0.9.188",
58
+ "version": "0.9.190",
59
59
  "types": "index.ts",
60
60
  "dbxToolsConfig": {
61
61
  "tags": [
@@ -1,10 +1,26 @@
1
- import { Spinner, Tabs, TabsContent, TabsList, TabsTrigger } from "@databricks/appkit-ui/react";
1
+ import {
2
+ Dialog,
3
+ DialogContent,
4
+ DialogTitle,
5
+ DialogTrigger,
6
+ Spinner,
7
+ Tabs,
8
+ TabsContent,
9
+ TabsList,
10
+ TabsTrigger,
11
+ } from "@databricks/appkit-ui/react";
2
12
  import type { GenieVisualizationEmbed, StatementData } from "@dbx-tools/shared-mastra";
3
13
  import { useEffect, useState } from "react";
4
14
  import { DataGrid } from "./data-grid.tsx";
5
15
  import { useMastraClient, useVisualizationFetch } from "../support/mastra-client.ts";
6
16
 
7
17
  const GENIE_IMAGE_LOADING_HEIGHT_PX = 320;
18
+ const GENIE_IMAGE_MAX_SCALE = 2;
19
+
20
+ interface ImageDimensions {
21
+ height: number;
22
+ width: number;
23
+ }
8
24
 
9
25
  const GenieImageLoading = () => (
10
26
  <div
@@ -16,7 +32,7 @@ const GenieImageLoading = () => (
16
32
  </div>
17
33
  );
18
34
 
19
- /** Chart/Table presentation for Genie's original, unmodified PNG. */
35
+ /** Chart/Table presentation for Genie's server-processed PNG. */
20
36
  export function GenieImageTabs({
21
37
  src,
22
38
  data,
@@ -27,8 +43,10 @@ export function GenieImageTabs({
27
43
  tableLoading?: boolean;
28
44
  }) {
29
45
  const [imageState, setImageState] = useState<"loading" | "loaded" | "error">("loading");
46
+ const [imageDimensions, setImageDimensions] = useState<ImageDimensions>();
30
47
  useEffect(() => {
31
48
  setImageState("loading");
49
+ setImageDimensions(undefined);
32
50
  }, [src]);
33
51
  return (
34
52
  <Tabs defaultValue="chart" className="not-prose my-3 min-w-0 max-w-full">
@@ -44,14 +62,46 @@ export function GenieImageTabs({
44
62
  ) : (
45
63
  <>
46
64
  {imageState === "loading" ? <GenieImageLoading /> : null}
47
- <img
48
- src={src}
49
- alt="Genie query visualization"
50
- className="block h-auto max-w-full rounded border border-border"
51
- style={imageState === "loaded" ? undefined : { display: "none" }}
52
- onLoad={() => setImageState("loaded")}
53
- onError={() => setImageState("error")}
54
- />
65
+ <Dialog>
66
+ <DialogTrigger asChild>
67
+ <button
68
+ type="button"
69
+ aria-label="Open Genie visualization"
70
+ className="block max-w-full cursor-zoom-in appearance-none rounded border border-border bg-transparent p-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
71
+ style={imageState === "loaded" ? undefined : { display: "none" }}
72
+ >
73
+ <img
74
+ src={src}
75
+ alt="Genie query visualization"
76
+ className="block h-auto max-w-full rounded"
77
+ onLoad={(event) => {
78
+ setImageDimensions({
79
+ height: event.currentTarget.naturalHeight,
80
+ width: event.currentTarget.naturalWidth,
81
+ });
82
+ setImageState("loaded");
83
+ }}
84
+ onError={() => setImageState("error")}
85
+ />
86
+ </button>
87
+ </DialogTrigger>
88
+ <DialogContent className="max-h-[calc(100dvh-1rem)] w-fit max-w-[calc(100dvw-1rem)] gap-0 overflow-hidden p-2 sm:max-w-[calc(100dvw-1rem)]">
89
+ <DialogTitle className="sr-only">Genie query visualization</DialogTitle>
90
+ <img
91
+ src={src}
92
+ alt="Genie query visualization"
93
+ className="block h-auto max-h-[calc(100dvh-2rem)] max-w-[calc(100dvw-2rem)] object-contain"
94
+ style={
95
+ imageDimensions
96
+ ? {
97
+ aspectRatio: `${imageDimensions.width} / ${imageDimensions.height}`,
98
+ width: imageDimensions.width * GENIE_IMAGE_MAX_SCALE,
99
+ }
100
+ : undefined
101
+ }
102
+ />
103
+ </DialogContent>
104
+ </Dialog>
55
105
  </>
56
106
  )}
57
107
  </TabsContent>