elbe-ui 0.4.15 → 0.4.18
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/api/api_worker.d.ts +4 -1
- package/dist/api/api_worker.js +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/ui/components/layout/header.d.ts +3 -2
- package/dist/ui/components/layout/page.d.ts +20 -0
- package/dist/ui/components/layout/page.js +39 -0
- package/package.json +1 -1
package/dist/api/api_worker.d.ts
CHANGED
|
@@ -15,7 +15,10 @@ export interface PostArgs extends GetArgs {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare class ApiWorker {
|
|
17
17
|
private apiURL;
|
|
18
|
-
|
|
18
|
+
private o?;
|
|
19
|
+
constructor(apiURL: string, o?: {
|
|
20
|
+
credentials?: "omit" | "include" | "same-origin";
|
|
21
|
+
} | undefined);
|
|
19
22
|
private _fetch;
|
|
20
23
|
get(path: string, args?: GetArgs): Promise<any>;
|
|
21
24
|
post(path: string, args: PostArgs): Promise<any>;
|
package/dist/api/api_worker.js
CHANGED
|
@@ -14,11 +14,13 @@ const _noArgs = {};
|
|
|
14
14
|
* to use it, you must first call `ApiService.init(apiURL)` with the base URL of your API.
|
|
15
15
|
*/
|
|
16
16
|
export class ApiWorker {
|
|
17
|
-
constructor(apiURL) {
|
|
17
|
+
constructor(apiURL, o) {
|
|
18
18
|
this.apiURL = apiURL;
|
|
19
|
+
this.o = o;
|
|
19
20
|
}
|
|
20
21
|
_fetch(p_1, method_1, _a) {
|
|
21
22
|
return __awaiter(this, arguments, void 0, function* (p, method, { path, query, body }) {
|
|
23
|
+
var _b, _c;
|
|
22
24
|
try {
|
|
23
25
|
p = path
|
|
24
26
|
? p.replace(/:([a-zA-Z0-9_]+)/g, (m, p1) => {
|
|
@@ -32,7 +34,7 @@ export class ApiWorker {
|
|
|
32
34
|
const queryStr = query != null ? "?" + new URLSearchParams(query).toString() : "";
|
|
33
35
|
const response = yield fetch(this.apiURL + p + queryStr, {
|
|
34
36
|
method,
|
|
35
|
-
credentials: "
|
|
37
|
+
credentials: (_c = (_b = this.o) === null || _b === void 0 ? void 0 : _b.credentials) !== null && _c !== void 0 ? _c : "same-origin",
|
|
36
38
|
headers: { "Content-Type": "application/json" },
|
|
37
39
|
body: body ? JSON.stringify(body) : undefined,
|
|
38
40
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from "./ui/components/layout/alignment";
|
|
|
22
22
|
export * from "./ui/components/layout/app_base";
|
|
23
23
|
export * from "./ui/components/layout/flex";
|
|
24
24
|
export * from "./ui/components/layout/header";
|
|
25
|
+
export * from "./ui/components/layout/page";
|
|
25
26
|
export * from "./ui/components/layout/scroll";
|
|
26
27
|
export * from "./ui/components/layout/spaced";
|
|
27
28
|
export * from "./ui/components/input/checkbox";
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./ui/components/layout/alignment";
|
|
|
25
25
|
export * from "./ui/components/layout/app_base";
|
|
26
26
|
export * from "./ui/components/layout/flex";
|
|
27
27
|
export * from "./ui/components/layout/header";
|
|
28
|
+
export * from "./ui/components/layout/page";
|
|
28
29
|
export * from "./ui/components/layout/scroll";
|
|
29
30
|
export * from "./ui/components/layout/spaced";
|
|
30
31
|
export * from "./ui/components/input/checkbox";
|
|
@@ -5,12 +5,13 @@ export type HeaderLogos = {
|
|
|
5
5
|
endLogo?: string | ElbeChild;
|
|
6
6
|
endLogoDark?: string | ElbeChild;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type HeaderProps = HeaderLogos & {
|
|
9
9
|
leading?: ElbeChild | "back" | "close";
|
|
10
10
|
title: string | ElbeChild;
|
|
11
11
|
centerTitle?: boolean;
|
|
12
12
|
actions?: ElbeChild[];
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare function Header(p: HeaderProps): import("preact").JSX.Element;
|
|
14
15
|
export declare function BackButton(p: {
|
|
15
16
|
onTap: () => void;
|
|
16
17
|
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ElbeChild, ElbeChildren } from "../../util/types";
|
|
2
|
+
import { HeaderProps } from "./header";
|
|
3
|
+
type ContentBaseProps = {
|
|
4
|
+
padding?: number;
|
|
5
|
+
narrow?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A component that represents a full page layout with a header and footer.
|
|
9
|
+
* It accepts header properties, content, and a footer element. All of these
|
|
10
|
+
* (except the children) are optional.
|
|
11
|
+
*
|
|
12
|
+
* ### Properties:
|
|
13
|
+
* - `narrow` will limit the width of the content to `900px`, and center it.
|
|
14
|
+
* - `padding` will add padding around the content, defaulting to `1rem`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Page(p: HeaderProps & ContentBaseProps & {
|
|
17
|
+
children: ElbeChildren;
|
|
18
|
+
footer: ElbeChild;
|
|
19
|
+
}): import("preact").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "preact/hooks";
|
|
3
|
+
import { Column } from "../../..";
|
|
4
|
+
import { Box } from "../base/box";
|
|
5
|
+
import { Header } from "./header";
|
|
6
|
+
/**
|
|
7
|
+
* A component that represents a full page layout with a header and footer.
|
|
8
|
+
* It accepts header properties, content, and a footer element. All of these
|
|
9
|
+
* (except the children) are optional.
|
|
10
|
+
*
|
|
11
|
+
* ### Properties:
|
|
12
|
+
* - `narrow` will limit the width of the content to `900px`, and center it.
|
|
13
|
+
* - `padding` will add padding around the content, defaulting to `1rem`.
|
|
14
|
+
*/
|
|
15
|
+
export function Page(p) {
|
|
16
|
+
const [hasHeader, setHasHeader] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const headerProps = Object.assign({}, p);
|
|
19
|
+
delete headerProps.children;
|
|
20
|
+
delete headerProps.footer;
|
|
21
|
+
delete headerProps.padding;
|
|
22
|
+
delete headerProps.narrow;
|
|
23
|
+
setHasHeader(Object.keys(headerProps).length > 0);
|
|
24
|
+
});
|
|
25
|
+
return (_jsxs(Box, { scheme: "primary", typeLabel: "page", style: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: "column",
|
|
28
|
+
alignItems: "stretch",
|
|
29
|
+
minHeight: "100vh",
|
|
30
|
+
}, children: [hasHeader && _jsx(Header, Object.assign({}, p)), _jsx(_ContentBase, { padding: p.padding, narrow: p.narrow, children: p.children }), p.footer] }));
|
|
31
|
+
}
|
|
32
|
+
function _ContentBase(p) {
|
|
33
|
+
return (_jsx(Column, { style: {
|
|
34
|
+
flex: 1,
|
|
35
|
+
padding: p.padding ? `${p.padding}rem` : "1rem",
|
|
36
|
+
width: p.narrow ? "min(100%, 900px)" : "auto",
|
|
37
|
+
margin: p.narrow ? "0 auto" : "0",
|
|
38
|
+
}, children: p.children }));
|
|
39
|
+
}
|