elbe-ui 0.2.37 → 0.2.44
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/README.md +6 -0
- package/dist/bit/bit.d.ts +4 -1
- package/dist/bit/bit.js +24 -28
- package/dist/bit/ctrl_bit.js +47 -28
- package/dist/elbe.css +71 -30
- package/dist/elbe.css.map +1 -1
- package/dist/index.js +33 -62
- package/dist/service/s_api.js +62 -49
- package/dist/ui/components/badge.js +13 -34
- package/dist/ui/components/base/box.js +21 -23
- package/dist/ui/components/base/card.js +19 -10
- package/dist/ui/components/base/padded.js +25 -16
- package/dist/ui/components/button/button.js +30 -22
- package/dist/ui/components/button/choose_button.js +7 -10
- package/dist/ui/components/button/icon_button.js +36 -26
- package/dist/ui/components/button/toggle_button.js +19 -10
- package/dist/ui/components/dialog.js +7 -10
- package/dist/ui/components/error_view.js +14 -16
- package/dist/ui/components/input/checkbox.js +17 -8
- package/dist/ui/components/input/input_field.js +28 -23
- package/dist/ui/components/input/range.js +26 -9
- package/dist/ui/components/input/select.js +16 -7
- package/dist/ui/components/input/text_area.js +17 -8
- package/dist/ui/components/layout/flex.js +24 -16
- package/dist/ui/components/layout/scaffold.d.ts +4 -3
- package/dist/ui/components/layout/scaffold.js +28 -18
- package/dist/ui/components/layout/scroll.js +10 -14
- package/dist/ui/components/layout/spaced.js +3 -6
- package/dist/ui/components/spinner.js +16 -19
- package/dist/ui/components/text.js +42 -37
- package/dist/ui/theme/color_theme.js +36 -42
- package/dist/ui/theme/colors.d.ts +2 -3
- package/dist/ui/theme/colors.js +42 -78
- package/dist/ui/theme/geometry_theme.js +8 -16
- package/dist/ui/theme/theme.js +12 -34
- package/dist/ui/theme/type_theme.js +11 -39
- package/dist/ui/util/confirm_dialog.js +1 -4
- package/dist/ui/util/error_view.js +4 -7
- package/dist/ui/util/toast.js +1 -4
- package/dist/ui/util/util.js +8 -13
- package/package.json +3 -2
package/dist/service/s_api.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
5
10
|
const _noArgs = {};
|
|
6
11
|
/**
|
|
7
12
|
* ApiService is a simple wrapper around fetch that handles JSON serialization and error handling.
|
|
8
13
|
* to use it, you must first call `ApiService.init(apiURL)` with the base URL of your API.
|
|
9
14
|
*/
|
|
10
|
-
class ApiService {
|
|
11
|
-
apiURL;
|
|
12
|
-
static _i = null;
|
|
15
|
+
export class ApiService {
|
|
13
16
|
static get i() {
|
|
14
17
|
if (!ApiService._i)
|
|
15
18
|
throw "ApiService not initialized. Call ApiService.init(apiURL)";
|
|
@@ -23,66 +26,76 @@ class ApiService {
|
|
|
23
26
|
throw "ApiService already initialized";
|
|
24
27
|
ApiService._i = new ApiService(apiURL);
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
_fetch(p_1, method_1, _a) {
|
|
30
|
+
return __awaiter(this, arguments, void 0, function* (p, method, { path, query, body }) {
|
|
31
|
+
var _b;
|
|
32
|
+
try {
|
|
33
|
+
p = path
|
|
34
|
+
? p.replace(/:([a-zA-Z0-9_]+)/g, (m, p1) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const v = path[p1];
|
|
37
|
+
if (v === undefined)
|
|
38
|
+
throw { code: 400, message: `missing parameter ${p1}` };
|
|
39
|
+
return (_a = v === null || v === void 0 ? void 0 : v.toString()) !== null && _a !== void 0 ? _a : "";
|
|
40
|
+
})
|
|
41
|
+
: p;
|
|
42
|
+
const queryStr = query != null ? "?" + new URLSearchParams(query).toString() : "";
|
|
43
|
+
const response = yield fetch(this.apiURL + p + queryStr, {
|
|
44
|
+
method,
|
|
45
|
+
credentials: "include",
|
|
46
|
+
headers: { "Content-Type": "application/json" },
|
|
47
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
48
|
+
});
|
|
49
|
+
if (response.ok) {
|
|
50
|
+
try {
|
|
51
|
+
return yield response.json();
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let data = null;
|
|
44
58
|
try {
|
|
45
|
-
|
|
59
|
+
data = yield response.clone().json();
|
|
46
60
|
}
|
|
47
61
|
catch (e) {
|
|
48
|
-
|
|
62
|
+
data = yield response.text();
|
|
49
63
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
throw {
|
|
65
|
+
code: response.status,
|
|
66
|
+
message: (_b = data.message) !== null && _b !== void 0 ? _b : "undefined error",
|
|
67
|
+
data,
|
|
68
|
+
};
|
|
54
69
|
}
|
|
55
70
|
catch (e) {
|
|
56
|
-
|
|
71
|
+
rethrow(e, 0, "unknown error");
|
|
57
72
|
}
|
|
58
|
-
|
|
59
|
-
code: response.status,
|
|
60
|
-
message: data.message ?? "undefined error",
|
|
61
|
-
data,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
rethrow(e, 0, "unknown error");
|
|
66
|
-
}
|
|
73
|
+
});
|
|
67
74
|
}
|
|
68
|
-
|
|
69
|
-
return this
|
|
75
|
+
get(path, args) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
return this._fetch(path, "GET", args || _noArgs);
|
|
78
|
+
});
|
|
70
79
|
}
|
|
71
|
-
|
|
72
|
-
return this
|
|
80
|
+
post(path, args) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
return this._fetch(path, "POST", args || _noArgs);
|
|
83
|
+
});
|
|
73
84
|
}
|
|
74
|
-
|
|
75
|
-
return this
|
|
85
|
+
delete(path, args) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
return this._fetch(path, "DELETE", args || _noArgs);
|
|
88
|
+
});
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
|
-
|
|
91
|
+
ApiService._i = null;
|
|
79
92
|
function rethrow(e, code, message) {
|
|
80
93
|
// if e implements the apiError interface, rethrow it:
|
|
81
94
|
if (e && e.code !== null && e.message !== null)
|
|
82
95
|
throw e;
|
|
83
96
|
throw { code, message, data: e };
|
|
84
97
|
}
|
|
85
|
-
function ifApiError(e) {
|
|
98
|
+
export function ifApiError(e) {
|
|
86
99
|
if (e && e.code !== null && e.message !== null)
|
|
87
100
|
return e;
|
|
88
101
|
return null;
|
|
@@ -1,53 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Badge = void 0;
|
|
7
|
-
exports.TestBadge = TestBadge;
|
|
8
|
-
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
9
|
-
const compat_1 = __importDefault(require("preact/compat"));
|
|
10
|
-
function TestBadge(p) {
|
|
11
|
-
return new Badge({ ...p, kind: "accent" });
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import React from "preact/compat";
|
|
3
|
+
export function TestBadge(p) {
|
|
4
|
+
return new Badge(Object.assign(Object.assign({}, p), { kind: "accent" }));
|
|
12
5
|
}
|
|
13
|
-
class Badge extends
|
|
6
|
+
export class Badge extends React.Component {
|
|
14
7
|
constructor(props) {
|
|
15
8
|
super(props);
|
|
16
9
|
}
|
|
17
10
|
static accent(p) {
|
|
18
|
-
return (
|
|
11
|
+
return _jsx(Badge, Object.assign({}, p, { kind: "accent" }));
|
|
19
12
|
}
|
|
20
13
|
static error(p) {
|
|
21
|
-
return (
|
|
14
|
+
return _jsx(Badge, Object.assign({}, p, { kind: "error" }));
|
|
22
15
|
}
|
|
23
16
|
static warning(p) {
|
|
24
|
-
return (
|
|
17
|
+
return _jsx(Badge, Object.assign({}, p, { kind: "warning" }));
|
|
25
18
|
}
|
|
26
19
|
static success(p) {
|
|
27
|
-
return (
|
|
20
|
+
return _jsx(Badge, Object.assign({}, p, { kind: "success" }));
|
|
28
21
|
}
|
|
29
22
|
static info(p) {
|
|
30
|
-
return (
|
|
23
|
+
return _jsx(Badge, Object.assign({}, p, { kind: "info" }));
|
|
31
24
|
}
|
|
32
25
|
render() {
|
|
33
|
-
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return (_jsxs("div", { style: {
|
|
34
28
|
position: "relative",
|
|
35
29
|
display: "inline-block",
|
|
36
|
-
}, children: [this.props.child, this.props.children, (
|
|
37
|
-
position: "absolute",
|
|
38
|
-
top: "-0.25rem",
|
|
39
|
-
right: "-0.25rem",
|
|
40
|
-
minWidth: "1.5rem",
|
|
41
|
-
minHeight: "1.5rem",
|
|
42
|
-
padding: "0rem .4rem",
|
|
43
|
-
borderRadius: "3rem",
|
|
44
|
-
fontWeight: "bold",
|
|
45
|
-
display: "flex",
|
|
46
|
-
justifyContent: "center",
|
|
47
|
-
alignItems: "center",
|
|
48
|
-
visibility: this.props.hidden ? "hidden" : "visible",
|
|
49
|
-
...this.props.style,
|
|
50
|
-
}, children: this.props.label ?? this.props.count })] }));
|
|
30
|
+
}, children: [this.props.child, this.props.children, _jsx("div", { class: `b ${this.props.kind} major ${(_a = this.props.class) !== null && _a !== void 0 ? _a : ""}`, style: Object.assign({ position: "absolute", top: "-0.25rem", right: "-0.25rem", minWidth: "1.5rem", minHeight: "1.5rem", padding: "0rem .4rem", borderRadius: "3rem", fontWeight: "bold", display: "flex", justifyContent: "center", alignItems: "center", visibility: this.props.hidden ? "hidden" : "visible" }, this.props.style), children: (_b = this.props.label) !== null && _b !== void 0 ? _b : this.props.count })] }));
|
|
51
31
|
}
|
|
52
32
|
}
|
|
53
|
-
exports.Badge = Badge;
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { Component, h } from "preact";
|
|
13
|
+
export function applyProps(p, classes, style) {
|
|
14
|
+
var _a;
|
|
7
15
|
if (Array.isArray(classes)) {
|
|
8
16
|
classes = classes.filter((c) => c).join(" ");
|
|
9
17
|
}
|
|
10
|
-
return {
|
|
11
|
-
id: p.id,
|
|
12
|
-
class: `${classes || ""} ${p.class || ""}`,
|
|
13
|
-
style: { ...(style ?? {}), ...(p.style ?? {}) },
|
|
14
|
-
...(p.tooltip ? { ["data-tooltip"]: p.tooltip } : {}),
|
|
15
|
-
};
|
|
18
|
+
return Object.assign({ id: p.id, class: `${classes || ""} ${p.class || ""}`, style: Object.assign(Object.assign({}, (style !== null && style !== void 0 ? style : {})), ((_a = p.style) !== null && _a !== void 0 ? _a : {})) }, (p.tooltip ? { ["data-tooltip"]: p.tooltip } : {}));
|
|
16
19
|
}
|
|
17
|
-
class Box extends
|
|
18
|
-
static primary = (p) => new Box({ ...p, scheme: "primary" }).render();
|
|
19
|
-
static secondary = (p) => new Box({ ...p, scheme: "secondary" }).render();
|
|
20
|
-
static inverse = (p) => new Box({ ...p, scheme: "inverse" }).render();
|
|
20
|
+
export class Box extends Component {
|
|
21
21
|
render() {
|
|
22
|
-
const { scheme, mode, padding, margin, children,
|
|
23
|
-
return
|
|
24
|
-
padding: `${padding}rem`,
|
|
25
|
-
margin: `${margin}rem`,
|
|
26
|
-
...elbe.style,
|
|
27
|
-
}), children);
|
|
22
|
+
const _a = this.props, { scheme, mode, padding, margin, children } = _a, elbe = __rest(_a, ["scheme", "mode", "padding", "margin", "children"]);
|
|
23
|
+
return h("div", applyProps(elbe, [scheme, mode], Object.assign({ padding: `${padding}rem`, margin: `${margin}rem` }, elbe.style)), children);
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
|
-
|
|
26
|
+
Box.primary = (p) => new Box(Object.assign(Object.assign({}, p), { scheme: "primary" })).render();
|
|
27
|
+
Box.secondary = (p) => new Box(Object.assign(Object.assign({}, p), { scheme: "secondary" })).render();
|
|
28
|
+
Box.inverse = (p) => new Box(Object.assign(Object.assign({}, p), { scheme: "inverse" })).render();
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
13
|
+
import { applyProps } from "./box";
|
|
14
|
+
export function Card(_a) {
|
|
15
|
+
var { mode, scheme = "primary", kind, manner, padding = 1, margin = 0, onTap, onLongTap, children } = _a, elbe = __rest(_a, ["mode", "scheme", "kind", "manner", "padding", "margin", "onTap", "onLongTap", "children"]);
|
|
16
|
+
return (_jsx("div", Object.assign({}, applyProps(elbe, ["card", mode, scheme, kind, manner], {
|
|
17
|
+
padding: `${padding}rem`,
|
|
18
|
+
margin: `${margin}rem`,
|
|
19
|
+
}), { onClick: onTap, onContextMenu: onLongTap, children: children })));
|
|
11
20
|
}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const compat_1 = __importDefault(require("preact/compat"));
|
|
9
|
-
class Padded extends compat_1.default.Component {
|
|
12
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
13
|
+
import React from "preact/compat";
|
|
14
|
+
export class Padded extends React.Component {
|
|
10
15
|
constructor(props) {
|
|
11
16
|
super(props);
|
|
12
17
|
}
|
|
13
|
-
static all = ({ amount = 1, ...p }) => ((0, jsx_runtime_1.jsx)(Padded, { ...p, top: amount, right: amount, bottom: amount, left: amount }));
|
|
14
|
-
static symmetric = ({ vertical = 0, horizontal = 0, ...p }) => ((0, jsx_runtime_1.jsx)(Padded, { ...p,
|
|
15
|
-
top: vertical,
|
|
16
|
-
bottom: vertical,
|
|
17
|
-
left: horizontal,
|
|
18
|
-
right: horizontal }));
|
|
19
18
|
render() {
|
|
20
|
-
return ((
|
|
19
|
+
return (_jsx("div", { style: {
|
|
21
20
|
paddingTop: `${this.props.top}rem`,
|
|
22
21
|
paddingRight: `${this.props.right}rem`,
|
|
23
22
|
paddingBottom: `${this.props.bottom}rem`,
|
|
@@ -25,4 +24,14 @@ class Padded extends compat_1.default.Component {
|
|
|
25
24
|
}, children: this.props.children }));
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
27
|
+
Padded.all = (_a) => {
|
|
28
|
+
var { amount = 1 } = _a, p = __rest(_a, ["amount"]);
|
|
29
|
+
return (_jsx(Padded, Object.assign({}, p, { top: amount, right: amount, bottom: amount, left: amount })));
|
|
30
|
+
};
|
|
31
|
+
Padded.symmetric = (_a) => {
|
|
32
|
+
var { vertical = 0, horizontal = 0 } = _a, p = __rest(_a, ["vertical", "horizontal"]);
|
|
33
|
+
return (_jsx(Padded, Object.assign({}, p, { top: vertical,
|
|
34
|
+
bottom: vertical,
|
|
35
|
+
left: horizontal,
|
|
36
|
+
right: horizontal })));
|
|
37
|
+
};
|
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
13
|
+
import { Component } from "preact";
|
|
14
|
+
import { _ElbeErr } from "../../util/error_view";
|
|
15
|
+
import { applyProps } from "../base/box";
|
|
16
|
+
export class Button extends Component {
|
|
13
17
|
render() {
|
|
14
18
|
return _btn(this.props, this.props.manner);
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
Button.major = (p) => _btn(p, "major");
|
|
22
|
+
Button.minor = (p) => _btn(p, "minor");
|
|
23
|
+
Button.flat = (p) => _btn(p, "flat");
|
|
24
|
+
Button.plain = (p) => _btn(p, "plain");
|
|
25
|
+
function _btn(_a, manner) {
|
|
26
|
+
var { kind, onTap, icon, label, children } = _a, elbe = __rest(_a, ["kind", "onTap", "icon", "label", "children"]);
|
|
27
|
+
return label || icon || children ? (_jsxs("button", Object.assign({}, applyProps(elbe, [
|
|
28
|
+
"row",
|
|
29
|
+
"gap-half",
|
|
30
|
+
"main-center",
|
|
31
|
+
kind !== null && kind !== void 0 ? kind : (manner != "plain" && "accent"),
|
|
32
|
+
manner,
|
|
33
|
+
!onTap && "disabled",
|
|
34
|
+
]), { disabled: !onTap, onClick: (e) => onTap && onTap(e), children: [typeof icon === "function" ? icon({}) : icon, label && _jsx("span", { children: label }), children] }))) : (_ElbeErr("Button requires either an icon and or a label, or a child"));
|
|
27
35
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function ChooseButton({ items, value, onChange, kind, column = false, }) {
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)("div", { class: `${column ? "column" : "row"} gap-none rounded accent minor card padding-none cross-stretch ${!onChange ? "disabled" : ""}`, style: "background: transparent", children: items.map((e) => ((0, jsx_runtime_1.jsxs)(button_1.Button, { manner: e.value === value ? "minor" : "flat", kind: kind, onTap: onChange && (() => onChange(e.value)), class: `sharp ${column ? "main-between gap-double" : ""}`, children: [(0, jsx_runtime_1.jsxs)("div", { class: "row gap-half", children: [typeof e.icon === "function" ? e.icon({}) : e.icon, e.label && (0, jsx_runtime_1.jsx)("span", { children: e.label })] }), column &&
|
|
10
|
-
(e.value === value ? (0, jsx_runtime_1.jsx)(lucide_react_1.CheckIcon, {}) : (0, jsx_runtime_1.jsx)(spaced_1.Spaced, { amount: 1.5 }))] }))) }));
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { CheckIcon } from "lucide-react";
|
|
3
|
+
import { Spaced } from "../layout/spaced";
|
|
4
|
+
import { Button } from "./button";
|
|
5
|
+
export function ChooseButton({ items, value, onChange, kind, column = false, }) {
|
|
6
|
+
return (_jsx("div", { class: `${column ? "column" : "row"} gap-none rounded accent minor card padding-none cross-stretch ${!onChange ? "disabled" : ""}`, style: "background: transparent", children: items.map((e) => (_jsxs(Button, { manner: e.value === value ? "minor" : "flat", kind: kind, onTap: onChange && (() => onChange(e.value)), class: `sharp ${column ? "main-between gap-double" : ""}`, children: [_jsxs("div", { class: "row gap-half", children: [typeof e.icon === "function" ? e.icon({}) : e.icon, e.label && _jsx("span", { children: e.label })] }), column &&
|
|
7
|
+
(e.value === value ? _jsx(CheckIcon, {}) : _jsx(Spaced, { amount: 1.5 }))] }))) }));
|
|
11
8
|
}
|
|
@@ -1,31 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
13
|
+
import { Component } from "preact";
|
|
14
|
+
import { applyProps, } from "../../..";
|
|
15
|
+
export class IconButton extends Component {
|
|
12
16
|
render() {
|
|
13
17
|
return _btn(this.props, this.props.manner);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
IconButton.major = (p) => _btn(p, "major");
|
|
21
|
+
IconButton.minor = (p) => _btn(p, "minor");
|
|
22
|
+
IconButton.flat = (p) => _btn(p, "flat");
|
|
23
|
+
IconButton.plain = (p) => _btn(p, "plain");
|
|
24
|
+
function _btn(_a, manner) {
|
|
25
|
+
var _b;
|
|
26
|
+
var { icon, onTap } = _a, elbe = __rest(_a, ["icon", "onTap"]);
|
|
27
|
+
if (manner === void 0) { manner = "major"; }
|
|
28
|
+
return (_jsx("button", Object.assign({}, applyProps(elbe, [
|
|
29
|
+
"row",
|
|
30
|
+
"main-center",
|
|
31
|
+
"gap-half",
|
|
32
|
+
(_b = elbe.kind) !== null && _b !== void 0 ? _b : (manner != "plain" && "accent"),
|
|
33
|
+
manner,
|
|
34
|
+
!onTap && "disabled",
|
|
35
|
+
], {
|
|
36
|
+
border: "none",
|
|
37
|
+
borderRadius: "3rem",
|
|
38
|
+
height: "3rem",
|
|
39
|
+
width: "3rem",
|
|
40
|
+
}), { onClick: (e) => onTap && onTap(e), children: typeof icon === "function" ? icon({}) : icon })));
|
|
31
41
|
}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
13
|
+
import { CheckIcon } from "lucide-react";
|
|
14
|
+
import { applyProps } from "../base/box";
|
|
15
|
+
import { Spaced } from "../layout/spaced";
|
|
16
|
+
import { Button } from "./button";
|
|
17
|
+
export function ToggleButton(_a) {
|
|
18
|
+
var { value, onChange, label, icon, kind } = _a, elbe = __rest(_a, ["value", "onChange", "label", "icon", "kind"]);
|
|
19
|
+
return (_jsxs(Button, Object.assign({ manner: value ? "minor" : "flat", kind: kind, onTap: onChange && (() => onChange(!value)) }, applyProps(elbe, "main-between", { gap: "1.5rem" }), { children: [_jsxs("div", { class: "row gap-half", children: [typeof icon === "function" ? icon({}) : icon, label && _jsx("span", { children: label })] }), value ? _jsx(CheckIcon, {}) : _jsx(Spaced, { amount: 1.5 })] })));
|
|
11
20
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const spaced_1 = require("./layout/spaced");
|
|
8
|
-
function ElbeDialog({ title, open, onClose, children, _style, }) {
|
|
9
|
-
return ((0, jsx_runtime_1.jsx)("dialog", { onClick: (e) => e.stopPropagation(), open: open, style: "text-align: start" + (_style ?? ""), children: (0, jsx_runtime_1.jsxs)("div", { class: "primary card plain-opaque padding-none", style: "max-width: 40rem; min-width: 10rem", children: [(0, jsx_runtime_1.jsxs)("div", { class: "row cross-center padded main-between", children: [(0, jsx_runtime_1.jsx)("div", { class: "body-l b", children: title }), (0, jsx_runtime_1.jsx)(icon_button_1.IconButton.plain, { icon: lucide_react_1.X, onTap: (e) => {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { X } from "lucide-react";
|
|
3
|
+
import { IconButton } from "./button/icon_button";
|
|
4
|
+
import { Spaced } from "./layout/spaced";
|
|
5
|
+
export function ElbeDialog({ title, open, onClose, children, _style, }) {
|
|
6
|
+
return (_jsx("dialog", { onClick: (e) => e.stopPropagation(), open: open, style: "text-align: start" + (_style !== null && _style !== void 0 ? _style : ""), children: _jsxs("div", { class: "primary card plain-opaque padding-none", style: "max-width: 40rem; min-width: 10rem", children: [_jsxs("div", { class: "row cross-center padded main-between", children: [_jsx("div", { class: "body-l b", children: title }), _jsx(IconButton.plain, { icon: X, onTap: (e) => {
|
|
10
7
|
e.stopPropagation();
|
|
11
8
|
e.preventDefault();
|
|
12
9
|
onClose();
|
|
13
|
-
} })] }), (
|
|
10
|
+
} })] }), _jsx(Spaced, { amount: 0.5 }), _jsx("div", { class: "padded", style: "max-height: 80vh; overflow: auto", children: children })] }) }));
|
|
14
11
|
}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const dialog_1 = require("./dialog");
|
|
11
|
-
function ErrorView({ error, retry, debug, }) {
|
|
12
|
-
const apiError = (0, s_api_1.ifApiError)(error) ?? {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useSignal } from "@preact/signals";
|
|
3
|
+
import { route } from "preact-router";
|
|
4
|
+
import { Icons } from "../..";
|
|
5
|
+
import { ifApiError } from "../../service/s_api";
|
|
6
|
+
import { ElbeDialog } from "./dialog";
|
|
7
|
+
export function ErrorView({ error, retry, debug, }) {
|
|
8
|
+
var _a;
|
|
9
|
+
const apiError = (_a = ifApiError(error)) !== null && _a !== void 0 ? _a : {
|
|
13
10
|
code: 0,
|
|
14
11
|
message: "unknown error",
|
|
15
12
|
data: error,
|
|
16
13
|
};
|
|
17
|
-
return !debug ? ((
|
|
14
|
+
return !debug ? (_jsx(PrettyErrorView, { apiError: apiError, retry: retry })) : (_jsxs("div", { class: "column padded card inverse cross-stretch", children: [_jsxs("h3", { style: "margin: 0", children: ["ERROR: ", apiError.code] }), _jsx("p", { children: apiError.message }), _jsx("pre", { children: JSON.stringify(apiError.data, null, 2) })] }));
|
|
18
15
|
}
|
|
19
|
-
function PrettyErrorView({ apiError, retry, labels = {
|
|
16
|
+
export function PrettyErrorView({ apiError, retry, labels = {
|
|
20
17
|
retry: "retry",
|
|
21
18
|
home: "go home",
|
|
22
19
|
details: "error details",
|
|
23
20
|
}, }) {
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const openSig = useSignal(false);
|
|
23
|
+
return (_jsxs("div", { class: "column padded cross-center", style: "margin: 1rem 0", children: [_jsx(Icons.OctagonAlert, {}), _jsx("h3", { style: "margin: 0", children: apiError.code }), _jsx("span", { class: "pointer", onClick: () => (openSig.value = true), children: apiError.message }), retry && (_jsxs("button", { class: "action", onClick: () => retry(), children: [_jsx(Icons.RotateCcw, {}), " ", (_a = labels.retry) !== null && _a !== void 0 ? _a : "retry"] })), apiError.code === 404 && (_jsxs("button", { class: "action", onClick: () => route("/"), children: [_jsx(Icons.House, {}), (_b = labels.home) !== null && _b !== void 0 ? _b : "go home"] })), _jsx(ElbeDialog, { title: (_c = labels.details) !== null && _c !== void 0 ? _c : "error details", open: openSig.value, onClose: () => (openSig.value = false), children: _jsx("pre", { class: "card inverse", children: JSON.stringify(apiError.data, null, 2) }) })] }));
|
|
26
24
|
}
|