elbe-ui 0.4.11 → 0.4.14
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/dist/ui/components/layout/app_base.d.ts +2 -1
- package/dist/ui/components/layout/app_base.js +10 -8
- package/dist/ui/components/layout/ctx_app_base.d.ts +0 -2
- package/dist/ui/components/layout/menu.d.ts +1 -2
- package/dist/ui/components/layout/menu.js +7 -3
- package/dist/ui/theme/theme.js +9 -1
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ElbeChild, HeaderLogos } from "../../..";
|
|
1
|
+
import { ElbeChild, ElbeChildren, HeaderLogos } from "../../..";
|
|
2
2
|
import { MenuItem } from "./menu";
|
|
3
3
|
export type AppBaseProps = HeaderLogos & {
|
|
4
4
|
initial?: string;
|
|
5
5
|
menu: MenuItem[];
|
|
6
6
|
globalActions?: ElbeChild[];
|
|
7
|
+
children: ElbeChildren;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* app base is a layout component that provides a side menu and a content area.
|
|
@@ -10,19 +10,21 @@ import { Menu } from "./menu";
|
|
|
10
10
|
* that will be displayed in the header of all pages.
|
|
11
11
|
*/
|
|
12
12
|
export function AppBase(p) {
|
|
13
|
-
var _a
|
|
14
|
-
const [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (_jsx(AppBaseContext.Provider, { value: Object.assign(Object.assign({}, state), { icons: {
|
|
13
|
+
var _a;
|
|
14
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
15
|
+
return (_jsx(AppBaseContext.Provider, { value: {
|
|
16
|
+
menuOpen: menuOpen,
|
|
17
|
+
icons: {
|
|
19
18
|
logo: p.logo,
|
|
20
19
|
logoDark: p.logoDark,
|
|
21
20
|
endLogo: p.endLogo,
|
|
22
21
|
endLogoDark: p.endLogoDark,
|
|
23
|
-
},
|
|
22
|
+
},
|
|
23
|
+
globalActions: (_a = p.globalActions) !== null && _a !== void 0 ? _a : [],
|
|
24
|
+
setMenuOpen: (b) => setMenuOpen(b),
|
|
25
|
+
}, children: _jsxs(Box, { scheme: "primary", style: {
|
|
24
26
|
display: "flex",
|
|
25
27
|
width: "100%",
|
|
26
28
|
minHeight: "100vh",
|
|
27
|
-
}, children: [_jsx(Menu, { items: p.menu }), _jsx("div", { style: { flex: 1 }, children:
|
|
29
|
+
}, children: [_jsx(Menu, { items: p.menu }), _jsx("div", { style: { flex: 1 }, children: p.children })] }) }));
|
|
28
30
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ElbeChild } from "../../util/types";
|
|
2
2
|
import { HeaderLogos } from "./header";
|
|
3
3
|
export interface _AppBaseState {
|
|
4
|
-
menuSelected: string | null;
|
|
5
4
|
menuOpen: boolean;
|
|
6
5
|
icons: HeaderLogos;
|
|
7
6
|
globalActions: ElbeChild[];
|
|
8
7
|
}
|
|
9
8
|
interface _AppBaseControl extends _AppBaseState {
|
|
10
9
|
setMenuOpen: (open: boolean) => void;
|
|
11
|
-
setMenuSelected: (selected: string) => void;
|
|
12
10
|
}
|
|
13
11
|
export declare const AppBaseContext: import("preact").Context<_AppBaseControl | null>;
|
|
14
12
|
export declare function useAppBase(): _AppBaseControl;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { ElbeChild } from "../../..";
|
|
2
1
|
import { IconChild } from "../button/icon_button";
|
|
3
2
|
export type MenuItem = {
|
|
4
3
|
id: string;
|
|
5
4
|
label: string;
|
|
6
5
|
icon?: IconChild;
|
|
7
6
|
bottom?: boolean;
|
|
8
|
-
|
|
7
|
+
disabled?: boolean;
|
|
9
8
|
};
|
|
10
9
|
export declare function Menu(p: {
|
|
11
10
|
items: MenuItem[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useComputed } from "@preact/signals";
|
|
2
3
|
import { MenuIcon } from "lucide-react";
|
|
4
|
+
import { route } from "preact-router";
|
|
3
5
|
import { useLayoutMode, useTheme, useThemeConfig } from "../../..";
|
|
4
6
|
import { Card, elevatedShadow } from "../base/card";
|
|
5
7
|
import { Button } from "../button/button";
|
|
@@ -52,8 +54,10 @@ export function Menu(p) {
|
|
|
52
54
|
} }), _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 })))] })) })] }));
|
|
53
55
|
}
|
|
54
56
|
function _MenuItemView({ item }) {
|
|
57
|
+
const selected = useComputed(() => {
|
|
58
|
+
const log = document.location.pathname;
|
|
59
|
+
return log.startsWith(`/${item.id}`);
|
|
60
|
+
});
|
|
55
61
|
const appBase = useAppBase();
|
|
56
|
-
return (_jsx(Button, { ariaLabel: item.label, contentAlign: "start", manner:
|
|
57
|
-
? () => appBase.setMenuSelected(item.id)
|
|
58
|
-
: undefined }));
|
|
62
|
+
return (_jsx(Button, { ariaLabel: item.label, contentAlign: "start", manner: selected.value ? "major" : "plain", label: appBase.menuOpen ? item.label : undefined, icon: item.icon, onTap: item.disabled ? undefined : () => route(`/${item.id}`, true) }));
|
|
59
63
|
}
|
package/dist/ui/theme/theme.js
CHANGED
|
@@ -36,7 +36,6 @@ export function ElbeTheme(p) {
|
|
|
36
36
|
function _addTooltip() {
|
|
37
37
|
return useEffect(() => {
|
|
38
38
|
const _gap = 8;
|
|
39
|
-
console.log("add tooltip");
|
|
40
39
|
const onHover = (e) => {
|
|
41
40
|
var _a;
|
|
42
41
|
const target = (_a = e.target) === null || _a === void 0 ? void 0 : _a.closest("[data-tooltip]");
|
|
@@ -63,6 +62,15 @@ function _addTooltip() {
|
|
|
63
62
|
left = window.innerWidth - tooltip.offsetWidth - _gap;
|
|
64
63
|
tooltip.style.top = `${top}px`;
|
|
65
64
|
tooltip.style.left = `${left}px`;
|
|
65
|
+
// remove tooltip when target is removed or mouse leaves
|
|
66
|
+
const observer = new MutationObserver(() => {
|
|
67
|
+
if (!document.body.contains(target) ||
|
|
68
|
+
target === null) {
|
|
69
|
+
tooltip.remove();
|
|
70
|
+
observer.disconnect();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
66
74
|
target.addEventListener("mouseleave", () => tooltip.remove(), {
|
|
67
75
|
once: true,
|
|
68
76
|
});
|