@malloy-publisher/sdk 0.0.32 → 0.0.33
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/index.cjs.js +15 -10
- package/dist/index.es.js +893 -875
- package/package.json +1 -1
- package/src/components/Notebook/NotebookCell.tsx +39 -26
- package/src/components/Package/Package.tsx +1 -1
- package/src/components/RenderedResult/ResultContainer.tsx +11 -13
- package/src/components/highlighter.ts +1 -1
package/package.json
CHANGED
|
@@ -5,20 +5,26 @@ import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
|
5
5
|
import {
|
|
6
6
|
CardActions,
|
|
7
7
|
Collapse,
|
|
8
|
-
Divider,
|
|
9
8
|
IconButton,
|
|
10
9
|
Stack,
|
|
11
10
|
Tooltip,
|
|
12
11
|
Typography,
|
|
13
|
-
Box,
|
|
14
12
|
} from "@mui/material";
|
|
15
13
|
import Markdown from "markdown-to-jsx";
|
|
16
|
-
import React, {
|
|
14
|
+
import React, { useEffect } from "react";
|
|
17
15
|
import { NotebookCell as ClientNotebookCell } from "../../client";
|
|
18
16
|
import { highlight } from "../highlighter";
|
|
19
17
|
import { SourcesExplorer } from "../Model";
|
|
20
|
-
import { StyledCard, StyledCardContent } from "../styles";
|
|
21
18
|
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
19
|
+
import { StyledCard, StyledCardContent } from "../styles";
|
|
20
|
+
|
|
21
|
+
// Add global style for code display
|
|
22
|
+
const codeStyle = `
|
|
23
|
+
.code-display pre {
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
22
28
|
|
|
23
29
|
interface NotebookCellProps {
|
|
24
30
|
cell: ClientNotebookCell;
|
|
@@ -39,9 +45,8 @@ export function NotebookCell({
|
|
|
39
45
|
expandEmbedding,
|
|
40
46
|
hideEmbeddingIcon,
|
|
41
47
|
}: NotebookCellProps) {
|
|
42
|
-
const [codeExpanded, setCodeExpanded] =
|
|
43
|
-
expandCodeCell
|
|
44
|
-
);
|
|
48
|
+
const [codeExpanded, setCodeExpanded] =
|
|
49
|
+
React.useState<boolean>(expandCodeCell);
|
|
45
50
|
const [embeddingExpanded, setEmbeddingExpanded] =
|
|
46
51
|
React.useState<boolean>(expandEmbedding);
|
|
47
52
|
const [highlightedMalloyCode, setHighlightedMalloyCode] =
|
|
@@ -73,7 +78,12 @@ export function NotebookCell({
|
|
|
73
78
|
(cell.type === "code" && (
|
|
74
79
|
<StyledCard variant="outlined" sx={{ height: "auto" }}>
|
|
75
80
|
{(!hideCodeCellIcon || (!hideEmbeddingIcon && cell.result)) && (
|
|
76
|
-
<Stack
|
|
81
|
+
<Stack
|
|
82
|
+
sx={{
|
|
83
|
+
flexDirection: "row",
|
|
84
|
+
justifyContent: "right",
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
77
87
|
<CardActions
|
|
78
88
|
sx={{
|
|
79
89
|
padding: "0px 10px 0px 10px",
|
|
@@ -142,7 +152,6 @@ export function NotebookCell({
|
|
|
142
152
|
</Stack>
|
|
143
153
|
)}
|
|
144
154
|
<Collapse in={embeddingExpanded} timeout="auto" unmountOnExit>
|
|
145
|
-
<Divider />
|
|
146
155
|
<Stack
|
|
147
156
|
sx={{
|
|
148
157
|
p: "10px",
|
|
@@ -176,29 +185,35 @@ export function NotebookCell({
|
|
|
176
185
|
</Stack>
|
|
177
186
|
</Collapse>
|
|
178
187
|
<Collapse in={codeExpanded} timeout="auto" unmountOnExit>
|
|
179
|
-
<
|
|
188
|
+
<style>{codeStyle}</style>
|
|
180
189
|
<Stack
|
|
181
190
|
sx={{
|
|
182
|
-
|
|
191
|
+
mx: "15px",
|
|
192
|
+
mb: "10px",
|
|
183
193
|
borderRadius: 0,
|
|
184
194
|
flexDirection: "row",
|
|
185
195
|
justifyContent: "space-between",
|
|
186
196
|
}}
|
|
187
197
|
>
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
198
|
+
<div
|
|
199
|
+
className="code-display"
|
|
200
|
+
style={{
|
|
201
|
+
fontSize: "12px",
|
|
202
|
+
width: "800px",
|
|
203
|
+
border: "1px solid rgb(220,220,220)",
|
|
204
|
+
}}
|
|
192
205
|
dangerouslySetInnerHTML={{
|
|
193
206
|
__html: highlightedMalloyCode,
|
|
194
207
|
}}
|
|
195
208
|
/>
|
|
196
209
|
</Stack>
|
|
197
210
|
</Collapse>
|
|
198
|
-
<Collapse
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
211
|
+
<Collapse
|
|
212
|
+
in={sourcesExpanded}
|
|
213
|
+
timeout="auto"
|
|
214
|
+
unmountOnExit
|
|
215
|
+
sx={{ p: "5px" }}
|
|
216
|
+
>
|
|
202
217
|
<SourcesExplorer
|
|
203
218
|
sourceAndPaths={cell.newSources.map((source) => {
|
|
204
219
|
const sourceInfo = JSON.parse(source) as Malloy.SourceInfo;
|
|
@@ -210,13 +225,11 @@ export function NotebookCell({
|
|
|
210
225
|
/>
|
|
211
226
|
</Collapse>
|
|
212
227
|
{cell.result && !sourcesExpanded && (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
/>
|
|
219
|
-
</>
|
|
228
|
+
<ResultContainer
|
|
229
|
+
result={cell.result}
|
|
230
|
+
minHeight={200}
|
|
231
|
+
maxHeight={800}
|
|
232
|
+
/>
|
|
220
233
|
)}
|
|
221
234
|
</StyledCard>
|
|
222
235
|
))
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExpandLess, ExpandMore } from "@mui/icons-material";
|
|
2
|
+
import { Box, IconButton } from "@mui/material";
|
|
3
|
+
import {
|
|
2
4
|
lazy,
|
|
3
5
|
Suspense,
|
|
4
|
-
useState,
|
|
5
|
-
useRef,
|
|
6
6
|
useCallback,
|
|
7
7
|
useEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
8
10
|
} from "react";
|
|
9
|
-
import { Box, IconButton } from "@mui/material";
|
|
10
|
-
import { ExpandMore, ExpandLess } from "@mui/icons-material";
|
|
11
11
|
|
|
12
12
|
const RenderedResult = lazy(() => import("../RenderedResult/RenderedResult"));
|
|
13
13
|
|
|
@@ -74,9 +74,9 @@ export default function ResultContainer({
|
|
|
74
74
|
|
|
75
75
|
const height = explicitHeight
|
|
76
76
|
? {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
minHeight: `${explicitHeight}px`,
|
|
78
|
+
height: `${explicitHeight}px`,
|
|
79
|
+
}
|
|
80
80
|
: {};
|
|
81
81
|
return (
|
|
82
82
|
<>
|
|
@@ -124,12 +124,10 @@ export default function ResultContainer({
|
|
|
124
124
|
left: 0,
|
|
125
125
|
right: 0,
|
|
126
126
|
height: "32px",
|
|
127
|
-
backgroundColor: "rgba(255,
|
|
128
|
-
borderTop: "1px solid #e0e0e0",
|
|
127
|
+
backgroundColor: "rgba(255,255,255,0.75)",
|
|
129
128
|
display: "flex",
|
|
130
129
|
alignItems: "center",
|
|
131
130
|
justifyContent: "center",
|
|
132
|
-
backdropFilter: "blur(2px)",
|
|
133
131
|
}}
|
|
134
132
|
>
|
|
135
133
|
<IconButton
|
|
@@ -148,9 +146,9 @@ export default function ResultContainer({
|
|
|
148
146
|
}
|
|
149
147
|
>
|
|
150
148
|
{isExpanded ? (
|
|
151
|
-
<ExpandLess sx={{ fontSize:
|
|
149
|
+
<ExpandLess sx={{ fontSize: 30 }} />
|
|
152
150
|
) : (
|
|
153
|
-
<ExpandMore sx={{ fontSize:
|
|
151
|
+
<ExpandMore sx={{ fontSize: 30 }} />
|
|
154
152
|
)}
|
|
155
153
|
</IconButton>
|
|
156
154
|
</Box>
|