elbe-ui 0.2.41 → 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.
Files changed (38) hide show
  1. package/dist/bit/bit.js +22 -25
  2. package/dist/bit/ctrl_bit.js +47 -28
  3. package/dist/elbe.css +58 -18
  4. package/dist/elbe.css.map +1 -1
  5. package/dist/index.js +33 -62
  6. package/dist/service/s_api.js +62 -49
  7. package/dist/ui/components/badge.js +13 -34
  8. package/dist/ui/components/base/box.js +21 -23
  9. package/dist/ui/components/base/card.js +19 -10
  10. package/dist/ui/components/base/padded.js +25 -16
  11. package/dist/ui/components/button/button.js +30 -22
  12. package/dist/ui/components/button/choose_button.js +7 -10
  13. package/dist/ui/components/button/icon_button.js +36 -26
  14. package/dist/ui/components/button/toggle_button.js +19 -10
  15. package/dist/ui/components/dialog.js +7 -10
  16. package/dist/ui/components/error_view.js +14 -16
  17. package/dist/ui/components/input/checkbox.js +17 -8
  18. package/dist/ui/components/input/input_field.js +28 -23
  19. package/dist/ui/components/input/range.js +26 -9
  20. package/dist/ui/components/input/select.js +16 -7
  21. package/dist/ui/components/input/text_area.js +17 -8
  22. package/dist/ui/components/layout/flex.js +24 -16
  23. package/dist/ui/components/layout/scaffold.d.ts +4 -3
  24. package/dist/ui/components/layout/scaffold.js +28 -18
  25. package/dist/ui/components/layout/scroll.js +10 -14
  26. package/dist/ui/components/layout/spaced.js +3 -6
  27. package/dist/ui/components/spinner.js +16 -19
  28. package/dist/ui/components/text.js +42 -37
  29. package/dist/ui/theme/color_theme.js +36 -42
  30. package/dist/ui/theme/colors.js +40 -77
  31. package/dist/ui/theme/geometry_theme.js +8 -16
  32. package/dist/ui/theme/theme.js +12 -34
  33. package/dist/ui/theme/type_theme.js +11 -39
  34. package/dist/ui/util/confirm_dialog.js +1 -4
  35. package/dist/ui/util/error_view.js +4 -7
  36. package/dist/ui/util/toast.js +1 -4
  37. package/dist/ui/util/util.js +8 -13
  38. package/package.json +3 -2
@@ -1,30 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Box = void 0;
4
- exports.applyProps = applyProps;
5
- const preact_1 = require("preact");
6
- function applyProps(p, classes, style) {
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 preact_1.Component {
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, ...elbe } = this.props;
23
- return (0, preact_1.h)("div", applyProps(elbe, [scheme, mode], {
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
- exports.Box = Box;
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Card = Card;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const box_1 = require("./box");
6
- function Card({ mode, scheme = "primary", kind, manner, padding = 1, margin = 0, onTap, onLongTap, children, ...elbe }) {
7
- return ((0, jsx_runtime_1.jsx)("div", { ...(0, box_1.applyProps)(elbe, ["card", mode, scheme, kind, manner], {
8
- padding: `${padding}rem`,
9
- margin: `${margin}rem`,
10
- }), onClick: onTap, onContextMenu: onLongTap, children: children }));
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
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Padded = void 0;
7
- const jsx_runtime_1 = require("preact/jsx-runtime");
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 ((0, jsx_runtime_1.jsx)("div", { style: {
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
- exports.Padded = Padded;
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Button = void 0;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const preact_1 = require("preact");
6
- const error_view_1 = require("../../util/error_view");
7
- const box_1 = require("../base/box");
8
- class Button extends preact_1.Component {
9
- static major = (p) => _btn(p, "major");
10
- static minor = (p) => _btn(p, "minor");
11
- static flat = (p) => _btn(p, "flat");
12
- static plain = (p) => _btn(p, "plain");
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
- exports.Button = Button;
18
- function _btn({ kind, onTap, icon, label, children, ...elbe }, manner) {
19
- return label || icon || children ? ((0, jsx_runtime_1.jsxs)("button", { ...(0, box_1.applyProps)(elbe, [
20
- "row",
21
- "gap-half",
22
- "main-center",
23
- kind ?? (manner != "plain" && "accent"),
24
- manner,
25
- !onTap && "disabled",
26
- ]), disabled: !onTap, onClick: (e) => onTap && onTap(e), children: [typeof icon === "function" ? icon({}) : icon, label && (0, jsx_runtime_1.jsx)("span", { children: label }), children] })) : ((0, error_view_1._ElbeErr)("Button requires either an icon and or a label, or a child"));
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChooseButton = ChooseButton;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const lucide_react_1 = require("lucide-react");
6
- const spaced_1 = require("../layout/spaced");
7
- const button_1 = require("./button");
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IconButton = void 0;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const preact_1 = require("preact");
6
- const __1 = require("../../..");
7
- class IconButton extends preact_1.Component {
8
- static major = (p) => _btn(p, "major");
9
- static minor = (p) => _btn(p, "minor");
10
- static flat = (p) => _btn(p, "flat");
11
- static plain = (p) => _btn(p, "plain");
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
- exports.IconButton = IconButton;
17
- function _btn({ icon, onTap, ...elbe }, manner = "major") {
18
- return ((0, jsx_runtime_1.jsx)("button", { ...(0, __1.applyProps)(elbe, [
19
- "row",
20
- "main-center",
21
- "gap-half",
22
- elbe.kind ?? (manner != "plain" && "accent"),
23
- manner,
24
- !onTap && "disabled",
25
- ], {
26
- border: "none",
27
- borderRadius: "3rem",
28
- height: "3rem",
29
- width: "3rem",
30
- }), onClick: (e) => onTap && onTap(e), children: typeof icon === "function" ? icon({}) : icon }));
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToggleButton = ToggleButton;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const lucide_react_1 = require("lucide-react");
6
- const box_1 = require("../base/box");
7
- const spaced_1 = require("../layout/spaced");
8
- const button_1 = require("./button");
9
- function ToggleButton({ value, onChange, label, icon, kind, ...elbe }) {
10
- return ((0, jsx_runtime_1.jsxs)(button_1.Button, { manner: value ? "minor" : "flat", kind: kind, onTap: onChange && (() => onChange(!value)), ...(0, box_1.applyProps)(elbe, "main-between", { gap: "1.5rem" }), children: [(0, jsx_runtime_1.jsxs)("div", { class: "row gap-half", children: [typeof icon === "function" ? icon({}) : icon, label && (0, jsx_runtime_1.jsx)("span", { children: label })] }), value ? (0, jsx_runtime_1.jsx)(lucide_react_1.CheckIcon, {}) : (0, jsx_runtime_1.jsx)(spaced_1.Spaced, { amount: 1.5 })] }));
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ElbeDialog = ElbeDialog;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const lucide_react_1 = require("lucide-react");
6
- const icon_button_1 = require("./button/icon_button");
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
- } })] }), (0, jsx_runtime_1.jsx)(spaced_1.Spaced, { amount: 0.5 }), (0, jsx_runtime_1.jsx)("div", { class: "padded", style: "max-height: 80vh; overflow: auto", children: children })] }) }));
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorView = ErrorView;
4
- exports.PrettyErrorView = PrettyErrorView;
5
- const jsx_runtime_1 = require("preact/jsx-runtime");
6
- const signals_1 = require("@preact/signals");
7
- const preact_router_1 = require("preact-router");
8
- const __1 = require("../..");
9
- const s_api_1 = require("../../service/s_api");
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 ? ((0, jsx_runtime_1.jsx)(PrettyErrorView, { apiError: apiError, retry: retry })) : ((0, jsx_runtime_1.jsxs)("div", { class: "column padded card inverse cross-stretch", children: [(0, jsx_runtime_1.jsxs)("h3", { style: "margin: 0", children: ["ERROR: ", apiError.code] }), (0, jsx_runtime_1.jsx)("p", { children: apiError.message }), (0, jsx_runtime_1.jsx)("pre", { children: JSON.stringify(apiError.data, null, 2) })] }));
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
- const openSig = (0, signals_1.useSignal)(false);
25
- return ((0, jsx_runtime_1.jsxs)("div", { class: "column padded cross-center", style: "margin: 1rem 0", children: [(0, jsx_runtime_1.jsx)(__1.Icons.OctagonAlert, {}), (0, jsx_runtime_1.jsx)("h3", { style: "margin: 0", children: apiError.code }), (0, jsx_runtime_1.jsx)("span", { class: "pointer", onClick: () => (openSig.value = true), children: apiError.message }), retry && ((0, jsx_runtime_1.jsxs)("button", { class: "action", onClick: () => retry(), children: [(0, jsx_runtime_1.jsx)(__1.Icons.RotateCcw, {}), " ", labels.retry ?? "retry"] })), apiError.code === 404 && ((0, jsx_runtime_1.jsxs)("button", { class: "action", onClick: () => (0, preact_router_1.route)("/"), children: [(0, jsx_runtime_1.jsx)(__1.Icons.House, {}), labels.home ?? "go home"] })), (0, jsx_runtime_1.jsx)(dialog_1.ElbeDialog, { title: labels.details ?? "error details", open: openSig.value, onClose: () => (openSig.value = false), children: (0, jsx_runtime_1.jsx)("pre", { class: "card inverse", children: JSON.stringify(apiError.data, null, 2) }) })] }));
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
  }
@@ -1,12 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Checkbox = Checkbox;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const box_1 = require("../base/box");
6
- function Checkbox({ value, label, onChange, ...elbe }) {
7
- return ((0, jsx_runtime_1.jsxs)("div", { class: `row ${onChange ? "" : "disabled"}`, style: {
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 { applyProps } from "../base/box";
14
+ export function Checkbox(_a) {
15
+ var { value, label, onChange } = _a, elbe = __rest(_a, ["value", "label", "onChange"]);
16
+ return (_jsxs("div", { class: `row ${onChange ? "" : "disabled"}`, style: {
8
17
  gap: ".75rem",
9
18
  filter: onChange ? "" : "grayscale(1)",
10
19
  opacity: onChange ? "" : "0.5",
11
- }, children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", ...(0, box_1.applyProps)(elbe), disabled: !onChange, checked: value, onChange: (e) => onChange?.(e.currentTarget.checked) }), label && (0, jsx_runtime_1.jsx)("div", { style: "margin-top: -.25rem", children: label })] }));
20
+ }, children: [_jsx("input", Object.assign({ type: "checkbox" }, applyProps(elbe), { disabled: !onChange, checked: value, onChange: (e) => onChange === null || onChange === void 0 ? void 0 : onChange(e.currentTarget.checked) })), label && _jsx("div", { style: "margin-top: -.25rem", children: label })] }));
12
21
  }
@@ -1,31 +1,36 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Field = void 0;
7
- const jsx_runtime_1 = require("preact/jsx-runtime");
8
- const compat_1 = __importDefault(require("preact/compat"));
9
- const box_1 = require("../base/box");
10
- const text_area_1 = require("./text_area");
11
- class Field extends compat_1.default.Component {
12
- static text = (p) => (0, jsx_runtime_1.jsx)(Field, { ...p, type: "text" });
13
- static number = (p) => (0, jsx_runtime_1.jsx)(Field, { ...p, type: "number" });
14
- static password = (p) => (0, jsx_runtime_1.jsx)(Field, { ...p, type: "password" });
15
- static date = (p) => (0, jsx_runtime_1.jsx)(Field, { ...p, type: "date" });
16
- static time = (p) => (0, jsx_runtime_1.jsx)(Field, { ...p, type: "time" });
17
- static email = (p) => (0, jsx_runtime_1.jsx)(Field, { ...p, type: "email" });
18
- static multiLine = text_area_1._TextArea;
12
+ import { jsx as _jsx } from "preact/jsx-runtime";
13
+ import React from "preact/compat";
14
+ import { applyProps } from "../base/box";
15
+ import { _TextArea } from "./text_area";
16
+ export class Field extends React.Component {
19
17
  render() {
20
- const { label, hint, readonly, type, value, onInput, ...elbe } = this.props;
21
- return ((0, jsx_runtime_1.jsx)("div", { style: {
18
+ var _a;
19
+ const _b = this.props, { label, hint, readonly, type, value, onInput } = _b, elbe = __rest(_b, ["label", "hint", "readonly", "type", "value", "onInput"]);
20
+ return (_jsx("div", { style: {
22
21
  width: "12rem !important",
23
22
  display: "flex",
24
23
  flexDirection: "column",
25
24
  alignItems: "stretch",
26
- }, "data-tooltip": this.props?.tooltip, children: (0, jsx_runtime_1.jsx)("input", { type: this.props.type, ...(0, box_1.applyProps)(this.props, null, {
27
- width: "100%",
28
- }), size: 5, label: this.props.label, placeholder: this.props.hint, value: this.props.value, onInput: (e) => this.props.onInput && this.props.onInput(e.currentTarget.value), readonly: this.props.readonly }) }));
25
+ }, "data-tooltip": (_a = this.props) === null || _a === void 0 ? void 0 : _a.tooltip, children: _jsx("input", Object.assign({ type: this.props.type }, applyProps(this.props, null, {
26
+ width: "100%",
27
+ }), { size: 5, label: this.props.label, placeholder: this.props.hint, value: this.props.value, onInput: (e) => this.props.onInput && this.props.onInput(e.currentTarget.value), readonly: this.props.readonly })) }));
29
28
  }
30
29
  }
31
- exports.Field = Field;
30
+ Field.text = (p) => _jsx(Field, Object.assign({}, p, { type: "text" }));
31
+ Field.number = (p) => _jsx(Field, Object.assign({}, p, { type: "number" }));
32
+ Field.password = (p) => _jsx(Field, Object.assign({}, p, { type: "password" }));
33
+ Field.date = (p) => _jsx(Field, Object.assign({}, p, { type: "date" }));
34
+ Field.time = (p) => _jsx(Field, Object.assign({}, p, { type: "time" }));
35
+ Field.email = (p) => _jsx(Field, Object.assign({}, p, { type: "email" }));
36
+ Field.multiLine = _TextArea;
@@ -1,14 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Range = Range;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const error_view_1 = require("../../util/error_view");
6
- const box_1 = require("../base/box");
7
- function Range({ value, onChange, min = 0, max = 100, step = 1, ...elbe }) {
8
- return min > max ? ((0, error_view_1._ElbeErr)("Range: max is smaller than min")) : ((0, jsx_runtime_1.jsx)("input", { type: "range", ...(0, box_1.applyProps)(elbe, null, {
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 { _ElbeErr } from "../../util/error_view";
14
+ import { applyProps } from "../base/box";
15
+ import { Card } from "../base/card";
16
+ export function Range(_a) {
17
+ var { value, onChange, min = 0, max = 100, step = 1 } = _a, elbe = __rest(_a, ["value", "onChange", "min", "max", "step"]);
18
+ return min > max ? (_ElbeErr("Range: max is smaller than min")) : (_jsx(Card, { scheme: "secondary", kind: "accent", manner: "minor", style: {
19
+ overflow: "unset",
20
+ backgroundColor: "transparent",
21
+ padding: "0",
22
+ margin: "0",
23
+ border: "none",
24
+ width: "100%",
25
+ }, children: _jsx("input", Object.assign({ type: "range" }, applyProps(elbe, null, {
9
26
  filter: onChange ? "" : "grayscale(1)",
10
27
  opacity: onChange ? "" : "0.5",
11
28
  cursor: onChange ? "pointer" : "not-allowed",
12
29
  width: "100%",
13
- }), min: min, max: max, step: step, disabled: !onChange, value: value, onInput: (e) => onChange?.(Number(e.currentTarget.value)) }));
30
+ }), { min: min, max: max, step: step, disabled: !onChange, value: value, onInput: (e) => onChange === null || onChange === void 0 ? void 0 : onChange(Number(e.currentTarget.value)) })) }));
14
31
  }
@@ -1,8 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Select = Select;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const box_1 = require("../base/box");
6
- function Select({ options, value, label, onChange, ...elbe }) {
7
- return ((0, jsx_runtime_1.jsx)("select", { ...(0, box_1.applyProps)(elbe), value: value, label: label, onChange: (e) => onChange(e.currentTarget.value), children: options.map(({ key, label }) => ((0, jsx_runtime_1.jsx)("option", { value: key, children: label }, key))) }));
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 "../base/box";
14
+ export function Select(_a) {
15
+ var { options, value, label, onChange } = _a, elbe = __rest(_a, ["options", "value", "label", "onChange"]);
16
+ return (_jsx("select", Object.assign({}, applyProps(elbe), { value: value, label: label, onChange: (e) => onChange(e.currentTarget.value), children: options.map(({ key, label }) => (_jsx("option", { value: key, children: label }, key))) })));
8
17
  }
@@ -1,13 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._TextArea = _TextArea;
4
- const jsx_runtime_1 = require("preact/jsx-runtime");
5
- const box_1 = require("../base/box");
6
- function _TextArea({ label, hint, readonly, rows = 4, maxLength, value, onInput, ...elbe }) {
7
- return ((0, jsx_runtime_1.jsx)("div", { style: {
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 "../base/box";
14
+ export function _TextArea(_a) {
15
+ var { label, hint, readonly, rows = 4, maxLength, value, onInput } = _a, elbe = __rest(_a, ["label", "hint", "readonly", "rows", "maxLength", "value", "onInput"]);
16
+ return (_jsx("div", { style: {
8
17
  width: "12rem !important",
9
18
  display: "flex",
10
19
  flexDirection: "column",
11
20
  alignItems: "stretch",
12
- }, "data-tooltip": elbe.tooltip, children: (0, jsx_runtime_1.jsx)("textarea", { ...(0, box_1.applyProps)(elbe, null, { width: "100%" }), label: label, size: 5, cols: 5, placeholder: hint, rows: rows, maxLength: maxLength, value: value, onInput: (e) => onInput && onInput(e.currentTarget.value), readonly: readonly }) }));
21
+ }, "data-tooltip": elbe.tooltip, children: _jsx("textarea", Object.assign({}, applyProps(elbe, null, { width: "100%" }), { label: label, size: 5, cols: 5, placeholder: hint, rows: rows, maxLength: maxLength, value: value, onInput: (e) => onInput && onInput(e.currentTarget.value), readonly: readonly })) }));
13
22
  }