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,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiService = void 0;
4
+ exports.ifApiError = ifApiError;
5
+ const _noArgs = {};
6
+ /**
7
+ * ApiService is a simple wrapper around fetch that handles JSON serialization and error handling.
8
+ * to use it, you must first call `ApiService.init(apiURL)` with the base URL of your API.
9
+ */
10
+ class ApiService {
11
+ apiURL;
12
+ static _i = null;
13
+ static get i() {
14
+ if (!ApiService._i)
15
+ throw "ApiService not initialized. Call ApiService.init(apiURL)";
16
+ return ApiService._i;
17
+ }
18
+ constructor(apiURL) {
19
+ this.apiURL = apiURL;
20
+ }
21
+ static init(apiURL) {
22
+ if (ApiService._i)
23
+ throw "ApiService already initialized";
24
+ ApiService._i = new ApiService(apiURL);
25
+ }
26
+ async _fetch(p, method, { path, query, body }) {
27
+ try {
28
+ p = path
29
+ ? p.replace(/:([a-zA-Z0-9_]+)/g, (m, p1) => {
30
+ const v = path[p1];
31
+ if (v === undefined)
32
+ throw { code: 400, message: `missing parameter ${p1}` };
33
+ return v?.toString() ?? "";
34
+ })
35
+ : p;
36
+ const queryStr = query != null ? "?" + new URLSearchParams(query).toString() : "";
37
+ const response = await fetch(this.apiURL + p + queryStr, {
38
+ method,
39
+ credentials: "include",
40
+ headers: { "Content-Type": "application/json" },
41
+ body: body ? JSON.stringify(body) : undefined,
42
+ });
43
+ if (response.ok) {
44
+ try {
45
+ return await response.json();
46
+ }
47
+ catch (e) {
48
+ return null;
49
+ }
50
+ }
51
+ let data = null;
52
+ try {
53
+ data = await response.clone().json();
54
+ }
55
+ catch (e) {
56
+ data = await response.text();
57
+ }
58
+ throw {
59
+ code: response.status,
60
+ message: data.message ?? "undefined error",
61
+ data,
62
+ };
63
+ }
64
+ catch (e) {
65
+ rethrow(e, 0, "unknown error");
66
+ }
67
+ }
68
+ async get(path, args) {
69
+ return this._fetch(path, "GET", args || _noArgs);
70
+ }
71
+ async post(path, args) {
72
+ return this._fetch(path, "POST", args || _noArgs);
73
+ }
74
+ async delete(path, args) {
75
+ return this._fetch(path, "DELETE", args || _noArgs);
76
+ }
77
+ }
78
+ exports.ApiService = ApiService;
79
+ function rethrow(e, code, message) {
80
+ // if e implements the apiError interface, rethrow it:
81
+ if (e && e.code !== null && e.message !== null)
82
+ throw e;
83
+ throw { code, message, data: e };
84
+ }
85
+ function ifApiError(e) {
86
+ if (e && e.code !== null && e.message !== null)
87
+ return e;
88
+ return null;
89
+ }
@@ -1,20 +1,20 @@
1
1
  import React from "preact/compat";
2
- import type { ElbeColorStyles } from "../color_theme";
2
+ import type { ElbeColorKinds } from "../theme/colors";
3
3
  import type { ElbeChild, ElbeChildren } from "../util/util";
4
- import type { ElbeProps } from "./box";
4
+ import type { ElbeProps } from "./base/box";
5
5
  export type BadgeProps = {
6
6
  count?: number;
7
- message?: string;
7
+ label?: string;
8
8
  child?: ElbeChild;
9
9
  hidden?: boolean;
10
10
  children?: ElbeChildren;
11
11
  } & ElbeProps;
12
12
  export declare function TestBadge(p: BadgeProps): Badge;
13
13
  export declare class Badge extends React.Component<BadgeProps & {
14
- colorStyle: ElbeColorStyles;
14
+ kind: ElbeColorKinds;
15
15
  }> {
16
16
  constructor(props: BadgeProps & {
17
- colorStyle: ElbeColorStyles;
17
+ kind: ElbeColorKinds;
18
18
  });
19
19
  static accent(p: BadgeProps): React.JSX.Element;
20
20
  static error(p: BadgeProps): React.JSX.Element;
@@ -0,0 +1,53 @@
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.Badge = void 0;
7
+ exports.TestBadge = TestBadge;
8
+ const jsx_runtime_1 = require("preact/jsx-runtime");
9
+ const compat_1 = __importDefault(require("preact/compat"));
10
+ function TestBadge(p) {
11
+ return new Badge({ ...p, kind: "accent" });
12
+ }
13
+ class Badge extends compat_1.default.Component {
14
+ constructor(props) {
15
+ super(props);
16
+ }
17
+ static accent(p) {
18
+ return (0, jsx_runtime_1.jsx)(Badge, { ...p, kind: "accent" });
19
+ }
20
+ static error(p) {
21
+ return (0, jsx_runtime_1.jsx)(Badge, { ...p, kind: "error" });
22
+ }
23
+ static warning(p) {
24
+ return (0, jsx_runtime_1.jsx)(Badge, { ...p, kind: "warning" });
25
+ }
26
+ static success(p) {
27
+ return (0, jsx_runtime_1.jsx)(Badge, { ...p, kind: "success" });
28
+ }
29
+ static info(p) {
30
+ return (0, jsx_runtime_1.jsx)(Badge, { ...p, kind: "info" });
31
+ }
32
+ render() {
33
+ return ((0, jsx_runtime_1.jsxs)("div", { style: {
34
+ position: "relative",
35
+ display: "inline-block",
36
+ }, children: [this.props.child, this.props.children, (0, jsx_runtime_1.jsx)("div", { class: `b ${this.props.kind} major ${this.props.class ?? ""}`, style: {
37
+ position: "absolute",
38
+ top: "-0.25rem",
39
+ right: "-0.25rem",
40
+ minWidth: "1.5rem",
41
+ minHeight: "1.5rem",
42
+ padding: "0rem .4rem",
43
+ borderRadius: "3rem",
44
+ fontWeight: "bold",
45
+ display: "flex",
46
+ justifyContent: "center",
47
+ alignItems: "center",
48
+ visibility: this.props.hidden ? "hidden" : "visible",
49
+ ...this.props.style,
50
+ }, children: this.props.label ?? this.props.count })] }));
51
+ }
52
+ }
53
+ exports.Badge = Badge;