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
@@ -1,11 +0,0 @@
1
- import { Icons } from "../..";
2
-
3
- export function Spinner({ padding = 2 }: { padding?: number }) {
4
- return (
5
- <div style={{ padding: `${padding}rem` }} class="centered">
6
- <div class="rotate-box">
7
- <Icons.LoaderCircle />
8
- </div>
9
- </div>
10
- );
11
- }
@@ -1,78 +0,0 @@
1
- import React from "preact/compat";
2
- import type { ElbeTypeStyles } from "../color_theme";
3
- import type { ElbeChildren } from "../util/util";
4
- import { applyProps, type ElbeProps } from "./box";
5
-
6
- export type TextProps = {
7
- align?: "start" | "center" | "end";
8
- bold?: boolean;
9
- italic?: boolean;
10
- underline?: boolean;
11
- striked?: boolean;
12
- color?: string;
13
- size?: number;
14
- children?: ElbeChildren;
15
- v?: string;
16
- } & ElbeProps;
17
-
18
- export class Text extends React.Component<
19
- TextProps & { typeStyle?: ElbeTypeStyles }
20
- > {
21
- static h1 = (p: TextProps) => <Text {...p} typeStyle="header-1" />;
22
- static h2 = (p: TextProps) => <Text {...p} typeStyle="header-2" />;
23
- static h3 = (p: TextProps) => <Text {...p} typeStyle="header-3" />;
24
- static h4 = (p: TextProps) => <Text {...p} typeStyle="header-4" />;
25
- static h5 = (p: TextProps) => <Text {...p} typeStyle="header-5" />;
26
- static h6 = (p: TextProps) => <Text {...p} typeStyle="header-6" />;
27
- static s = (p: TextProps) => <Text {...p} typeStyle="text-s" />;
28
- static m = (p: TextProps) => <Text {...p} typeStyle="text-m" />;
29
- static l = (p: TextProps) => <Text {...p} typeStyle="text-l" />;
30
- static code = (p: TextProps) => <Text {...p} typeStyle="code" />;
31
-
32
- constructor({
33
- typeStyle = "text-m",
34
- ...props
35
- }: TextProps & { typeStyle?: ElbeTypeStyles }) {
36
- super({ ...props, typeStyle });
37
- }
38
-
39
- render() {
40
- const {
41
- align,
42
- bold,
43
- italic,
44
- underline,
45
- striked,
46
- color,
47
- size,
48
- children,
49
- typeStyle,
50
- v,
51
- ...elbe
52
- } = this.props;
53
- return (
54
- <span
55
- {...applyProps(
56
- elbe,
57
- [
58
- "text",
59
- align,
60
- bold && "b",
61
- italic && "i",
62
- underline && "underline",
63
- striked && "striked",
64
- color,
65
- typeStyle,
66
- ],
67
- {
68
- fontSize: size ? `${size}rem` : "",
69
- color: color || "",
70
- }
71
- )}
72
- >
73
- {v}
74
- {children}
75
- </span>
76
- );
77
- }
78
- }
@@ -1,52 +0,0 @@
1
- import { Icons, applyProps } from "../..";
2
- import { _ElbeErr } from "../util/error_view";
3
- import type { ElbeChild } from "../util/util";
4
- import type { ElbeProps } from "./box";
5
- import { Card } from "./card";
6
- import { Column, FlexSpace } from "./flex";
7
-
8
- export type ToggleButtonItem<T> = {
9
- icon?: (_: any) => ElbeChild;
10
- label: string;
11
- key: T;
12
- };
13
-
14
- export function ToggleButton<T>({
15
- items,
16
- onSelect,
17
- value,
18
- ...elbe
19
- }: {
20
- items: ToggleButtonItem<T>[];
21
-
22
- onSelect: ((value: T) => void) | null;
23
- value: T;
24
- } & ElbeProps) {
25
- return items.length < 1 ? (
26
- _ElbeErr("ToggleButton requires at least one item")
27
- ) : (
28
- <Card
29
- mode="light"
30
- colorScheme="primary"
31
- padding={0}
32
- {...applyProps(elbe, null, { overflow: "hidden", width: "100%" })}
33
- >
34
- <Column stretch gap={0}>
35
- {items.map((item) => (
36
- <Card
37
- onTap={onSelect ? () => onSelect(item.key) : undefined}
38
- class={`row b ${onSelect ? "pointer" : "disabled"}`}
39
- style={{ border: "none", borderRadius: 0, gap: ".75rem" }}
40
- colorStyle="accent"
41
- colorManner={value === item.key ? "minor" : "action"}
42
- >
43
- {item.icon?.({})}
44
- {item.label}
45
- <FlexSpace />
46
- {value === item.key && <Icons.Check />}
47
- </Card>
48
- ))}
49
- </Column>
50
- </Card>
51
- );
52
- }
@@ -1,3 +0,0 @@
1
- export function Spaced({ amount = 1 }) {
2
- return <div style={{ width: amount + "rem", height: amount + "rem" }}></div>;
3
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * show a simple confirm dialog
3
- * @param param0 the title and message of the dialog
4
- * @returns a promise that resolves to true if the user clicks "yes" or "okay" and false if the user clicks "no"
5
- */
6
- export function showConfirmDialog({
7
- title,
8
- message,
9
- okay = false,
10
- }: {
11
- message: string;
12
- title: string;
13
- okay?: boolean;
14
- }): Promise<boolean> {
15
- return new Promise((resolve, reject) => {
16
- const dialog = document.createElement("div");
17
- dialog.classList.add("dialog");
18
- dialog.innerHTML = `<dialog open>
19
- <div
20
- class=" card plain-opaque"
21
- style="max-width: 30rem; min-width: 10rem"
22
- >
23
- <div class="row cross-start">
24
- <div class="flex-1 b" style="margin-top: 0.47rem; font-size: 1.2rem">
25
- ${title}
26
- </div>
27
- <button class="integrated" style="width: 3rem" onclick="conf_resolve(false)">
28
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x "><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>
29
- </button>
30
- </div>
31
- <div style="margin-top: 1rem; margin-bottom: 1rem">
32
- ${message}
33
- </div>
34
- <div class="row main-end gap">
35
-
36
- ${
37
- okay
38
- ? '<button class="loud" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(true)">okay</button>'
39
- : '<button class="loud minor" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(false)">no</button>' +
40
- '<button class="loud" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(true)">yes</button>'
41
- }
42
- </div>
43
-
44
- </div>
45
- </dialog>
46
- `;
47
- document.body.appendChild(dialog);
48
- (window as any)["conf_resolve"] = (v: any) => {
49
- document.body.removeChild(dialog);
50
- resolve(v);
51
- };
52
- });
53
- }
@@ -1,16 +0,0 @@
1
- import { Icons } from "../..";
2
-
3
- export function _ElbeErr(msg: string) {
4
- return (
5
- <div
6
- class="row text-s gap-half"
7
- style="background: #ee0044; color: white; border-radius: 4px; text-align: left; padding: .5rem"
8
- >
9
- <Icons.CircleX />
10
- <div class="column gap-none cross-stretch">
11
- <b class="text-s">elbe error</b>
12
- <span style="margin-top: -.125rem">{msg}</span>
13
- </div>
14
- </div>
15
- );
16
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * show a toast message at the bottom of the screen
3
- * @param message the message to show
4
- */
5
-
6
- export function showToast(message: string) {
7
- const toast = document.createElement("div");
8
- toast.classList.add("toast");
9
- toast.innerText = message;
10
- document.body.appendChild(toast);
11
- setTimeout(() => {
12
- toast.remove();
13
- }, 3000);
14
- }
@@ -1,36 +0,0 @@
1
- import type React from "preact/compat";
2
- import { showToast } from "./toast";
3
-
4
- export type ElbeChild = React.ReactNode;
5
- export type ElbeChildren = ElbeChild[] | ElbeChild;
6
-
7
- /**
8
- * use the web share api if available, otherwise copy the data to the clipboard
9
- * @param data the data you want to share
10
- * @param toastMsg the message to show in the toast if the share api is not available
11
- */
12
- export function share(
13
- data: { title: string; text?: string; url: string },
14
- toastMsg = "copied to clipboard. Share it with others."
15
- ) {
16
- const msg = `${data.title}\n${data.text ?? ""}\n\n${data.url}`;
17
-
18
- if (navigator.share) {
19
- navigator.share(data).catch(() => copyToClipboard(msg, toastMsg));
20
- } else {
21
- copyToClipboard(msg, toastMsg);
22
- }
23
- }
24
-
25
- /**
26
- * copy the text to the clipboard
27
- * @param text the text to copy to the clipboard
28
- * @param toastMsg the message to show in the toast
29
- */
30
- export function copyToClipboard(
31
- text: string,
32
- toastMsg = "copied to clipboard"
33
- ) {
34
- navigator.clipboard.writeText(text);
35
- if (toastMsg) showToast(toastMsg);
36
- }
@@ -1,149 +0,0 @@
1
- @use "sass:color";
2
- @function cPart($c, $part) {@return color.channel($c, $part, $space: rgb)}
3
-
4
- @function cHumanGray($c) {
5
- @return calc(((cPart($c, "red") * 299) + (cPart($c,"green") * 587) + (cPart($c,"blue") * 114)) / 1000);
6
- }
7
-
8
- @function contrast($colorA, $colorB) {
9
- $yiqA: cHumanGray($colorA);
10
- $yiqB: cHumanGray($colorB);
11
- @return abs($yiqA - $yiqB);
12
- }
13
-
14
- @function mg($map, $value) {
15
- @return map-get($map, $value);
16
- }
17
-
18
- @function ifn($a, $b) {
19
- @return if($a ==null, $b, $a);
20
- }
21
-
22
- @function inter($colorA, $colorB: #888888, $weight: 50%) {
23
- @return mix($colorA, $colorB, $weight);
24
- }
25
-
26
- @mixin colored($back, $front, $border) {
27
- color: $front;
28
- background-color: $back;
29
- border-color: $border;
30
- }
31
-
32
- @mixin blinking($length: 1s) {
33
- animation: blinker $length linear infinite;
34
- }
35
-
36
- @keyframes blinker {
37
- 50% {
38
- opacity: 0;
39
- }
40
- }
41
-
42
- // SHOW WHEN THE STYLES ARE NOT BEING USED WITHIN A MODE
43
- @each $style, $s_colors in $c-styles {
44
- .#{$style} {
45
- @include blinking();
46
- @include colored(rgb(255, 55, 0), white, transparent);
47
- }
48
- }
49
-
50
- //COLORS
51
-
52
- @each $mode, $m_colors in $c-modes {
53
- .#{$mode} {
54
- $mode_back: mg($m_colors, back);
55
- $mode_front: mg($m_colors, front);
56
- $mode_border: mg($m_colors, border);
57
- @include colored($mode_back, $mode_front, $mode_border);
58
-
59
- .plain {
60
- @include colored(transparent, $mode_front, $mode_border);
61
- }
62
-
63
- .plain-opaque {
64
- @include colored($mode_back, $mode_front, $mode_border);
65
- }
66
-
67
- & {
68
- --c-mode: #{$mode};
69
- }
70
-
71
- @each $style, $s_colors in $c-styles {
72
- $back: mg($s_colors, back);
73
- $border: ifn(mg($s_colors, border), $back);
74
-
75
- $effectiveBack: ifn(
76
- if(mg($s_colors, back) == transparent, $mode_back, mg($s_colors, back)),
77
- $mode_back
78
- );
79
- $front: ifn(
80
- mg($s_colors, front),
81
- if(contrast($mode_front, $effectiveBack) > 128, $mode_front, $mode_back)
82
- );
83
-
84
- & {
85
- --c-#{$style}: #{$back};
86
- }
87
-
88
- .#{$style} {
89
- animation: none;
90
-
91
- @include colored($back, $front, $border);
92
-
93
- &.minor {
94
- $mback: inter(mg($s_colors, back), mg($m_colors, back), 25%);
95
- $mfront: mg($s_colors, back);
96
- $mborder: ifn(mg($s_colors, border), $mfront);
97
-
98
- @include colored($mback, $mfront, $mborder);
99
-
100
- &.hovered {
101
- $hback: inter($mback, $mfront, 90%);
102
- @include colored($hback, $mfront, $mborder);
103
- }
104
-
105
- &.pressed {
106
- $pback: inter($mback, $mfront, 75%);
107
- @include colored($pback, $mfront, $mborder);
108
- }
109
-
110
- &.disabled {
111
- $disback: grayscale($mback);
112
- $disfront: grayscale($mfront);
113
- $disborder: if($mborder ==null, null, grayscale($mborder));
114
-
115
- @include colored($disback, $disfront, $disborder);
116
- }
117
- }
118
-
119
- &.hovered {
120
- $hback: inter($back, $front, 95%);
121
- $hborder: if(
122
- $border ==transparent,
123
- transparent,
124
- inter($border, $front, 95%)
125
- );
126
- @include colored($hback, $front, $hborder);
127
- }
128
-
129
- &.pressed {
130
- $pback: inter($back, $front, 85%);
131
- $pborder: if(
132
- $border ==transparent,
133
- transparent,
134
- inter($border, $front, 85%)
135
- );
136
- @include colored($pback, $front, $pborder);
137
- }
138
-
139
- &.disabled {
140
- @include colored(
141
- grayscale($back),
142
- grayscale($front),
143
- grayscale($back)
144
- );
145
- }
146
- }
147
- }
148
- }
149
- }