elbe-ui 0.4.14 → 0.4.15
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.
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VNode } from "preact";
|
|
2
|
+
import { NestedArray } from "preact-iso";
|
|
3
|
+
import { ElbeChild, HeaderLogos } from "../../..";
|
|
2
4
|
import { MenuItem } from "./menu";
|
|
3
5
|
export type AppBaseProps = HeaderLogos & {
|
|
4
6
|
initial?: string;
|
|
5
7
|
menu: MenuItem[];
|
|
6
8
|
globalActions?: ElbeChild[];
|
|
7
|
-
children:
|
|
9
|
+
children: NestedArray<VNode>;
|
|
8
10
|
};
|
|
9
11
|
/**
|
|
10
12
|
* app base is a layout component that provides a side menu and a content area.
|
|
@@ -12,4 +14,8 @@ export type AppBaseProps = HeaderLogos & {
|
|
|
12
14
|
* used to create a consistent layout for pages. You can also pass global actions
|
|
13
15
|
* that will be displayed in the header of all pages.
|
|
14
16
|
*/
|
|
15
|
-
export declare function AppBase(p: AppBaseProps): import("preact
|
|
17
|
+
export declare function AppBase(p: AppBaseProps): import("preact").JSX.Element;
|
|
18
|
+
export declare const Redirect: (p: {
|
|
19
|
+
path: string;
|
|
20
|
+
to: string;
|
|
21
|
+
}) => null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Router, useLocation } from "preact-iso";
|
|
3
|
+
import { useEffect, useState } from "preact/compat";
|
|
3
4
|
import { Box } from "../../..";
|
|
4
5
|
import { AppBaseContext } from "./ctx_app_base";
|
|
5
6
|
import { Menu } from "./menu";
|
|
@@ -10,7 +11,7 @@ import { Menu } from "./menu";
|
|
|
10
11
|
* that will be displayed in the header of all pages.
|
|
11
12
|
*/
|
|
12
13
|
export function AppBase(p) {
|
|
13
|
-
var _a;
|
|
14
|
+
var _a, _b;
|
|
14
15
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
15
16
|
return (_jsx(AppBaseContext.Provider, { value: {
|
|
16
17
|
menuOpen: menuOpen,
|
|
@@ -26,5 +27,12 @@ export function AppBase(p) {
|
|
|
26
27
|
display: "flex",
|
|
27
28
|
width: "100%",
|
|
28
29
|
minHeight: "100vh",
|
|
29
|
-
}, children: [_jsx(Menu, { items: p.menu }), _jsx("div", { style: { flex: 1 }, children: p.children })] }) }));
|
|
30
|
+
}, children: [_jsx(Menu, { items: p.menu }), _jsx("div", { style: { flex: 1 }, children: _jsxs(Router, { children: [_jsx(Redirect, { path: "/", to: `/${(_b = p.initial) !== null && _b !== void 0 ? _b : p.menu[0].id}` }), p.children] }) })] }) }));
|
|
30
31
|
}
|
|
32
|
+
export const Redirect = (p) => {
|
|
33
|
+
const location = useLocation();
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
location.route(p.to, true);
|
|
36
|
+
}, [p.to]);
|
|
37
|
+
return null; // This component doesn't render anything
|
|
38
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
import { useComputed } from "@preact/signals";
|
|
3
2
|
import { MenuIcon } from "lucide-react";
|
|
4
|
-
import {
|
|
3
|
+
import { useLocation } from "preact-iso";
|
|
5
4
|
import { useLayoutMode, useTheme, useThemeConfig } from "../../..";
|
|
6
5
|
import { Card, elevatedShadow } from "../base/card";
|
|
7
6
|
import { Button } from "../button/button";
|
|
@@ -54,10 +53,7 @@ export function Menu(p) {
|
|
|
54
53
|
} }), _jsx(Column, { flex: 1, scroll: true, noScrollbar: true, children: topBot.top.map((i) => (_jsx(_MenuItemView, { item: i }))) }), topBot.bottom.map((i) => (_jsx(_MenuItemView, { item: i })))] })) })] }));
|
|
55
54
|
}
|
|
56
55
|
function _MenuItemView({ item }) {
|
|
57
|
-
const
|
|
58
|
-
const log = document.location.pathname;
|
|
59
|
-
return log.startsWith(`/${item.id}`);
|
|
60
|
-
});
|
|
56
|
+
const location = useLocation();
|
|
61
57
|
const appBase = useAppBase();
|
|
62
|
-
return (_jsx(Button, { ariaLabel: item.label, contentAlign: "start", manner:
|
|
58
|
+
return (_jsx(Button, { ariaLabel: item.label, contentAlign: "start", manner: location.path.startsWith(`/${item.id}`) ? "major" : "plain", label: appBase.menuOpen ? item.label : undefined, icon: item.icon, onTap: item.disabled ? undefined : () => location.route(`/${item.id}`, true) }));
|
|
63
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elbe-ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"author": "Robin Naumann",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"colors-convert": "^1.4.1",
|
|
39
39
|
"lucide-react": "^0.438.0",
|
|
40
40
|
"preact": "^10.24.2",
|
|
41
|
+
"preact-iso": "^2.9.1",
|
|
41
42
|
"preact-router": "^4.1.2",
|
|
42
43
|
"vite": "^5.4.10"
|
|
43
44
|
}
|