elbe-ui 2.0.2 → 2.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/dist/ui/app/app.js +8 -0
- package/dist/ui/app/app_ctxt.d.ts +2 -0
- package/dist/ui/components/button/button.js +19 -19
- package/dist/ui/components/layout/page.d.ts +7 -1
- package/dist/ui/components/layout/page.js +10 -2
- package/dist/ui/util/root.d.ts +3 -0
- package/dist/ui/util/root.js +6 -4
- package/package.json +2 -2
package/dist/ui/app/app.js
CHANGED
|
@@ -26,6 +26,14 @@ function _App(p) {
|
|
|
26
26
|
p.config,
|
|
27
27
|
p.themeSelector,
|
|
28
28
|
]);
|
|
29
|
+
useMemo(() => {
|
|
30
|
+
if (p.config.noGlobalStyles)
|
|
31
|
+
return;
|
|
32
|
+
// apply global background of html and body elements
|
|
33
|
+
const bg = themeSelected.theme.color.currentColor.back.asCss();
|
|
34
|
+
document.documentElement.style.backgroundColor = bg;
|
|
35
|
+
document.body.style.backgroundColor = bg;
|
|
36
|
+
}, [themeSelected, p.config.noGlobalStyles]);
|
|
29
37
|
const menuItems = useMemo(() => {
|
|
30
38
|
return _extractMenuItems(p.children);
|
|
31
39
|
}, [p.children]);
|
|
@@ -9,6 +9,8 @@ export type AppConfig = {
|
|
|
9
9
|
routerConfig?: {
|
|
10
10
|
basePath?: string;
|
|
11
11
|
};
|
|
12
|
+
/** If true, global styles will not be applied. This can be useful for embedding Elbe in an existing app with its own styles. */
|
|
13
|
+
noGlobalStyles?: boolean;
|
|
12
14
|
};
|
|
13
15
|
type _MenuState = {
|
|
14
16
|
isOpen: boolean;
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Component } from "react";
|
|
14
14
|
import { Row, Text } from "../../..";
|
|
15
15
|
import { useApp } from "../../app/app_ctxt";
|
|
16
|
-
import { useToolbar } from "../../util/ctx_toolbar";
|
|
16
|
+
import { ToolbarContext, useToolbar } from "../../util/ctx_toolbar";
|
|
17
17
|
import { applyProps } from "../base/box";
|
|
18
18
|
import { WithStateTheme } from "../base/state_builder";
|
|
19
19
|
import { WithTooltip } from "../tooltip";
|
|
@@ -35,24 +35,24 @@ function _Btn(_a) {
|
|
|
35
35
|
const baseTheme = _appThemeContext.useTheme().useWith(({ color }) => ({
|
|
36
36
|
color: Object.assign(Object.assign({}, color), { selection: Object.assign(Object.assign({}, color.selection), { kind: kind !== null && kind !== void 0 ? kind : color.selection.kind, manner: manner }) }),
|
|
37
37
|
}), [kind, manner]);
|
|
38
|
-
return label || icon || children ? (_jsx(WithTooltip, { tooltip: elbe.tooltip, children: _jsx(WithStateTheme, { theme: baseTheme, disabled: !onTap, children: _jsx("button", Object.assign({}, applyProps("button", Object.assign(Object.assign({ role: "button" }, elbe), { flex: (toolbarCtx === null || toolbarCtx === void 0 ? void 0 : toolbarCtx.isInOverflow) ? 1 : elbe.flex }), ["elbe_colored"], {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
return label || icon || children ? (_jsx(ToolbarContext.Provider, { value: null, children: _jsx(WithTooltip, { tooltip: elbe.tooltip, children: _jsx(WithStateTheme, { theme: baseTheme, disabled: !onTap, children: _jsx("button", Object.assign({}, applyProps("button", Object.assign(Object.assign({ role: "button" }, elbe), { flex: (toolbarCtx === null || toolbarCtx === void 0 ? void 0 : toolbarCtx.isInOverflow) ? 1 : elbe.flex }), ["elbe_colored"], {
|
|
39
|
+
/*backgroundColor: elbe.transparent
|
|
40
|
+
? "transparent"
|
|
41
|
+
: usedTheme.theme.color.currentColor.back.asCss(),*/
|
|
42
|
+
cursor: "inherit",
|
|
43
|
+
padding: "0.25rem .75rem",
|
|
44
|
+
minHeight: "3rem",
|
|
45
|
+
minWidth: "3rem",
|
|
46
|
+
border: "none",
|
|
47
|
+
backgroundColor: elbe.transparent ? "transparent" : undefined,
|
|
48
|
+
borderRadius: elbe.sharp
|
|
49
|
+
? 0
|
|
50
|
+
: baseTheme.theme.geometry.radius + "rem",
|
|
51
|
+
}), { title: elbe.tooltip ? undefined : (_b = elbe.ariaLabel) !== null && _b !== void 0 ? _b : label, disabled: !onTap, onClick: (e) => onTap && onTap(e), children: _jsxs(Row, { cross: "center", main: contentAlign !== null && contentAlign !== void 0 ? contentAlign : ((toolbarCtx === null || toolbarCtx === void 0 ? void 0 : toolbarCtx.isInOverflow) ? "start" : "center"), gap: (_c = elbe.gap) !== null && _c !== void 0 ? _c : 0.5, children: [_jsx(Icon, { icon: icon }), !(toolbarCtx === null || toolbarCtx === void 0 ? void 0 : toolbarCtx.isInToolbar) && label && (_jsx(Text, { bold: true, style: {
|
|
52
|
+
whiteSpace: "nowrap",
|
|
53
|
+
overflow: "hidden",
|
|
54
|
+
textOverflow: "ellipsis",
|
|
55
|
+
}, v: label })), children] }) })) }) }) })) : (_jsx("div", {})
|
|
56
56
|
//_ElbeErr("Button requires either an icon and or a label, or a child")
|
|
57
57
|
);
|
|
58
58
|
}
|
|
@@ -16,9 +16,15 @@ type ContentBaseProps = {
|
|
|
16
16
|
* - `padding` will add padding around the content, defaulting to `1rem`.
|
|
17
17
|
* - `leading` can be used to add a back or close button to the header. Setting it
|
|
18
18
|
* "back" or "close" will automatically show the button if there is history to go back to.
|
|
19
|
+
* - `title` sets the title of the page in the header.
|
|
20
|
+
* - `centerTitle` will center the title in the header.
|
|
21
|
+
* - `actions` can be used to add action buttons to the header.
|
|
22
|
+
* - `scheme` sets the color scheme of the page.
|
|
23
|
+
* - `footer` can be used to set a custom footer element. If not provided, the app's default
|
|
24
|
+
* footer will be used. If set to `null`, no footer will be rendered.
|
|
19
25
|
*/
|
|
20
26
|
export declare function Page(p: HeaderProps & ContentBaseProps & {
|
|
21
27
|
children?: ElbeChildren;
|
|
22
|
-
footer?: ElbeChild;
|
|
28
|
+
footer?: ElbeChild | null;
|
|
23
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
24
30
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Column } from "../../..";
|
|
3
|
+
import { useApp } from "../../app/app_ctxt";
|
|
3
4
|
import { Box } from "../base/box";
|
|
4
5
|
import { Header } from "./header";
|
|
5
6
|
function _hasMoreThan(p, expected) {
|
|
@@ -15,9 +16,16 @@ function _hasMoreThan(p, expected) {
|
|
|
15
16
|
* - `padding` will add padding around the content, defaulting to `1rem`.
|
|
16
17
|
* - `leading` can be used to add a back or close button to the header. Setting it
|
|
17
18
|
* "back" or "close" will automatically show the button if there is history to go back to.
|
|
19
|
+
* - `title` sets the title of the page in the header.
|
|
20
|
+
* - `centerTitle` will center the title in the header.
|
|
21
|
+
* - `actions` can be used to add action buttons to the header.
|
|
22
|
+
* - `scheme` sets the color scheme of the page.
|
|
23
|
+
* - `footer` can be used to set a custom footer element. If not provided, the app's default
|
|
24
|
+
* footer will be used. If set to `null`, no footer will be rendered.
|
|
18
25
|
*/
|
|
19
26
|
export function Page(p) {
|
|
20
|
-
var _a;
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const appConfig = useApp();
|
|
21
29
|
const hasHeader = _hasMoreThan(p, [
|
|
22
30
|
"children",
|
|
23
31
|
"footer",
|
|
@@ -32,7 +40,7 @@ export function Page(p) {
|
|
|
32
40
|
alignItems: "stretch",
|
|
33
41
|
minHeight: "100vh",
|
|
34
42
|
height: p.noScroll ? "100vh" : "auto",
|
|
35
|
-
}, children: [hasHeader && _jsx(Header, Object.assign({}, p)), _jsx(_ContentBase, { padding: p.padding, narrow: p.narrow, children: p.children }), p.footer] }));
|
|
43
|
+
}, children: [hasHeader && _jsx(Header, Object.assign({}, p)), _jsx(_ContentBase, { padding: p.padding, narrow: p.narrow, children: p.children }), p.footer === null ? null : (_b = p.footer) !== null && _b !== void 0 ? _b : appConfig.appConfig.footer] }));
|
|
36
44
|
}
|
|
37
45
|
function _ContentBase(p) {
|
|
38
46
|
return (_jsx(Column, { style: {
|
package/dist/ui/util/root.d.ts
CHANGED
|
@@ -5,12 +5,15 @@ export declare const elbeDomElements: {
|
|
|
5
5
|
};
|
|
6
6
|
readonly elbe_dialog: {
|
|
7
7
|
readonly zindex: 1000;
|
|
8
|
+
readonly position: "absolute";
|
|
8
9
|
};
|
|
9
10
|
readonly elbe_tooltip: {
|
|
10
11
|
readonly zindex: 2000;
|
|
12
|
+
readonly position: "absolute";
|
|
11
13
|
};
|
|
12
14
|
readonly elbe_toast: {
|
|
13
15
|
readonly zindex: 3000;
|
|
16
|
+
readonly position: "fixed";
|
|
14
17
|
};
|
|
15
18
|
};
|
|
16
19
|
export declare function getRootElement(id: keyof typeof elbeDomElements): HTMLElement;
|
package/dist/ui/util/root.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRoot } from "react-dom/client";
|
|
2
2
|
export const elbeDomElements = {
|
|
3
3
|
elbe_app: { zindex: 0 },
|
|
4
|
-
elbe_dialog: { zindex: 1000 },
|
|
5
|
-
elbe_tooltip: { zindex: 2000 },
|
|
6
|
-
elbe_toast: { zindex: 3000 },
|
|
4
|
+
elbe_dialog: { zindex: 1000, position: "absolute" },
|
|
5
|
+
elbe_tooltip: { zindex: 2000, position: "absolute" },
|
|
6
|
+
elbe_toast: { zindex: 3000, position: "fixed" },
|
|
7
7
|
};
|
|
8
8
|
export function getRootElement(id) {
|
|
9
9
|
const existing = document.getElementById(id);
|
|
@@ -12,7 +12,9 @@ export function getRootElement(id) {
|
|
|
12
12
|
console.info(`ELBE: root element '${id}' not found. Creating...`);
|
|
13
13
|
const el = document.createElement("div");
|
|
14
14
|
el.id = id;
|
|
15
|
-
|
|
15
|
+
for (const [key, value] of Object.entries(elbeDomElements[id])) {
|
|
16
|
+
el.style[key] = value;
|
|
17
|
+
}
|
|
16
18
|
el.setAttribute("note", "auto-created by elbe-ui");
|
|
17
19
|
document.body.appendChild(el);
|
|
18
20
|
return el;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elbe-ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"author": "Robin Naumann",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build:css": "sass -q style/elbe-util.scss dist/elbe.css",
|
|
25
25
|
"build": "rm -rf ./dist && bun run build:ts && bun run build:dts && bun run build:css ",
|
|
26
26
|
"dev": "bun run build && (cd example && bun run dev)",
|
|
27
|
-
"pub": "bun run build && npm publish"
|
|
27
|
+
"pub": "npm login && bun run build && npm publish"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/bun": "^1.3.4",
|