@zac-apps/commons 2.0.3 → 2.2.0-beta.1

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -733
  2. package/package.json +62 -61
package/dist/index.js CHANGED
@@ -1,733 +1 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import * as React from 'react';
3
- import React__default, { useState, useEffect } from 'react';
4
- import Snackbar from '@mui/material/Snackbar';
5
- import MuiAlert from '@mui/material/Alert';
6
- import { jsx, jsxs } from 'react/jsx-runtime';
7
- import Grid from '@mui/material/Grid';
8
- import Accordion from '@mui/material/Accordion';
9
- import AccordionSummary from '@mui/material/AccordionSummary';
10
- import AccordionDetails from '@mui/material/AccordionDetails';
11
- import Typography from '@mui/material/Typography';
12
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
13
- import { createTheme, ThemeProvider, CssBaseline } from '@mui/material';
14
- import { green, yellow, pink, lightGreen, red } from '@mui/material/colors';
15
- import Link, { Link as Link$2 } from 'next/link';
16
- import Link$1 from '@mui/material/Link';
17
- import Box from '@mui/material/Box';
18
- import AppBar from '@mui/material/AppBar';
19
- import Toolbar from '@mui/material/Toolbar';
20
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
21
- import { usePathname, useRouter } from 'next/navigation';
22
- import IconButton from '@mui/material/IconButton';
23
- import MenuItem from '@mui/material/MenuItem';
24
- import Menu from '@mui/material/Menu';
25
- import Divider from '@mui/material/Divider';
26
- import MenuIcon from '@mui/icons-material/Menu';
27
- import MenuOpenIcon from '@mui/icons-material/MenuOpen';
28
- import Table from '@mui/material/Table';
29
- import TableContainer from '@mui/material/TableContainer';
30
- import Paper from '@mui/material/Paper';
31
- import TextField from '@mui/material/TextField';
32
- import InputAdornment from '@mui/material/InputAdornment';
33
- import CircularProgress from '@mui/material/CircularProgress';
34
- import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
35
- import ToggleButton from '@mui/material/ToggleButton';
36
- import Image from 'next/image';
37
- import Button from '@mui/material/Button';
38
- import { styled } from '@mui/material/styles';
39
- import TableCell, { tableCellClasses } from '@mui/material/TableCell';
40
- import useMediaQuery from '@mui/material/useMediaQuery';
41
- import Drawer from '@mui/material/Drawer';
42
- import List from '@mui/material/List';
43
- import ListItem from '@mui/material/ListItem';
44
- import ManageSearchIcon from '@mui/icons-material/ManageSearch';
45
- import CloseIcon from '@mui/icons-material/Close';
46
-
47
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
48
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
49
- var Alert = /*#__PURE__*/React__default.forwardRef(function Alert(props, ref) {
50
- return /*#__PURE__*/jsx(MuiAlert, _objectSpread({
51
- elevation: 6,
52
- ref: ref,
53
- variant: "filled"
54
- }, props));
55
- });
56
- function ErrorAlert(_ref) {
57
- var alert = _ref.alert,
58
- SetAlert = _ref.SetAlert,
59
- message = _ref.message;
60
- var handleClose = function handleClose(event, reason) {
61
- if (reason === "clickaway") {
62
- return;
63
- }
64
- SetAlert(false);
65
- };
66
- return /*#__PURE__*/jsx(Snackbar, {
67
- open: alert,
68
- autoHideDuration: 3000,
69
- onClose: handleClose,
70
- children: /*#__PURE__*/jsx(Alert, {
71
- severity: "error",
72
- onClose: handleClose,
73
- sx: {
74
- width: "100%"
75
- },
76
- children: message
77
- })
78
- });
79
- }
80
-
81
- var AppTheme = createTheme({
82
- palette: {
83
- primary: {
84
- main: "#c1002a"
85
- },
86
- secondary: {
87
- main: "#636363"
88
- },
89
- error: {
90
- main: pink[900]
91
- },
92
- running: {
93
- main: red[900],
94
- contrastText: "#fff"
95
- },
96
- available: {
97
- main: lightGreen[200],
98
- contrastText: "#000"
99
- },
100
- info: {
101
- main: pink[100]
102
- },
103
- success: {
104
- main: yellow[500]
105
- },
106
- empty: {
107
- main: green[500],
108
- contrastText: "#000"
109
- }
110
- }
111
- });
112
-
113
- function AppCard(props) {
114
- return /*#__PURE__*/jsx(Grid, {
115
- size: {
116
- xs: props.xs || props.size || 12,
117
- lg: props.lg || props.size || 6,
118
- md: props.md || 12
119
- },
120
- children: /*#__PURE__*/jsxs(Accordion, {
121
- defaultExpanded: !props.collapsed,
122
- square: false,
123
- elevation: 2,
124
- children: [/*#__PURE__*/jsx(AccordionSummary, {
125
- expandIcon: /*#__PURE__*/jsx(ExpandMoreIcon, {}),
126
- sx: {
127
- backgroundColor: AppTheme.palette.divider
128
- },
129
- children: /*#__PURE__*/jsx(Typography, {
130
- variant: "h5",
131
- children: props.title
132
- })
133
- }), /*#__PURE__*/jsx(AccordionDetails, {
134
- children: props.children
135
- })]
136
- })
137
- });
138
- }
139
-
140
- function AppGrid(_ref) {
141
- var children = _ref.children,
142
- reverse = _ref.reverse;
143
- var wrapper = reverse ? "wrap-reverse" : "wrap";
144
- return /*#__PURE__*/jsx(Grid, {
145
- container: true,
146
- spacing: 2,
147
- sx: {
148
- display: "flex",
149
- flexGrow: 1,
150
- justifyContent: "center",
151
- flexWrap: wrapper
152
- },
153
- children: children
154
- });
155
- }
156
-
157
- function AppMenu(_ref) {
158
- var title = _ref.title,
159
- iconUrl = _ref.iconUrl,
160
- iconAlt = _ref.iconAlt,
161
- children = _ref.children;
162
- if (!title) {
163
- title = "JGU-ZAC Apps";
164
- }
165
- return /*#__PURE__*/jsx(AppBar, {
166
- position: "sticky",
167
- children: /*#__PURE__*/jsxs(Toolbar, {
168
- children: [children, "\u2003", /*#__PURE__*/jsx(Typography, {
169
- variant: "h6",
170
- component: "div",
171
- sx: {
172
- flexGrow: 1
173
- },
174
- children: title
175
- }), iconUrl ? /*#__PURE__*/jsx("img", {
176
- src: iconUrl,
177
- width: "48px",
178
- alt: iconAlt
179
- }) : null]
180
- })
181
- });
182
- }
183
-
184
- function MenuButton(_ref) {
185
- var anchorEl = _ref.anchorEl;
186
- if (anchorEl) {
187
- return /*#__PURE__*/jsx(MenuOpenIcon, {});
188
- } else {
189
- return /*#__PURE__*/jsx(MenuIcon, {});
190
- }
191
- }
192
-
193
- function NextListMenu(_ref) {
194
- var availApps = _ref.availApps,
195
- start = _ref.start,
196
- basePath = _ref.basePath;
197
- var _React$useState = React.useState(null),
198
- _React$useState2 = _slicedToArray(_React$useState, 2),
199
- anchorEl = _React$useState2[0],
200
- setAnchorEl = _React$useState2[1];
201
- var open = Boolean(anchorEl);
202
- var handleClickListItem = function handleClickListItem(event) {
203
- setAnchorEl(event.currentTarget);
204
- };
205
- var handleClose = function handleClose() {
206
- setAnchorEl(null);
207
- };
208
- var pathname = usePathname();
209
- if (!basePath || basePath === null) {
210
- basePath = "/";
211
- }
212
- function StartEntry() {
213
- if (start) {
214
- return /*#__PURE__*/jsxs(React.Fragment, {
215
- children: [/*#__PURE__*/jsx(MenuItem, {
216
- component: Link,
217
- href: basePath,
218
- selected: pathname === basePath,
219
- onClick: handleClose,
220
- children: "Start"
221
- }), /*#__PURE__*/jsx(Divider, {})]
222
- });
223
- } else return null;
224
- }
225
- return /*#__PURE__*/jsxs("div", {
226
- children: [/*#__PURE__*/jsx(IconButton, {
227
- size: "large",
228
- edge: "start",
229
- color: "inherit",
230
- "aria-label": "menu",
231
- sx: {
232
- mr: 2
233
- },
234
- onClick: handleClickListItem,
235
- children: /*#__PURE__*/jsx(MenuButton, {
236
- anchorEl: anchorEl
237
- })
238
- }), /*#__PURE__*/jsxs(Menu, {
239
- id: "lock-menu",
240
- anchorEl: anchorEl,
241
- open: open,
242
- onClose: handleClose,
243
- slotProps: {
244
- "aria-labelledby": "lock-button",
245
- role: "listbox"
246
- },
247
- children: [/*#__PURE__*/jsx(StartEntry, {}), availApps.map(function (option, index) {
248
- return /*#__PURE__*/jsx(MenuItem, {
249
- component: Link,
250
- href: option.path,
251
- selected: pathname === option.path + "/",
252
- onClick: handleClose,
253
- children: option.name
254
- }, option.name);
255
- })]
256
- })]
257
- });
258
- }
259
-
260
- function Footer(_ref) {
261
- var footerContent = _ref.footerContent;
262
- return /*#__PURE__*/jsx(React__default.Fragment, {
263
- children: /*#__PURE__*/jsx(Grid, {
264
- sx: {
265
- p: 1,
266
- backgroundColor: AppTheme.palette.divider,
267
- display: "flex",
268
- flexDirection: "row",
269
- justifyContent: "center",
270
- alignItems: "center",
271
- minHeight: 64
272
- },
273
- children: /*#__PURE__*/jsx(Grid, {
274
- children: /*#__PURE__*/jsx(Typography, {
275
- variant: "body2",
276
- children: footerContent
277
- })
278
- })
279
- })
280
- });
281
- }
282
-
283
- function AppWrapper(_ref) {
284
- var title = _ref.title,
285
- availApps = _ref.availApps,
286
- footerContent = _ref.footerContent,
287
- children = _ref.children,
288
- basePath = _ref.basePath,
289
- menu = _ref.menu,
290
- iconUrl = _ref.iconUrl,
291
- iconAlt = _ref.iconAlt;
292
- if (!basePath || basePath === null) {
293
- basePath = "/";
294
- }
295
- if (!footerContent || footerContent === null) {
296
- footerContent = "";
297
- }
298
- return /*#__PURE__*/jsxs(React__default.Fragment, {
299
- children: [/*#__PURE__*/jsx(AppMenu, {
300
- title: /*#__PURE__*/jsx(Link$1, {
301
- component: Link$2,
302
- href: basePath,
303
- sx: {
304
- color: AppTheme.palette.primary.contrastText
305
- },
306
- children: title
307
- }),
308
- iconUrl: iconUrl,
309
- iconAlt: iconAlt,
310
- children: menu ? /*#__PURE__*/jsx(NextListMenu, {
311
- availApps: availApps,
312
- basePath: basePath,
313
- start: true
314
- }) : null
315
- }), /*#__PURE__*/jsx(Box, {
316
- sx: {
317
- p: 3,
318
- minHeight: "calc(100% - 128px)",
319
- display: "flex",
320
- justifyContent: "center"
321
- },
322
- children: children
323
- }), /*#__PURE__*/jsx(Footer, {
324
- footerContent: footerContent
325
- })]
326
- });
327
- }
328
-
329
- function AppRoot(_ref) {
330
- var title = _ref.title,
331
- availApps = _ref.availApps,
332
- footerContent = _ref.footerContent,
333
- basePath = _ref.basePath,
334
- iconUrl = _ref.iconUrl,
335
- iconAlt = _ref.iconAlt,
336
- children = _ref.children;
337
- return /*#__PURE__*/jsxs(ThemeProvider, {
338
- theme: AppTheme,
339
- children: [/*#__PURE__*/jsx(CssBaseline, {}), /*#__PURE__*/jsx(AppWrapper, {
340
- title: title,
341
- availApps: availApps,
342
- footerContent: footerContent,
343
- basePath: basePath,
344
- iconUrl: iconUrl,
345
- iconAlt: iconAlt,
346
- menu: true,
347
- children: children
348
- })]
349
- });
350
- }
351
-
352
- function AppTable(_ref) {
353
- var children = _ref.children;
354
- return /*#__PURE__*/jsx(TableContainer, {
355
- component: Paper,
356
- children: /*#__PURE__*/jsx(Table, {
357
- size: "small",
358
- "aria-label": "a dense table",
359
- children: children
360
- })
361
- });
362
- }
363
-
364
- function DivTitle(_ref) {
365
- var children = _ref.children;
366
- return /*#__PURE__*/jsx(Divider, {
367
- textAlign: "left",
368
- children: children
369
- });
370
- }
371
-
372
- function NumField(_ref) {
373
- var input = _ref.input,
374
- SetInput = _ref.SetInput,
375
- error = _ref.error,
376
- SetError = _ref.SetError,
377
- minValue = _ref.minValue,
378
- maxValue = _ref.maxValue,
379
- adornment = _ref.adornment,
380
- label = _ref.label,
381
- helperText = _ref.helperText,
382
- size = _ref.size;
383
- var _useState = useState(""),
384
- _useState2 = _slicedToArray(_useState, 2),
385
- errorMessage = _useState2[0],
386
- SetErrorMessage = _useState2[1];
387
- var _useState3 = useState(false),
388
- _useState4 = _slicedToArray(_useState3, 2),
389
- alert = _useState4[0],
390
- SetAlert = _useState4[1];
391
- var sx = {};
392
- if (size === "small") {
393
- sx = {
394
- maxWidth: 75
395
- };
396
- }
397
- function handleEntry(e) {
398
- var errorFound = false;
399
- var inputVal = e.target.value;
400
- if (!inputVal.match(/[0-9-]*/)[0] || inputVal.match(/[0-9-]*/)[0] !== inputVal) {
401
- errorFound = true;
402
- SetErrorMessage("Input is not numerical.");
403
- }
404
- if (inputVal > maxValue || inputVal < minValue) {
405
- errorFound = true;
406
- SetErrorMessage("Input is outside allowed boundaries.");
407
- }
408
- SetInput(inputVal);
409
- SetError(errorFound);
410
- SetAlert(errorFound);
411
- }
412
- return /*#__PURE__*/jsxs(React__default.Fragment, {
413
- children: [/*#__PURE__*/jsx(TextField, {
414
- size: "small",
415
- sx: sx,
416
- onChange: function onChange(e) {
417
- return handleEntry(e);
418
- },
419
- value: input,
420
- error: error,
421
- label: label,
422
- helperText: helperText,
423
- inputProps: {
424
- inputMode: "numeric"
425
- },
426
- InputProps: {
427
- endAdornment: /*#__PURE__*/jsx(InputAdornment, {
428
- position: "end",
429
- children: adornment
430
- })
431
- }
432
- }), /*#__PURE__*/jsx(ErrorAlert, {
433
- alert: alert,
434
- SetAlert: SetAlert,
435
- message: errorMessage
436
- })]
437
- });
438
- }
439
-
440
- function Percentage(number) {
441
- var resultStr = number.toString() + " %";
442
- return resultStr;
443
- }
444
-
445
- function Progress() {
446
- return /*#__PURE__*/jsx(Grid, {
447
- container: true,
448
- sx: {
449
- display: "flex",
450
- flexGrow: 1,
451
- justifyContent: "center",
452
- alignContent: "center"
453
- },
454
- children: /*#__PURE__*/jsx(CircularProgress, {})
455
- });
456
- }
457
-
458
- function PublicFetch(_ref) {
459
- var url = _ref.url,
460
- SetState = _ref.SetState,
461
- SetMetaData = _ref.SetMetaData,
462
- reload = _ref.reload,
463
- SetReload = _ref.SetReload;
464
- _ref.error;
465
- var SetError = _ref.SetError;
466
- var _useState = useState(),
467
- _useState2 = _slicedToArray(_useState, 2),
468
- internal = _useState2[0],
469
- SetInternal = _useState2[1];
470
- var _useState3 = useState(),
471
- _useState4 = _slicedToArray(_useState3, 2);
472
- _useState4[0];
473
- var SetInternalError = _useState4[1];
474
- var state = null;
475
- if (!SetState) {
476
- SetState = SetInternal;
477
- state = internal;
478
- }
479
- if (!SetError) {
480
- SetError = SetInternalError;
481
- }
482
- if (!reload) {
483
- reload = false;
484
- }
485
- useEffect(function () {
486
- try {
487
- fetch(url, {
488
- headers: {
489
- "Content-Type": "application/json",
490
- Accept: "application/json"
491
- }
492
- }).then(function (response) {
493
- if (SetMetaData) {
494
- SetMetaData(response.headers);
495
- }
496
- console.log(response);
497
- if (!response.ok) {
498
- SetError({
499
- error: response.statusText
500
- });
501
- return {
502
- error: response.statusText
503
- };
504
- } else {
505
- return response.json();
506
- }
507
- }).then(function (json) {
508
- console.log(json);
509
- SetState(json);
510
- });
511
- } catch (e) {
512
- console.log(e);
513
- SetError({
514
- error: e
515
- });
516
- }
517
- if (SetReload) {
518
- SetReload(false);
519
- }
520
- }, [reload]);
521
- return state;
522
- }
523
-
524
- function RespGrid(_ref) {
525
- var children = _ref.children,
526
- matches = _ref.matches,
527
- justify = _ref.justify;
528
- if (matches) {
529
- return /*#__PURE__*/jsx(Grid, {
530
- sx: {
531
- display: "flex",
532
- justifyContent: justify,
533
- alignItems: "center"
534
- },
535
- children: children
536
- });
537
- } else {
538
- return /*#__PURE__*/jsx(Grid, {
539
- sx: {
540
- display: "flex",
541
- flexDirection: "column",
542
- justifyContent: "center",
543
- alignItems: "center"
544
- },
545
- children: children
546
- });
547
- }
548
- }
549
-
550
- function SpecSwitch(_ref) {
551
- var listmode = _ref.listmode,
552
- setup = _ref.setup,
553
- spec = _ref.spec,
554
- SetSpec = _ref.SetSpec,
555
- SetFilter = _ref.SetFilter,
556
- routerActive = _ref.routerActive;
557
- var router = routerActive ? useRouter() : null;
558
- var pathname = routerActive ? usePathname() : null;
559
- return /*#__PURE__*/jsx(React__default.Fragment, {
560
- children: /*#__PURE__*/jsx(Grid, {
561
- children: /*#__PURE__*/jsx(ToggleButtonGroup, {
562
- value: spec,
563
- exclusive: true,
564
- color: "primary",
565
- onChange: function onChange(event, value) {
566
- if (value !== null) {
567
- SetSpec(value);
568
- SetFilter ? SetFilter({}) : null;
569
- routerActive ? router.push(pathname + "?spec=" + value + "&mode=" + listmode) : null;
570
- }
571
- },
572
- size: "small",
573
- children: Object.keys(setup).map(function (entry) {
574
- return /*#__PURE__*/jsx(ToggleButton, {
575
- value: entry,
576
- children: entry
577
- }, "spec_" + entry);
578
- })
579
- })
580
- })
581
- });
582
- }
583
-
584
- function Start(_ref) {
585
- var availApps = _ref.availApps;
586
- return /*#__PURE__*/jsx(Grid, {
587
- children: /*#__PURE__*/jsxs(AppCard, {
588
- title: "Welcome to ZAC Apps",
589
- xs: 12,
590
- lg: 8,
591
- children: [/*#__PURE__*/jsx("p", {
592
- children: "Select an app to get started."
593
- }), /*#__PURE__*/jsx(Grid, {
594
- container: true,
595
- sx: {
596
- display: "flex",
597
- flexWrap: "wrap",
598
- justifyContent: "center"
599
- },
600
- children: availApps.map(function (app) {
601
- return /*#__PURE__*/jsxs(Button, {
602
- sx: {
603
- m: 5,
604
- minWidth: 250,
605
- display: "flex",
606
- flexDirection: "column"
607
- },
608
- variant: "outlined",
609
- component: Link$2,
610
- href: app.path,
611
- children: [/*#__PURE__*/jsx("p", {
612
- children: /*#__PURE__*/jsx(Image, {
613
- src: app.icon,
614
- alt: app.name,
615
- height: 100
616
- })
617
- }), /*#__PURE__*/jsx("p", {
618
- children: app.name
619
- })]
620
- }, "button_" + app.path);
621
- })
622
- })]
623
- })
624
- });
625
- }
626
-
627
- var TableHeadCell = styled(TableCell)(function (_ref) {
628
- var theme = _ref.theme;
629
- return _defineProperty(_defineProperty({}, "&.".concat(tableCellClasses.head), {
630
- backgroundColor: theme.palette.grey[300]
631
- }), "&.".concat(tableCellClasses.body), {
632
- fontSize: 14
633
- });
634
- });
635
-
636
- function useFetch(_ref) {
637
- var url = _ref.url,
638
- reload = _ref.reload,
639
- SetReload = _ref.SetReload;
640
- // Define states for data and metadata
641
-
642
- var _useState = useState(),
643
- _useState2 = _slicedToArray(_useState, 2),
644
- data = _useState2[0],
645
- SetData = _useState2[1];
646
- var _useState3 = useState(),
647
- _useState4 = _slicedToArray(_useState3, 2),
648
- metadata = _useState4[0],
649
- SetMetadata = _useState4[1];
650
-
651
- // Fetch data from url
652
-
653
- useEffect(function () {
654
- fetch(url, {
655
- headers: {
656
- "Content-Type": "application/json",
657
- Accept: "application/json"
658
- }
659
- }).then(function (response) {
660
- SetMetadata(response.headers);
661
- console.log(response);
662
- return response.json();
663
- }).then(function (json) {
664
- console.log(json);
665
- SetData(json);
666
- });
667
- if (reload) {
668
- SetReload(false); // Reset reload state
669
- }
670
- }, [reload]); // Fetch is triggered by reload state
671
-
672
- // Return data and metadata as object
673
-
674
- var internal = {
675
- data: data,
676
- metadata: metadata
677
- };
678
- return internal;
679
- }
680
-
681
- function AppDrawer(_ref) {
682
- var children = _ref.children;
683
- var matches = useMediaQuery(AppTheme.breakpoints.up("lg"));
684
- var _useState = useState(false),
685
- _useState2 = _slicedToArray(_useState, 2),
686
- open = _useState2[0],
687
- SetOpen = _useState2[1];
688
- var toggleDrawer = function toggleDrawer(state) {
689
- return function (event) {
690
- if (event.type === "keydown" && (event.key === "Tab" || event.key === "Shift")) {
691
- return;
692
- }
693
- SetOpen(state);
694
- };
695
- };
696
- var list = function list() {
697
- return /*#__PURE__*/jsx(Box, {
698
- role: "presentation",
699
- width: matches ? "420px" : "100%",
700
- children: /*#__PURE__*/jsxs(List, {
701
- children: [/*#__PURE__*/jsx(ListItem, {
702
- sx: {
703
- justifyContent: "right"
704
- },
705
- children: /*#__PURE__*/jsx(IconButton, {
706
- onClick: toggleDrawer(false),
707
- children: /*#__PURE__*/jsx(CloseIcon, {})
708
- })
709
- }), /*#__PURE__*/jsx(Divider, {}), children]
710
- })
711
- });
712
- };
713
- return /*#__PURE__*/jsxs(React__default.Fragment, {
714
- children: [/*#__PURE__*/jsx(Button, {
715
- variant: "outlined",
716
- onClick: toggleDrawer(true),
717
- startIcon: /*#__PURE__*/jsx(ManageSearchIcon, {
718
- fontSize: "inherit"
719
- }),
720
- children: "Search/Filter"
721
- }), /*#__PURE__*/jsx(Drawer, {
722
- anchor: "left",
723
- open: open,
724
- onClose: toggleDrawer(false),
725
- sx: {
726
- maxWidth: "350px"
727
- },
728
- children: list()
729
- })]
730
- });
731
- }
732
-
733
- export { AppCard, AppDrawer, AppGrid, AppMenu, AppRoot, AppTable, AppTheme, AppWrapper, DivTitle, ErrorAlert, Footer, MenuButton, NextListMenu, NumField, Percentage, Progress, PublicFetch, RespGrid, SpecSwitch, Start, TableHeadCell, useFetch };
1
+ import e from"@babel/runtime/helpers/objectWithoutProperties";import r from"@babel/runtime/helpers/defineProperty";import*as t from"react";import n,{useState as i,useEffect as o}from"react";import a from"@mui/material/Snackbar";import l from"@mui/material/Alert";import{jsx as c,jsxs as m}from"react/jsx-runtime";import u from"@mui/material/Grid";import p from"@mui/material/Accordion";import s from"@mui/material/AccordionSummary";import f from"@mui/material/AccordionDetails";import d from"@mui/material/Typography";import h from"@mui/icons-material/ExpandMore";import{createTheme as y,ThemeProvider as x,CssBaseline as b}from"@mui/material";import{green as g,yellow as v,pink as j,lightGreen as C,red as O}from"@mui/material/colors";import A,{Link as P}from"next/link";import w from"@mui/material/Link";import S from"@mui/material/Box";import k from"@mui/material/AppBar";import T from"@mui/material/Toolbar";import D from"@babel/runtime/helpers/slicedToArray";import{usePathname as I,useRouter as E}from"next/navigation";import z from"@mui/material/IconButton";import F from"@mui/material/MenuItem";import M from"@mui/material/Menu";import B from"@mui/material/Divider";import W from"@mui/icons-material/Menu";import G from"@mui/icons-material/MenuOpen";import U from"@mui/material/Table";import H from"@mui/material/TableContainer";import L from"@mui/material/Paper";import R from"@mui/material/TextField";import V from"@mui/material/InputAdornment";import Z from"@mui/material/CircularProgress";import _ from"@mui/material/ToggleButtonGroup";import q from"@mui/material/ToggleButton";import J from"next/image";import Q from"@mui/material/Button";import{styled as K}from"@mui/material/styles";import N,{tableCellClasses as X}from"@mui/material/TableCell";import Y from"@mui/material/useMediaQuery";import $ from"@mui/material/Drawer";import ee from"@mui/material/List";import re from"@mui/material/ListItem";import te from"@mui/icons-material/ManageSearch";import ne from"@mui/icons-material/Close";var ie=["alert","setAlert","message"];function oe(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}var ae=n.forwardRef(function(e,t){return c(l,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?oe(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}({elevation:6,ref:t,variant:"filled"},e))});function le(r){var t=r.alert,n=r.setAlert,i=r.message,o=e(r,ie),l=o.autoHideDuration||3e3,m=o.severity||"error",u=o.sx||{width:"100%"},p=function(e,r){"clickaway"!==r&&n(!1)};return c(a,{open:t,autoHideDuration:l,onClose:p,children:c(ae,{severity:m,onClose:p,sx:u,children:i})})}var ce=y({palette:{primary:{main:"#c1002a"},secondary:{main:"#636363"},error:{main:j[900]},running:{main:O[900],contrastText:"#fff"},available:{main:C[200],contrastText:"#000"},info:{main:j[100]},success:{main:v[500]},empty:{main:g[500],contrastText:"#000"}}});function me(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?me(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):me(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pe(e){var r=e.sx||{};return c(u,{size:{xs:e.xs||e.size||12,lg:e.lg||e.size||6,md:e.md||12},sx:ue({},r),children:m(p,{defaultExpanded:!e.collapsed,square:!1,elevation:2,children:[c(s,{expandIcon:c(h,{}),sx:{backgroundColor:ce.palette.divider},children:c(d,{variant:"h5",children:e.title})}),c(f,{children:e.children})]})})}function se(e){var r=e.children,t=e.reverse;return c(u,{container:!0,spacing:2,sx:{display:"flex",flexGrow:1,justifyContent:"center",flexWrap:t?"wrap-reverse":"wrap"},children:r})}function fe(e){var r=e.title,t=e.iconUrl,n=e.iconAlt,i=e.children;return r||(r="JGU-ZAC Apps"),c(k,{position:"sticky",children:m(T,{children:[i," ",c(d,{variant:"h6",component:"div",sx:{flexGrow:1},children:r}),t?c("img",{src:t,width:"48px",alt:n}):null]})})}function de(e){var r=e.anchorEl;return c(r?G:W,{})}function he(e){var r=e.availApps,n=e.start,i=e.basePath,o=t.useState(null),a=D(o,2),l=a[0],u=a[1],p=Boolean(l),s=function(){u(null)},f=I();function d(){return n?m(t.Fragment,{children:[c(F,{component:A,href:i,selected:f===i,onClick:s,children:"Start"}),c(B,{})]}):null}return i&&null!==i||(i="/"),m("div",{children:[c(z,{size:"large",edge:"start",color:"inherit","aria-label":"menu",sx:{mr:2},onClick:function(e){u(e.currentTarget)},children:c(de,{anchorEl:l})}),m(M,{id:"lock-menu",anchorEl:l,open:p,onClose:s,slotProps:{"aria-labelledby":"lock-button",role:"listbox"},children:[c(d,{}),r.map(function(e,r){return c(F,{component:A,href:e.path,selected:f===e.path+"/",onClick:s,children:e.name},e.name)})]})]})}function ye(e){var r=e.footerContent;return c(n.Fragment,{children:c(u,{sx:{p:1,backgroundColor:ce.palette.divider,display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",minHeight:64},children:c(u,{children:c(d,{variant:"body2",children:r})})})})}function xe(e){var r=e.title,t=e.availApps,i=e.footerContent,o=e.children,a=e.basePath,l=e.menu,u=e.iconUrl,p=e.iconAlt;return a&&null!==a||(a="/"),i&&null!==i||(i=""),m(n.Fragment,{children:[c(fe,{title:c(w,{component:P,href:a,sx:{color:ce.palette.primary.contrastText},children:r}),iconUrl:u,iconAlt:p,children:l?c(he,{availApps:t,basePath:a,start:!0}):null}),c(S,{sx:{p:3,minHeight:"calc(100% - 128px)",display:"flex",justifyContent:"center"},children:o}),c(ye,{footerContent:i})]})}function be(e){var r=e.title,t=e.availApps,n=e.footerContent,i=e.basePath,o=e.iconUrl,a=e.iconAlt,l=e.children;return m(x,{theme:ce,children:[c(b,{}),c(xe,{title:r,availApps:t,footerContent:n,basePath:i,iconUrl:o,iconAlt:a,menu:!0,children:l})]})}function ge(e){var r=e.children;return c(H,{component:L,children:c(U,{size:"small","aria-label":"a dense table",children:r})})}function ve(e){var r=e.children;return c(B,{textAlign:"left",children:r})}function je(e){var r=e.input,t=e.SetInput,o=e.error,a=e.SetError,l=e.minValue,u=e.maxValue,p=e.adornment,s=e.label,f=e.helperText,d=e.size,h=i(""),y=D(h,2),x=y[0],b=y[1],g=i(!1),v=D(g,2),j=v[0],C=v[1],O={};return"small"===d&&(O={maxWidth:75}),m(n.Fragment,{children:[c(R,{size:"small",sx:O,onChange:function(e){return function(e){var r=!1,n=e.target.value;n.match(/[0-9-]*/)[0]&&n.match(/[0-9-]*/)[0]===n||(r=!0,b("Input is not numerical.")),(n>u||n<l)&&(r=!0,b("Input is outside allowed boundaries.")),t(n),a(r),C(r)}(e)},value:r,error:o,label:s,helperText:f,inputProps:{inputMode:"numeric"},InputProps:{endAdornment:c(V,{position:"end",children:p})}}),c(le,{alert:j,SetAlert:C,message:x})]})}function Ce(e){return e.toString()+" %"}function Oe(){return c(u,{container:!0,sx:{display:"flex",flexGrow:1,justifyContent:"center",alignContent:"center"},children:c(Z,{})})}function Ae(e){var r=e.url,t=e.SetState,n=e.SetMetaData,a=e.reload,l=e.SetReload;e.error;var c=e.SetError,m=i(),u=D(m,2),p=u[0],s=u[1],f=i(),d=D(f,2);d[0];var h=d[1],y=null;return t||(t=s,y=p),c||(c=h),a||(a=!1),o(function(){try{fetch(r,{headers:{"Content-Type":"application/json",Accept:"application/json"}}).then(function(e){return n&&n(e.headers),console.log(e),e.ok?e.json():(c({error:e.statusText}),{error:e.statusText})}).then(function(e){console.log(e),t(e)})}catch(e){console.log(e),c({error:e})}l&&l(!1)},[a]),y}function Pe(e){var r=e.children,t=e.matches,n=e.justify;return c(u,t?{sx:{display:"flex",justifyContent:n,alignItems:"center"},children:r}:{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:r})}function we(e){var r=e.listmode,t=e.setup,i=e.spec,o=e.SetSpec,a=e.SetFilter,l=e.routerActive,m=l?E():null,p=l?I():null;return c(n.Fragment,{children:c(u,{children:c(_,{value:i,exclusive:!0,color:"primary",onChange:function(e,t){null!==t&&(o(t),a&&a({}),l&&m.push(p+"?spec="+t+"&mode="+r))},size:"small",children:Object.keys(t).map(function(e){return c(q,{value:e,children:e},"spec_"+e)})})})})}function Se(e){var r=e.availApps;return c(u,{children:m(pe,{title:"Welcome to ZAC Apps",xs:12,lg:8,children:[c("p",{children:"Select an app to get started."}),c(u,{container:!0,sx:{display:"flex",flexWrap:"wrap",justifyContent:"center"},children:r.map(function(e){return m(Q,{sx:{m:5,minWidth:250,display:"flex",flexDirection:"column"},variant:"outlined",component:P,href:e.path,children:[c("p",{children:c(J,{src:e.icon,alt:e.name,height:100})}),c("p",{children:e.name})]},"button_"+e.path)})})]})})}var ke=K(N)(function(e){var t=e.theme;return r(r({},"&.".concat(X.head),{backgroundColor:t.palette.grey[300]}),"&.".concat(X.body),{fontSize:14})});function Te(e){var r=e.url,t=e.reload,n=e.SetReload,a=i(),l=D(a,2),c=l[0],m=l[1],u=i(),p=D(u,2),s=p[0],f=p[1];return o(function(){fetch(r,{headers:{"Content-Type":"application/json",Accept:"application/json"}}).then(function(e){return f(e.headers),console.log(e),e.json()}).then(function(e){console.log(e),m(e)}),t&&n(!1)},[t]),{data:c,metadata:s}}function De(e){var r=e.children,t=Y(ce.breakpoints.up("lg")),o=i(!1),a=D(o,2),l=a[0],u=a[1],p=function(e){return function(r){("keydown"!==r.type||"Tab"!==r.key&&"Shift"!==r.key)&&u(e)}};return m(n.Fragment,{children:[c(Q,{variant:"outlined",onClick:p(!0),startIcon:c(te,{fontSize:"inherit"}),children:"Search/Filter"}),c($,{anchor:"left",open:l,onClose:p(!1),sx:{maxWidth:"350px"},children:c(S,{role:"presentation",width:t?"420px":"100%",children:m(ee,{children:[c(re,{sx:{justifyContent:"right"},children:c(z,{onClick:p(!1),children:c(ne,{})})}),c(B,{}),r]})})})]})}export{pe as AppCard,De as AppDrawer,se as AppGrid,fe as AppMenu,be as AppRoot,ge as AppTable,ce as AppTheme,xe as AppWrapper,ve as DivTitle,le as ErrorAlert,ye as Footer,de as MenuButton,he as NextListMenu,je as NumField,Ce as Percentage,Oe as Progress,Ae as PublicFetch,Pe as RespGrid,we as SpecSwitch,Se as Start,ke as TableHeadCell,Te as useFetch};
package/package.json CHANGED
@@ -1,63 +1,64 @@
1
1
  {
2
- "name": "@zac-apps/commons",
3
- "version": "2.0.3",
4
- "scripts": {
5
- "rollup": "node_modules/rollup/dist/rollup.js",
6
- "dev": "next dev",
7
- "build": "rollup -c",
8
- "start": "next start",
9
- "lint": "next lint",
10
- "storybook": "storybook dev -p 6006",
11
- "build-storybook": "storybook build",
12
- "semantic-release": "semantic-release"
13
- },
14
- "main": "dist/index.js",
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "files": [
19
- "dist"
20
- ],
21
- "repository": {
22
- "type": "git",
23
- "url": "https://gitlab.rlp.net/zac/zac-apps-commons.git"
24
- },
25
- "keywords": [
26
- "JGU"
27
- ],
28
- "author": "ZAC",
29
- "license": "CC-BY-SA-4.0",
30
- "dependencies": {
31
- "@emotion/react": "^11.14.0",
32
- "@emotion/styled": "^11.14.1",
33
- "@mui/icons-material": "^7.3.5",
34
- "@mui/material": "^7.3.5"
35
- },
36
- "devDependencies": {
37
- "@babel/plugin-transform-runtime": "^7.28.5",
38
- "@rollup/plugin-babel": "^6.1.0",
39
- "@rollup/plugin-commonjs": "^29.0.0",
40
- "@rollup/plugin-json": "^6.1.0",
41
- "@rollup/plugin-node-resolve": "^16.0.3",
42
- "@semantic-release/git": "^10.0.1",
43
- "@semantic-release/gitlab": "^13.2.9",
44
- "@semantic-release/npm": "^13.1.2",
45
- "@storybook/addon-links": "^10.0.8",
46
- "@storybook/addon-onboarding": "^10.0.8",
47
- "@storybook/nextjs": "^10.0.8",
48
- "@storybook/react": "^10.0.8",
49
- "babel-loader": "^10.0.0",
50
- "eslint": "^9",
51
- "eslint-config-next": "16.0.3",
52
- "eslint-plugin-storybook": "^10.0.8",
53
- "rollup": "^4.53.3",
54
- "semantic-release": "^25.0.2",
55
- "storybook": "^10.0.8"
56
- },
57
- "peerDependencies": {
58
- "next": "^16 || ^15",
59
- "react": "^19 || ^18",
60
- "react-dom": "^19 || ^18"
61
- },
62
- "description": "This package contains common components for the ZAC Apps."
2
+ "name": "@zac-apps/commons",
3
+ "version": "2.2.0-beta.1",
4
+ "scripts": {
5
+ "rollup": "node_modules/rollup/dist/rollup.js",
6
+ "dev": "next dev",
7
+ "build": "rollup -c",
8
+ "start": "next start",
9
+ "lint": "next lint",
10
+ "storybook": "storybook dev -p 6006",
11
+ "build-storybook": "storybook build",
12
+ "semantic-release": "semantic-release"
13
+ },
14
+ "main": "dist/index.js",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://gitlab.rlp.net/zac/zac-apps-commons.git"
24
+ },
25
+ "keywords": [
26
+ "JGU"
27
+ ],
28
+ "author": "ZAC",
29
+ "license": "CC-BY-SA-4.0",
30
+ "dependencies": {
31
+ "@emotion/react": "^11.14.0",
32
+ "@emotion/styled": "^11.14.1",
33
+ "@mui/icons-material": "^7.3.7",
34
+ "@mui/material": "^7.3.7"
35
+ },
36
+ "devDependencies": {
37
+ "@babel/plugin-transform-runtime": "^7.28.5",
38
+ "@rollup/plugin-babel": "^6.1.0",
39
+ "@rollup/plugin-commonjs": "^29.0.0",
40
+ "@rollup/plugin-json": "^6.1.0",
41
+ "@rollup/plugin-node-resolve": "^16.0.3",
42
+ "@rollup/plugin-terser": "^0.4.4",
43
+ "@semantic-release/git": "^10.0.1",
44
+ "@semantic-release/gitlab": "^13.2.9",
45
+ "@semantic-release/npm": "^13.1.3",
46
+ "@storybook/addon-links": "^10.1.11",
47
+ "@storybook/addon-onboarding": "^10.1.11",
48
+ "@storybook/nextjs": "^10.1.11",
49
+ "@storybook/react": "^10.1.11",
50
+ "babel-loader": "^10.0.0",
51
+ "eslint": "^9",
52
+ "eslint-config-next": "16.1.3",
53
+ "eslint-plugin-storybook": "^10.1.11",
54
+ "rollup": "^4.55.2",
55
+ "semantic-release": "^25.0.2",
56
+ "storybook": "^10.1.11"
57
+ },
58
+ "peerDependencies": {
59
+ "next": "^16 || ^15",
60
+ "react": "^19 || ^18",
61
+ "react-dom": "^19 || ^18"
62
+ },
63
+ "description": "This package contains common components for the ZAC Apps."
63
64
  }