elbe-ui 0.3.1 → 0.4.1

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 (80) 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 +6 -3
  5. package/dist/index.js +6 -3
  6. package/dist/ui/components/badge.d.ts +1 -1
  7. package/dist/ui/components/banner.d.ts +3 -2
  8. package/dist/ui/components/banner.js +13 -7
  9. package/dist/ui/components/base/box.d.ts +28 -27
  10. package/dist/ui/components/base/card.d.ts +6 -4
  11. package/dist/ui/components/base/card.js +6 -2
  12. package/dist/ui/components/base/roles.d.ts +1 -0
  13. package/dist/ui/components/base/roles.js +1 -0
  14. package/dist/ui/components/button/button.d.ts +1 -0
  15. package/dist/ui/components/button/button.js +12 -4
  16. package/dist/ui/components/button/choose_button.js +3 -2
  17. package/dist/ui/components/button/icon_button.d.ts +3 -0
  18. package/dist/ui/components/button/icon_button.js +9 -2
  19. package/dist/ui/components/button/toggle_button.js +7 -1
  20. package/dist/ui/components/dialog.d.ts +1 -1
  21. package/dist/ui/components/footer.js +1 -1
  22. package/dist/ui/components/input/checkbox.d.ts +2 -5
  23. package/dist/ui/components/input/checkbox.js +10 -19
  24. package/dist/ui/components/input/range.js +4 -1
  25. package/dist/ui/components/input/select.js +1 -1
  26. package/dist/ui/components/input/switch.d.ts +6 -2
  27. package/dist/ui/components/input/switch.js +25 -22
  28. package/dist/ui/components/input/text/input_field.d.ts +28 -0
  29. package/dist/ui/components/input/text/input_field.js +70 -0
  30. package/dist/ui/components/input/text/multi_line.d.ts +10 -0
  31. package/dist/ui/components/input/text/multi_line.js +19 -0
  32. package/dist/ui/components/input/text/single_line.d.ts +18 -0
  33. package/dist/ui/components/input/text/single_line.js +28 -0
  34. package/dist/ui/components/layout/app_base.d.ts +14 -0
  35. package/dist/ui/components/layout/app_base.js +30 -0
  36. package/dist/ui/components/layout/ctx_app_base.d.ts +16 -0
  37. package/dist/ui/components/layout/ctx_app_base.js +13 -0
  38. package/dist/ui/components/layout/flex.d.ts +4 -2
  39. package/dist/ui/components/layout/flex.js +13 -5
  40. package/dist/ui/components/layout/header.d.ts +18 -18
  41. package/dist/ui/components/layout/header.js +54 -48
  42. package/dist/ui/components/layout/menu.d.ts +12 -0
  43. package/dist/ui/components/layout/menu.js +59 -0
  44. package/dist/ui/components/layout/spaced.d.ts +4 -2
  45. package/dist/ui/components/layout/spaced.js +6 -2
  46. package/dist/ui/components/layout/toolbar.d.ts +7 -0
  47. package/dist/ui/components/layout/toolbar.js +71 -0
  48. package/dist/ui/components/progress_bar.js +7 -5
  49. package/dist/ui/components/spinner.js +4 -0
  50. package/dist/ui/components/text.d.ts +1 -1
  51. package/dist/ui/components/text.js +4 -4
  52. package/dist/ui/theme/color_theme.d.ts +1 -1
  53. package/dist/ui/theme/color_theme.js +63 -52
  54. package/dist/ui/theme/colors.d.ts +33 -13
  55. package/dist/ui/theme/colors.js +42 -15
  56. package/dist/ui/theme/geometry_theme.js +2 -4
  57. package/dist/ui/theme/seed.d.ts +18 -8
  58. package/dist/ui/theme/seed.js +4 -1
  59. package/dist/ui/theme/theme.d.ts +3 -5
  60. package/dist/ui/theme/theme.js +9 -12
  61. package/dist/ui/theme/theme_context.d.ts +18 -0
  62. package/dist/ui/theme/theme_context.js +26 -0
  63. package/dist/ui/theme/type_theme.js +5 -2
  64. package/dist/ui/util/ctx_toolbar.d.ts +8 -0
  65. package/dist/ui/util/ctx_toolbar.js +9 -0
  66. package/dist/ui/util/l10n/l10n.d.ts +35 -0
  67. package/dist/ui/util/l10n/l10n.js +68 -0
  68. package/dist/ui/util/single_key.d.ts +11 -0
  69. package/dist/ui/util/single_key.js +1 -0
  70. package/dist/ui/util/types.d.ts +9 -0
  71. package/dist/ui/util/types.js +1 -0
  72. package/dist/ui/util/util.d.ts +5 -3
  73. package/dist/ui/util/util.js +36 -1
  74. package/package.json +1 -1
  75. package/dist/ui/components/input/input_field.d.ts +0 -22
  76. package/dist/ui/components/input/input_field.js +0 -36
  77. package/dist/ui/components/input/text_area.d.ts +0 -10
  78. package/dist/ui/components/input/text_area.js +0 -22
  79. package/dist/ui/components/layout/scaffold.d.ts +0 -15
  80. package/dist/ui/components/layout/scaffold.js +0 -31
@@ -10,9 +10,10 @@ 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 { applyProps } from "./box";
13
+ import { applyProps, } from "../../..";
14
+ export const elevatedShadow = "0 0 15px rgba(0,0,0,.2)";
14
15
  export function Card(_a) {
15
- var { mode, scheme = "primary", kind, manner, padding = 1, margin = 0, onTap, onLongTap, frosted, bordered, sharp, children } = _a, elbe = __rest(_a, ["mode", "scheme", "kind", "manner", "padding", "margin", "onTap", "onLongTap", "frosted", "bordered", "sharp", "children"]);
16
+ var { mode, scheme = "primary", kind, manner, padding = 1, margin = 0, onTap, onLongTap, frosted, bordered, elevated, sharp, disabled, overflow, children } = _a, elbe = __rest(_a, ["mode", "scheme", "kind", "manner", "padding", "margin", "onTap", "onLongTap", "frosted", "bordered", "elevated", "sharp", "disabled", "overflow", "children"]);
16
17
  return (_jsx("div", Object.assign({}, applyProps("card", elbe, [
17
18
  "card",
18
19
  mode,
@@ -22,8 +23,11 @@ export function Card(_a) {
22
23
  frosted && "frosted",
23
24
  bordered && "bordered",
24
25
  sharp && "sharp",
26
+ disabled && "disabled",
25
27
  ], {
26
28
  padding: `${padding}rem`,
27
29
  margin: `${margin}rem`,
30
+ overflow: overflow,
31
+ boxShadow: elevated ? elevatedShadow : undefined,
28
32
  }), { onClick: onTap, onContextMenu: onLongTap, children: children })));
29
33
  }
@@ -0,0 +1 @@
1
+ export type AriaRoles = "alert" | "alertdialog" | "application" | "article" | "banner" | "button" | "cell" | "checkbox" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "dialog" | "directory" | "document" | "feed" | "figure" | "form" | "grid" | "gridcell" | "group" | "heading" | "img" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem";
@@ -0,0 +1 @@
1
+ export {};
@@ -5,6 +5,7 @@ import type { IconChild } from "./icon_button";
5
5
  export type ButtonProps = ActionElbeProps & {
6
6
  kind?: ElbeColorKinds;
7
7
  transparent?: boolean;
8
+ contentAlign?: "start" | "center" | "end";
8
9
  onTap?: (e: Event) => void;
9
10
  } & {
10
11
  icon?: IconChild;
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
13
13
  import { Component } from "preact";
14
+ import { useToolbar } from "../../util/ctx_toolbar";
14
15
  import { _ElbeErr } from "../../util/error_view";
15
16
  import { applyProps } from "../base/box";
16
17
  export class Button extends Component {
@@ -23,15 +24,22 @@ Button.minor = (p) => _btn(p, "minor");
23
24
  Button.flat = (p) => _btn(p, "flat");
24
25
  Button.plain = (p) => _btn(p, "plain");
25
26
  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("button", elbe, [
27
+ var _b;
28
+ var { kind, onTap, icon, label, children, contentAlign } = _a, elbe = __rest(_a, ["kind", "onTap", "icon", "label", "children", "contentAlign"]);
29
+ const toolbarCtx = useToolbar();
30
+ return label || icon || children ? (_jsxs("button", Object.assign({}, applyProps("button", Object.assign(Object.assign({ role: "button" }, elbe), { flex: (toolbarCtx === null || toolbarCtx === void 0 ? void 0 : toolbarCtx.isInOverflow) ? 1 : elbe.flex }), [
28
31
  "row",
29
32
  "gap-half",
30
- "main-center",
31
33
  kind !== null && kind !== void 0 ? kind : (manner != "plain" && "accent"),
32
34
  manner,
33
35
  !onTap && "disabled",
34
36
  ], {
37
+ overflow: "hidden",
38
+ justifyContent: contentAlign !== null && contentAlign !== void 0 ? contentAlign : ((toolbarCtx === null || toolbarCtx === void 0 ? void 0 : toolbarCtx.isInOverflow) ? "start" : "center"),
35
39
  backgroundColor: elbe.transparent ? "transparent" : null,
36
- }), { 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"));
40
+ }), { title: (_b = elbe.ariaLabel) !== null && _b !== void 0 ? _b : label, disabled: !onTap, onClick: (e) => onTap && onTap(e), children: [typeof icon === "function" ? icon({}) : icon, !(toolbarCtx === null || toolbarCtx === void 0 ? void 0 : toolbarCtx.isInToolbar) && label && (_jsx("div", { style: {
41
+ whiteSpace: "nowrap",
42
+ overflow: "hidden",
43
+ textOverflow: "ellipsis",
44
+ }, children: label })), children] }))) : (_ElbeErr("Button requires either an icon and or a label, or a child"));
37
45
  }
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { CheckIcon } from "lucide-react";
3
+ import { Card } from "../base/card";
3
4
  import { Spaced } from "../layout/spaced";
4
5
  import { Button } from "./button";
5
6
  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; overflow: hidden", children: items.map((e) => {
7
+ return (_jsx(Card, { kind: "accent", manner: "major", padding: 0, overflow: "hidden", role: "radiogroup", disabled: !onChange, class: `${column ? "column" : "row"} gap-none`, children: items.map((e) => {
7
8
  var _a, _b;
8
- return (_jsxs(Button, { ariaLabel: (_b = (_a = e.ariaLabel) !== null && _a !== void 0 ? _a : e.label) !== null && _b !== void 0 ? _b : null, 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 &&
9
+ return (_jsxs(Button, { ariaLabel: (_b = (_a = e.ariaLabel) !== null && _a !== void 0 ? _a : e.label) !== null && _b !== void 0 ? _b : null, manner: e.value === value ? "major" : "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 &&
9
10
  (e.value === value ? _jsx(CheckIcon, {}) : _jsx(Spaced, { amount: 1.5 }))] }));
10
11
  }) }));
11
12
  }
@@ -16,3 +16,6 @@ export declare class IconButton extends Component<IconButtonProps & {
16
16
  static plain: (p: IconButtonProps) => import("preact").JSX.Element;
17
17
  render(): import("preact").JSX.Element;
18
18
  }
19
+ export declare function _IconChild(p: {
20
+ icon: IconChild | null;
21
+ }): any;
@@ -22,7 +22,7 @@ IconButton.minor = (p) => _btn(p, "minor");
22
22
  IconButton.flat = (p) => _btn(p, "flat");
23
23
  IconButton.plain = (p) => _btn(p, "plain");
24
24
  function _btn(_a, manner) {
25
- var _b;
25
+ var _b, _c;
26
26
  var { icon, onTap } = _a, elbe = __rest(_a, ["icon", "onTap"]);
27
27
  if (manner === void 0) { manner = "major"; }
28
28
  return (_jsx("button", Object.assign({}, applyProps("icon_button", elbe, [
@@ -38,5 +38,12 @@ function _btn(_a, manner) {
38
38
  borderRadius: "3rem",
39
39
  height: "3rem",
40
40
  width: "3rem",
41
- }), { onClick: (e) => onTap && onTap(e), children: typeof icon === "function" ? icon({}) : icon })));
41
+ }), { title: (_c = elbe.ariaLabel) !== null && _c !== void 0 ? _c : undefined, onClick: (e) => onTap && onTap(e), children: _jsx(_IconChild, { icon: icon }) })));
42
+ }
43
+ export function _IconChild(p) {
44
+ if (!p.icon)
45
+ return null;
46
+ if (typeof p.icon === "function")
47
+ return p.icon({});
48
+ return p.icon;
42
49
  }
@@ -11,10 +11,16 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
13
13
  import { CheckIcon } from "lucide-react";
14
+ import { useThemeConfig } from "../../theme/theme_context";
14
15
  import { applyProps } from "../base/box";
16
+ import { Padded } from "../base/padded";
15
17
  import { Spaced } from "../layout/spaced";
16
18
  import { Button } from "./button";
17
19
  export function ToggleButton(_a) {
18
20
  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("toggle_button", 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 })] })));
21
+ const tConfig = useThemeConfig();
22
+ return (_jsxs(Button, Object.assign({ manner: value ? "major" : "flat", kind: kind, onTap: onChange && (() => onChange(!value)) }, applyProps("toggle_button", elbe, "main-between"), { children: [_jsxs("div", { class: "row gap-none", children: [typeof icon === "function" ? icon({}) : icon, icon && _jsx(Spaced, { width: 0.5 }), label && _jsx("span", { children: label })] }), _jsx("div", { style: {
23
+ transition: tConfig.reducedMotion ? null : "width 0.2s ease-in-out",
24
+ width: value ? "2.5rem" : "0rem",
25
+ }, children: value && (_jsx(Padded, { class: "centered", left: 1, children: _jsx(CheckIcon, {}) })) })] })));
20
26
  }
@@ -1,4 +1,4 @@
1
- import type { ElbeChildren } from "../util/util";
1
+ import type { ElbeChildren } from "../util/types";
2
2
  export declare function ElbeDialog({ title, open, onClose, children, _style, }: {
3
3
  _style?: string;
4
4
  title: string;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
2
  import { HeartIcon } from "lucide-react";
3
3
  import { Card, Column, FlexSpace, Link, Row } from "../..";
4
4
  export function Footer({ left, right, copyright, version, legal, }) {
5
- return (_jsx(Card, { scheme: "secondary", sharp: true, style: {
5
+ return (_jsx(Card, { scheme: "secondary", sharp: true, role: "contentinfo", ariaLabel: "footer", style: {
6
6
  borderLeft: "none",
7
7
  borderRight: "none",
8
8
  borderBottom: "none",
@@ -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/types";
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;