diff --git a/examples/layout-manager-playground/package-lock.json b/examples/layout-manager-playground/package-lock.json index 5cf55e835..ce5c1cad9 100644 --- a/examples/layout-manager-playground/package-lock.json +++ b/examples/layout-manager-playground/package-lock.json @@ -14,6 +14,7 @@ "@metacell/geppetto-meta-client": "file:.yalc/@metacell/geppetto-meta-client", "@metacell/geppetto-meta-core": "file:.yalc/@metacell/geppetto-meta-core", "@metacell/geppetto-meta-ui": "file:.yalc/@metacell/geppetto-meta-ui", + "@mui/icons-material": "^5.14.0", "@mui/material": "^5.14.0", "@types/jest": "^27.5.2", "@types/node": "^16.18.38", @@ -33,7 +34,7 @@ } }, ".yalc/@metacell/geppetto-meta-client": { - "version": "1.2.2", + "version": "1.2.7", "license": "MIT", "dependencies": { "@material-ui/core": "^4.1.3", @@ -46,11 +47,11 @@ } }, ".yalc/@metacell/geppetto-meta-core": { - "version": "1.2.2", + "version": "1.2.7", "license": "MIT" }, ".yalc/@metacell/geppetto-meta-ui": { - "version": "1.2.2", + "version": "1.2.7", "license": "MIT", "peerDependencies": { "@fortawesome/fontawesome-free": "^6.4.0", @@ -59,7 +60,7 @@ "@fortawesome/react-fontawesome": "^0.1.9", "@material-ui/core": "4.11.4", "@material-ui/icons": "^4.11.2", - "@metacell/geppetto-meta-core": "1.2.2", + "@metacell/geppetto-meta-core": "1.2.7", "aframe": "<1.1.0", "aframe-slice9-component": ">=1.0.0", "ami.js": ">=0.32.0", @@ -1913,8 +1914,9 @@ "license": "MIT" }, "node_modules/@babel/runtime": { - "version": "7.22.11", - "license": "MIT", + "version": "7.24.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.0.tgz", + "integrity": "sha512-Chk32uHMg6TnQdvw2e9IlqPpFX/6NLuK0Ys2PqLb7/gL5uFn9mXvK715FGLlOLQrcO4qIkNHkvPGktzzXexsFw==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -3041,6 +3043,31 @@ "url": "https://opencollective.com/mui" } }, + "node_modules/@mui/icons-material": { + "version": "5.15.11", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.15.11.tgz", + "integrity": "sha512-R5ZoQqnKpd+5Ew7mBygTFLxgYsQHPhgR3TDXSgIHYIjGzYuyPLmGLSdcPUoMdi6kxiYqHlpPj4NJxlbaFD0UHA==", + "dependencies": { + "@babel/runtime": "^7.23.9" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@mui/material": "^5.0.0", + "@types/react": "^17.0.0 || ^18.0.0", + "react": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@mui/material": { "version": "5.14.0", "license": "MIT", @@ -15517,7 +15544,9 @@ "version": "0.8.0" }, "@babel/runtime": { - "version": "7.22.11", + "version": "7.24.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.0.tgz", + "integrity": "sha512-Chk32uHMg6TnQdvw2e9IlqPpFX/6NLuK0Ys2PqLb7/gL5uFn9mXvK715FGLlOLQrcO4qIkNHkvPGktzzXexsFw==", "requires": { "regenerator-runtime": "^0.14.0" }, @@ -16197,6 +16226,14 @@ "@mui/core-downloads-tracker": { "version": "5.14.0" }, + "@mui/icons-material": { + "version": "5.15.11", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.15.11.tgz", + "integrity": "sha512-R5ZoQqnKpd+5Ew7mBygTFLxgYsQHPhgR3TDXSgIHYIjGzYuyPLmGLSdcPUoMdi6kxiYqHlpPj4NJxlbaFD0UHA==", + "requires": { + "@babel/runtime": "^7.23.9" + } + }, "@mui/material": { "version": "5.14.0", "requires": { diff --git a/examples/layout-manager-playground/package.json b/examples/layout-manager-playground/package.json index 36ad5a162..e6172e9aa 100644 --- a/examples/layout-manager-playground/package.json +++ b/examples/layout-manager-playground/package.json @@ -10,6 +10,7 @@ "@metacell/geppetto-meta-core": "file:.yalc/@metacell/geppetto-meta-core", "@metacell/geppetto-meta-ui": "file:.yalc/@metacell/geppetto-meta-ui", "@mui/material": "^5.14.0", + "@mui/icons-material": "^5.14.0", "@types/jest": "^27.5.2", "@types/node": "^16.18.38", "@types/react": "17.0.52", diff --git a/examples/layout-manager-playground/src/pages/HomePage.tsx b/examples/layout-manager-playground/src/pages/HomePage.tsx index f5a17ec51..3335570f6 100644 --- a/examples/layout-manager-playground/src/pages/HomePage.tsx +++ b/examples/layout-manager-playground/src/pages/HomePage.tsx @@ -1,14 +1,26 @@ import React, { useEffect, useState } from 'react'; -import { useDispatch, useStore } from 'react-redux'; -import { Box, Button, CircularProgress, Stack, TextField } from "@mui/material" -import InputLabel from '@mui/material/InputLabel'; -import MenuItem from '@mui/material/MenuItem'; -import FormControl from '@mui/material/FormControl'; +import { useDispatch, useStore, useSelector } from 'react-redux'; +import { + Box, + Button, + CircularProgress, + IconButton, + Stack, + TextField, + Tooltip, + InputLabel, + MenuItem, + FormControl +} from "@mui/material" +import VisibilityOffIcon from '@mui/icons-material/VisibilityOff'; +import VisibilityOnIcon from '@mui/icons-material/Visibility'; import Select, { SelectChangeEvent } from '@mui/material/Select'; // @ts-ignore import { getLayoutManagerInstance } from "@metacell/geppetto-meta-client/common/layout/LayoutManager"; // @ts-ignore -import { addWidget } from '@metacell/geppetto-meta-client/common/layout/actions'; +import { addWidget, updateWidget } from '@metacell/geppetto-meta-client/common/layout/actions'; +// @ts-ignore +import { Widget, WidgetStatus } from "@metacell/geppetto-meta-client/common/layout/model"; import '@metacell/geppetto-meta-ui/flex-layout/style/dark.scss' import { componentWidget } from "../widgets"; @@ -16,10 +28,13 @@ import { componentWidget } from "../widgets"; const HomePage = () => { const store = useStore(); const dispatch = useDispatch(); + // @ts-ignore + const widgets = useSelector(state => state.widgets); const [LayoutComponent, setLayoutComponent] = useState(undefined); const [panel, setPanel] = useState("topLeft"); const [name, setName] = useState("Component 1"); const [color, setColor] = useState("red"); + useEffect(() => { if (LayoutComponent === undefined) { const myManager = getLayoutManagerInstance(); @@ -27,13 +42,21 @@ const HomePage = () => { setLayoutComponent(myManager.getComponent() as React.ComponentType); } } - }, [store]) + }, [store, LayoutComponent]) const addComponent = () => { dispatch(addWidget(componentWidget(name, color, panel))); }; + const activateWidget = (widget: Widget) => { + const updatedWidget = { ...widget }; + updatedWidget.status = WidgetStatus.ACTIVE; + updatedWidget.panelName = panel; + dispatch(updateWidget(updatedWidget)); + }; + + return ( { display: 'flex', padding: 2 }}> - + setName(event.target.value as string) - } /> + }/> Panel