@malloy-publisher/sdk 0.0.46 → 0.0.48
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-Bn1ONmkh.js → RenderedResult-C-inxkIP.js} +2 -2
- package/dist/{RenderedResult-eQGiBJrZ.cjs → RenderedResult-CW3J1ORR.cjs} +1 -1
- package/dist/components/AnalyzePackageButton.d.ts +5 -0
- package/dist/components/MutableNotebook/MutableNotebookList.d.ts +6 -0
- package/dist/components/MutableNotebook/index.d.ts +2 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/{index-CRJL0zjn.cjs → index-CcsVBhrp.cjs} +536 -536
- package/dist/{index-GV49y9rz.js → index-LVZKfoHS.js} +24213 -24010
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +24 -22
- package/dist/{vendor-Cr_5VY0T.js → vendor-9erH7dIW.js} +20880 -24729
- package/dist/vendor-C4KRaQNJ.cjs +245 -0
- package/package.json +1 -1
- package/src/components/AnalyzePackageButton.tsx +185 -0
- package/src/components/MutableNotebook/MutableNotebookList.tsx +69 -0
- package/src/components/MutableNotebook/index.ts +3 -3
- package/src/components/index.ts +1 -0
- package/vite.config.ts +1 -1
- package/dist/vendor-CxEyd3N4.cjs +0 -342
- package/vite.config.ts.timestamp-1732998513502-40117fb4923d1.mjs +0 -55
package/package.json
CHANGED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Add, Launch } from "@mui/icons-material";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Menu,
|
|
5
|
+
MenuItem,
|
|
6
|
+
ListItemIcon,
|
|
7
|
+
ListItemText,
|
|
8
|
+
Typography,
|
|
9
|
+
Dialog,
|
|
10
|
+
DialogTitle,
|
|
11
|
+
DialogContent,
|
|
12
|
+
FormControl,
|
|
13
|
+
TextField,
|
|
14
|
+
} from "@mui/material";
|
|
15
|
+
import {
|
|
16
|
+
NotebookStorageProvider,
|
|
17
|
+
BrowserNotebookStorage,
|
|
18
|
+
MutableNotebookList,
|
|
19
|
+
} from "./MutableNotebook";
|
|
20
|
+
import React from "react";
|
|
21
|
+
import { useRouterClickHandler } from "./click_helper";
|
|
22
|
+
|
|
23
|
+
export interface AnalyzePackageButtonProps {
|
|
24
|
+
projectName: string;
|
|
25
|
+
packageName: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function AnalyzePackageButton({
|
|
29
|
+
projectName,
|
|
30
|
+
packageName,
|
|
31
|
+
}: AnalyzePackageButtonProps) {
|
|
32
|
+
const [workbookName, setWorkbookName] = React.useState("");
|
|
33
|
+
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
34
|
+
const [newDialogOpen, setNewDialogOpen] = React.useState(false);
|
|
35
|
+
const [openDialogOpen, setOpenDialogOpen] = React.useState(false);
|
|
36
|
+
const navigate = useRouterClickHandler();
|
|
37
|
+
|
|
38
|
+
const open = Boolean(anchorEl);
|
|
39
|
+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
40
|
+
setAnchorEl(event.currentTarget);
|
|
41
|
+
};
|
|
42
|
+
const handleMenuClose = () => {
|
|
43
|
+
setAnchorEl(null);
|
|
44
|
+
};
|
|
45
|
+
const handleOpenDialogClose = () => {
|
|
46
|
+
setOpenDialogOpen(false);
|
|
47
|
+
};
|
|
48
|
+
const handleNewDialogClose = () => {
|
|
49
|
+
setNewDialogOpen(false);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleNotebookClick = (notebook: string, event: React.MouseEvent) => {
|
|
53
|
+
setOpenDialogOpen(false);
|
|
54
|
+
// Navigate to the ScratchNotebookPage with anchor text for notebookPath
|
|
55
|
+
navigate(
|
|
56
|
+
`/${projectName}/${packageName}/scratchNotebook/${encodeURIComponent(notebook)}`,
|
|
57
|
+
event,
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const createNotebookClick = (event?: React.MouseEvent) => {
|
|
62
|
+
setNewDialogOpen(false);
|
|
63
|
+
// Navigate to the ScratchNotebookPage with anchor text for notebookPath
|
|
64
|
+
navigate(
|
|
65
|
+
`/${projectName}/${packageName}/scratchNotebook/${encodeURIComponent(workbookName)}`,
|
|
66
|
+
event,
|
|
67
|
+
);
|
|
68
|
+
setWorkbookName("");
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
<Button
|
|
74
|
+
aria-controls={open ? "basic-menu" : undefined}
|
|
75
|
+
aria-haspopup="true"
|
|
76
|
+
aria-expanded={open ? "true" : undefined}
|
|
77
|
+
onClick={handleClick}
|
|
78
|
+
sx={{ height: "40px" }}
|
|
79
|
+
>
|
|
80
|
+
Analyze Package
|
|
81
|
+
</Button>
|
|
82
|
+
<Menu
|
|
83
|
+
id="basic-menu"
|
|
84
|
+
anchorEl={anchorEl}
|
|
85
|
+
open={open}
|
|
86
|
+
onClose={handleMenuClose}
|
|
87
|
+
slotProps={{
|
|
88
|
+
list: {
|
|
89
|
+
"aria-labelledby": "basic-button",
|
|
90
|
+
},
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<MenuItem
|
|
94
|
+
onClick={() => {
|
|
95
|
+
setNewDialogOpen(true);
|
|
96
|
+
handleMenuClose();
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<ListItemIcon>
|
|
100
|
+
<Add fontSize="small" />
|
|
101
|
+
</ListItemIcon>
|
|
102
|
+
<ListItemText>
|
|
103
|
+
<Typography variant="body2">New Workbook</Typography>
|
|
104
|
+
</ListItemText>
|
|
105
|
+
</MenuItem>
|
|
106
|
+
<MenuItem
|
|
107
|
+
onClick={() => {
|
|
108
|
+
setOpenDialogOpen(true);
|
|
109
|
+
handleMenuClose();
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
<ListItemIcon>
|
|
113
|
+
<Launch fontSize="small" />
|
|
114
|
+
</ListItemIcon>
|
|
115
|
+
<ListItemText>
|
|
116
|
+
<Typography variant="body2">Open Workbook</Typography>
|
|
117
|
+
</ListItemText>
|
|
118
|
+
</MenuItem>
|
|
119
|
+
</Menu>
|
|
120
|
+
<Dialog
|
|
121
|
+
open={newDialogOpen}
|
|
122
|
+
onClose={handleNewDialogClose}
|
|
123
|
+
sx={{
|
|
124
|
+
"& .MuiDialog-paper": {
|
|
125
|
+
width: "100%",
|
|
126
|
+
maxWidth: "300px",
|
|
127
|
+
},
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
<DialogTitle variant="subtitle1" sx={{ fontWeight: "medium" }}>
|
|
131
|
+
Create Workbook
|
|
132
|
+
</DialogTitle>
|
|
133
|
+
<DialogContent>
|
|
134
|
+
<FormControl
|
|
135
|
+
sx={{
|
|
136
|
+
width: "100%",
|
|
137
|
+
display: "flex",
|
|
138
|
+
alignItems: "center",
|
|
139
|
+
gap: 2,
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<TextField
|
|
143
|
+
label="Workbook Name"
|
|
144
|
+
value={workbookName}
|
|
145
|
+
onChange={(e) => setWorkbookName(e.target.value)}
|
|
146
|
+
sx={{
|
|
147
|
+
width: "100%",
|
|
148
|
+
maxWidth: "400px",
|
|
149
|
+
mt: 1,
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
152
|
+
<Button onClick={(event) => createNotebookClick(event)}>
|
|
153
|
+
Create
|
|
154
|
+
</Button>
|
|
155
|
+
</FormControl>
|
|
156
|
+
</DialogContent>
|
|
157
|
+
</Dialog>
|
|
158
|
+
<Dialog
|
|
159
|
+
open={openDialogOpen}
|
|
160
|
+
onClose={handleOpenDialogClose}
|
|
161
|
+
sx={{
|
|
162
|
+
"& .MuiDialog-paper": {
|
|
163
|
+
width: "100%",
|
|
164
|
+
maxWidth: "300px",
|
|
165
|
+
},
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
<DialogTitle variant="subtitle1" sx={{ fontWeight: "medium" }}>
|
|
169
|
+
Open Workbook
|
|
170
|
+
</DialogTitle>
|
|
171
|
+
<DialogContent>
|
|
172
|
+
<NotebookStorageProvider
|
|
173
|
+
notebookStorage={new BrowserNotebookStorage()}
|
|
174
|
+
userContext={{
|
|
175
|
+
project: projectName,
|
|
176
|
+
package: packageName,
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
<MutableNotebookList onNotebookClick={handleNotebookClick} />
|
|
180
|
+
</NotebookStorageProvider>
|
|
181
|
+
</DialogContent>
|
|
182
|
+
</Dialog>
|
|
183
|
+
</>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Box, Divider, List, ListItem, ListItemText } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useNotebookStorage } from "./NotebookStorageProvider";
|
|
4
|
+
|
|
5
|
+
interface MutableNotebookListProps {
|
|
6
|
+
onNotebookClick: (notebook: string, event: React.MouseEvent) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function MutableNotebookList({
|
|
10
|
+
onNotebookClick,
|
|
11
|
+
}: MutableNotebookListProps) {
|
|
12
|
+
const { notebookStorage, userContext } = useNotebookStorage();
|
|
13
|
+
const [notebooks, setNotebooks] = React.useState<string[]>([]);
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
if (notebookStorage && userContext) {
|
|
17
|
+
setNotebooks(notebookStorage.listNotebooks(userContext));
|
|
18
|
+
}
|
|
19
|
+
}, [notebookStorage, userContext]);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<Divider />
|
|
24
|
+
<Box
|
|
25
|
+
sx={{
|
|
26
|
+
maxHeight: "300px",
|
|
27
|
+
overflow: "auto",
|
|
28
|
+
"&::-webkit-scrollbar": {
|
|
29
|
+
width: "8px",
|
|
30
|
+
},
|
|
31
|
+
"&::-webkit-scrollbar-track": {
|
|
32
|
+
background: "transparent",
|
|
33
|
+
},
|
|
34
|
+
"&::-webkit-scrollbar-thumb": {
|
|
35
|
+
background: "rgba(0,0,0,0.2)",
|
|
36
|
+
borderRadius: "4px",
|
|
37
|
+
},
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<List dense>
|
|
41
|
+
{notebooks.length === 0 && (
|
|
42
|
+
<ListItem>
|
|
43
|
+
<ListItemText
|
|
44
|
+
primary="No notebooks found."
|
|
45
|
+
sx={{ textAlign: "center" }}
|
|
46
|
+
/>
|
|
47
|
+
</ListItem>
|
|
48
|
+
)}
|
|
49
|
+
{notebooks.map((notebook) => (
|
|
50
|
+
<ListItem
|
|
51
|
+
key={notebook}
|
|
52
|
+
onClick={(event: React.MouseEvent) =>
|
|
53
|
+
onNotebookClick(notebook, event)
|
|
54
|
+
}
|
|
55
|
+
sx={{
|
|
56
|
+
cursor: "pointer",
|
|
57
|
+
"&:hover": {
|
|
58
|
+
backgroundColor: "action.hover",
|
|
59
|
+
},
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<ListItemText primary={notebook} />
|
|
63
|
+
</ListItem>
|
|
64
|
+
))}
|
|
65
|
+
</List>
|
|
66
|
+
</Box>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { BrowserNotebookStorage } from "./BrowserNotebookStorage";
|
|
2
2
|
export { default as MutableNotebook } from "./MutableNotebook";
|
|
3
3
|
export type { NotebookStorage, UserContext } from "./NotebookStorage";
|
|
4
|
+
export { MutableNotebookList } from "./MutableNotebookList";
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
default as NotebookStorageProvider,
|
|
7
|
+
useNotebookStorage,
|
|
7
8
|
} from "./NotebookStorageProvider";
|
|
8
|
-
|
package/src/components/index.ts
CHANGED
|
@@ -9,3 +9,4 @@ export * from "./Loading";
|
|
|
9
9
|
export { useRouterClickHandler } from "./click_helper";
|
|
10
10
|
export { ServerProvider, useServer } from "./ServerProvider";
|
|
11
11
|
export type { ServerContextValue, ServerProviderProps } from "./ServerProvider";
|
|
12
|
+
export { AnalyzePackageButton } from "./AnalyzePackageButton";
|
package/vite.config.ts
CHANGED