@canmingir/link 1.2.31 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canmingir/link",
3
- "version": "1.2.31",
3
+ "version": "1.2.33",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -1,8 +1,7 @@
1
- import DeleteIcon from "@mui/icons-material/Delete";
2
1
  import DialogTooltip from "../DialogTootip/DialogTooltip";
3
- import SaveIcon from "@mui/icons-material/Save";
4
2
 
5
3
  import { Box, Button, ToggleButton, ToggleButtonGroup } from "@mui/material";
4
+ import { Delete, Save } from "@mui/icons-material";
6
5
  import { useEffect, useState } from "react";
7
6
 
8
7
  function APIDialogAction({
@@ -72,7 +71,7 @@ function APIDialogAction({
72
71
  variant="contained"
73
72
  color="error"
74
73
  onClick={deleteMethod}
75
- startIcon={<DeleteIcon />}
74
+ startIcon={<Delete />}
76
75
  data-cy="delete-api-button-yes"
77
76
  >
78
77
  Delete
@@ -85,7 +84,7 @@ function APIDialogAction({
85
84
  color="error"
86
85
  onClick={handleTooltipOpen}
87
86
  disabled={deleteDisable}
88
- startIcon={<DeleteIcon />}
87
+ startIcon={<Delete />}
89
88
  data-cy="delete-api-button"
90
89
  >
91
90
  Delete
@@ -96,7 +95,7 @@ function APIDialogAction({
96
95
  color="primary"
97
96
  onClick={saveApiDialog}
98
97
  disabled={saveDisable}
99
- startIcon={<SaveIcon />}
98
+ startIcon={<Save />}
100
99
  data-cy="save-api-button"
101
100
  >
102
101
  Save
@@ -1,4 +1,4 @@
1
- import AddIcon from "@mui/icons-material/Add";
1
+ import { Add } from "@mui/icons-material";
2
2
  import ParamTable from "../ParamTable";
3
3
 
4
4
  import { Box, Fab } from "@mui/material";
@@ -47,7 +47,7 @@ const APIParams = ({ types, paramsRef, addParams }) => {
47
47
  onClick={handleAddParams}
48
48
  data-cy="add-param-button"
49
49
  >
50
- <AddIcon />
50
+ <Add />
51
51
  </Fab>
52
52
  </Box>
53
53
  </Box>
@@ -1,4 +1,4 @@
1
- import LanguageIcon from "@mui/icons-material/Language";
1
+ import { Language } from "@mui/icons-material";
2
2
  import styles from "./styles";
3
3
 
4
4
  import {
@@ -72,7 +72,7 @@ const APIPath = ({
72
72
  </Grid>
73
73
  </Grid>
74
74
  <Button onClick={onTypesButtonClick} data-cy="types-button">
75
- <LanguageIcon sx={styles.icon} />
75
+ <Language sx={styles.icon} />
76
76
  Types
77
77
  </Button>
78
78
  </Grid>
@@ -1,411 +1,173 @@
1
- import AddIcon from "@mui/icons-material/Add";
2
1
  import ArrowIcon from "./Arrow";
3
- import BlankTreeMessage from "../BlankTreeMessage/BlankTreeMessage";
4
- import DeleteIcon from "@mui/icons-material/Delete";
5
- import DeleteMethodDialog from "./DeleteMethodDialog";
6
- import EditIcon from "@mui/icons-material/Edit";
7
- import Error from "@mui/icons-material/Error";
8
- import Fade from "@mui/material/Fade";
9
- import ResourceMenu from "../ResourceMenu";
2
+ import { Error } from "@mui/icons-material";
10
3
  import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
11
4
  import { TreeItem } from "@mui/x-tree-view/TreeItem";
12
- import styles from "./styles";
13
- import { publish, useEvent } from "@nucleoidai/react-event";
14
- import { useTheme } from "@mui/material/styles";
15
5
 
16
- import {
17
- Box,
18
- Card,
19
- CardActions,
20
- Fab,
21
- Grid,
22
- Menu,
23
- MenuItem,
24
- Tooltip,
25
- Typography,
26
- } from "@mui/material";
27
- import React, { useEffect, useRef, useState } from "react";
28
-
29
- function APITree() {
30
- const map = useRef({});
31
- const [selected, setSelected] = React.useState(null);
32
- const [contextMenu, setContextMenu] = React.useState(null);
33
- const [rightClickMethod, setRightClickMethod] = React.useState();
34
- const [methodDisabled, setMethodDisabled] = useState();
35
- const [open, setOpen] = useState(false);
36
- const [resourceMenu, setResourceMenu] = React.useState(false);
37
- const [anchor, setAnchor] = React.useState();
38
- const [expanded, setExpanded] = useState([]);
39
- const [errors] = useEvent("DIAGNOSTICS_COMPLETED", []);
40
- const theme = useTheme();
41
-
42
- const [selectedAPI] = useEvent("SELECTED_API_CHANGED", {
43
- path: "/",
44
- method: "GET",
45
- });
46
-
47
- const [api] = useEvent("API_DATA_CHANGED", []);
48
- const apiExists = api.length > 0;
49
-
50
- const expandList = React.useMemo(() => [], []);
51
-
52
- const handleToggle = (event, ids) => {
53
- setExpanded(ids);
54
- };
55
-
56
- const handleExpandClick = () => {
57
- setExpanded([...expandList]);
58
- };
59
-
60
- const select = (id, callDispatch = true) => {
61
- if (map.current[id]) {
62
- setSelected(id);
63
- if (callDispatch) {
64
- publish("SELECTED_API_CHANGED", map.current[id]);
65
- }
66
- }
67
- };
68
-
69
- useEffect(() => {
70
- const selectedId = Object.keys(map.current).find(
71
- (key) =>
72
- map.current[key].path === selectedAPI.path &&
73
- map.current[key].method === selectedAPI.method
74
- );
75
- if (selectedId) {
76
- select(selectedId, false);
77
- }
78
- // eslint-disable-next-line react-hooks/exhaustive-deps
79
- }, [selectedAPI]);
80
-
81
- const handleContextMenu = (event, hash) => {
82
- event.preventDefault();
83
-
84
- if (hash) select(hash);
85
-
86
- setRightClickMethod(hash);
87
-
88
- setContextMenu(
89
- !contextMenu
90
- ? {
91
- mouseX: event.clientX,
92
- mouseY: event.clientY,
93
- }
94
- : null
95
- );
96
- };
97
-
98
- const handleResourceMenu = (event) => {
99
- event.preventDefault();
100
-
101
- setResourceMenu(true);
102
- setAnchor(event);
103
- };
104
-
105
- const handleCloseResourceMenu = () => {
106
- setResourceMenu(false);
107
- };
108
-
109
- const handleClose = () => {
110
- setRightClickMethod(null);
111
- setContextMenu(null);
112
- };
113
-
114
- const editMethod = () => {
115
- publish("API_DIALOG_OPEN", { type: "method", action: "edit" });
116
- handleClose();
117
- };
118
-
119
- const deleteMethod = () => {
120
- publish("API_METHOD_DELETE", {});
121
- setOpen(false);
122
- };
123
-
124
- const handleDeleteMethod = () => {
125
- setOpen(true);
126
- handleClose();
127
- };
128
-
129
- const checkMethodDeletable = () => {
130
- const countMethodsForPath = (path) => {
131
- return api.filter((endpoint) => endpoint.path === path).length;
132
- };
133
- if (selectedAPI) {
134
- const apiSelectedPath = selectedAPI.path;
135
-
136
- return countMethodsForPath(apiSelectedPath) <= 1;
137
- }
138
- return false;
139
- };
140
-
141
- useEffect(() => {
142
- if (!selected) {
143
- select(Object.keys(map.current)[0]);
144
- }
145
- setMethodDisabled(checkMethodDeletable());
146
- handleExpandClick();
147
-
148
- // eslint-disable-next-line react-hooks/exhaustive-deps
149
- }, [selected, api, selectedAPI]);
6
+ import { Box, Tooltip } from "@mui/material";
7
+ import React, { useMemo } from "react";
8
+
9
+ function APITree({
10
+ api = [],
11
+ errors = [],
12
+ theme = {},
13
+ expanded = [],
14
+ selected = null,
15
+ onExpand = () => {},
16
+ onSelect = () => {},
17
+ rightClickMethod = null,
18
+ }) {
19
+ const map = useMemo(() => ({}), []);
20
+
21
+ const treeNodes = useMemo(() => {
22
+ return compile(api, errors, theme, map, rightClickMethod);
23
+ }, [api, errors, theme, map, rightClickMethod]);
150
24
 
151
25
  return (
152
- <Card sx={{ height: "100%" }}>
153
- {apiExists ? (
154
- <>
155
- <Grid sx={styles.apiTreeGrid}>
156
- {open && (
157
- <DeleteMethodDialog
158
- setOpen={setOpen}
159
- deleteMethod={deleteMethod}
160
- />
161
- )}
162
- <SimpleTreeView
163
- slots={{
164
- collapseIcon: () => <ArrowIcon down />,
165
- expandIcon: () => <ArrowIcon right />,
166
- }}
167
- expandedItems={expanded}
168
- onExpandedItemsChange={(event, itemIds) => setExpanded(itemIds)}
169
- selectedItems={selected}
170
- onSelectedItemsChange={(event, itemId) => select(itemId)}
171
- sx={{
172
- marginTop: "10px",
173
- }}
174
- >
175
- {compile(
176
- api,
177
- handleContextMenu,
178
- expandList,
179
- rightClickMethod,
180
- errors,
181
- theme,
182
- select,
183
- handleResourceMenu,
184
- map.current
185
- )}
186
- </SimpleTreeView>
187
-
188
- <Menu
189
- open={contextMenu !== null}
190
- onClose={handleClose}
191
- anchorReference="anchorPosition"
192
- anchorPosition={
193
- contextMenu !== null
194
- ? { top: contextMenu.mouseY, left: contextMenu.mouseX }
195
- : undefined
196
- }
197
- slots={{
198
- transition: Fade
199
- }}
200
- >
201
- <MenuItem
202
- onClick={() => {
203
- editMethod();
204
- }}
205
- data-cy="edit-method-menu-item"
206
- >
207
- <EditIcon />
208
- <Typography sx={styles.menuItemText}>Edit</Typography>
209
- </MenuItem>
210
- <MenuItem
211
- onClick={handleDeleteMethod}
212
- disabled={methodDisabled}
213
- data-cy="delete-method-button"
214
- >
215
- <DeleteIcon />
216
- <Typography sx={styles.menuItemText}>Delete</Typography>
217
- </MenuItem>
218
- </Menu>
219
- <ResourceMenu
220
- anchor={anchor}
221
- openMenu={resourceMenu}
222
- handleClose={handleCloseResourceMenu}
223
- />
224
- </Grid>
225
-
226
- <CardActions>
227
- <Fab
228
- variant="button"
229
- size={"small"}
230
- onClick={handleResourceMenu}
231
- data-cy="resource-menu"
232
- >
233
- <AddIcon />
234
- </Fab>
235
- </CardActions>
236
- </>
237
- ) : (
238
- <BlankTreeMessage item={"API"} />
239
- )}
240
- </Card>
26
+ <SimpleTreeView
27
+ slots={{
28
+ collapseIcon: () => <ArrowIcon down />,
29
+ expandIcon: () => <ArrowIcon right />,
30
+ }}
31
+ expandedItems={expanded}
32
+ onExpandedItemsChange={onExpand}
33
+ selectedItems={selected}
34
+ onSelectedItemsChange={onSelect}
35
+ sx={{ marginTop: "10px" }}
36
+ >
37
+ {treeNodes}
38
+ </SimpleTreeView>
241
39
  );
242
40
  }
243
41
 
244
42
  export const compile = (
245
43
  apiData,
246
- handleContextMenu,
247
- expandList,
248
- rightClickMethod,
249
44
  errors,
250
45
  theme,
251
- select,
252
- handleResourceMenu,
253
- map
46
+ map,
47
+ rightClickMethod = null
254
48
  ) => {
255
- if (apiData.length !== 0) {
256
- const groupedByPath = apiData.reduce((acc, endpoint) => {
257
- const parts = endpoint.path.split("/");
258
- let currentLevel = acc;
259
-
260
- if (endpoint.path === "/") {
261
- if (!currentLevel["/"]) {
262
- currentLevel["/"] = {
263
- methods: [],
264
- children: {},
265
- };
266
- }
267
- currentLevel["/"].methods.push(endpoint);
268
- } else {
269
- currentLevel = currentLevel["/"].children;
270
-
271
- parts.forEach((part, idx, arr) => {
272
- if (idx !== 0) {
273
- const currentPart = "/" + part;
49
+ if (!apiData || apiData.length === 0) return null;
274
50
 
275
- if (!currentLevel[currentPart]) {
276
- currentLevel[currentPart] = {
277
- methods: [],
278
- children: {},
279
- };
280
- }
51
+ const groupedByPath = apiData.reduce((acc, endpoint) => {
52
+ const parts = endpoint.path.split("/");
53
+ let currentLevel = acc;
281
54
 
282
- if (idx === arr.length - 1) {
283
- currentLevel[currentPart].methods.push(endpoint);
284
- } else {
285
- currentLevel = currentLevel[currentPart].children;
286
- }
287
- }
288
- });
289
- }
55
+ if (!acc["/"]) {
56
+ acc["/"] = { methods: [], children: {} };
57
+ }
290
58
 
59
+ if (endpoint.path === "/") {
60
+ acc["/"].methods.push(endpoint);
291
61
  return acc;
292
- }, {});
62
+ }
293
63
 
294
- const renderTree = (data) => {
295
- // eslint-disable-next-line
296
- let resourceHash;
297
- // eslint-disable-next-line
64
+ currentLevel = acc["/"].children;
298
65
 
299
- return Object.keys(data).map((path) => {
300
- const { methods, children } = data[path];
66
+ parts.forEach((part, idx) => {
67
+ if (idx === 0) return;
301
68
 
302
- const methodItems = methods.map((method) => {
303
- const payload = { path: method.path, method: method.method };
304
- const hash = (resourceHash = window.btoa(JSON.stringify(payload)));
305
- map[hash] = payload;
69
+ const currentPart = "/" + part;
306
70
 
307
- const error = errors.find((item) => {
308
- const [errPath, errMethod] = item.file.fileName.split(".", 2);
309
- if (errPath === method.path && errMethod === method.method) {
310
- return item;
311
- } else {
312
- return null;
313
- }
314
- });
71
+ if (!currentLevel[currentPart]) {
72
+ currentLevel[currentPart] = {
73
+ methods: [],
74
+ children: {},
75
+ };
76
+ }
315
77
 
316
- return (
317
- <TreeItem
318
- key={hash}
319
- itemId={hash}
320
- onContextMenu={(event) => handleContextMenu(event, hash)}
321
- sx={{
322
- bgcolor:
323
- hash === rightClickMethod &&
324
- (theme.palette.custom?.apiTreeRightClick ||
325
- theme.palette.action.selected),
326
- }}
327
- label={
328
- <Box
329
- sx={{
330
- display: "flex",
331
- flexDirection: "row",
332
- alignItems: "center",
333
- justifyContent: "space-between",
334
- }}
335
- data-cy={`method-${method.path}${method.method}`}
336
- >
337
- <Box sx={theme.custom?.apiTreeItem}>
338
- <span
339
- style={{
340
- display: "flex",
341
- flexDirection: "row",
342
- alignItems: "center",
343
- justifyContent: "center",
344
- }}
345
- >
346
- {method.method.toUpperCase()}
347
- </span>
348
- </Box>
349
- {error && (
350
- <Tooltip title={error.messageText} placement={"right"}>
351
- <Error sx={{ color: "#8f8f91" }} />
352
- </Tooltip>
353
- )}
354
- </Box>
355
- }
356
- />
357
- );
358
- });
78
+ if (idx === parts.length - 1) {
79
+ currentLevel[currentPart].methods.push(endpoint);
80
+ } else {
81
+ currentLevel = currentLevel[currentPart].children;
82
+ }
83
+ });
359
84
 
360
- const childItems = children ? renderTree(children) : [];
361
- expandList.push(path);
85
+ return acc;
86
+ }, {});
362
87
 
363
- const handleResourceClick = (event) => {
364
- event.stopPropagation();
88
+ const renderTree = (data) => {
89
+ return Object.keys(data).map((path) => {
90
+ const { methods, children } = data[path];
365
91
 
366
- if (methods.length > 0) {
367
- const firstMethod = methods[0];
368
- const payload = {
369
- path: firstMethod.path,
370
- method: firstMethod.method,
371
- };
372
- const hash = window.btoa(JSON.stringify(payload));
373
- select(hash);
374
- }
375
- };
92
+ const methodItems = methods.map((method) => {
93
+ const payload = { path: method.path, method: method.method };
94
+ const hash = window.btoa(JSON.stringify(payload));
95
+ map[hash] = payload;
376
96
 
377
- const handleResourceContextMenu = (event) => {
378
- event.preventDefault();
379
- handleResourceClick(event);
380
- handleResourceMenu(event);
381
- };
97
+ const error = errors.find((item) => {
98
+ const [errPath, errMethod] =
99
+ item?.file?.fileName?.split(".", 2) || [];
100
+ return errPath === method.path && errMethod === method.method;
101
+ });
102
+
103
+ const highlightStyle =
104
+ rightClickMethod === hash
105
+ ? {
106
+ bgcolor: theme?.palette?.custom?.apiTreeRightClick || "#e0e0e0",
107
+ }
108
+ : {};
382
109
 
383
110
  return (
384
111
  <TreeItem
385
- key={path}
386
- itemId={path}
112
+ key={hash}
113
+ itemId={hash}
114
+ sx={highlightStyle}
387
115
  label={
388
- <div
389
- className="path"
390
- onClick={(e) => e.stopPropagation()}
391
- onContextMenu={handleResourceContextMenu}
392
- style={{ cursor: "default" }}
393
- data-cy={`path-${path}`}
116
+ <Box
117
+ sx={{
118
+ display: "flex",
119
+ flexDirection: "row",
120
+ alignItems: "center",
121
+ justifyContent: "space-between",
122
+ }}
123
+ data-cy={`method-${method.path}${method.method}`}
394
124
  >
395
- {path}
396
- </div>
125
+ <Box>
126
+ <span
127
+ style={{
128
+ display: "flex",
129
+ alignItems: "center",
130
+ justifyContent: "center",
131
+ }}
132
+ >
133
+ {method.method.toUpperCase()}
134
+ </span>
135
+ </Box>
136
+
137
+ {error && (
138
+ <Tooltip title={error.messageText} placement="right">
139
+ <Error sx={{ color: "#8f8f91" }} />
140
+ </Tooltip>
141
+ )}
142
+ </Box>
397
143
  }
398
- >
399
- {[...methodItems, ...childItems]}
400
- </TreeItem>
144
+ />
401
145
  );
402
146
  });
403
- };
404
147
 
405
- return renderTree(groupedByPath);
406
- } else {
407
- return null;
408
- }
148
+ const childItems = children ? renderTree(children) : [];
149
+
150
+ return (
151
+ <TreeItem
152
+ key={path}
153
+ itemId={path}
154
+ label={
155
+ <div
156
+ className="path"
157
+ style={{ cursor: "default" }}
158
+ data-cy={`path-${path}`}
159
+ >
160
+ {path}
161
+ </div>
162
+ }
163
+ >
164
+ {[...methodItems, ...childItems]}
165
+ </TreeItem>
166
+ );
167
+ });
168
+ };
169
+
170
+ return renderTree(groupedByPath);
409
171
  };
410
172
 
411
173
  export default APITree;
@@ -1,20 +1,21 @@
1
- import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
2
- import KeyboardArrowLeftIcon from "@mui/icons-material/KeyboardArrowLeft";
3
- import KeyboardArrowRightIcon from "@mui/icons-material/KeyboardArrowRight";
4
- import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
5
1
  import React from "react";
6
2
 
7
- // fill: "#212121", old fill color
3
+ import {
4
+ KeyboardArrowDown,
5
+ KeyboardArrowLeft,
6
+ KeyboardArrowRight,
7
+ KeyboardArrowUp,
8
+ } from "@mui/icons-material";
8
9
 
9
10
  function Arrow({ up, down, right, left }) {
10
11
  return up ? (
11
- <KeyboardArrowUpIcon />
12
+ <KeyboardArrowUp />
12
13
  ) : down ? (
13
- <KeyboardArrowDownIcon />
14
+ <KeyboardArrowDown />
14
15
  ) : right ? (
15
- <KeyboardArrowRightIcon />
16
+ <KeyboardArrowRight />
16
17
  ) : left ? (
17
- <KeyboardArrowLeftIcon />
18
+ <KeyboardArrowLeft />
18
19
  ) : null;
19
20
  }
20
21
 
@@ -1,6 +1,7 @@
1
1
  import FlowNode from "./FlowNode";
2
2
  import { useGraphOperations } from "../hooks/useGraphOperations";
3
3
 
4
+ import { Box, alpha } from "@mui/material";
4
5
  import React, { useMemo, useState } from "react";
5
6
  import { assertLinkedGraph, buildTreeFromLinked } from "../utils/flowUtils";
6
7
 
@@ -62,19 +63,31 @@ export const Flow = ({
62
63
  }, [nodesById, roots]);
63
64
 
64
65
  return (
65
- <FlowNode
66
- node={treeData}
67
- variant={variant}
68
- style={style}
69
- plugin={plugin}
70
- isRoot={true}
71
- nodesById={allNodesById}
72
- onPaste={editable ? handlePaste : undefined}
73
- onCut={editable ? handleCut : undefined}
74
- onConnect={editable ? handleConnect : undefined}
75
- floatingNodes={floatingNodes}
76
- height={height}
77
- />
66
+ <Box
67
+ sx={{
68
+ backgroundImage: (theme) => `
69
+ radial-gradient(
70
+ ${alpha(theme.palette.divider, 0.08)} 1px,
71
+ transparent 1px
72
+ )
73
+ `,
74
+ backgroundSize: "16px 16px",
75
+ }}
76
+ >
77
+ <FlowNode
78
+ node={treeData}
79
+ variant={variant}
80
+ style={style}
81
+ plugin={plugin}
82
+ isRoot={true}
83
+ nodesById={allNodesById}
84
+ onPaste={editable ? handlePaste : undefined}
85
+ onCut={editable ? handleCut : undefined}
86
+ onConnect={editable ? handleConnect : undefined}
87
+ floatingNodes={floatingNodes}
88
+ height={height}
89
+ />
90
+ </Box>
78
91
  );
79
92
  };
80
93
 
@@ -1,8 +1,6 @@
1
- import { Close } from "@mui/icons-material";
2
- import Fullscreen from "@mui/icons-material/Fullscreen";
3
- import FullscreenExit from "@mui/icons-material/FullscreenExit";
4
1
  import React from "react";
5
2
 
3
+ import { Close, Fullscreen, FullscreenExit } from "@mui/icons-material";
6
4
  import {
7
5
  Dialog,
8
6
  DialogActions,
@@ -12,7 +10,7 @@ import {
12
10
  } from "@mui/material";
13
11
  import { storage, useStorage } from "@nucleoidjs/webstorage";
14
12
 
15
- export default function NucDialog({
13
+ function NucDialog({
16
14
  title,
17
15
  minWidth = 600,
18
16
  children,
@@ -106,3 +104,5 @@ export default function NucDialog({
106
104
  </Dialog>
107
105
  );
108
106
  }
107
+
108
+ export default NucDialog;
@@ -1,5 +1,5 @@
1
1
  import { DataGrid } from "@mui/x-data-grid";
2
- import HighlightOffIcon from "@mui/icons-material/HighlightOff";
2
+ import { HighlightOff } from "@mui/icons-material";
3
3
  import React from "react";
4
4
  import TypeMenu from "./TypeMenu";
5
5
  import styles from "./styles";
@@ -100,7 +100,7 @@ const ParamTable = ({ types, params, setParams }) => {
100
100
  onClick={() => removeParam(id)}
101
101
  size="large"
102
102
  >
103
- <HighlightOffIcon />
103
+ <HighlightOff />
104
104
  </IconButton>
105
105
  );
106
106
  },
@@ -1,6 +1,6 @@
1
- import { Alert } from "@mui/material";
2
1
  import React from "react";
3
- import Snackbar from "@mui/material/Snackbar";
2
+
3
+ import { Alert, Snackbar } from "@mui/material";
4
4
 
5
5
  export default function AlertMassage({ message }) {
6
6
  const [open, setOpen] = React.useState(true);
@@ -1,11 +1,14 @@
1
- import Button from "@mui/material/Button";
2
- import Dialog from "@mui/material/Dialog";
3
- import DialogActions from "@mui/material/DialogActions";
4
- import DialogContent from "@mui/material/DialogContent";
5
- import DialogTitle from "@mui/material/DialogTitle";
6
- import { Typography } from "@mui/material";
7
1
  import { forwardRef } from "react";
8
2
 
3
+ import {
4
+ Button,
5
+ Dialog,
6
+ DialogActions,
7
+ DialogContent,
8
+ DialogTitle,
9
+ Typography,
10
+ } from "@mui/material";
11
+
9
12
  const DeleteResourceDialog = forwardRef(({ setOpen, deleteResource }, ref) => {
10
13
  const resource = ref.current;
11
14
 
@@ -1,14 +1,11 @@
1
1
  import AlertMassage from "./AlertMassage";
2
- import DeleteIcon from "@mui/icons-material/Delete";
3
2
  import DeleteResourceDialog from "./DeleteResourceDialog";
4
- import Fade from "@mui/material/Fade";
5
- import HttpIcon from "@mui/icons-material/Http";
6
3
  import React from "react";
7
- import SourceIcon from "@mui/icons-material/Source";
8
4
  import styles from "./styles";
9
5
  import { useRef } from "react";
10
6
 
11
- import { Divider, Menu, MenuItem, Typography } from "@mui/material";
7
+ import { Delete, Http, Source } from "@mui/icons-material";
8
+ import { Divider, Fade, Menu, MenuItem, Typography } from "@mui/material";
12
9
  import { publish, useEvent } from "@nucleoidai/react-event";
13
10
 
14
11
  const ResourceMenu = (props) => {
@@ -130,7 +127,7 @@ const ResourceMenu = (props) => {
130
127
  }}
131
128
  >
132
129
  <MenuItem onClick={addResource} data-cy="add-resource">
133
- <SourceIcon />
130
+ <Source />
134
131
  <Typography sx={styles.menuItemText}>Resource</Typography>
135
132
  </MenuItem>
136
133
  <MenuItem
@@ -138,7 +135,7 @@ const ResourceMenu = (props) => {
138
135
  disabled={methodDisabled}
139
136
  data-cy="add-method"
140
137
  >
141
- <HttpIcon />
138
+ <Http />
142
139
  <Typography sx={styles.menuItemText}>Method</Typography>
143
140
  </MenuItem>
144
141
  <Divider />
@@ -147,7 +144,7 @@ const ResourceMenu = (props) => {
147
144
  disabled={selectedAPI?.path === "/"}
148
145
  data-cy="delete-resource"
149
146
  >
150
- <DeleteIcon />
147
+ <Delete />
151
148
  <Typography sx={styles.menuItemText}>Delete</Typography>
152
149
  </MenuItem>
153
150
  </Menu>
@@ -1,11 +1,10 @@
1
- import ChevronRightIcon from "@mui/icons-material/ChevronRight";
2
- import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
1
+ import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
2
+ import { TreeItem } from "@mui/x-tree-view/TreeItem";
3
3
  import { v4 as uuidv4 } from "uuid";
4
4
 
5
5
  import { Box, Typography } from "@mui/material";
6
+ import { ChevronRight, ExpandMore } from "@mui/icons-material";
6
7
  import React, { useEffect, useState } from "react";
7
- import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
8
- import { TreeItem } from "@mui/x-tree-view/TreeItem";
9
8
 
10
9
  const Schema = ({ initialData = {}, customTypes = [] }) => {
11
10
  const [schemaData, setSchemaData] = useState({});
@@ -159,8 +158,8 @@ const Schema = ({ initialData = {}, customTypes = [] }) => {
159
158
  return (
160
159
  <SimpleTreeView
161
160
  slots={{
162
- collapseIcon: () => <ExpandMoreIcon />,
163
- expandIcon: () => <ChevronRightIcon />,
161
+ collapseIcon: () => <ExpandMore />,
162
+ expandIcon: () => <ChevronRight />,
164
163
  }}
165
164
  defaultExpandedItems={["1"]}
166
165
  sx={{
@@ -1,15 +1,17 @@
1
- import AddCircleOutlineIcon from "@mui/icons-material/AddCircleOutline";
2
- import ChevronRightIcon from "@mui/icons-material/ChevronRight";
3
- import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
4
1
  import IconButton from "@mui/material/IconButton";
5
- import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutline";
6
2
  import SchemaPropertyEditor from "./SchemaPropertyEditor";
3
+ import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
4
+ import { TreeItem } from "@mui/x-tree-view/TreeItem";
7
5
  import { v4 as uuidv4 } from "uuid";
8
6
 
7
+ import {
8
+ AddCircleOutline,
9
+ ChevronRight,
10
+ ExpandMore,
11
+ RemoveCircleOutline,
12
+ } from "@mui/icons-material";
9
13
  import { Box, Typography } from "@mui/material";
10
14
  import React, { forwardRef, useEffect, useState } from "react";
11
- import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
12
- import { TreeItem } from "@mui/x-tree-view/TreeItem";
13
15
  import { addProperty, changeProperty, removeProperty } from "./SchemaUtils";
14
16
 
15
17
  const SchemaEditor = forwardRef(
@@ -109,7 +111,7 @@ const SchemaEditor = forwardRef(
109
111
  }}
110
112
  data-cy={`add-property-button-${node.id}`}
111
113
  >
112
- <AddCircleOutlineIcon fontSize="small" />
114
+ <AddCircleOutline fontSize="small" />
113
115
  </IconButton>
114
116
  )}
115
117
  </Box>
@@ -128,7 +130,7 @@ const SchemaEditor = forwardRef(
128
130
  color: (theme) => theme.palette.grey[600],
129
131
  }}
130
132
  >
131
- <RemoveCircleOutlineIcon fontSize="small" />
133
+ <RemoveCircleOutline fontSize="small" />
132
134
  </IconButton>
133
135
  )}
134
136
  </Box>
@@ -212,8 +214,8 @@ const SchemaEditor = forwardRef(
212
214
  return (
213
215
  <SimpleTreeView
214
216
  slots={{
215
- collapseIcon: () => <ExpandMoreIcon data-cy="collapse-icon" />,
216
- expandIcon: () => <ChevronRightIcon data-cy="expand-icon" />,
217
+ collapseIcon: () => <ExpandMore data-cy="collapse-icon" />,
218
+ expandIcon: () => <ChevronRight data-cy="expand-icon" />,
217
219
  }}
218
220
  defaultExpandedItems={["1"]}
219
221
  sx={{
package/src/lib/index.js CHANGED
@@ -48,3 +48,4 @@ export { default as ResourceMenu } from "./ResourceMenu";
48
48
  export { default as Schema } from "./Schema";
49
49
  export { default as SchemaEditor } from "./SchemaEditor";
50
50
  export { default as ToggleableMenu } from "./ToggleableMenu";
51
+ export { default as APIBody } from "./NewApiBody/NewAPIBody";
package/vite/vite.js CHANGED
@@ -36,7 +36,14 @@ async function vite() {
36
36
  esbuildOptions: {
37
37
  jsx: "automatic",
38
38
  },
39
- include: ["@mui/material", "@nucleoidai/platform", "axios-auth-refresh"],
39
+ include: [
40
+ "@mui/material",
41
+ "@nucleoidai/platform",
42
+ "axios-auth-refresh",
43
+ "@emotion/react",
44
+ "@emotion/styled",
45
+ "@emotion/css",
46
+ ],
40
47
  },
41
48
  resolve: {
42
49
  alias: [
@@ -70,11 +77,15 @@ async function vite() {
70
77
  }
71
78
 
72
79
  if (id.includes("node_modules")) {
73
- return id
80
+ const packageName = id
74
81
  .toString()
75
82
  .split("node_modules/")[1]
76
83
  .split("/")[0]
77
84
  .toString();
85
+
86
+ if (packageName === "@emotion") return undefined;
87
+
88
+ return packageName;
78
89
  }
79
90
  },
80
91
  },