@malloy-publisher/sdk 0.0.30 → 0.0.32
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/RenderedResult-B9Gth8IY.cjs +1 -0
- package/dist/RenderedResult-Drg_uJPZ.js +30 -0
- package/dist/client/api.d.ts +6 -0
- package/dist/components/Home/Home.d.ts +1 -1
- package/dist/components/Model/NamedQueries.d.ts +7 -0
- package/dist/components/Package/Connections.d.ts +1 -1
- package/dist/components/Package/FileTreeView.d.ts +2 -1
- package/dist/components/Package/Models.d.ts +1 -1
- package/dist/components/Package/Notebooks.d.ts +1 -1
- package/dist/components/Package/Package.d.ts +1 -1
- package/dist/components/Project/Packages.d.ts +1 -1
- package/dist/components/Project/Project.d.ts +1 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -0
- package/dist/components/click_helper.d.ts +8 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/styles.d.ts +2 -2
- package/dist/index.cjs.js +463 -463
- package/dist/index.es.js +12221 -12111
- package/dist/vendor-BH1c2Hhy.cjs +443 -0
- package/dist/{vendor-C36FjD0v.js → vendor-DfRellEl.js} +27439 -24442
- package/package.json +8 -8
- package/src/components/Home/Home.tsx +4 -2
- package/src/components/Model/Model.tsx +35 -30
- package/src/components/Model/NamedQueries.tsx +156 -0
- package/src/components/Model/SourcesExplorer.tsx +14 -14
- package/src/components/MutableNotebook/MutableCell.tsx +3 -1
- package/src/components/MutableNotebook/MutableNotebook.tsx +5 -5
- package/src/components/Notebook/Notebook.tsx +24 -20
- package/src/components/Notebook/NotebookCell.tsx +33 -41
- package/src/components/Package/Connections.tsx +1 -1
- package/src/components/Package/FileTreeView.tsx +6 -6
- package/src/components/Package/Models.tsx +1 -1
- package/src/components/Package/Notebooks.tsx +1 -1
- package/src/components/Package/Package.tsx +2 -1
- package/src/components/Project/Packages.tsx +4 -8
- package/src/components/Project/Project.tsx +1 -1
- package/src/components/RenderedResult/RenderedResult.tsx +42 -2
- package/src/components/RenderedResult/ResultContainer.tsx +161 -0
- package/src/components/click_helper.ts +37 -0
- package/src/components/index.ts +1 -0
- package/src/components/styles.ts +2 -2
- package/vite.config.ts +0 -1
- package/dist/RenderedResult-C1_N6KvU.js +0 -12
- package/dist/RenderedResult-Df-v_vru.cjs +0 -1
- package/dist/vendor-DSpmIox9.cjs +0 -360
|
@@ -15,7 +15,7 @@ interface PackageProps {
|
|
|
15
15
|
projectName: string;
|
|
16
16
|
packageName: string;
|
|
17
17
|
versionId?: string;
|
|
18
|
-
navigate?: (to: string) => void;
|
|
18
|
+
navigate?: (to: string, event?: React.MouseEvent) => void;
|
|
19
19
|
accessToken?: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -106,6 +106,7 @@ export default function Package({
|
|
|
106
106
|
<Notebook
|
|
107
107
|
notebookPath={README_NOTEBOOK}
|
|
108
108
|
expandCodeCells={true}
|
|
109
|
+
hideEmbeddingIcons={true}
|
|
109
110
|
/>
|
|
110
111
|
</Grid>
|
|
111
112
|
</Grid>
|
|
@@ -9,7 +9,7 @@ const queryClient = new QueryClient();
|
|
|
9
9
|
interface ProjectProps {
|
|
10
10
|
server?: string;
|
|
11
11
|
projectName: string;
|
|
12
|
-
navigate
|
|
12
|
+
navigate: (to: string, event?: React.MouseEvent) => void;
|
|
13
13
|
accessToken?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -34,12 +34,6 @@ export default function Project({
|
|
|
34
34
|
queryClient,
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
if (!navigate) {
|
|
38
|
-
navigate = (to: string) => {
|
|
39
|
-
window.location.href = to;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
37
|
return (
|
|
44
38
|
<>
|
|
45
39
|
{!isSuccess && !isError && (
|
|
@@ -74,7 +68,9 @@ export default function Project({
|
|
|
74
68
|
<StyledCard
|
|
75
69
|
variant="outlined"
|
|
76
70
|
sx={{ padding: "10px", cursor: "pointer" }}
|
|
77
|
-
onClick={() =>
|
|
71
|
+
onClick={(event) =>
|
|
72
|
+
navigate(p.name + "/", event)
|
|
73
|
+
}
|
|
78
74
|
>
|
|
79
75
|
<StyledCardContent>
|
|
80
76
|
<Typography
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import type { MalloyRenderProps } from "@malloydata/render";
|
|
3
3
|
import "@malloydata/render/webcomponent";
|
|
4
|
-
import React, { useEffect, useRef } from "react";
|
|
4
|
+
import React, { useEffect, useRef, useCallback } from "react";
|
|
5
5
|
|
|
6
6
|
type MalloyRenderElement = HTMLElement & MalloyRenderProps;
|
|
7
7
|
|
|
@@ -19,14 +19,54 @@ declare global {
|
|
|
19
19
|
|
|
20
20
|
interface RenderedResultProps {
|
|
21
21
|
result: string;
|
|
22
|
+
onSizeChange?: (height: number) => void;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export default function RenderedResult({
|
|
25
|
+
export default function RenderedResult({
|
|
26
|
+
result,
|
|
27
|
+
onSizeChange,
|
|
28
|
+
}: RenderedResultProps) {
|
|
25
29
|
const ref = useRef<MalloyRenderElement>(null);
|
|
30
|
+
|
|
26
31
|
useEffect(() => {
|
|
27
32
|
if (ref.current) {
|
|
28
33
|
ref.current.malloyResult = JSON.parse(result);
|
|
29
34
|
}
|
|
30
35
|
}, [result]);
|
|
36
|
+
|
|
37
|
+
// Set up size measurement using scrollHeight instead of ResizeObserver
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!ref.current || !onSizeChange) return;
|
|
40
|
+
|
|
41
|
+
const element = ref.current;
|
|
42
|
+
|
|
43
|
+
// Function to measure and report size
|
|
44
|
+
const measureSize = () => {
|
|
45
|
+
if (element) {
|
|
46
|
+
const height = element.offsetHeight;
|
|
47
|
+
if (height > 0) {
|
|
48
|
+
onSizeChange(height);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Initial measurement after a brief delay to let content render
|
|
54
|
+
const timeoutId = setTimeout(measureSize, 100);
|
|
55
|
+
|
|
56
|
+
// Also measure when the malloy result changes
|
|
57
|
+
const observer = new MutationObserver(measureSize);
|
|
58
|
+
observer.observe(element, {
|
|
59
|
+
childList: true,
|
|
60
|
+
subtree: true,
|
|
61
|
+
attributes: true,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Cleanup
|
|
65
|
+
return () => {
|
|
66
|
+
clearTimeout(timeoutId);
|
|
67
|
+
observer.disconnect();
|
|
68
|
+
};
|
|
69
|
+
}, [onSizeChange, result]);
|
|
70
|
+
|
|
31
71
|
return <malloy-render ref={ref} />;
|
|
32
72
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
lazy,
|
|
3
|
+
Suspense,
|
|
4
|
+
useState,
|
|
5
|
+
useRef,
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { Box, IconButton } from "@mui/material";
|
|
10
|
+
import { ExpandMore, ExpandLess } from "@mui/icons-material";
|
|
11
|
+
|
|
12
|
+
const RenderedResult = lazy(() => import("../RenderedResult/RenderedResult"));
|
|
13
|
+
|
|
14
|
+
interface ResultContainerProps {
|
|
15
|
+
result: string | undefined;
|
|
16
|
+
minHeight: number;
|
|
17
|
+
maxHeight: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function ResultContainer({
|
|
21
|
+
result,
|
|
22
|
+
minHeight,
|
|
23
|
+
maxHeight,
|
|
24
|
+
}: ResultContainerProps) {
|
|
25
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
26
|
+
const [contentHeight, setContentHeight] = useState<number>(0);
|
|
27
|
+
const [shouldShowToggle, setShouldShowToggle] = useState(false);
|
|
28
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
29
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
30
|
+
const [explicitHeight, setExplicitHeight] = useState<number>(undefined);
|
|
31
|
+
|
|
32
|
+
const handleToggle = useCallback(() => {
|
|
33
|
+
const wasExpanded = isExpanded;
|
|
34
|
+
setIsExpanded(!isExpanded);
|
|
35
|
+
|
|
36
|
+
// If we're collapsing (going from expanded to collapsed), scroll to top
|
|
37
|
+
if (wasExpanded && containerRef.current) {
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
containerRef.current?.scrollIntoView({
|
|
40
|
+
behavior: "smooth",
|
|
41
|
+
block: "start",
|
|
42
|
+
});
|
|
43
|
+
}, 100); // Small delay to allow the collapse animation to start
|
|
44
|
+
}
|
|
45
|
+
}, [isExpanded]);
|
|
46
|
+
|
|
47
|
+
// Handle size changes from RenderedResult
|
|
48
|
+
const handleSizeChange = useCallback((height: number) => {
|
|
49
|
+
console.log("Content height received:", height);
|
|
50
|
+
setContentHeight(height);
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
// Determine if toggle should be shown based on content height vs container height
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
// Only proceed if we have a measured content height
|
|
56
|
+
if (contentHeight === 0) {
|
|
57
|
+
setShouldShowToggle(false);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// The available height should be the minHeight minus the padding
|
|
62
|
+
// We don't subtract toggle button height here since we're deciding whether to show it
|
|
63
|
+
const availableHeight = minHeight - 20; // Estimate padding
|
|
64
|
+
const exceedsHeight = contentHeight > availableHeight;
|
|
65
|
+
if (contentHeight < availableHeight) {
|
|
66
|
+
setExplicitHeight(contentHeight + 20);
|
|
67
|
+
}
|
|
68
|
+
setShouldShowToggle(exceedsHeight);
|
|
69
|
+
}, [contentHeight, minHeight]);
|
|
70
|
+
|
|
71
|
+
if (!result) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const height = explicitHeight
|
|
76
|
+
? {
|
|
77
|
+
minHeight: `${explicitHeight}px`,
|
|
78
|
+
height: `${explicitHeight}px`,
|
|
79
|
+
}
|
|
80
|
+
: {};
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
<Box
|
|
84
|
+
ref={containerRef}
|
|
85
|
+
sx={{
|
|
86
|
+
position: "relative",
|
|
87
|
+
minHeight: `${minHeight}px`,
|
|
88
|
+
maxHeight: `${isExpanded ? maxHeight : minHeight}px`,
|
|
89
|
+
border: "0px",
|
|
90
|
+
borderRadius: 0,
|
|
91
|
+
overflow: "hidden",
|
|
92
|
+
display: "flex",
|
|
93
|
+
flexDirection: "column",
|
|
94
|
+
...height,
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
{/* Content area */}
|
|
98
|
+
<Box
|
|
99
|
+
ref={contentRef}
|
|
100
|
+
sx={{
|
|
101
|
+
flex: 1,
|
|
102
|
+
overflow: isExpanded ? "auto" : "hidden",
|
|
103
|
+
p: 1,
|
|
104
|
+
// Adjust bottom padding when toggle is shown to prevent content overlap
|
|
105
|
+
pb: shouldShowToggle ? "40px" : 1,
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{(result && (
|
|
109
|
+
<Suspense fallback={<div>Loading result...</div>}>
|
|
110
|
+
<RenderedResult
|
|
111
|
+
result={result}
|
|
112
|
+
onSizeChange={handleSizeChange}
|
|
113
|
+
/>
|
|
114
|
+
</Suspense>
|
|
115
|
+
)) || <div> Loading...</div>}
|
|
116
|
+
</Box>
|
|
117
|
+
|
|
118
|
+
{/* Toggle button - only show if content exceeds container height */}
|
|
119
|
+
{shouldShowToggle && (
|
|
120
|
+
<Box
|
|
121
|
+
sx={{
|
|
122
|
+
position: "absolute",
|
|
123
|
+
bottom: 0,
|
|
124
|
+
left: 0,
|
|
125
|
+
right: 0,
|
|
126
|
+
height: "32px",
|
|
127
|
+
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
128
|
+
borderTop: "1px solid #e0e0e0",
|
|
129
|
+
display: "flex",
|
|
130
|
+
alignItems: "center",
|
|
131
|
+
justifyContent: "center",
|
|
132
|
+
backdropFilter: "blur(2px)",
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<IconButton
|
|
136
|
+
size="small"
|
|
137
|
+
onClick={handleToggle}
|
|
138
|
+
sx={{
|
|
139
|
+
color: "text.secondary",
|
|
140
|
+
"&:hover": {
|
|
141
|
+
backgroundColor: "rgba(0, 0, 0, 0.04)",
|
|
142
|
+
},
|
|
143
|
+
}}
|
|
144
|
+
title={
|
|
145
|
+
isExpanded
|
|
146
|
+
? "Collapse to original size"
|
|
147
|
+
: "Expand to full size"
|
|
148
|
+
}
|
|
149
|
+
>
|
|
150
|
+
{isExpanded ? (
|
|
151
|
+
<ExpandLess sx={{ fontSize: 20 }} />
|
|
152
|
+
) : (
|
|
153
|
+
<ExpandMore sx={{ fontSize: 20 }} />
|
|
154
|
+
)}
|
|
155
|
+
</IconButton>
|
|
156
|
+
</Box>
|
|
157
|
+
)}
|
|
158
|
+
</Box>
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useNavigate } from "react-router-dom";
|
|
2
|
+
import { MouseEvent } from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Custom hook that returns a function for handling clicks with proper modifier key support.
|
|
6
|
+
* The returned function handles CMD/Ctrl clicks to open in new tabs, regular clicks for navigation.
|
|
7
|
+
*
|
|
8
|
+
* @returns A function that takes a relative URL and either navigates or opens in new tab
|
|
9
|
+
*/
|
|
10
|
+
export function useRouterClickHandler() {
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
|
|
13
|
+
return (to: string, event?: MouseEvent) => {
|
|
14
|
+
// If no event or no modifier keys, use normal navigation
|
|
15
|
+
if (
|
|
16
|
+
!event ||
|
|
17
|
+
(!event.metaKey &&
|
|
18
|
+
!event.ctrlKey &&
|
|
19
|
+
!event.shiftKey &&
|
|
20
|
+
event.button !== 1)
|
|
21
|
+
) {
|
|
22
|
+
navigate(to);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// For modifier keys or middle mouse, let browser handle it by opening URL
|
|
27
|
+
const href = new URL(to, window.location.href).href;
|
|
28
|
+
|
|
29
|
+
if (event.metaKey || event.ctrlKey || event.button === 1) {
|
|
30
|
+
// CMD/Ctrl click or middle mouse - open in new tab
|
|
31
|
+
window.open(href, "_blank");
|
|
32
|
+
} else if (event.shiftKey) {
|
|
33
|
+
// Shift click - open in new window
|
|
34
|
+
window.open(href, "_blank");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
package/src/components/index.ts
CHANGED
package/src/components/styles.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const StyledCard = styled(Card)({
|
|
|
9
9
|
export const StyledCardContent = styled(CardContent)({
|
|
10
10
|
display: "flex",
|
|
11
11
|
flexDirection: "column",
|
|
12
|
-
padding: "0px
|
|
12
|
+
padding: "0px 4px 4px 4px",
|
|
13
13
|
flexGrow: 1,
|
|
14
14
|
"&:last-child": {
|
|
15
15
|
paddingBottom: 0,
|
|
@@ -17,7 +17,7 @@ export const StyledCardContent = styled(CardContent)({
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
export const StyledCardMedia = styled(CardMedia)({
|
|
20
|
-
padding: "0px
|
|
20
|
+
padding: "0px 4px 0px 4px",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
export const StyledExplorerPage = styled("div")({
|
package/vite.config.ts
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { j as t } from "./vendor-C36FjD0v.js";
|
|
2
|
-
import "./index.es.js";
|
|
3
|
-
import { useRef as o, useEffect as n } from "react";
|
|
4
|
-
function l({ result: r }) {
|
|
5
|
-
const e = o(null);
|
|
6
|
-
return n(() => {
|
|
7
|
-
e.current && (e.current.malloyResult = JSON.parse(r));
|
|
8
|
-
}, [r]), /* @__PURE__ */ t.jsx("malloy-render", { ref: e });
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
l as default
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./vendor-DSpmIox9.cjs");require("./index.cjs.js");const t=require("react");function n({result:r}){const e=t.useRef(null);return t.useEffect(()=>{e.current&&(e.current.malloyResult=JSON.parse(r))},[r]),u.jsxRuntimeExports.jsx("malloy-render",{ref:e})}exports.default=n;
|