@basthon/console-react 0.6.8 → 0.8.7
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/lib/components/app.d.ts
CHANGED
package/lib/components/app.js
CHANGED
|
@@ -6,11 +6,13 @@ import { useGUI } from "../hooks/gui";
|
|
|
6
6
|
import stateManager from "../state-manager";
|
|
7
7
|
import { DispatchContext } from "../hooks/dispatch";
|
|
8
8
|
import { StateContext } from "../hooks/state";
|
|
9
|
+
import { HiddenButtonsContext } from "../hooks/hidden-buttons";
|
|
9
10
|
import { Header } from "./header";
|
|
10
11
|
import { MainContainer } from "./main-container";
|
|
11
12
|
import { Footer } from "./footer";
|
|
12
13
|
import * as styles from "./styles.module.scss";
|
|
13
|
-
const
|
|
14
|
+
const noHiddenButtons = [];
|
|
15
|
+
const InnerApp = ({ initFromStorage, storedStates, forceTheme, compactHeader, header, panelTitles, hiddenButtons, onChangeEditor, children, }) => {
|
|
14
16
|
const gui = useGUI();
|
|
15
17
|
// state
|
|
16
18
|
const [state, dispatch] = stateManager.useReducer(gui.language, initFromStorage ?? true, storedStates);
|
|
@@ -26,12 +28,12 @@ const InnerApp = ({ initFromStorage, storedStates, forceTheme, compactHeader, he
|
|
|
26
28
|
};
|
|
27
29
|
}, [theme]);
|
|
28
30
|
// build component
|
|
29
|
-
return (_jsx(DispatchContext.Provider, { value: dispatch, children:
|
|
31
|
+
return (_jsx(DispatchContext.Provider, { value: dispatch, children: _jsx(StateContext.Provider, { value: { ...state, theme }, children: _jsxs(HiddenButtonsContext.Provider, { value: hiddenButtons ?? noHiddenButtons, children: [children, _jsxs("div", { className: styles.root, children: [header !== undefined ? (header) : (_jsx(Header, { language: language, theme: theme, compact: compactHeader })), stateManager.ready(state) && (_jsx(MainContainer, { language: language, theme: theme, viewMode: stateManager.viewMode(state), rightPanel: stateManager.rightPanel(state), graphicsDirty: stateManager.graphicsDirty(state), editorContent: stateManager.editorContent(state), onChangeEditor: onChangeEditor, compactHeader: compactHeader, panelTitles: panelTitles })), _jsx(Footer, { theme: theme })] })] }) }) }));
|
|
30
32
|
};
|
|
31
33
|
/**
|
|
32
34
|
* Main app setting up state manager, header, main container and footer.
|
|
33
35
|
*/
|
|
34
|
-
const ConsoleApp = ({ initFromStorage, storedStates, forceTheme, compactHeader, header, panelTitles, onChangeEditor, children, ...props }) => {
|
|
36
|
+
const ConsoleApp = ({ initFromStorage, storedStates, forceTheme, compactHeader, header, panelTitles, hiddenButtons, onChangeEditor, children, ...props }) => {
|
|
35
37
|
// custom GUI classes should extend the console's GUI
|
|
36
38
|
props.GUI ?? (props.GUI = GUI);
|
|
37
39
|
const innerProps = {
|
|
@@ -41,6 +43,7 @@ const ConsoleApp = ({ initFromStorage, storedStates, forceTheme, compactHeader,
|
|
|
41
43
|
compactHeader,
|
|
42
44
|
header,
|
|
43
45
|
panelTitles,
|
|
46
|
+
hiddenButtons,
|
|
44
47
|
onChangeEditor,
|
|
45
48
|
};
|
|
46
49
|
return (_jsx(BasthonContext, { ...props, children: _jsx(InnerApp, { ...innerProps, children: children }) }));
|
package/lib/components/button.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useHiddenButtons } from "../hooks/hidden-buttons";
|
|
2
3
|
import * as styles from "./styles.module.scss";
|
|
3
4
|
const Button = ({ children, titled, blink, className: extraClassName, ...props }) => {
|
|
5
|
+
const hiddenButtons = useHiddenButtons();
|
|
6
|
+
if (props.id != null && hiddenButtons.includes(props.id))
|
|
7
|
+
return null;
|
|
4
8
|
const classNames = [styles.btn];
|
|
5
9
|
if (blink === true)
|
|
6
10
|
classNames.push(styles["btn-eye-catcher"]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
/* ids of the buttons that should not be displayed */
|
|
3
|
+
const HiddenButtonsContext = createContext([]);
|
|
4
|
+
const useHiddenButtons = () => useContext(HiddenButtonsContext);
|
|
5
|
+
export { HiddenButtonsContext, useHiddenButtons };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basthon/console-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "Basthon - Console React Component",
|
|
5
5
|
"homepage": "https://basthon.fr",
|
|
6
6
|
"bugs": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"clean": "rimraf lib/"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@basthon/gui-react": "0.78.
|
|
56
|
+
"@basthon/gui-react": "0.78.7",
|
|
57
57
|
"@fontsource/open-sans": "^5.2.7",
|
|
58
58
|
"@fortawesome/fontawesome-svg-core": "7.3.0",
|
|
59
59
|
"@fortawesome/free-regular-svg-icons": "7.3.0",
|