@zac-apps/commons 2.1.0 → 2.2.0-beta.2

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 -737
  2. package/package.json +62 -61
package/dist/index.js CHANGED
@@ -1,737 +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$1(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$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(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$1({
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 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; }
114
- 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; }
115
- function AppCard(props) {
116
- var userSx = props.sx || {};
117
- return /*#__PURE__*/jsx(Grid, {
118
- size: {
119
- xs: props.xs || props.size || 12,
120
- lg: props.lg || props.size || 6,
121
- md: props.md || 12
122
- },
123
- sx: _objectSpread({}, userSx),
124
- children: /*#__PURE__*/jsxs(Accordion, {
125
- defaultExpanded: !props.collapsed,
126
- square: false,
127
- elevation: 2,
128
- children: [/*#__PURE__*/jsx(AccordionSummary, {
129
- expandIcon: /*#__PURE__*/jsx(ExpandMoreIcon, {}),
130
- sx: {
131
- backgroundColor: AppTheme.palette.divider
132
- },
133
- children: /*#__PURE__*/jsx(Typography, {
134
- variant: "h5",
135
- children: props.title
136
- })
137
- }), /*#__PURE__*/jsx(AccordionDetails, {
138
- children: props.children
139
- })]
140
- })
141
- });
142
- }
143
-
144
- function AppGrid(_ref) {
145
- var children = _ref.children,
146
- reverse = _ref.reverse;
147
- var wrapper = reverse ? "wrap-reverse" : "wrap";
148
- return /*#__PURE__*/jsx(Grid, {
149
- container: true,
150
- spacing: 2,
151
- sx: {
152
- display: "flex",
153
- flexGrow: 1,
154
- justifyContent: "center",
155
- flexWrap: wrapper
156
- },
157
- children: children
158
- });
159
- }
160
-
161
- function AppMenu(_ref) {
162
- var title = _ref.title,
163
- iconUrl = _ref.iconUrl,
164
- iconAlt = _ref.iconAlt,
165
- children = _ref.children;
166
- if (!title) {
167
- title = "JGU-ZAC Apps";
168
- }
169
- return /*#__PURE__*/jsx(AppBar, {
170
- position: "sticky",
171
- children: /*#__PURE__*/jsxs(Toolbar, {
172
- children: [children, "\u2003", /*#__PURE__*/jsx(Typography, {
173
- variant: "h6",
174
- component: "div",
175
- sx: {
176
- flexGrow: 1
177
- },
178
- children: title
179
- }), iconUrl ? /*#__PURE__*/jsx("img", {
180
- src: iconUrl,
181
- width: "48px",
182
- alt: iconAlt
183
- }) : null]
184
- })
185
- });
186
- }
187
-
188
- function MenuButton(_ref) {
189
- var anchorEl = _ref.anchorEl;
190
- if (anchorEl) {
191
- return /*#__PURE__*/jsx(MenuOpenIcon, {});
192
- } else {
193
- return /*#__PURE__*/jsx(MenuIcon, {});
194
- }
195
- }
196
-
197
- function NextListMenu(_ref) {
198
- var availApps = _ref.availApps,
199
- start = _ref.start,
200
- basePath = _ref.basePath;
201
- var _React$useState = React.useState(null),
202
- _React$useState2 = _slicedToArray(_React$useState, 2),
203
- anchorEl = _React$useState2[0],
204
- setAnchorEl = _React$useState2[1];
205
- var open = Boolean(anchorEl);
206
- var handleClickListItem = function handleClickListItem(event) {
207
- setAnchorEl(event.currentTarget);
208
- };
209
- var handleClose = function handleClose() {
210
- setAnchorEl(null);
211
- };
212
- var pathname = usePathname();
213
- if (!basePath || basePath === null) {
214
- basePath = "/";
215
- }
216
- function StartEntry() {
217
- if (start) {
218
- return /*#__PURE__*/jsxs(React.Fragment, {
219
- children: [/*#__PURE__*/jsx(MenuItem, {
220
- component: Link,
221
- href: basePath,
222
- selected: pathname === basePath,
223
- onClick: handleClose,
224
- children: "Start"
225
- }), /*#__PURE__*/jsx(Divider, {})]
226
- });
227
- } else return null;
228
- }
229
- return /*#__PURE__*/jsxs("div", {
230
- children: [/*#__PURE__*/jsx(IconButton, {
231
- size: "large",
232
- edge: "start",
233
- color: "inherit",
234
- "aria-label": "menu",
235
- sx: {
236
- mr: 2
237
- },
238
- onClick: handleClickListItem,
239
- children: /*#__PURE__*/jsx(MenuButton, {
240
- anchorEl: anchorEl
241
- })
242
- }), /*#__PURE__*/jsxs(Menu, {
243
- id: "lock-menu",
244
- anchorEl: anchorEl,
245
- open: open,
246
- onClose: handleClose,
247
- slotProps: {
248
- "aria-labelledby": "lock-button",
249
- role: "listbox"
250
- },
251
- children: [/*#__PURE__*/jsx(StartEntry, {}), availApps.map(function (option, index) {
252
- return /*#__PURE__*/jsx(MenuItem, {
253
- component: Link,
254
- href: option.path,
255
- selected: pathname === option.path + "/",
256
- onClick: handleClose,
257
- children: option.name
258
- }, option.name);
259
- })]
260
- })]
261
- });
262
- }
263
-
264
- function Footer(_ref) {
265
- var footerContent = _ref.footerContent;
266
- return /*#__PURE__*/jsx(React__default.Fragment, {
267
- children: /*#__PURE__*/jsx(Grid, {
268
- sx: {
269
- p: 1,
270
- backgroundColor: AppTheme.palette.divider,
271
- display: "flex",
272
- flexDirection: "row",
273
- justifyContent: "center",
274
- alignItems: "center",
275
- minHeight: 64
276
- },
277
- children: /*#__PURE__*/jsx(Grid, {
278
- children: /*#__PURE__*/jsx(Typography, {
279
- variant: "body2",
280
- children: footerContent
281
- })
282
- })
283
- })
284
- });
285
- }
286
-
287
- function AppWrapper(_ref) {
288
- var title = _ref.title,
289
- availApps = _ref.availApps,
290
- footerContent = _ref.footerContent,
291
- children = _ref.children,
292
- basePath = _ref.basePath,
293
- menu = _ref.menu,
294
- iconUrl = _ref.iconUrl,
295
- iconAlt = _ref.iconAlt;
296
- if (!basePath || basePath === null) {
297
- basePath = "/";
298
- }
299
- if (!footerContent || footerContent === null) {
300
- footerContent = "";
301
- }
302
- return /*#__PURE__*/jsxs(React__default.Fragment, {
303
- children: [/*#__PURE__*/jsx(AppMenu, {
304
- title: /*#__PURE__*/jsx(Link$1, {
305
- component: Link$2,
306
- href: basePath,
307
- sx: {
308
- color: AppTheme.palette.primary.contrastText
309
- },
310
- children: title
311
- }),
312
- iconUrl: iconUrl,
313
- iconAlt: iconAlt,
314
- children: menu ? /*#__PURE__*/jsx(NextListMenu, {
315
- availApps: availApps,
316
- basePath: basePath,
317
- start: true
318
- }) : null
319
- }), /*#__PURE__*/jsx(Box, {
320
- sx: {
321
- p: 3,
322
- minHeight: "calc(100% - 128px)",
323
- display: "flex",
324
- justifyContent: "center"
325
- },
326
- children: children
327
- }), /*#__PURE__*/jsx(Footer, {
328
- footerContent: footerContent
329
- })]
330
- });
331
- }
332
-
333
- function AppRoot(_ref) {
334
- var title = _ref.title,
335
- availApps = _ref.availApps,
336
- footerContent = _ref.footerContent,
337
- basePath = _ref.basePath,
338
- iconUrl = _ref.iconUrl,
339
- iconAlt = _ref.iconAlt,
340
- children = _ref.children;
341
- return /*#__PURE__*/jsxs(ThemeProvider, {
342
- theme: AppTheme,
343
- children: [/*#__PURE__*/jsx(CssBaseline, {}), /*#__PURE__*/jsx(AppWrapper, {
344
- title: title,
345
- availApps: availApps,
346
- footerContent: footerContent,
347
- basePath: basePath,
348
- iconUrl: iconUrl,
349
- iconAlt: iconAlt,
350
- menu: true,
351
- children: children
352
- })]
353
- });
354
- }
355
-
356
- function AppTable(_ref) {
357
- var children = _ref.children;
358
- return /*#__PURE__*/jsx(TableContainer, {
359
- component: Paper,
360
- children: /*#__PURE__*/jsx(Table, {
361
- size: "small",
362
- "aria-label": "a dense table",
363
- children: children
364
- })
365
- });
366
- }
367
-
368
- function DivTitle(_ref) {
369
- var children = _ref.children;
370
- return /*#__PURE__*/jsx(Divider, {
371
- textAlign: "left",
372
- children: children
373
- });
374
- }
375
-
376
- function NumField(_ref) {
377
- var input = _ref.input,
378
- SetInput = _ref.SetInput,
379
- error = _ref.error,
380
- SetError = _ref.SetError,
381
- minValue = _ref.minValue,
382
- maxValue = _ref.maxValue,
383
- adornment = _ref.adornment,
384
- label = _ref.label,
385
- helperText = _ref.helperText,
386
- size = _ref.size;
387
- var _useState = useState(""),
388
- _useState2 = _slicedToArray(_useState, 2),
389
- errorMessage = _useState2[0],
390
- SetErrorMessage = _useState2[1];
391
- var _useState3 = useState(false),
392
- _useState4 = _slicedToArray(_useState3, 2),
393
- alert = _useState4[0],
394
- SetAlert = _useState4[1];
395
- var sx = {};
396
- if (size === "small") {
397
- sx = {
398
- maxWidth: 75
399
- };
400
- }
401
- function handleEntry(e) {
402
- var errorFound = false;
403
- var inputVal = e.target.value;
404
- if (!inputVal.match(/[0-9-]*/)[0] || inputVal.match(/[0-9-]*/)[0] !== inputVal) {
405
- errorFound = true;
406
- SetErrorMessage("Input is not numerical.");
407
- }
408
- if (inputVal > maxValue || inputVal < minValue) {
409
- errorFound = true;
410
- SetErrorMessage("Input is outside allowed boundaries.");
411
- }
412
- SetInput(inputVal);
413
- SetError(errorFound);
414
- SetAlert(errorFound);
415
- }
416
- return /*#__PURE__*/jsxs(React__default.Fragment, {
417
- children: [/*#__PURE__*/jsx(TextField, {
418
- size: "small",
419
- sx: sx,
420
- onChange: function onChange(e) {
421
- return handleEntry(e);
422
- },
423
- value: input,
424
- error: error,
425
- label: label,
426
- helperText: helperText,
427
- inputProps: {
428
- inputMode: "numeric"
429
- },
430
- InputProps: {
431
- endAdornment: /*#__PURE__*/jsx(InputAdornment, {
432
- position: "end",
433
- children: adornment
434
- })
435
- }
436
- }), /*#__PURE__*/jsx(ErrorAlert, {
437
- alert: alert,
438
- SetAlert: SetAlert,
439
- message: errorMessage
440
- })]
441
- });
442
- }
443
-
444
- function Percentage(number) {
445
- var resultStr = number.toString() + " %";
446
- return resultStr;
447
- }
448
-
449
- function Progress() {
450
- return /*#__PURE__*/jsx(Grid, {
451
- container: true,
452
- sx: {
453
- display: "flex",
454
- flexGrow: 1,
455
- justifyContent: "center",
456
- alignContent: "center"
457
- },
458
- children: /*#__PURE__*/jsx(CircularProgress, {})
459
- });
460
- }
461
-
462
- function PublicFetch(_ref) {
463
- var url = _ref.url,
464
- SetState = _ref.SetState,
465
- SetMetaData = _ref.SetMetaData,
466
- reload = _ref.reload,
467
- SetReload = _ref.SetReload;
468
- _ref.error;
469
- var SetError = _ref.SetError;
470
- var _useState = useState(),
471
- _useState2 = _slicedToArray(_useState, 2),
472
- internal = _useState2[0],
473
- SetInternal = _useState2[1];
474
- var _useState3 = useState(),
475
- _useState4 = _slicedToArray(_useState3, 2);
476
- _useState4[0];
477
- var SetInternalError = _useState4[1];
478
- var state = null;
479
- if (!SetState) {
480
- SetState = SetInternal;
481
- state = internal;
482
- }
483
- if (!SetError) {
484
- SetError = SetInternalError;
485
- }
486
- if (!reload) {
487
- reload = false;
488
- }
489
- useEffect(function () {
490
- try {
491
- fetch(url, {
492
- headers: {
493
- "Content-Type": "application/json",
494
- Accept: "application/json"
495
- }
496
- }).then(function (response) {
497
- if (SetMetaData) {
498
- SetMetaData(response.headers);
499
- }
500
- console.log(response);
501
- if (!response.ok) {
502
- SetError({
503
- error: response.statusText
504
- });
505
- return {
506
- error: response.statusText
507
- };
508
- } else {
509
- return response.json();
510
- }
511
- }).then(function (json) {
512
- console.log(json);
513
- SetState(json);
514
- });
515
- } catch (e) {
516
- console.log(e);
517
- SetError({
518
- error: e
519
- });
520
- }
521
- if (SetReload) {
522
- SetReload(false);
523
- }
524
- }, [reload]);
525
- return state;
526
- }
527
-
528
- function RespGrid(_ref) {
529
- var children = _ref.children,
530
- matches = _ref.matches,
531
- justify = _ref.justify;
532
- if (matches) {
533
- return /*#__PURE__*/jsx(Grid, {
534
- sx: {
535
- display: "flex",
536
- justifyContent: justify,
537
- alignItems: "center"
538
- },
539
- children: children
540
- });
541
- } else {
542
- return /*#__PURE__*/jsx(Grid, {
543
- sx: {
544
- display: "flex",
545
- flexDirection: "column",
546
- justifyContent: "center",
547
- alignItems: "center"
548
- },
549
- children: children
550
- });
551
- }
552
- }
553
-
554
- function SpecSwitch(_ref) {
555
- var listmode = _ref.listmode,
556
- setup = _ref.setup,
557
- spec = _ref.spec,
558
- SetSpec = _ref.SetSpec,
559
- SetFilter = _ref.SetFilter,
560
- routerActive = _ref.routerActive;
561
- var router = routerActive ? useRouter() : null;
562
- var pathname = routerActive ? usePathname() : null;
563
- return /*#__PURE__*/jsx(React__default.Fragment, {
564
- children: /*#__PURE__*/jsx(Grid, {
565
- children: /*#__PURE__*/jsx(ToggleButtonGroup, {
566
- value: spec,
567
- exclusive: true,
568
- color: "primary",
569
- onChange: function onChange(event, value) {
570
- if (value !== null) {
571
- SetSpec(value);
572
- SetFilter ? SetFilter({}) : null;
573
- routerActive ? router.push(pathname + "?spec=" + value + "&mode=" + listmode) : null;
574
- }
575
- },
576
- size: "small",
577
- children: Object.keys(setup).map(function (entry) {
578
- return /*#__PURE__*/jsx(ToggleButton, {
579
- value: entry,
580
- children: entry
581
- }, "spec_" + entry);
582
- })
583
- })
584
- })
585
- });
586
- }
587
-
588
- function Start(_ref) {
589
- var availApps = _ref.availApps;
590
- return /*#__PURE__*/jsx(Grid, {
591
- children: /*#__PURE__*/jsxs(AppCard, {
592
- title: "Welcome to ZAC Apps",
593
- xs: 12,
594
- lg: 8,
595
- children: [/*#__PURE__*/jsx("p", {
596
- children: "Select an app to get started."
597
- }), /*#__PURE__*/jsx(Grid, {
598
- container: true,
599
- sx: {
600
- display: "flex",
601
- flexWrap: "wrap",
602
- justifyContent: "center"
603
- },
604
- children: availApps.map(function (app) {
605
- return /*#__PURE__*/jsxs(Button, {
606
- sx: {
607
- m: 5,
608
- minWidth: 250,
609
- display: "flex",
610
- flexDirection: "column"
611
- },
612
- variant: "outlined",
613
- component: Link$2,
614
- href: app.path,
615
- children: [/*#__PURE__*/jsx("p", {
616
- children: /*#__PURE__*/jsx(Image, {
617
- src: app.icon,
618
- alt: app.name,
619
- height: 100
620
- })
621
- }), /*#__PURE__*/jsx("p", {
622
- children: app.name
623
- })]
624
- }, "button_" + app.path);
625
- })
626
- })]
627
- })
628
- });
629
- }
630
-
631
- var TableHeadCell = styled(TableCell)(function (_ref) {
632
- var theme = _ref.theme;
633
- return _defineProperty(_defineProperty({}, "&.".concat(tableCellClasses.head), {
634
- backgroundColor: theme.palette.grey[300]
635
- }), "&.".concat(tableCellClasses.body), {
636
- fontSize: 14
637
- });
638
- });
639
-
640
- function useFetch(_ref) {
641
- var url = _ref.url,
642
- reload = _ref.reload,
643
- SetReload = _ref.SetReload;
644
- // Define states for data and metadata
645
-
646
- var _useState = useState(),
647
- _useState2 = _slicedToArray(_useState, 2),
648
- data = _useState2[0],
649
- SetData = _useState2[1];
650
- var _useState3 = useState(),
651
- _useState4 = _slicedToArray(_useState3, 2),
652
- metadata = _useState4[0],
653
- SetMetadata = _useState4[1];
654
-
655
- // Fetch data from url
656
-
657
- useEffect(function () {
658
- fetch(url, {
659
- headers: {
660
- "Content-Type": "application/json",
661
- Accept: "application/json"
662
- }
663
- }).then(function (response) {
664
- SetMetadata(response.headers);
665
- console.log(response);
666
- return response.json();
667
- }).then(function (json) {
668
- console.log(json);
669
- SetData(json);
670
- });
671
- if (reload) {
672
- SetReload(false); // Reset reload state
673
- }
674
- }, [reload]); // Fetch is triggered by reload state
675
-
676
- // Return data and metadata as object
677
-
678
- var internal = {
679
- data: data,
680
- metadata: metadata
681
- };
682
- return internal;
683
- }
684
-
685
- function AppDrawer(_ref) {
686
- var children = _ref.children;
687
- var matches = useMediaQuery(AppTheme.breakpoints.up("lg"));
688
- var _useState = useState(false),
689
- _useState2 = _slicedToArray(_useState, 2),
690
- open = _useState2[0],
691
- SetOpen = _useState2[1];
692
- var toggleDrawer = function toggleDrawer(state) {
693
- return function (event) {
694
- if (event.type === "keydown" && (event.key === "Tab" || event.key === "Shift")) {
695
- return;
696
- }
697
- SetOpen(state);
698
- };
699
- };
700
- var list = function list() {
701
- return /*#__PURE__*/jsx(Box, {
702
- role: "presentation",
703
- width: matches ? "420px" : "100%",
704
- children: /*#__PURE__*/jsxs(List, {
705
- children: [/*#__PURE__*/jsx(ListItem, {
706
- sx: {
707
- justifyContent: "right"
708
- },
709
- children: /*#__PURE__*/jsx(IconButton, {
710
- onClick: toggleDrawer(false),
711
- children: /*#__PURE__*/jsx(CloseIcon, {})
712
- })
713
- }), /*#__PURE__*/jsx(Divider, {}), children]
714
- })
715
- });
716
- };
717
- return /*#__PURE__*/jsxs(React__default.Fragment, {
718
- children: [/*#__PURE__*/jsx(Button, {
719
- variant: "outlined",
720
- onClick: toggleDrawer(true),
721
- startIcon: /*#__PURE__*/jsx(ManageSearchIcon, {
722
- fontSize: "inherit"
723
- }),
724
- children: "Search/Filter"
725
- }), /*#__PURE__*/jsx(Drawer, {
726
- anchor: "left",
727
- open: open,
728
- onClose: toggleDrawer(false),
729
- sx: {
730
- maxWidth: "350px"
731
- },
732
- children: list()
733
- })]
734
- });
735
- }
736
-
737
- 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 S}from"next/link";import P from"@mui/material/Link";import w 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(P,{component:S,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(w,{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 Se(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 Pe(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 we(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:S,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(w,{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,Se as RespGrid,Pe as SpecSwitch,we 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.1.0",
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.2",
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
  }