elbe-ui 0.3.1 → 0.4.0

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 (71) hide show
  1. package/README.md +12 -0
  2. package/dist/elbe.css +57 -56
  3. package/dist/elbe.css.map +1 -1
  4. package/dist/index.d.ts +4 -3
  5. package/dist/index.js +4 -3
  6. package/dist/ui/components/banner.d.ts +3 -2
  7. package/dist/ui/components/banner.js +13 -7
  8. package/dist/ui/components/base/box.d.ts +7 -5
  9. package/dist/ui/components/base/card.d.ts +5 -1
  10. package/dist/ui/components/base/card.js +5 -1
  11. package/dist/ui/components/base/roles.d.ts +1 -0
  12. package/dist/ui/components/base/roles.js +1 -0
  13. package/dist/ui/components/button/button.d.ts +1 -0
  14. package/dist/ui/components/button/button.js +12 -4
  15. package/dist/ui/components/button/choose_button.js +3 -2
  16. package/dist/ui/components/button/icon_button.d.ts +3 -0
  17. package/dist/ui/components/button/icon_button.js +9 -2
  18. package/dist/ui/components/button/toggle_button.js +7 -1
  19. package/dist/ui/components/footer.js +1 -1
  20. package/dist/ui/components/input/checkbox.d.ts +2 -5
  21. package/dist/ui/components/input/checkbox.js +10 -19
  22. package/dist/ui/components/input/range.js +4 -1
  23. package/dist/ui/components/input/select.js +1 -1
  24. package/dist/ui/components/input/switch.d.ts +6 -2
  25. package/dist/ui/components/input/switch.js +25 -22
  26. package/dist/ui/components/input/text/input_field.d.ts +28 -0
  27. package/dist/ui/components/input/text/input_field.js +70 -0
  28. package/dist/ui/components/input/text/multi_line.d.ts +10 -0
  29. package/dist/ui/components/input/text/multi_line.js +19 -0
  30. package/dist/ui/components/input/text/single_line.d.ts +18 -0
  31. package/dist/ui/components/input/text/single_line.js +28 -0
  32. package/dist/ui/components/layout/app_base.d.ts +14 -0
  33. package/dist/ui/components/layout/app_base.js +30 -0
  34. package/dist/ui/components/layout/ctx_app_base.d.ts +16 -0
  35. package/dist/ui/components/layout/ctx_app_base.js +13 -0
  36. package/dist/ui/components/layout/flex.d.ts +4 -2
  37. package/dist/ui/components/layout/flex.js +13 -5
  38. package/dist/ui/components/layout/header.d.ts +18 -18
  39. package/dist/ui/components/layout/header.js +54 -48
  40. package/dist/ui/components/layout/menu.d.ts +12 -0
  41. package/dist/ui/components/layout/menu.js +56 -0
  42. package/dist/ui/components/layout/spaced.d.ts +4 -2
  43. package/dist/ui/components/layout/spaced.js +6 -2
  44. package/dist/ui/components/layout/toolbar.d.ts +7 -0
  45. package/dist/ui/components/layout/toolbar.js +71 -0
  46. package/dist/ui/components/progress_bar.js +7 -5
  47. package/dist/ui/components/spinner.js +4 -0
  48. package/dist/ui/components/text.js +4 -4
  49. package/dist/ui/theme/color_theme.d.ts +1 -1
  50. package/dist/ui/theme/color_theme.js +63 -52
  51. package/dist/ui/theme/colors.d.ts +33 -13
  52. package/dist/ui/theme/colors.js +42 -15
  53. package/dist/ui/theme/geometry_theme.js +2 -4
  54. package/dist/ui/theme/seed.d.ts +18 -8
  55. package/dist/ui/theme/seed.js +4 -1
  56. package/dist/ui/theme/theme.d.ts +3 -5
  57. package/dist/ui/theme/theme.js +9 -12
  58. package/dist/ui/theme/theme_context.d.ts +18 -0
  59. package/dist/ui/theme/theme_context.js +26 -0
  60. package/dist/ui/theme/type_theme.js +5 -2
  61. package/dist/ui/util/ctx_toolbar.d.ts +8 -0
  62. package/dist/ui/util/ctx_toolbar.js +9 -0
  63. package/dist/ui/util/util.d.ts +6 -0
  64. package/dist/ui/util/util.js +35 -0
  65. package/package.json +1 -1
  66. package/dist/ui/components/input/input_field.d.ts +0 -22
  67. package/dist/ui/components/input/input_field.js +0 -36
  68. package/dist/ui/components/input/text_area.d.ts +0 -10
  69. package/dist/ui/components/input/text_area.js +0 -22
  70. package/dist/ui/components/layout/scaffold.d.ts +0 -15
  71. package/dist/ui/components/layout/scaffold.js +0 -31
@@ -1,6 +1,3 @@
1
+ import { BooleanInputProps } from "../../..";
1
2
  import { ActionElbeProps } from "../base/box";
2
- export declare function Checkbox({ value, label, onChange, ...elbe }: {
3
- value: boolean;
4
- label?: string;
5
- onChange?: ((checked: boolean) => void) | null;
6
- } & ActionElbeProps): import("preact").JSX.Element;
3
+ export declare function Checkbox(p: BooleanInputProps & ActionElbeProps): import("preact").JSX.Element;
@@ -1,23 +1,14 @@
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
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { _InputSpacer, useThemeConfig } from "../../..";
13
3
  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: {
4
+ export function Checkbox(p) {
5
+ const tConfig = useThemeConfig();
6
+ return _InputSpacer(p, _jsxs("div", { class: `row ${p.onChange ? "" : "disabled"}`, style: {
17
7
  gap: ".75rem",
18
- filter: onChange ? "" : "grayscale(1)",
19
- opacity: onChange ? "" : "0.5",
20
- }, children: [_jsx("input", Object.assign({ type: "checkbox" }, applyProps("checkbox", elbe, value ? ["accent major"] : "accent minor", {
21
- background: value ? null : "transparent",
22
- }), { 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 })] }));
8
+ filter: p.onChange ? "" : "grayscale(1)",
9
+ opacity: p.onChange ? "" : "0.5",
10
+ }, children: [_jsx("input", Object.assign({ type: "checkbox" }, applyProps("checkbox", Object.assign({ role: "checkbox" }, p), p.value ? ["accent major"] : "accent minor", {
11
+ background: p.value ? null : "transparent",
12
+ transition: tConfig.reducedMotion ? "none" : null,
13
+ }), { disabled: !p.onChange, checked: p.value, onClick: (e) => e.stopPropagation(), onChange: (e) => { var _a; return (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, e.currentTarget.checked); } })), p.label && _jsx("div", { style: "margin-top: -.25rem", children: p.label })] }));
23
14
  }
@@ -10,11 +10,13 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "preact/jsx-runtime";
13
+ import { useTheme } from "../../theme/theme_context";
13
14
  import { _ElbeErr } from "../../util/error_view";
14
15
  import { applyProps } from "../base/box";
15
16
  import { Card } from "../base/card";
16
17
  export function Range(_a) {
17
18
  var { value, onChange, min = 0, max = 100, step = 1 } = _a, elbe = __rest(_a, ["value", "onChange", "min", "max", "step"]);
19
+ const theme = useTheme();
18
20
  return min > max ? (_ElbeErr("Range: max is smaller than min")) : (_jsx(Card, { ariaLabel: null, scheme: "secondary", kind: "accent", manner: "minor", style: {
19
21
  overflow: "unset",
20
22
  backgroundColor: "transparent",
@@ -22,10 +24,11 @@ export function Range(_a) {
22
24
  margin: "0",
23
25
  border: "none",
24
26
  width: "100%",
25
- }, children: _jsx("input", Object.assign({ type: "range" }, applyProps("range", elbe, null, {
27
+ }, children: _jsx("input", Object.assign({ type: "range" }, applyProps("range", Object.assign({ role: "slider" }, elbe), null, {
26
28
  filter: onChange ? "" : "grayscale(1)",
27
29
  opacity: onChange ? "" : "0.5",
28
30
  cursor: onChange ? "pointer" : "not-allowed",
29
31
  width: "100%",
32
+ borderRadius: theme.geometry.radius + "rem",
30
33
  }), { min: min, max: max, step: step, disabled: !onChange, value: value, onInput: (e) => onChange === null || onChange === void 0 ? void 0 : onChange(Number(e.currentTarget.value)) })) }));
31
34
  }
@@ -13,5 +13,5 @@ import { jsx as _jsx } from "preact/jsx-runtime";
13
13
  import { applyProps } from "../base/box";
14
14
  export function Select(_a) {
15
15
  var { options, value, label, onChange } = _a, elbe = __rest(_a, ["options", "value", "label", "onChange"]);
16
- return (_jsx("select", Object.assign({}, applyProps("select", elbe), { value: value, label: label, onChange: (e) => onChange(e.currentTarget.value), children: options.map(({ key, label }) => (_jsx("option", { value: key, children: label }, key))) })));
16
+ return (_jsx("select", Object.assign({}, applyProps("select", elbe), { value: value, label: label, role: "combobox", onChange: (e) => onChange(e.currentTarget.value), children: options.map(({ key, label }) => (_jsx("option", { value: key, children: label }, key))) })));
17
17
  }
@@ -1,6 +1,10 @@
1
+ import { JSX } from "preact/jsx-runtime";
1
2
  import { ActionElbeProps } from "../../..";
2
- export declare function Switch({ value, label, onChange, ...elbe }: {
3
+ export type BooleanInputProps = {
3
4
  value: boolean;
4
5
  label?: string;
6
+ compact?: boolean;
5
7
  onChange?: ((checked: boolean) => void) | null;
6
- } & ActionElbeProps): import("preact").JSX.Element;
8
+ };
9
+ export declare function Switch(p: BooleanInputProps & ActionElbeProps): JSX.Element;
10
+ export declare function _InputSpacer(p: BooleanInputProps, children: JSX.Element): JSX.Element;
@@ -1,45 +1,39 @@
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
1
  import { jsx as _jsx } from "preact/jsx-runtime";
13
2
  import { CheckIcon, XIcon } from "lucide-react";
14
3
  import { applyProps } from "../../..";
15
- export function Switch(_a) {
16
- var { value, label, onChange } = _a, elbe = __rest(_a, ["value", "label", "onChange"]);
17
- return (_jsx("button", Object.assign({ onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(!value) }, applyProps("switch", elbe, ["bordered card accent"], {
4
+ import { useThemeConfig } from "../../theme/theme_context";
5
+ export function Switch(p) {
6
+ const tConfig = useThemeConfig();
7
+ return _InputSpacer(p, _jsx("button", Object.assign({ onClick: (e) => {
8
+ var _a;
9
+ (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, !p.value);
10
+ e.stopPropagation();
11
+ } }, applyProps("switch", Object.assign({ role: "switch" }, p), ["bordered card accent"], {
18
12
  minHeight: 0,
19
13
  minWidth: 0,
20
- filter: onChange ? "" : "grayscale(1)",
21
- opacity: onChange ? "" : "0.5",
14
+ filter: p.onChange ? "" : "grayscale(1)",
15
+ opacity: p.onChange ? "" : "0.5",
22
16
  height: "1.8rem",
23
17
  width: "2.7rem",
24
18
  position: "relative",
25
- padding: "0rem",
19
+ padding: 0,
26
20
  borderColor: "var(--c-context-front)",
27
- backgroundColor: value
21
+ backgroundColor: p.value
28
22
  ? "var(--c-context-front)"
29
23
  : "var(--c-context-back)",
30
24
  display: "flex",
31
25
  alignItems: "center",
32
- transition: "border-color 0.25s, border-width 0.25s",
26
+ transition: tConfig.reducedMotion ? "none" : "background-color 0.25s",
33
27
  }), { children: _jsx("div", { style: {
34
28
  position: "absolute",
35
- left: value ? "1.2rem" : "0.4rem",
29
+ left: p.value ? "1.2rem" : "0.4rem",
36
30
  height: ".8rem",
37
31
  width: ".8rem",
38
32
  display: "flex",
39
33
  alignItems: "center",
40
34
  justifyContent: "center",
41
- transition: "left 0.25s",
42
- }, children: value ? (_jsx(CheckIcon, { color: "var(--c-context-back)",
35
+ transition: tConfig.reducedMotion ? "none" : "left 0.25s",
36
+ }, children: p.value ? (_jsx(CheckIcon, { color: "var(--c-context-back)",
43
37
  //width=".8rem"
44
38
  //height=".8rem"
45
39
  absoluteStrokeWidth: false, strokeWidth: "0.3rem" })) : (_jsx(XIcon, { color: "var(--c-context-front)",
@@ -47,3 +41,12 @@ export function Switch(_a) {
47
41
  //height=".8rem"
48
42
  absoluteStrokeWidth: false, strokeWidth: "0.3rem" })) }) })));
49
43
  }
44
+ export function _InputSpacer(p, children) {
45
+ return (_jsx("div", { onClick: () => { var _a; return (_a = p.onChange) === null || _a === void 0 ? void 0 : _a.call(p, !p.value); }, style: {
46
+ display: "flex",
47
+ justifyContent: "center",
48
+ alignItems: "center",
49
+ minHeight: p.compact ? "0rem" : "3rem",
50
+ minWidth: p.compact ? "0rem" : "3rem",
51
+ }, children: children }));
52
+ }
@@ -0,0 +1,28 @@
1
+ import React from "preact/compat";
2
+ import { ElbeProps } from "../../base/box";
3
+ import { SLInputFieldProps } from "./single_line";
4
+ export type InputFieldProps = {
5
+ id?: string;
6
+ label: string;
7
+ hideLabel?: boolean;
8
+ hint?: string;
9
+ value: string | number;
10
+ onInput?: (value: string) => void;
11
+ width?: number;
12
+ infoMessage?: string;
13
+ warningMessage?: string;
14
+ errorMessage?: string;
15
+ successMessage?: string;
16
+ } & ElbeProps;
17
+ export declare class Field<T extends InputFieldProps> extends React.Component<T & {
18
+ type: "text" | "number" | "password" | "date" | "time" | "email" | "area";
19
+ }> {
20
+ static text: (p: SLInputFieldProps) => React.JSX.Element;
21
+ static number: (p: SLInputFieldProps) => React.JSX.Element;
22
+ static password: (p: SLInputFieldProps) => React.JSX.Element;
23
+ static date: (p: SLInputFieldProps) => React.JSX.Element;
24
+ static time: (p: SLInputFieldProps) => React.JSX.Element;
25
+ static email: (p: SLInputFieldProps) => React.JSX.Element;
26
+ static multiLine: (p: InputFieldProps) => React.JSX.Element;
27
+ render(): React.JSX.Element;
28
+ }
@@ -0,0 +1,70 @@
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 React from "preact/compat";
14
+ import { KindAlertIcon, Text } from "../../../..";
15
+ import { randomAlphaNum } from "../../../util/util";
16
+ import { Card } from "../../base/card";
17
+ import { Row } from "../../layout/flex";
18
+ import { _MultiLineField } from "./multi_line";
19
+ import { _SingleLineField } from "./single_line";
20
+ export class Field extends React.Component {
21
+ render() {
22
+ var _a, _b, _c;
23
+ const _d = this.props, { label, hint, type, value, onInput } = _d, elbe = __rest(_d, ["label", "hint", "type", "value", "onInput"]);
24
+ const id = (_a = this.props.id) !== null && _a !== void 0 ? _a : randomAlphaNum(8, "input_field_");
25
+ const msg = this.props
26
+ .errorMessage
27
+ ? { kind: "error", msg: this.props.errorMessage }
28
+ : this.props.warningMessage
29
+ ? { kind: "warning", msg: this.props.warningMessage }
30
+ : this.props.infoMessage
31
+ ? { kind: "info", msg: this.props.infoMessage }
32
+ : this.props.successMessage
33
+ ? { kind: "success", msg: this.props.successMessage }
34
+ : null;
35
+ return (_jsxs("div", { style: {
36
+ flex: this.props.flex
37
+ ? this.props.flex === true
38
+ ? 1
39
+ : this.props.flex
40
+ : null,
41
+ width: this.props.flex ? null : ((_b = this.props.width) !== null && _b !== void 0 ? _b : 12) + "rem",
42
+ display: "flex",
43
+ flexDirection: "column",
44
+ alignItems: "stretch",
45
+ filter: this.props.onInput ? null : "grayscale(1) opacity(0.5)",
46
+ pointerEvents: this.props.onInput ? null : "none",
47
+ cursor: this.props.onInput ? null : "not-allowed",
48
+ }, "data-tooltip": (_c = this.props) === null || _c === void 0 ? void 0 : _c.tooltip, children: [_jsx("label", { htmlFor: id, style: {
49
+ display: this.props.hideLabel ? "none" : "block",
50
+ fontSize: "0.8rem",
51
+ padding: "0.2rem 0.5rem",
52
+ }, children: label }), _jsxs(Card, { style: {
53
+ display: "flex",
54
+ flexDirection: "column",
55
+ alignItems: "stretch",
56
+ border: "none",
57
+ }, kind: msg === null || msg === void 0 ? void 0 : msg.kind, padding: 0, manner: msg ? "major" : "plain", children: [_jsx(Card, { padding: 0, style: {
58
+ border: "none",
59
+ }, kind: "plain", children: _jsx(Card, { kind: msg === null || msg === void 0 ? void 0 : msg.kind, manner: msg ? "minor" : "plain", class: "text_field_base", overflow: "hidden", padding: 0, bordered: true, children: type === "area" ? (_jsx(_MultiLineField, { props: this.props, id: id })) : (_jsx(_SingleLineField, { props: this.props, msg: msg, type: type !== null && type !== void 0 ? type : "text", id: id })) }) }), msg && (_jsxs(Row, { gap: 0.5, style: {
60
+ padding: "0.25rem 0.5rem",
61
+ }, children: [_jsx(KindAlertIcon, { kind: msg.kind, size: "body-s" }), _jsx(Text.s, { bold: true, v: msg.msg, flex: true })] }))] })] }));
62
+ }
63
+ }
64
+ Field.text = (p) => _jsx(Field, Object.assign({}, p, { type: "text" }));
65
+ Field.number = (p) => _jsx(Field, Object.assign({}, p, { type: "number" }));
66
+ Field.password = (p) => _jsx(Field, Object.assign({}, p, { type: "password" }));
67
+ Field.date = (p) => _jsx(Field, Object.assign({}, p, { type: "date" }));
68
+ Field.time = (p) => _jsx(Field, Object.assign({}, p, { type: "time" }));
69
+ Field.email = (p) => _jsx(Field, Object.assign({}, p, { type: "email" }));
70
+ Field.multiLine = (p) => _jsx(Field, Object.assign({}, p, { type: "area" }));
@@ -0,0 +1,10 @@
1
+ import { InputFieldProps } from "./input_field";
2
+ export interface MLInputFieldProps extends InputFieldProps {
3
+ rows?: number;
4
+ maxLength?: number;
5
+ notResizable?: boolean;
6
+ }
7
+ export declare function _MultiLineField(p: {
8
+ props: MLInputFieldProps;
9
+ id: string;
10
+ }): import("preact").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ import { applyProps } from "../../base/box";
3
+ export function _MultiLineField(p) {
4
+ var _a, _b;
5
+ return (_jsx("textarea", Object.assign({ "data-tooltip": p.props.tooltip }, applyProps("text_area", Object.assign(Object.assign({}, p.props), { id: p.id, ariaLabel: (_a = p.props.ariaLabel) !== null && _a !== void 0 ? _a : p.props.label }), null, {
6
+ width: "100%",
7
+ background: "none",
8
+ border: "none",
9
+ outline: "none",
10
+ padding: "1rem",
11
+ margin: "0 0",
12
+ resize: p.props.notResizable ? "none" : "vertical",
13
+ }), { size: 5, cols: 5, placeholder: p.props.hint, rows: (_b = p.props.rows) !== null && _b !== void 0 ? _b : 5, maxLength: p.props.maxLength, value: p.props.value, onInput: (e) => {
14
+ var _a, _b;
15
+ e.stopPropagation();
16
+ e.preventDefault();
17
+ (_b = (_a = p.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, e.currentTarget.value);
18
+ }, readonly: p.props.onInput ? false : true })));
19
+ }
@@ -0,0 +1,18 @@
1
+ import { ElbeAlertKinds, IconChild, InputFieldProps } from "../../../..";
2
+ type _InputMsg = {
3
+ kind: ElbeAlertKinds;
4
+ msg: string;
5
+ };
6
+ export interface SLInputFieldProps extends InputFieldProps {
7
+ leading?: IconChild;
8
+ onLeadingTap?: () => void;
9
+ trailing?: IconChild;
10
+ onTrailingTap?: () => void;
11
+ }
12
+ export declare function _SingleLineField(p: {
13
+ props: SLInputFieldProps;
14
+ msg: _InputMsg | null;
15
+ type: string;
16
+ id: string;
17
+ }): import("preact").JSX.Element;
18
+ export {};
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { applyProps, Card, IconButton, Row, Spaced, } from "../../../..";
3
+ export function _SingleLineField(p) {
4
+ var _a, _b, _c;
5
+ return (_jsxs(Row, { gap: 0, children: [_jsx(_Supplement, { kind: (_a = p.msg) === null || _a === void 0 ? void 0 : _a.kind, icon: p.props.leading, onTap: p.props.onLeadingTap }), _jsx("input", Object.assign({ type: p.type }, applyProps("text_field", Object.assign(Object.assign({}, p.props), { id: p.id, ariaLabel: (_b = p.props.ariaLabel) !== null && _b !== void 0 ? _b : p.props.label }), null, {
6
+ width: "100%",
7
+ height: "3rem",
8
+ flex: 1,
9
+ border: "none",
10
+ outline: "none",
11
+ background: "none",
12
+ }), { size: 5, label: p.props.label, placeholder: p.props.hint, value: p.props.value, onInput: (e) => p.props.onInput && p.props.onInput(e.currentTarget.value), readonly: p.props.onInput ? false : true })), _jsx(_Supplement, { kind: (_c = p.msg) === null || _c === void 0 ? void 0 : _c.kind, trailing: true, icon: p.props.trailing, onTap: p.props.onTrailingTap })] }));
13
+ }
14
+ function _Supplement(p) {
15
+ if (!p.icon)
16
+ return _jsx(Spaced, { width: 0.75 });
17
+ return (_jsx(Card, { sharp: true, padding: 0, style: {
18
+ border: "none",
19
+ background: p.onTap ? null : "transparent",
20
+ }, children: _jsx(IconButton, { kind: p.kind, manner: p.kind ? "minor" : "plain", ariaLabel: p.trailing ? "trailing icon" : "leading icon", icon: p.icon, style: {
21
+ borderRadius: 0,
22
+ background: p.onTap ? null : "transparent",
23
+ }, onTap: (e) => {
24
+ var _a;
25
+ e.stopPropagation();
26
+ (_a = p.onTap) === null || _a === void 0 ? void 0 : _a.call(p);
27
+ } }) }));
28
+ }
@@ -0,0 +1,14 @@
1
+ import { ElbeChild, HeaderLogos } from "../../..";
2
+ import { MenuItem } from "./menu";
3
+ export type AppBaseProps = HeaderLogos & {
4
+ initial?: string;
5
+ menu: MenuItem[];
6
+ globalActions?: ElbeChild[];
7
+ };
8
+ /**
9
+ * app base is a layout component that provides a side menu and a content area.
10
+ * it is designed to be used as a base for other components and is
11
+ * used to create a consistent layout for pages. You can also pass global actions
12
+ * that will be displayed in the header of all pages.
13
+ */
14
+ export declare function AppBase(p: AppBaseProps): import("preact/compat").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { useState } from "preact/compat";
3
+ import { Box } from "../../..";
4
+ import { AppBaseContext } from "./ctx_app_base";
5
+ import { Menu } from "./menu";
6
+ /**
7
+ * app base is a layout component that provides a side menu and a content area.
8
+ * it is designed to be used as a base for other components and is
9
+ * used to create a consistent layout for pages. You can also pass global actions
10
+ * that will be displayed in the header of all pages.
11
+ */
12
+ export function AppBase(p) {
13
+ var _a, _b, _c, _d, _e, _f;
14
+ const [state, setState] = useState({
15
+ menuSelected: (_c = (_a = p.initial) !== null && _a !== void 0 ? _a : (_b = p.menu[0]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null,
16
+ menuOpen: false,
17
+ icons: {
18
+ logo: p.logo,
19
+ logoDark: p.logoDark,
20
+ endLogo: p.endLogo,
21
+ endLogoDark: p.endLogoDark,
22
+ },
23
+ globalActions: (_d = p.globalActions) !== null && _d !== void 0 ? _d : [],
24
+ });
25
+ return (_jsx(AppBaseContext.Provider, { value: Object.assign(Object.assign({}, state), { setMenuOpen: (b) => setState(Object.assign(Object.assign({}, state), { menuOpen: b })), setMenuSelected: (s) => setState(Object.assign(Object.assign({}, state), { menuSelected: s })) }), children: _jsxs(Box, { scheme: "primary", style: {
26
+ display: "flex",
27
+ width: "100%",
28
+ minHeight: "100vh",
29
+ }, children: [_jsx(Menu, { items: p.menu }), _jsx("div", { style: { flex: 1 }, children: (_f = (_e = p.menu.find((i) => i.id == state.menuSelected)) === null || _e === void 0 ? void 0 : _e.component) !== null && _f !== void 0 ? _f : _jsx("div", {}) })] }) }));
30
+ }
@@ -0,0 +1,16 @@
1
+ import { ElbeChild } from "../../util/util";
2
+ import { HeaderLogos } from "./header";
3
+ export interface _AppBaseState {
4
+ menuSelected: string | null;
5
+ menuOpen: boolean;
6
+ icons: HeaderLogos;
7
+ globalActions: ElbeChild[];
8
+ }
9
+ interface _AppBaseControl extends _AppBaseState {
10
+ setMenuOpen: (open: boolean) => void;
11
+ setMenuSelected: (selected: string) => void;
12
+ }
13
+ export declare const AppBaseContext: import("preact").Context<_AppBaseControl | null>;
14
+ export declare function useAppBase(): _AppBaseControl;
15
+ export declare function maybeAppBase(): _AppBaseControl | null;
16
+ export {};
@@ -0,0 +1,13 @@
1
+ import { createContext } from "preact";
2
+ import { useContext } from "preact/hooks";
3
+ export const AppBaseContext = createContext(null);
4
+ export function useAppBase() {
5
+ const ctx = useContext(AppBaseContext);
6
+ if (ctx)
7
+ return ctx;
8
+ throw new Error("useAppBase must be used within an AppBase. try using maybeAppBase()");
9
+ }
10
+ export function maybeAppBase() {
11
+ var _a;
12
+ return (_a = useContext(AppBaseContext)) !== null && _a !== void 0 ? _a : null;
13
+ }
@@ -2,11 +2,13 @@ import { type ElbeProps } from "../base/box";
2
2
  export type FlexProps = {
3
3
  children: any;
4
4
  gap?: number;
5
+ scroll?: boolean;
6
+ noScrollbar?: boolean;
5
7
  main?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly";
6
8
  cross?: "start" | "center" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly";
7
9
  } & ElbeProps;
8
10
  export declare function FlexSpace({}: {}): import("preact").JSX.Element;
9
- export declare function Column({ gap, main, cross, children, ...p }: FlexProps): import("preact").JSX.Element;
10
- export declare function Row({ gap, main, cross, wrap, children, ...p }: FlexProps & {
11
+ export declare function Column({ gap, main, cross, children, noScrollbar, scroll, ...p }: FlexProps): import("preact").JSX.Element;
12
+ export declare function Row({ gap, main, cross, wrap, children, noScrollbar, scroll, ...p }: FlexProps & {
11
13
  wrap?: boolean;
12
14
  }): import("preact").JSX.Element;
@@ -15,17 +15,25 @@ export function FlexSpace({}) {
15
15
  return _jsx("div", { style: "flex:1" });
16
16
  }
17
17
  export function Column(_a) {
18
- var { gap = 1, main = "start", cross = "stretch", children } = _a, p = __rest(_a, ["gap", "main", "cross", "children"]);
19
- return _Flex(false, { gap, main, cross, children }, p, false);
18
+ var { gap = 1, main = "start", cross = "stretch", children, noScrollbar = false, scroll = false } = _a, p = __rest(_a, ["gap", "main", "cross", "children", "noScrollbar", "scroll"]);
19
+ return _Flex(false, { gap, main, cross, scroll, noScrollbar, children }, p, false);
20
20
  }
21
21
  export function Row(_a) {
22
- var { gap = 1, main = "start", cross, wrap = false, children } = _a, p = __rest(_a, ["gap", "main", "cross", "wrap", "children"]);
23
- return _Flex(true, { gap, main, cross, children }, p, wrap);
22
+ var { gap = 1, main = "start", cross, wrap = false, children, noScrollbar = false, scroll = false } = _a, p = __rest(_a, ["gap", "main", "cross", "wrap", "children", "noScrollbar", "scroll"]);
23
+ return _Flex(true, { gap, main, cross, scroll, noScrollbar, children }, p, wrap);
24
24
  }
25
25
  function _Flex(row, p, elbe, wraps) {
26
- return (_jsx("div", Object.assign({}, applyProps("flex", elbe, [row ? "row" : "column", wraps && "wrap"], {
26
+ var _a;
27
+ return (_jsx("div", Object.assign({}, applyProps("flex", elbe, [
28
+ row ? "row" : "column",
29
+ wraps && "wrap",
30
+ p.noScrollbar && "no-scrollbar",
31
+ ], {
27
32
  justifyContent: p.main,
28
33
  alignItems: p.cross,
29
34
  gap: `${p.gap}rem`,
35
+ overflowX: !row ? null : p.scroll ? "auto" : null,
36
+ overflowY: row ? null : p.scroll ? "auto" : null,
37
+ flex: ((_a = p.flex) !== null && _a !== void 0 ? _a : p.scroll) ? 1 : null,
30
38
  }), { children: p.children })));
31
39
  }
@@ -1,19 +1,19 @@
1
- import { JSX } from "preact/jsx-runtime";
2
- export type HeaderParams = {
3
- title?: string;
4
- back?: null | "close" | "back" | JSX.Element;
5
- actions?: any;
6
- _absolute?: boolean;
1
+ import { ElbeChild } from "../../..";
2
+ export type HeaderLogos = {
3
+ logo?: string | ElbeChild;
4
+ logoDark?: string | ElbeChild;
5
+ endLogo?: string | ElbeChild;
6
+ endLogoDark?: string | ElbeChild;
7
7
  };
8
- /**
9
- * Header is a layout component that provides a header for a page.
10
- * It is used to create a consistent header for pages.
11
- * @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.
12
- * @param title - The title of the page.
13
- * @param actions - The actions to show on the right side of the header.
14
- * @param children - The children to show in the header. If children are provided, the title is ignored.
15
- */
16
- export declare function Header({ back, title, actions, _absolute, children, height, }: HeaderParams & {
17
- children?: any;
18
- height?: number;
19
- }): JSX.Element;
8
+ export declare function Header(p: HeaderLogos & {
9
+ leading?: ElbeChild | "back" | "close";
10
+ title: string | ElbeChild;
11
+ centerTitle?: boolean;
12
+ actions?: ElbeChild[];
13
+ }): import("preact").JSX.Element;
14
+ export declare function BackButton(p: {
15
+ onTap: () => void;
16
+ }): import("preact").JSX.Element;
17
+ export declare function CloseButton(p: {
18
+ onTap: () => void;
19
+ }): import("preact").JSX.Element;