@malloy-publisher/sdk 0.0.36 → 0.0.37
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-DphykkT6.cjs → RenderedResult-ChKXzRBq.cjs} +1 -1
- package/dist/{RenderedResult-BlNz8j4d.js → RenderedResult-DkEsDzXb.js} +2 -2
- package/dist/components/Model/SourcesExplorer.d.ts +2 -2
- package/dist/components/MutableNotebook/EditableMalloyCell.d.ts +3 -3
- package/dist/components/MutableNotebook/MutableCell.d.ts +3 -4
- package/dist/components/MutableNotebook/MutableNotebook.d.ts +2 -1
- package/dist/{index-nKbldp0y.cjs → index-7mmEVMId.cjs} +314 -314
- package/dist/{index-DvGSfdDD.js → index-DdtGkJIk.js} +25143 -25072
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/{vendor-C8UD-eyK.js → vendor-C6w9JpPA.js} +16199 -19097
- package/dist/{vendor-BH1c2Hhy.cjs → vendor-DAoHVNwq.cjs} +140 -241
- package/package.json +1 -1
- package/src/components/Model/NamedQueries.tsx +13 -13
- package/src/components/Model/SourcesExplorer.tsx +21 -41
- package/src/components/MutableNotebook/EditableMalloyCell.tsx +4 -22
- package/src/components/MutableNotebook/ModelPicker.tsx +31 -52
- package/src/components/MutableNotebook/MutableCell.tsx +229 -137
- package/src/components/MutableNotebook/MutableNotebook.tsx +102 -62
- package/src/components/Package/Package.tsx +1 -1
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import CheckIcon from "@mui/icons-material/Check";
|
|
2
|
+
import CodeIcon from "@mui/icons-material/Code";
|
|
3
|
+
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
|
|
4
|
+
import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
|
|
3
5
|
import {
|
|
4
|
-
Stack,
|
|
5
|
-
Collapse,
|
|
6
|
-
CardActions,
|
|
7
|
-
CardContent,
|
|
8
|
-
IconButton,
|
|
9
|
-
Tooltip,
|
|
10
|
-
Button,
|
|
11
6
|
Box,
|
|
12
|
-
|
|
7
|
+
Button,
|
|
8
|
+
CardActions,
|
|
9
|
+
Collapse,
|
|
13
10
|
Dialog,
|
|
14
11
|
DialogActions,
|
|
12
|
+
DialogContent,
|
|
15
13
|
DialogTitle,
|
|
14
|
+
IconButton,
|
|
15
|
+
Stack,
|
|
16
|
+
Tooltip,
|
|
17
|
+
Typography,
|
|
16
18
|
} from "@mui/material";
|
|
17
|
-
import
|
|
19
|
+
import MDEditor from "@uiw/react-md-editor";
|
|
18
20
|
import Markdown from "markdown-to-jsx";
|
|
19
|
-
import {
|
|
20
|
-
import { Divider } from "@mui/material";
|
|
21
|
+
import React, { useEffect, useState } from "react";
|
|
21
22
|
import { highlight } from "../highlighter";
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
import {
|
|
24
|
+
emptyQueryExplorerResult,
|
|
25
|
+
QueryExplorerResult,
|
|
26
|
+
SourceAndPath,
|
|
27
|
+
} from "../Model/SourcesExplorer";
|
|
27
28
|
import { NotebookCellValue } from "../NotebookManager";
|
|
28
|
-
import { SourceAndPath } from "../Model/SourcesExplorer";
|
|
29
29
|
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
30
|
+
import { StyledCard } from "../styles";
|
|
31
|
+
import { EditableMalloyCell } from "./EditableMalloyCell";
|
|
30
32
|
|
|
31
33
|
interface NotebookCellProps {
|
|
32
34
|
cell: NotebookCellValue;
|
|
33
35
|
expandCodeCell?: boolean;
|
|
34
36
|
expandEmbedding?: boolean;
|
|
37
|
+
hideEmbeddingIcons?: boolean;
|
|
35
38
|
editingMalloy?: boolean;
|
|
36
39
|
editingMarkdown?: boolean;
|
|
37
40
|
sourceAndPaths: SourceAndPath[];
|
|
38
|
-
newCell: React.ReactNode;
|
|
39
41
|
onCellChange: (cell: NotebookCellValue) => void;
|
|
40
42
|
onClose: () => void;
|
|
41
43
|
onEdit: () => void;
|
|
@@ -46,10 +48,10 @@ export function MutableCell({
|
|
|
46
48
|
cell,
|
|
47
49
|
expandCodeCell,
|
|
48
50
|
expandEmbedding,
|
|
51
|
+
hideEmbeddingIcons,
|
|
49
52
|
editingMalloy,
|
|
50
53
|
editingMarkdown,
|
|
51
54
|
sourceAndPaths,
|
|
52
|
-
newCell,
|
|
53
55
|
onCellChange,
|
|
54
56
|
onClose,
|
|
55
57
|
onEdit,
|
|
@@ -63,6 +65,9 @@ export function MutableCell({
|
|
|
63
65
|
React.useState<string>();
|
|
64
66
|
const [highlightedEmbedCode, setHighlightedEmbedCode] =
|
|
65
67
|
React.useState<string>();
|
|
68
|
+
const [query, setQuery] = React.useState<QueryExplorerResult>(
|
|
69
|
+
emptyQueryExplorerResult(),
|
|
70
|
+
);
|
|
66
71
|
|
|
67
72
|
useEffect(() => {
|
|
68
73
|
if (!cell.isMarkdown)
|
|
@@ -85,6 +90,23 @@ export function MutableCell({
|
|
|
85
90
|
};
|
|
86
91
|
const noSources = sourceAndPaths.length === 0;
|
|
87
92
|
|
|
93
|
+
const saveResult = (modelPath: string, sourceName: string) => {
|
|
94
|
+
// Convert the results of the Query Explorer into
|
|
95
|
+
// the stringified JSON objects that are stored in the cell.
|
|
96
|
+
onCellChange({
|
|
97
|
+
...cell,
|
|
98
|
+
value: query.query,
|
|
99
|
+
result: query.malloyResult
|
|
100
|
+
? JSON.stringify(query.malloyResult)
|
|
101
|
+
: undefined,
|
|
102
|
+
queryInfo: query.malloyQuery
|
|
103
|
+
? JSON.stringify(query.malloyQuery)
|
|
104
|
+
: undefined,
|
|
105
|
+
sourceName,
|
|
106
|
+
modelPath,
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
88
110
|
const deleteButton = (
|
|
89
111
|
<Tooltip title="Delete Cell">
|
|
90
112
|
<IconButton size="small" onClick={() => setDeleteDialogOpen(true)}>
|
|
@@ -126,17 +148,20 @@ export function MutableCell({
|
|
|
126
148
|
);
|
|
127
149
|
const buttons = cell.isMarkdown ? (
|
|
128
150
|
<>
|
|
129
|
-
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
{editingMarkdown ? (
|
|
152
|
+
<Tooltip title="Save">
|
|
153
|
+
<IconButton size="small" onClick={onClose}>
|
|
154
|
+
<CheckIcon />
|
|
155
|
+
</IconButton>
|
|
156
|
+
</Tooltip>
|
|
157
|
+
) : (
|
|
158
|
+
<Tooltip title="Edit">
|
|
159
|
+
<IconButton size="small" onClick={onEdit}>
|
|
160
|
+
<EditOutlinedIcon />
|
|
161
|
+
</IconButton>
|
|
162
|
+
</Tooltip>
|
|
138
163
|
)}
|
|
139
|
-
{
|
|
164
|
+
{!editingMarkdown && deleteButton}
|
|
140
165
|
</>
|
|
141
166
|
) : (
|
|
142
167
|
<>
|
|
@@ -152,7 +177,7 @@ export function MutableCell({
|
|
|
152
177
|
</IconButton>
|
|
153
178
|
</Tooltip>
|
|
154
179
|
)}
|
|
155
|
-
{!editingMalloy && cell.result && (
|
|
180
|
+
{!hideEmbeddingIcons && !editingMalloy && cell.result && (
|
|
156
181
|
<Tooltip
|
|
157
182
|
title={embeddingExpanded ? "Hide Embedding" : "View Embedding"}
|
|
158
183
|
>
|
|
@@ -166,45 +191,49 @@ export function MutableCell({
|
|
|
166
191
|
</IconButton>
|
|
167
192
|
</Tooltip>
|
|
168
193
|
)}
|
|
169
|
-
{
|
|
170
|
-
|
|
194
|
+
{editingMalloy && (
|
|
195
|
+
<Tooltip title="Save">
|
|
196
|
+
<IconButton
|
|
197
|
+
size="small"
|
|
198
|
+
onClick={() => {
|
|
199
|
+
saveResult(cell.modelPath, cell.sourceName);
|
|
200
|
+
onClose();
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
<CheckIcon />
|
|
204
|
+
</IconButton>
|
|
205
|
+
</Tooltip>
|
|
206
|
+
)}
|
|
171
207
|
{!editingMalloy && (
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
208
|
+
<Tooltip title="Edit">
|
|
209
|
+
<IconButton size="small" onClick={onEdit}>
|
|
210
|
+
<EditOutlinedIcon />
|
|
211
|
+
</IconButton>
|
|
212
|
+
</Tooltip>
|
|
175
213
|
)}
|
|
176
|
-
{
|
|
214
|
+
{!editingMalloy && deleteButton}
|
|
177
215
|
</>
|
|
178
216
|
);
|
|
217
|
+
|
|
179
218
|
const buttonStack = (
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
</Stack>
|
|
192
|
-
<Box
|
|
193
|
-
sx={{
|
|
194
|
-
borderBottom: "1px solid #e0e0e0",
|
|
195
|
-
mx: "10px",
|
|
196
|
-
width: "auto",
|
|
197
|
-
}}
|
|
198
|
-
/>
|
|
199
|
-
</>
|
|
219
|
+
<Stack
|
|
220
|
+
sx={{
|
|
221
|
+
flexDirection: "row",
|
|
222
|
+
justifyContent: "right",
|
|
223
|
+
mt: "20px",
|
|
224
|
+
mb: "5px",
|
|
225
|
+
mx: "5px",
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
<CardActions>{buttons}</CardActions>
|
|
229
|
+
</Stack>
|
|
200
230
|
);
|
|
201
231
|
return (
|
|
202
|
-
|
|
203
|
-
{
|
|
204
|
-
|
|
232
|
+
<>
|
|
233
|
+
{buttonStack}
|
|
234
|
+
{cell.isMarkdown ? (
|
|
205
235
|
<>
|
|
206
|
-
{
|
|
207
|
-
{editingMarkdown && (
|
|
236
|
+
{editingMarkdown ? (
|
|
208
237
|
<MDEditor
|
|
209
238
|
value={value}
|
|
210
239
|
preview="edit"
|
|
@@ -213,96 +242,159 @@ export function MutableCell({
|
|
|
213
242
|
updateMarkdown(newValue);
|
|
214
243
|
}}
|
|
215
244
|
/>
|
|
245
|
+
) : (
|
|
246
|
+
<StyledCard variant="outlined" sx={{ borderRadius: 0 }}>
|
|
247
|
+
<Box
|
|
248
|
+
sx={{
|
|
249
|
+
px: 0.5,
|
|
250
|
+
pt: 0,
|
|
251
|
+
mt: 0,
|
|
252
|
+
"& h1, & h2, & h3, & h4, & h5, & h6": {
|
|
253
|
+
mt: 0.5,
|
|
254
|
+
mb: 0.5,
|
|
255
|
+
},
|
|
256
|
+
"& p": { mt: 0.5, mb: 0.5 },
|
|
257
|
+
"& ul, & ol": { mt: 0.5, mb: 0.5 },
|
|
258
|
+
"& li": { mt: 0, mb: 0 },
|
|
259
|
+
"& pre, & code": { mt: 0.5, mb: 0.5 },
|
|
260
|
+
"& blockquote": { mt: 0.5, mb: 0.5 },
|
|
261
|
+
}}
|
|
262
|
+
>
|
|
263
|
+
{value ? (
|
|
264
|
+
<Markdown>{value}</Markdown>
|
|
265
|
+
) : (
|
|
266
|
+
<>
|
|
267
|
+
<Typography
|
|
268
|
+
sx={{
|
|
269
|
+
p: 2,
|
|
270
|
+
textAlign: "center",
|
|
271
|
+
variant: "subtitle2",
|
|
272
|
+
fontWeight: "medium",
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
Markdown is empty
|
|
276
|
+
</Typography>
|
|
277
|
+
<Typography
|
|
278
|
+
sx={{
|
|
279
|
+
mb: 2,
|
|
280
|
+
textAlign: "center",
|
|
281
|
+
variant: "body2",
|
|
282
|
+
}}
|
|
283
|
+
>
|
|
284
|
+
Click the edit button and add some markdown.
|
|
285
|
+
</Typography>
|
|
286
|
+
</>
|
|
287
|
+
)}
|
|
288
|
+
</Box>
|
|
289
|
+
</StyledCard>
|
|
216
290
|
)}
|
|
217
|
-
<Box
|
|
218
|
-
sx={{
|
|
219
|
-
px: 0.5,
|
|
220
|
-
pt: 0,
|
|
221
|
-
mt: 0,
|
|
222
|
-
"& h1, & h2, & h3, & h4, & h5, & h6": { mt: 0.5, mb: 0.5 },
|
|
223
|
-
"& p": { mt: 0.5, mb: 0.5 },
|
|
224
|
-
"& ul, & ol": { mt: 0.5, mb: 0.5 },
|
|
225
|
-
"& li": { mt: 0, mb: 0 },
|
|
226
|
-
"& pre, & code": { mt: 0.5, mb: 0.5 },
|
|
227
|
-
"& blockquote": { mt: 0.5, mb: 0.5 },
|
|
228
|
-
}}
|
|
229
|
-
>
|
|
230
|
-
<Markdown>{value}</Markdown>
|
|
231
|
-
</Box>
|
|
232
291
|
</>
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
292
|
+
) : (
|
|
293
|
+
<>
|
|
294
|
+
<Collapse in={embeddingExpanded} timeout="auto" unmountOnExit>
|
|
295
|
+
<Stack
|
|
296
|
+
sx={{
|
|
297
|
+
p: "10px",
|
|
298
|
+
borderRadius: 0,
|
|
299
|
+
flexDirection: "row",
|
|
300
|
+
justifyContent: "space-between",
|
|
301
|
+
}}
|
|
302
|
+
>
|
|
303
|
+
<Typography
|
|
304
|
+
component="div"
|
|
240
305
|
sx={{
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
flexDirection: "row",
|
|
244
|
-
justifyContent: "space-between",
|
|
306
|
+
fontSize: "12px",
|
|
307
|
+
"& .line": { textWrap: "wrap" },
|
|
245
308
|
}}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
<
|
|
309
|
+
dangerouslySetInnerHTML={{
|
|
310
|
+
__html: highlightedEmbedCode,
|
|
311
|
+
}}
|
|
312
|
+
/>
|
|
313
|
+
</Stack>
|
|
314
|
+
</Collapse>
|
|
315
|
+
<Collapse in={codeExpanded} timeout="auto" unmountOnExit>
|
|
316
|
+
<Stack
|
|
317
|
+
sx={{
|
|
318
|
+
p: "10px",
|
|
319
|
+
borderRadius: 0,
|
|
320
|
+
flexDirection: "row",
|
|
321
|
+
justifyContent: "space-between",
|
|
322
|
+
}}
|
|
323
|
+
>
|
|
324
|
+
<Typography
|
|
325
|
+
component="div"
|
|
326
|
+
className="content"
|
|
262
327
|
sx={{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
flexDirection: "row",
|
|
266
|
-
justifyContent: "space-between",
|
|
328
|
+
fontSize: "12px",
|
|
329
|
+
"& .line": { textWrap: "wrap" },
|
|
267
330
|
}}
|
|
268
|
-
|
|
331
|
+
dangerouslySetInnerHTML={{
|
|
332
|
+
__html: highlightedMalloyCode,
|
|
333
|
+
}}
|
|
334
|
+
/>
|
|
335
|
+
</Stack>
|
|
336
|
+
</Collapse>
|
|
337
|
+
{editingMalloy &&
|
|
338
|
+
(noSources ? (
|
|
339
|
+
<>
|
|
269
340
|
<Typography
|
|
270
|
-
component="div"
|
|
271
|
-
className="content"
|
|
272
341
|
sx={{
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
__html: highlightedMalloyCode,
|
|
342
|
+
p: 2,
|
|
343
|
+
textAlign: "center",
|
|
344
|
+
variant: "subtitle2",
|
|
345
|
+
fontWeight: "medium",
|
|
278
346
|
}}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
</Collapse>
|
|
282
|
-
{editingMalloy &&
|
|
283
|
-
(noSources ? (
|
|
284
|
-
<Typography>
|
|
285
|
-
No Model Imports. Please add a model import above.
|
|
347
|
+
>
|
|
348
|
+
No Model Imports
|
|
286
349
|
</Typography>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
350
|
+
<Typography
|
|
351
|
+
sx={{ mb: 2, textAlign: "center", variant: "body2" }}
|
|
352
|
+
>
|
|
353
|
+
Please add a model import above.
|
|
354
|
+
</Typography>
|
|
355
|
+
</>
|
|
356
|
+
) : (
|
|
357
|
+
<EditableMalloyCell
|
|
358
|
+
sourceAndPaths={sourceAndPaths}
|
|
359
|
+
onChange={(query) => {
|
|
360
|
+
setQuery(query);
|
|
361
|
+
}}
|
|
362
|
+
cell={cell}
|
|
363
|
+
/>
|
|
364
|
+
))}
|
|
365
|
+
{!editingMalloy && cell.result && (
|
|
366
|
+
<StyledCard variant="outlined" sx={{ borderRadius: 0 }}>
|
|
296
367
|
<ResultContainer
|
|
297
368
|
result={cell.result}
|
|
298
369
|
minHeight={300}
|
|
299
370
|
maxHeight={800}
|
|
300
371
|
/>
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
372
|
+
</StyledCard>
|
|
373
|
+
)}
|
|
374
|
+
{!editingMalloy && !cell.result && (
|
|
375
|
+
<StyledCard variant="outlined" sx={{ borderRadius: 0 }}>
|
|
376
|
+
<Typography
|
|
377
|
+
sx={{
|
|
378
|
+
p: 2,
|
|
379
|
+
textAlign: "center",
|
|
380
|
+
variant: "subtitle2",
|
|
381
|
+
fontWeight: "medium",
|
|
382
|
+
}}
|
|
383
|
+
>
|
|
384
|
+
Explore is empty
|
|
385
|
+
</Typography>
|
|
386
|
+
<Typography
|
|
387
|
+
sx={{ mb: 2, textAlign: "center", variant: "body2" }}
|
|
388
|
+
>
|
|
389
|
+
Click the edit button and explore the data in the model
|
|
390
|
+
to see results.
|
|
391
|
+
</Typography>
|
|
392
|
+
</StyledCard>
|
|
393
|
+
)}
|
|
394
|
+
</>
|
|
395
|
+
)}
|
|
304
396
|
{deleteDialogOpen && deleteDialog}
|
|
305
|
-
|
|
397
|
+
</>
|
|
306
398
|
);
|
|
307
399
|
}
|
|
308
400
|
|