pankosmia-rcl 0.0.2 → 0.0.4
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 +2 -2
- package/src/App.jsx +0 -38
- package/src/componentDemos/DialogExampleDemo.jsx +0 -16
- package/src/componentDemos/DrawerDemo.jsx +0 -72
- package/src/componentDemos/InternetSwitchDemo.jsx +0 -34
- package/src/componentDemos/index.js +0 -3
- package/src/demoHelpers/Demo.jsx +0 -10
- package/src/demoHelpers/Demos.jsx +0 -9
- package/src/index.css +0 -15
- package/src/index.jsx +0 -15
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pankosmia-rcl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"homepage": "/clients/core-client-rcl",
|
|
6
|
-
"main": "src/rcl",
|
|
6
|
+
"main": "src/rcl/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@emotion/react": "^11.13.3",
|
|
9
9
|
"@emotion/styled": "^11.13.0",
|
package/src/App.jsx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState, useCallback } from 'react';
|
|
2
|
-
import { Box } from "@mui/material";
|
|
3
|
-
import { InternetSwitchDemo } from './componentDemos';
|
|
4
|
-
import DialogExampleDemo from './componentDemos/DialogExampleDemo';
|
|
5
|
-
import Demos from './demoHelpers/Demos';
|
|
6
|
-
import Demo from './demoHelpers/Demo';
|
|
7
|
-
import DrawerDemo from './componentDemos/DrawerDemo';
|
|
8
|
-
|
|
9
|
-
function App() {
|
|
10
|
-
const [maxWindowHeight, setMaxWindowHeight] = useState(window.innerHeight - 64);
|
|
11
|
-
const handleWindowResize = useCallback(event => {
|
|
12
|
-
setMaxWindowHeight(window.innerHeight - 64);
|
|
13
|
-
}, []);
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
window.addEventListener('resize', handleWindowResize);
|
|
17
|
-
return () => {
|
|
18
|
-
window.removeEventListener('resize', handleWindowResize);
|
|
19
|
-
};
|
|
20
|
-
}, [handleWindowResize]);
|
|
21
|
-
|
|
22
|
-
return <Box sx={{ maxHeight: maxWindowHeight }}>
|
|
23
|
-
<Demos>
|
|
24
|
-
<Demo title="InternetSwitch">
|
|
25
|
-
<InternetSwitchDemo />
|
|
26
|
-
</Demo>
|
|
27
|
-
<Demo title="Dialog">
|
|
28
|
-
<DialogExampleDemo />
|
|
29
|
-
</Demo>
|
|
30
|
-
<Demo title="Drawer">
|
|
31
|
-
<DrawerDemo />
|
|
32
|
-
</Demo>
|
|
33
|
-
</Demos>
|
|
34
|
-
</Box>
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default App;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import PanDialog from "../rcl/PanDialog";
|
|
3
|
-
import { Button } from "@mui/material";
|
|
4
|
-
|
|
5
|
-
export default function DialogExampleDemo() {
|
|
6
|
-
const [openDialog, setOpenDialog] = useState(null);
|
|
7
|
-
const contentOpenDialog = Boolean(openDialog)
|
|
8
|
-
|
|
9
|
-
return <>
|
|
10
|
-
<Button onClick={(event) => {
|
|
11
|
-
setOpenDialog(event.target)
|
|
12
|
-
}}> open dialog </Button>
|
|
13
|
-
<PanDialog open={contentOpenDialog} closeFn={() => setOpenDialog(false)} >test</PanDialog>
|
|
14
|
-
</>
|
|
15
|
-
|
|
16
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import DrawerComponent from '../rcl/DrawerComponent';
|
|
2
|
-
import {useContext, useState, useEffect, useRef} from "react";
|
|
3
|
-
import {debugContext, getJson} from "pithekos-lib";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function DrawerDemo() {
|
|
7
|
-
|
|
8
|
-
const {debugRef} = useContext(debugContext);
|
|
9
|
-
const [drawerIsOpen, setDrawerIsOpen] = useState(false);
|
|
10
|
-
const [menuItems, setMenuItems] = useState([]);
|
|
11
|
-
const [showAdvanced, setShowAdvanced] = useState(true);
|
|
12
|
-
const [drawerWidth, setDrawerWidth] = useState('auto');
|
|
13
|
-
const [widthLocked, setWidthLocked] = useState(false);
|
|
14
|
-
const measurementRef = useRef(null);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
let timeoutId;
|
|
18
|
-
if (drawerIsOpen && !widthLocked) {
|
|
19
|
-
timeoutId = setTimeout(() => {
|
|
20
|
-
if (measurementRef.current) {
|
|
21
|
-
const width = measurementRef.current.clientWidth;
|
|
22
|
-
|
|
23
|
-
if (width > 0) {
|
|
24
|
-
setDrawerWidth(`${width}px`);
|
|
25
|
-
setWidthLocked(true);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}, 50);
|
|
29
|
-
return () => clearTimeout(timeoutId);
|
|
30
|
-
}
|
|
31
|
-
}, [drawerIsOpen, widthLocked]);
|
|
32
|
-
|
|
33
|
-
useEffect(
|
|
34
|
-
() => {
|
|
35
|
-
const doFetch = async () => {
|
|
36
|
-
const fetched = await getJson("/list-clients", debugRef.current);
|
|
37
|
-
if (fetched.ok) {
|
|
38
|
-
setMenuItems(
|
|
39
|
-
fetched.json.filter(
|
|
40
|
-
i => !i.exclude_from_menu && (debugRef.current || !i.requires.debug)
|
|
41
|
-
)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
doFetch().then();
|
|
46
|
-
},
|
|
47
|
-
[debugRef.current]
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const toggleDebug = (ev) => {
|
|
51
|
-
getJson(`/debug/${debugRef.current ? "disable" : "enable"}`)
|
|
52
|
-
.then(
|
|
53
|
-
() => {
|
|
54
|
-
ev.stopPropagation();
|
|
55
|
-
ev.preventDefault();
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return <DrawerComponent
|
|
61
|
-
drawerIsOpen={drawerIsOpen}
|
|
62
|
-
setDrawerIsOpen={setDrawerIsOpen}
|
|
63
|
-
menuItems={menuItems}
|
|
64
|
-
toggleDebug={toggleDebug}
|
|
65
|
-
showAdvanced={showAdvanced}
|
|
66
|
-
setShowAdvanced={setShowAdvanced}
|
|
67
|
-
drawerWidth={drawerWidth}
|
|
68
|
-
measurementRef={measurementRef}
|
|
69
|
-
/>
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default DrawerDemo;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import InternetSwitch from '../rcl/InternetSwitch';
|
|
2
|
-
import {useContext, useState} from "react";
|
|
3
|
-
import {debugContext, netContext, postEmptyJson} from "pithekos-lib";
|
|
4
|
-
|
|
5
|
-
function InternetSwitchDemo() {
|
|
6
|
-
|
|
7
|
-
const [internetDialogOpen, setInternetDialogOpen] = useState(false);
|
|
8
|
-
const {enabledRef} = useContext(netContext);
|
|
9
|
-
const {debugRef} = useContext(debugContext);
|
|
10
|
-
|
|
11
|
-
const disableInternet = () => {
|
|
12
|
-
postEmptyJson('/net/disable', debugRef.current)
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const enableInternet = () => {
|
|
16
|
-
postEmptyJson('/net/enable', debugRef.current)
|
|
17
|
-
};
|
|
18
|
-
const handleInternetToggleClick = () => {
|
|
19
|
-
if (!enabledRef.current) {
|
|
20
|
-
setInternetDialogOpen(true);
|
|
21
|
-
} else {
|
|
22
|
-
disableInternet();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return <InternetSwitch
|
|
27
|
-
enableInternet={enableInternet}
|
|
28
|
-
handleInternetToggleClick={handleInternetToggleClick}
|
|
29
|
-
internetDialogOpen={internetDialogOpen}
|
|
30
|
-
setInternetDialogOpen={setInternetDialogOpen}
|
|
31
|
-
/>
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default InternetSwitchDemo;
|
package/src/demoHelpers/Demo.jsx
DELETED
package/src/index.css
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
padding: 0;
|
|
4
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
5
|
-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
6
|
-
sans-serif;
|
|
7
|
-
-webkit-font-smoothing: antialiased;
|
|
8
|
-
-moz-osx-font-smoothing: grayscale;
|
|
9
|
-
overflow: hidden;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
code {
|
|
13
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
14
|
-
monospace;
|
|
15
|
-
}
|
package/src/index.jsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {createRoot} from "react-dom/client";
|
|
2
|
-
import {SpSpa} from "pithekos-lib";
|
|
3
|
-
import App from "./App";
|
|
4
|
-
import './index.css';
|
|
5
|
-
|
|
6
|
-
createRoot(document.getElementById("root"))
|
|
7
|
-
.render(
|
|
8
|
-
<SpSpa
|
|
9
|
-
requireNet={false}
|
|
10
|
-
titleKey="pages:core-client-rcl:title"
|
|
11
|
-
currentId="core-client-rcl"
|
|
12
|
-
>
|
|
13
|
-
<App/>
|
|
14
|
-
</SpSpa>
|
|
15
|
-
);
|