elbe-ui 0.2.26 → 0.2.34

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 (102) hide show
  1. package/dist/bit/bit.js +83 -0
  2. package/dist/bit/ctrl_bit.js +89 -0
  3. package/dist/elbe.css +621 -0
  4. package/dist/elbe.css.map +1 -0
  5. package/dist/index.d.ts +1549 -17
  6. package/dist/index.js +64 -18577
  7. package/dist/service/s_api.js +89 -0
  8. package/dist/ui/components/badge.d.ts +5 -5
  9. package/dist/ui/components/badge.js +53 -0
  10. package/dist/ui/components/base/box.d.ts +2564 -0
  11. package/dist/ui/components/base/box.js +30 -0
  12. package/dist/ui/components/base/card.d.ts +14 -0
  13. package/dist/ui/components/base/card.js +11 -0
  14. package/dist/ui/components/base/padded.js +28 -0
  15. package/dist/ui/components/button/button.d.ts +21 -0
  16. package/dist/ui/components/button/button.js +27 -0
  17. package/dist/ui/components/button/choose_button.d.ts +14 -0
  18. package/dist/ui/components/button/choose_button.js +11 -0
  19. package/dist/ui/components/button/icon_button.d.ts +17 -0
  20. package/dist/ui/components/button/icon_button.js +31 -0
  21. package/dist/ui/components/button/toggle_button.d.ts +10 -0
  22. package/dist/ui/components/button/toggle_button.js +11 -0
  23. package/dist/ui/components/dialog.js +14 -0
  24. package/dist/ui/components/error_view.js +26 -0
  25. package/dist/ui/components/input/checkbox.d.ts +1 -1
  26. package/dist/ui/components/input/checkbox.js +12 -0
  27. package/dist/ui/components/input/input_field.d.ts +1 -1
  28. package/dist/ui/components/input/input_field.js +31 -0
  29. package/dist/ui/components/input/range.d.ts +1 -1
  30. package/dist/ui/components/input/range.js +14 -0
  31. package/dist/ui/components/input/select.d.ts +1 -1
  32. package/dist/ui/components/input/select.js +8 -0
  33. package/dist/ui/components/input/text_area.d.ts +1 -1
  34. package/dist/ui/components/input/text_area.js +13 -0
  35. package/dist/ui/components/{flex.d.ts → layout/flex.d.ts} +1 -1
  36. package/dist/ui/components/layout/flex.js +23 -0
  37. package/dist/ui/components/{scaffold.d.ts → layout/scaffold.d.ts} +7 -3
  38. package/dist/ui/components/layout/scaffold.js +44 -0
  39. package/dist/ui/components/layout/scroll.d.ts +18 -0
  40. package/dist/ui/components/layout/scroll.js +20 -0
  41. package/dist/ui/components/layout/spaced.js +7 -0
  42. package/dist/ui/components/spinner.d.ts +10 -2
  43. package/dist/ui/components/spinner.js +48 -0
  44. package/dist/ui/components/text.d.ts +5 -5
  45. package/dist/ui/components/text.js +42 -0
  46. package/dist/ui/theme/color_theme.d.ts +2 -0
  47. package/dist/ui/theme/color_theme.js +63 -0
  48. package/dist/ui/theme/colors.d.ts +142 -0
  49. package/dist/ui/theme/colors.js +317 -0
  50. package/dist/ui/theme/geometry_theme.d.ts +16 -0
  51. package/dist/ui/theme/geometry_theme.js +38 -0
  52. package/dist/ui/theme/theme.d.ts +28 -0
  53. package/dist/ui/theme/theme.js +49 -0
  54. package/dist/ui/theme/type_theme.d.ts +38 -0
  55. package/dist/ui/theme/type_theme.js +98 -0
  56. package/dist/ui/util/confirm_dialog.js +46 -0
  57. package/dist/ui/util/error_view.js +8 -0
  58. package/dist/ui/util/toast.js +17 -0
  59. package/dist/ui/util/util.d.ts +2 -0
  60. package/dist/ui/util/util.js +39 -0
  61. package/package.json +14 -15
  62. package/dist/ui/color_theme.d.ts +0 -5
  63. package/dist/ui/components/box.d.ts +0 -1027
  64. package/dist/ui/components/button.d.ts +0 -23
  65. package/dist/ui/components/card.d.ts +0 -14
  66. package/dist/ui/components/icon_button.d.ts +0 -19
  67. package/dist/ui/components/toggle_button.d.ts +0 -12
  68. package/elbe.scss +0 -100
  69. package/src/bit/bit.tsx +0 -128
  70. package/src/bit/ctrl_bit.tsx +0 -112
  71. package/src/index.tsx +0 -29
  72. package/src/service/s_api.ts +0 -102
  73. package/src/ui/color_theme.ts +0 -24
  74. package/src/ui/components/badge.tsx +0 -78
  75. package/src/ui/components/box.tsx +0 -49
  76. package/src/ui/components/button.tsx +0 -61
  77. package/src/ui/components/card.tsx +0 -45
  78. package/src/ui/components/dialog.tsx +0 -51
  79. package/src/ui/components/error_view.tsx +0 -72
  80. package/src/ui/components/flex.tsx +0 -64
  81. package/src/ui/components/icon_button.tsx +0 -56
  82. package/src/ui/components/input/checkbox.tsx +0 -32
  83. package/src/ui/components/input/input_field.tsx +0 -57
  84. package/src/ui/components/input/range.tsx +0 -37
  85. package/src/ui/components/input/select.tsx +0 -29
  86. package/src/ui/components/input/text_area.tsx +0 -45
  87. package/src/ui/components/padded.tsx +0 -62
  88. package/src/ui/components/scaffold.tsx +0 -79
  89. package/src/ui/components/spinner.tsx +0 -11
  90. package/src/ui/components/text.tsx +0 -78
  91. package/src/ui/components/toggle_button.tsx +0 -52
  92. package/src/ui/components/util.tsx +0 -3
  93. package/src/ui/util/confirm_dialog.ts +0 -53
  94. package/src/ui/util/error_view.tsx +0 -16
  95. package/src/ui/util/toast.ts +0 -14
  96. package/src/ui/util/util.ts +0 -36
  97. package/style/color_style.scss +0 -149
  98. package/style/components.scss +0 -476
  99. package/style/root.scss +0 -50
  100. package/style/type_style.scss +0 -22
  101. /package/dist/ui/components/{padded.d.ts → base/padded.d.ts} +0 -0
  102. /package/dist/ui/components/{util.d.ts → layout/spaced.d.ts} +0 -0
@@ -0,0 +1,30 @@
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) {
7
+ if (Array.isArray(classes)) {
8
+ classes = classes.filter((c) => c).join(" ");
9
+ }
10
+ return {
11
+ id: p.id,
12
+ class: `${classes || ""} ${p.class || ""}`,
13
+ style: { ...(style ?? {}), ...(p.style ?? {}) },
14
+ ...(p.tooltip ? { ["data-tooltip"]: p.tooltip } : {}),
15
+ };
16
+ }
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();
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);
28
+ }
29
+ }
30
+ exports.Box = Box;
@@ -0,0 +1,14 @@
1
+ import type { ElbeColorKinds, ElbeColorManners, ElbeColorModes, ElbeColorSchemes } from "../../theme/colors";
2
+ import type { ElbeChildren } from "../../util/util";
3
+ import { type ElbeProps } from "./box";
4
+ export declare function Card({ mode, scheme, kind, manner, padding, margin, onTap, onLongTap, children, ...elbe }: {
5
+ mode?: ElbeColorModes;
6
+ scheme?: ElbeColorSchemes;
7
+ kind?: ElbeColorKinds;
8
+ manner?: ElbeColorManners;
9
+ padding?: number;
10
+ margin?: number;
11
+ onTap?: () => void;
12
+ onLongTap?: () => void;
13
+ children?: ElbeChildren;
14
+ } & ElbeProps): import("preact").JSX.Element;
@@ -0,0 +1,11 @@
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 }));
11
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
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 {
10
+ constructor(props) {
11
+ super(props);
12
+ }
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
+ render() {
20
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
21
+ paddingTop: `${this.props.top}rem`,
22
+ paddingRight: `${this.props.right}rem`,
23
+ paddingBottom: `${this.props.bottom}rem`,
24
+ paddingLeft: `${this.props.left}rem`,
25
+ }, children: this.props.children }));
26
+ }
27
+ }
28
+ exports.Padded = Padded;
@@ -0,0 +1,21 @@
1
+ import { Component } from "preact";
2
+ import type { ElbeColorKinds, ElbeColorManners } from "../../theme/colors";
3
+ import { type ElbeProps } from "../base/box";
4
+ import type { IconChild } from "./icon_button";
5
+ export type ButtonProps = ElbeProps & {
6
+ kind?: ElbeColorKinds;
7
+ onTap?: (e: Event) => void;
8
+ } & {
9
+ icon?: IconChild;
10
+ label?: string;
11
+ children?: any;
12
+ };
13
+ export declare class Button extends Component<ButtonProps & {
14
+ manner: ElbeColorManners;
15
+ }> {
16
+ static major: (p: ButtonProps) => import("preact").JSX.Element;
17
+ static minor: (p: ButtonProps) => import("preact").JSX.Element;
18
+ static flat: (p: ButtonProps) => import("preact").JSX.Element;
19
+ static plain: (p: ButtonProps) => import("preact").JSX.Element;
20
+ render(): import("preact").JSX.Element;
21
+ }
@@ -0,0 +1,27 @@
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");
13
+ render() {
14
+ return _btn(this.props, this.props.manner);
15
+ }
16
+ }
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"));
27
+ }
@@ -0,0 +1,14 @@
1
+ import type { ElbeColorKinds } from "../../theme/colors";
2
+ import type { IconChild } from "./icon_button";
3
+ export interface ChooseItem<T> {
4
+ value: T;
5
+ label?: string;
6
+ icon?: IconChild;
7
+ }
8
+ export declare function ChooseButton<T>({ items, value, onChange, kind, column, }: {
9
+ items: ChooseItem<T>[];
10
+ value: T;
11
+ onChange?: (v: T) => void;
12
+ kind?: ElbeColorKinds;
13
+ column?: boolean;
14
+ }): import("preact").JSX.Element;
@@ -0,0 +1,11 @@
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 }))] }))) }));
11
+ }
@@ -0,0 +1,17 @@
1
+ import { Component } from "preact";
2
+ import { type ElbeChild, type ElbeColorKinds, type ElbeColorManners, type ElbeProps } from "../../..";
3
+ export type IconChild = ElbeChild | ((_: any) => ElbeChild);
4
+ export type IconButtonProps = {
5
+ icon?: IconChild;
6
+ kind?: ElbeColorKinds;
7
+ onTap?: (e: Event) => void;
8
+ } & ElbeProps;
9
+ export declare class IconButton extends Component<IconButtonProps & {
10
+ manner?: ElbeColorManners;
11
+ }> {
12
+ static major: (p: IconButtonProps) => import("preact").JSX.Element;
13
+ static minor: (p: IconButtonProps) => import("preact").JSX.Element;
14
+ static flat: (p: IconButtonProps) => import("preact").JSX.Element;
15
+ static plain: (p: IconButtonProps) => import("preact").JSX.Element;
16
+ render(): import("preact").JSX.Element;
17
+ }
@@ -0,0 +1,31 @@
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");
12
+ render() {
13
+ return _btn(this.props, this.props.manner);
14
+ }
15
+ }
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 }));
31
+ }
@@ -0,0 +1,10 @@
1
+ import type { ElbeColorKinds } from "../../theme/colors";
2
+ import { type ElbeProps } from "../base/box";
3
+ import type { IconChild } from "./icon_button";
4
+ export declare function ToggleButton({ value, onChange, label, icon, kind, ...elbe }: {
5
+ value: boolean;
6
+ onChange?: (v: boolean) => void;
7
+ kind?: ElbeColorKinds;
8
+ label: string;
9
+ icon?: IconChild;
10
+ } & ElbeProps): import("preact").JSX.Element;
@@ -0,0 +1,11 @@
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 })] }));
11
+ }
@@ -0,0 +1,14 @@
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) => {
10
+ e.stopPropagation();
11
+ e.preventDefault();
12
+ 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 })] }) }));
14
+ }
@@ -0,0 +1,26 @@
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) ?? {
13
+ code: 0,
14
+ message: "unknown error",
15
+ data: error,
16
+ };
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) })] }));
18
+ }
19
+ function PrettyErrorView({ apiError, retry, labels = {
20
+ retry: "retry",
21
+ home: "go home",
22
+ details: "error details",
23
+ }, }) {
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) }) })] }));
26
+ }
@@ -1,4 +1,4 @@
1
- import { type ElbeProps } from "../box";
1
+ import { type ElbeProps } from "../base/box";
2
2
  export declare function Checkbox({ value, label, onChange, ...elbe }: {
3
3
  value: boolean;
4
4
  label?: string;
@@ -0,0 +1,12 @@
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: {
8
+ gap: ".75rem",
9
+ filter: onChange ? "" : "grayscale(1)",
10
+ 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 })] }));
12
+ }
@@ -1,5 +1,5 @@
1
1
  import React from "preact/compat";
2
- import { type ElbeProps } from "../box";
2
+ import { type ElbeProps } from "../base/box";
3
3
  import { _TextArea } from "./text_area";
4
4
  export type InputFieldProps = {
5
5
  label?: string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
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;
19
+ render() {
20
+ const { label, hint, readonly, type, value, onInput, ...elbe } = this.props;
21
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
22
+ width: "12rem !important",
23
+ display: "flex",
24
+ flexDirection: "column",
25
+ 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 }) }));
29
+ }
30
+ }
31
+ exports.Field = Field;
@@ -1,4 +1,4 @@
1
- import { type ElbeProps } from "../box";
1
+ import { type ElbeProps } from "../base/box";
2
2
  export declare function Range({ value, onChange, min, max, step, ...elbe }: {
3
3
  value: number;
4
4
  min?: number;
@@ -0,0 +1,14 @@
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, {
9
+ filter: onChange ? "" : "grayscale(1)",
10
+ opacity: onChange ? "" : "0.5",
11
+ cursor: onChange ? "pointer" : "not-allowed",
12
+ width: "100%",
13
+ }), min: min, max: max, step: step, disabled: !onChange, value: value, onInput: (e) => onChange?.(Number(e.currentTarget.value)) }));
14
+ }
@@ -1,4 +1,4 @@
1
- import { type ElbeProps } from "../box";
1
+ import { type ElbeProps } from "../base/box";
2
2
  export declare function Select({ options, value, label, onChange, ...elbe }: {
3
3
  options: {
4
4
  key: string;
@@ -0,0 +1,8 @@
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))) }));
8
+ }
@@ -1,4 +1,4 @@
1
- import { type ElbeProps } from "../box";
1
+ import { type ElbeProps } from "../base/box";
2
2
  export declare function _TextArea({ label, hint, readonly, rows, maxLength, value, onInput, ...elbe }: {
3
3
  label?: string;
4
4
  hint: string;
@@ -0,0 +1,13 @@
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: {
8
+ width: "12rem !important",
9
+ display: "flex",
10
+ flexDirection: "column",
11
+ 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 }) }));
13
+ }
@@ -1,4 +1,4 @@
1
- import { type ElbeProps } from "./box";
1
+ import { type ElbeProps } from "../base/box";
2
2
  export type FlexProps = {
3
3
  children: any;
4
4
  gap?: number;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlexSpace = FlexSpace;
4
+ exports.Column = Column;
5
+ exports.Row = Row;
6
+ const jsx_runtime_1 = require("preact/jsx-runtime");
7
+ const box_1 = require("../base/box");
8
+ function FlexSpace({}) {
9
+ return (0, jsx_runtime_1.jsx)("div", { style: "flex:1" });
10
+ }
11
+ function Column({ gap = 1, main = "start", cross = "stretch", stretch = false, children, ...p }) {
12
+ return _Flex(false, { gap, main, cross, stretch, children }, p);
13
+ }
14
+ function Row({ gap = 1, main = "start", cross, stretch = false, children, ...p }) {
15
+ return _Flex(true, { gap, main, cross, stretch, children }, p);
16
+ }
17
+ function _Flex(row, p, elbe) {
18
+ return ((0, jsx_runtime_1.jsx)("div", { ...(0, box_1.applyProps)(elbe, row ? "row" : "column", {
19
+ justifyContent: p.main,
20
+ alignItems: p.cross || (p.stretch ? "stretch" : "center"),
21
+ gap: `${p.gap}rem`,
22
+ }), children: p.children }));
23
+ }
@@ -1,7 +1,9 @@
1
+ import { type ElbeColorSchemes } from "../../..";
1
2
  type HeaderParams = {
2
3
  title?: string;
3
4
  back: null | "close" | "back";
4
5
  actions?: any;
6
+ limitedHeight?: number;
5
7
  };
6
8
  /**
7
9
  * Header is a layout component that provides a header for a page.
@@ -10,14 +12,16 @@ type HeaderParams = {
10
12
  * @param title - The title of the page.
11
13
  * @param actions - The actions to show on the right side of the header.
12
14
  */
13
- export declare function Header({ back, title, actions }: HeaderParams): import("preact/compat").JSX.Element;
15
+ export declare function Header({ back, title, actions, limitedHeight }: HeaderParams): import("preact").JSX.Element;
14
16
  /**
15
17
  * Scaffold is a layout component that provides a header and a content area.
16
18
  * It is used to create a consistent layout for pages.
17
19
  */
18
- export declare function Scaffold({ children, limited, gap, ...header }: {
20
+ export declare function Scaffold({ children, limited, gap, padded, scheme, ...header }: {
19
21
  limited?: boolean;
20
22
  children: any;
21
23
  gap?: number;
22
- } & HeaderParams): import("preact/compat").JSX.Element;
24
+ padded?: boolean;
25
+ scheme?: ElbeColorSchemes;
26
+ } & HeaderParams): import("preact").JSX.Element;
23
27
  export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Header = Header;
4
+ exports.Scaffold = Scaffold;
5
+ const jsx_runtime_1 = require("preact/jsx-runtime");
6
+ const hooks_1 = require("preact/hooks");
7
+ const __1 = require("../../..");
8
+ const icon_button_1 = require("../button/icon_button");
9
+ const flex_1 = require("./flex");
10
+ /**
11
+ * Header is a layout component that provides a header for a page.
12
+ * It is used to create a consistent header for pages.
13
+ * @param back - The back button type. If null, no back button is shown. If "close", a close button is shown. If "back", a back button is shown.
14
+ * @param title - The title of the page.
15
+ * @param actions - The actions to show on the right side of the header.
16
+ */
17
+ function Header({ back, title, actions, limitedHeight }) {
18
+ if (history.length == 0)
19
+ back = null;
20
+ const goBack = () => history.go(-1);
21
+ const [isScrolledTop, setIsScrolled] = (0, hooks_1.useState)(false);
22
+ (0, hooks_1.useEffect)(() => {
23
+ const _handle = () => setIsScrolled(window.scrollY > 0);
24
+ window.addEventListener("scroll", _handle);
25
+ return () => {
26
+ window.removeEventListener("scroll", _handle);
27
+ };
28
+ }, []);
29
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { style: "height: 4.5rem" }), (0, jsx_runtime_1.jsxs)("div", { class: "header", style: {
30
+ borderColor: isScrolledTop ? "" : "transparent",
31
+ position: limitedHeight ? "absolute" : "fixed",
32
+ }, children: [(0, jsx_runtime_1.jsx)("div", { class: "flex-1", children: back ? ((0, jsx_runtime_1.jsx)(icon_button_1.IconButton.plain, { icon: back === "back" ? __1.Icons.ArrowLeft : __1.Icons.X, onTap: goBack })) : null }), (0, jsx_runtime_1.jsx)(__1.Text.h4, { v: title }), (0, jsx_runtime_1.jsx)(flex_1.Row, { class: "flex-1", gap: 0.5, main: "end", children: actions })] })] }));
33
+ }
34
+ /**
35
+ * Scaffold is a layout component that provides a header and a content area.
36
+ * It is used to create a consistent layout for pages.
37
+ */
38
+ function Scaffold({ children, limited = false, gap = 1, padded = true, scheme, ...header }) {
39
+ return ((0, jsx_runtime_1.jsxs)(flex_1.Column, { cross: "stretch", gap: 0, class: `${scheme ?? "primary"}`, style: {
40
+ overflowY: header.limitedHeight ? "scroll" : null,
41
+ maxHeight: header.limitedHeight ? `${header.limitedHeight}rem` : null,
42
+ //height: header.limitToParent ? "100px" : null,
43
+ }, children: [(0, jsx_runtime_1.jsx)(Header, { ...header }), (0, jsx_runtime_1.jsx)("div", { class: `${padded ? "padded" : ""} ${limited ? "base-limited" : ""}`, children: (0, jsx_runtime_1.jsx)(flex_1.Column, { cross: "stretch", gap: gap ?? 1, children: children }) })] }));
44
+ }
@@ -0,0 +1,18 @@
1
+ import { Component } from "preact";
2
+ import { type ElbeProps } from "../base/box";
3
+ export type ScrollProps = ElbeProps & {
4
+ innerClass?: string;
5
+ height?: number;
6
+ width?: number;
7
+ children?: any;
8
+ };
9
+ type _ScrollProps = ScrollProps & {
10
+ axis: "vertical" | "horizontal";
11
+ };
12
+ export declare class Scroll extends Component<_ScrollProps> {
13
+ constructor(props: _ScrollProps);
14
+ static vertical: (p: ScrollProps) => import("preact").JSX.Element;
15
+ static horizontal: (p: ScrollProps) => import("preact").JSX.Element;
16
+ render(): import("preact").JSX.Element;
17
+ }
18
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Scroll = void 0;
4
+ const jsx_runtime_1 = require("preact/jsx-runtime");
5
+ const preact_1 = require("preact");
6
+ const box_1 = require("../base/box");
7
+ class Scroll extends preact_1.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ }
11
+ static vertical = (p) => new Scroll({ ...p, axis: "vertical" }).render();
12
+ static horizontal = (p) => new Scroll({ ...p, axis: "horizontal" }).render();
13
+ render() {
14
+ return ((0, jsx_runtime_1.jsx)("div", { ...(0, box_1.applyProps)(this.props, null, {
15
+ overflowY: this.props.axis === "vertical" ? "scroll" : "hidden",
16
+ overflowX: this.props.axis === "horizontal" ? "scroll" : "hidden",
17
+ }), children: (0, jsx_runtime_1.jsx)("div", { class: this.props.innerClass, style: this.props.axis === "horizontal" ? "min-width: min-content;" : "", children: this.props.children }) }));
18
+ }
19
+ }
20
+ exports.Scroll = Scroll;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Spaced = Spaced;
4
+ const jsx_runtime_1 = require("preact/jsx-runtime");
5
+ function Spaced({ amount = 1 }) {
6
+ return (0, jsx_runtime_1.jsx)("div", { style: { width: amount + "rem", height: amount + "rem" } });
7
+ }
@@ -1,3 +1,11 @@
1
- export declare function Spinner({ padding }: {
1
+ import { Component } from "preact";
2
+ export type SpinnerProps = {
2
3
  padding?: number;
3
- }): import("preact").JSX.Element;
4
+ };
5
+ export declare class Spinner extends Component<{
6
+ manner?: "flat" | "plain";
7
+ } & SpinnerProps> {
8
+ static flat: (p: SpinnerProps) => import("preact").JSX.Element;
9
+ static plain: (p: SpinnerProps) => import("preact").JSX.Element;
10
+ render(): import("preact").JSX.Element;
11
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Spinner = void 0;
4
+ const jsx_runtime_1 = require("preact/jsx-runtime");
5
+ const signals_1 = require("@preact/signals");
6
+ const preact_1 = require("preact");
7
+ const hooks_1 = require("preact/hooks");
8
+ function _toPath(c, yFac, yOffset = 0, clamp = [0, 1], xFac = 1) {
9
+ return c
10
+ .filter((p) => p[0] >= clamp[0] && p[0] <= clamp[1])
11
+ .map((p, i) => (i === 0 ? "M" : "L") +
12
+ (((p[0] - 0.5) * xFac + 0.5) * 100).toFixed(2) +
13
+ "," +
14
+ (p[1] * yFac + yOffset).toFixed(2))
15
+ .join(" ");
16
+ }
17
+ class Spinner extends preact_1.Component {
18
+ static flat = (p) => new Spinner({ manner: "flat", ...p }).render();
19
+ static plain = (p) => new Spinner({ manner: "plain", ...p }).render();
20
+ render() {
21
+ const flat = (this.props.manner ?? "flat") === "flat";
22
+ const xSig = (0, signals_1.useSignal)(0);
23
+ (0, hooks_1.useEffect)(() => {
24
+ const interval = setInterval(() => {
25
+ xSig.value = (xSig.value + 2) % 100;
26
+ }, 16);
27
+ return () => clearInterval(interval);
28
+ });
29
+ const path = (0, signals_1.useComputed)(() => {
30
+ const x = xSig.value;
31
+ const path = [];
32
+ for (let i = 0; i <= 1; i += 0.01) {
33
+ const pos = (i * 1 + x * 0.01) * Math.PI * 2; // angle = 0 -> 2π
34
+ const y = Math.sin(pos);
35
+ path.push([i, y]);
36
+ }
37
+ return path;
38
+ });
39
+ return ((0, jsx_runtime_1.jsx)("div", { class: `${flat ? "accent flat" : "plain"}`, style: {
40
+ padding: `${this.props.padding ?? 1}rem`,
41
+ }, children: (0, jsx_runtime_1.jsx)("svg", { style: "width: 40px; height: 40px", viewBox: `-10 -10 120 120`, children: [
42
+ _toPath(path.value, 13, 20, [0.4, 0.8], 1),
43
+ _toPath(path.value, 10, 50),
44
+ _toPath(path.value, 11, 80, [0.2, 0.6], 1),
45
+ ].map((p) => ((0, jsx_runtime_1.jsx)("path", { d: p, fill: "none", stroke: "currentcolor", "stroke-width": "10", "stroke-linecap": "round" }))) }) }));
46
+ }
47
+ }
48
+ exports.Spinner = Spinner;