elbe-ui 0.2.30 → 0.2.37

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/dist/bit/bit.d.ts +34 -0
  2. package/dist/bit/bit.js +83 -0
  3. package/dist/bit/ctrl_bit.d.ts +30 -0
  4. package/dist/bit/ctrl_bit.js +89 -0
  5. package/dist/elbe.css +203 -284
  6. package/dist/elbe.css.map +1 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +1 -0
  9. package/dist/service/s_api.d.ts +30 -0
  10. package/dist/service/s_api.js +89 -0
  11. package/dist/ui/components/badge.d.ts +25 -0
  12. package/dist/ui/components/badge.js +53 -0
  13. package/dist/ui/components/base/box.d.ts +2564 -0
  14. package/dist/ui/components/base/box.js +30 -0
  15. package/dist/ui/components/base/card.d.ts +14 -0
  16. package/dist/ui/components/base/card.js +11 -0
  17. package/dist/ui/components/base/padded.d.ts +25 -0
  18. package/dist/ui/components/base/padded.js +28 -0
  19. package/dist/ui/components/button/button.d.ts +21 -0
  20. package/dist/ui/components/button/button.js +27 -0
  21. package/dist/ui/components/button/choose_button.d.ts +14 -0
  22. package/dist/ui/components/button/choose_button.js +11 -0
  23. package/dist/ui/components/button/icon_button.d.ts +17 -0
  24. package/dist/ui/components/button/icon_button.js +31 -0
  25. package/dist/ui/components/button/toggle_button.d.ts +10 -0
  26. package/dist/ui/components/button/toggle_button.js +11 -0
  27. package/dist/ui/components/dialog.d.ts +8 -0
  28. package/dist/ui/components/dialog.js +14 -0
  29. package/dist/ui/components/error_view.d.ts +15 -0
  30. package/dist/ui/components/error_view.js +26 -0
  31. package/dist/ui/components/input/checkbox.d.ts +6 -0
  32. package/dist/ui/components/input/checkbox.js +12 -0
  33. package/dist/ui/components/input/input_field.d.ts +22 -0
  34. package/dist/ui/components/input/input_field.js +31 -0
  35. package/dist/ui/components/input/range.d.ts +8 -0
  36. package/dist/ui/components/input/range.js +14 -0
  37. package/dist/ui/components/input/select.d.ts +10 -0
  38. package/dist/ui/components/input/select.js +8 -0
  39. package/dist/ui/components/input/text_area.d.ts +10 -0
  40. package/dist/ui/components/input/text_area.js +13 -0
  41. package/dist/ui/components/layout/flex.d.ts +11 -0
  42. package/dist/ui/components/layout/flex.js +23 -0
  43. package/dist/ui/components/layout/scaffold.d.ts +27 -0
  44. package/dist/ui/components/layout/scaffold.js +44 -0
  45. package/dist/ui/components/layout/scroll.d.ts +18 -0
  46. package/dist/ui/components/layout/scroll.js +20 -0
  47. package/dist/ui/components/layout/spaced.d.ts +3 -0
  48. package/dist/ui/components/layout/spaced.js +7 -0
  49. package/dist/ui/components/spinner.d.ts +11 -0
  50. package/dist/ui/components/spinner.js +48 -0
  51. package/dist/ui/components/text.d.ts +33 -0
  52. package/dist/ui/components/text.js +42 -0
  53. package/dist/ui/theme/color_theme.d.ts +2 -0
  54. package/dist/ui/theme/color_theme.js +63 -0
  55. package/dist/ui/theme/colors.d.ts +142 -0
  56. package/dist/ui/theme/colors.js +317 -0
  57. package/dist/ui/theme/geometry_theme.d.ts +16 -0
  58. package/dist/ui/theme/geometry_theme.js +38 -0
  59. package/dist/ui/theme/theme.d.ts +28 -0
  60. package/dist/ui/theme/theme.js +49 -0
  61. package/dist/ui/theme/type_theme.d.ts +38 -0
  62. package/dist/ui/theme/type_theme.js +98 -0
  63. package/dist/ui/util/confirm_dialog.d.ts +10 -0
  64. package/dist/ui/util/confirm_dialog.js +46 -0
  65. package/dist/ui/util/error_view.d.ts +1 -0
  66. package/dist/ui/util/error_view.js +8 -0
  67. package/dist/ui/util/toast.d.ts +5 -0
  68. package/dist/ui/util/toast.js +17 -0
  69. package/dist/ui/util/util.d.ts +21 -0
  70. package/dist/ui/util/util.js +39 -0
  71. package/package.json +3 -6
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColorTheme = exports.ModeColor = exports.SchemeColor = exports.KindColor = exports.MannerColor = exports.StateColor = exports.LayerColor = exports.colors = exports.cLayers = exports.cStates = exports.cManners = exports.cKinds = exports.cSchemes = exports.cModes = void 0;
4
+ const colors_convert_1 = require("colors-convert");
5
+ const util_1 = require("../util/util");
6
+ const color_theme_1 = require("./color_theme");
7
+ exports.cModes = ["light", "dark"];
8
+ exports.cSchemes = ["primary", "secondary", "inverse"];
9
+ exports.cKinds = [
10
+ "plain",
11
+ "accent",
12
+ "info",
13
+ "success",
14
+ "warning",
15
+ "error",
16
+ ];
17
+ exports.cManners = ["major", "minor", "flat", "plain"];
18
+ exports.cStates = ["neutral", "hover", "active", "disabled"];
19
+ exports.cLayers = ["back", "front", "border"];
20
+ class RGBAColor {
21
+ r;
22
+ g;
23
+ b;
24
+ a;
25
+ constructor(r, g, b, a) {
26
+ this.r = r;
27
+ this.g = g;
28
+ this.b = b;
29
+ this.a = a;
30
+ }
31
+ asCss() {
32
+ return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`;
33
+ }
34
+ get isDark() {
35
+ return this.luminance < 0.5;
36
+ }
37
+ get luminance() {
38
+ const [r, g, b] = [this.r, this.g, this.b].map((v) => {
39
+ v /= 255;
40
+ return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
41
+ });
42
+ return r * 0.2126 + g * 0.7152 + b * 0.0722;
43
+ }
44
+ get hex() {
45
+ const c = [this.r, this.g, this.b].map((v) => Math.round(v).toString(16).padStart(2, "0"));
46
+ const a = Math.round(this.a * 255)
47
+ .toString(16)
48
+ .padStart(2, "0");
49
+ return `#${c.join("")}${a}`;
50
+ }
51
+ static _fromHex(hex) {
52
+ if (!hex)
53
+ return new RGBAColor(0, 0, 0, 0);
54
+ const c = hex.replace("#", "").padEnd(6, "0").padEnd(8, "f").toLowerCase();
55
+ console.log(c);
56
+ return new RGBAColor(parseInt(c.substring(0, 2), 16), parseInt(c.substring(2, 4), 16), parseInt(c.substring(4, 6), 16), parseInt(c.substring(6, 8), 16) / 255);
57
+ }
58
+ desaturated(f = 1) {
59
+ const avg = (this.r + this.g + this.b) / 3;
60
+ return new RGBAColor(this.r + (avg - this.r) * f, this.g + (avg - this.g) * f, this.b + (avg - this.b) * f, this.a);
61
+ }
62
+ withAlpha(a) {
63
+ return new RGBAColor(this.r, this.g, this.b, a);
64
+ }
65
+ inter(other, factor) {
66
+ return new RGBAColor(this.r + (other.r - this.r) * factor, this.g + (other.g - this.g) * factor, this.b + (other.b - this.b) * factor, this.a + (other.a - this.a) * factor);
67
+ }
68
+ mirrorBrightness(factor = 1) {
69
+ const hsl = (0, colors_convert_1.rgbToHsl)({ r: this.r, g: this.g, b: this.b });
70
+ const newL = (50 - hsl.l) * (factor * 2 - 1) + 50;
71
+ const rgb = (0, colors_convert_1.hslToRgb)({
72
+ ...hsl,
73
+ l: (0, util_1.clamp)(newL, 0, 100),
74
+ s: (0, util_1.clamp)(hsl.s, 0, 100),
75
+ //s: -Math.abs(2 * newL - 100) + 100,
76
+ });
77
+ return new RGBAColor(rgb.r, rgb.g, rgb.b, this.a);
78
+ }
79
+ get values() {
80
+ return [this.r, this.g, this.b, this.a];
81
+ }
82
+ hasWCAGContrast(color) {
83
+ return this.contrastRatio(color) >= 3;
84
+ }
85
+ contrastRatio(color) {
86
+ const l1 = this.luminance;
87
+ const l2 = color.luminance;
88
+ return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
89
+ }
90
+ }
91
+ exports.colors = {
92
+ transparent: new RGBAColor(0, 0, 0, 0),
93
+ white: new RGBAColor(255, 255, 255, 1),
94
+ black: new RGBAColor(0, 0, 0, 1),
95
+ blueAccent: new RGBAColor(60, 119, 246, 1),
96
+ blue: new RGBAColor(32, 89, 153, 1),
97
+ green: new RGBAColor(35, 144, 78, 1),
98
+ yellow: new RGBAColor(240, 221, 21, 1),
99
+ red: new RGBAColor(243, 67, 67, 1),
100
+ };
101
+ class LayerColor extends RGBAColor {
102
+ back;
103
+ border;
104
+ borderContext;
105
+ front;
106
+ constructor(back, front, border, borderContext) {
107
+ super(back.r, back.g, back.b, back.a);
108
+ this.back = back;
109
+ this.border = border;
110
+ this.borderContext = borderContext;
111
+ this.front = front ?? (back.isDark ? exports.colors.white : exports.colors.black);
112
+ }
113
+ asCss() {
114
+ return (`background-color: ${this.back.asCss()};\n` +
115
+ `color: ${this.front.asCss()};\n` +
116
+ `border-color: ${this.border?.asCss() ?? "transparent"};\n` +
117
+ //`border-color: ${this.border?.asCss() ?? "transparent"};\n` +
118
+ this.contextCss());
119
+ }
120
+ inter(other, factor) {
121
+ return new LayerColor(this.back.inter(other.back, factor), this.front.inter(other.front, factor), this.border?.inter(other.border ?? exports.colors.transparent, factor), this.borderContext?.inter(other.borderContext ?? exports.colors.transparent, factor));
122
+ }
123
+ mirrorBrightness(factor) {
124
+ return new LayerColor(this.back.mirrorBrightness(factor), this.front.mirrorBrightness(factor), this.border?.mirrorBrightness(factor), this.borderContext?.mirrorBrightness(factor));
125
+ }
126
+ desaturated() {
127
+ return new LayerColor(this.back.desaturated(), this.front.desaturated(), this.border?.desaturated(), this.borderContext?.desaturated());
128
+ }
129
+ static fromHex(back, front, border) {
130
+ if (front === undefined && border === undefined) {
131
+ return LayerColor.fromBack(RGBAColor._fromHex(back));
132
+ }
133
+ return new LayerColor(RGBAColor._fromHex(back), RGBAColor._fromHex(front ?? null), RGBAColor._fromHex(border ?? null));
134
+ }
135
+ static fromBack(back, c) {
136
+ const front = back.isDark ? exports.colors.white : exports.colors.black;
137
+ return new LayerColor(back, c?.front ?? front, c?.border ?? front);
138
+ }
139
+ contextCss() {
140
+ return (`--c-context-back: ${this.back.asCss()};\n` +
141
+ `--c-context-front: ${this.front.asCss()};` +
142
+ `--c-context-border: ${(this.borderContext ?? this.border)?.asCss() ?? "transparent"};`);
143
+ }
144
+ }
145
+ exports.LayerColor = LayerColor;
146
+ class StateColor extends LayerColor {
147
+ neutral;
148
+ hover;
149
+ active;
150
+ disabled;
151
+ constructor(neutral, hover, active, disabled) {
152
+ super(neutral.back, neutral.front, neutral.border);
153
+ this.neutral = neutral;
154
+ this.hover = hover;
155
+ this.active = active;
156
+ this.disabled = disabled;
157
+ }
158
+ asCss() {
159
+ const els = [
160
+ ".action",
161
+ ":is(button)",
162
+ ":is(a)",
163
+ ":is(input)",
164
+ ":is(select)",
165
+ ];
166
+ const disS = "&.disabled, & :disabled, &:disabled";
167
+ const hoverS = els.map((e) => `&${e}:hover:not(${disS})`).join(", ");
168
+ const activeS = els.map((e) => `&${e}:active:not(${disS})`).join(", ");
169
+ return (`${this.neutral.asCss()} \n` +
170
+ `${hoverS} { ${this.hover.asCss()} }\n` +
171
+ `${activeS} { ${this.active.asCss()} }\n` +
172
+ `${disS} { ${this.disabled.asCss()} }`);
173
+ }
174
+ static generate(_, context, style, fromFront) {
175
+ function _make(factor) {
176
+ const front = style.front;
177
+ return new LayerColor((fromFront
178
+ ? context.back.inter(front, factor)
179
+ : style.back.inter(context.back.mirrorBrightness(), factor)).withAlpha(Math.max(style.back.a, 0.2)), front, style.border, style.borderContext);
180
+ }
181
+ return new StateColor(style, _make(0.075), _make(0.25), style.desaturated());
182
+ }
183
+ }
184
+ exports.StateColor = StateColor;
185
+ class MannerColor extends StateColor {
186
+ major;
187
+ minor;
188
+ flat;
189
+ constructor(major, minor, flat) {
190
+ const m = major ?? flat;
191
+ super(m.neutral, m.hover, m.active, m.disabled);
192
+ this.major = major;
193
+ this.minor = minor;
194
+ this.flat = flat;
195
+ }
196
+ asCss(fallback) {
197
+ const maj = this.major ?? fallback?.major;
198
+ const min = this.minor ?? fallback?.minor;
199
+ return (`${this.flat.asCss()}\n` +
200
+ (maj ? `&.major { ${maj.asCss()} } \n` : "") +
201
+ (min ? `&.minor { ${min.asCss()} } \n` : "") +
202
+ `&.flat { ${this.flat.asCss()} }\n`);
203
+ }
204
+ raisedCss() {
205
+ const maj = this.major;
206
+ const min = this.minor;
207
+ return ((maj ? ` .major { ${maj.asCss()} } \n` : "") +
208
+ (min ? ` .minor { ${min.asCss()} } \n` : ""));
209
+ }
210
+ static generate(s, c, style) {
211
+ return new MannerColor(style ? StateColor.generate(s, c, s.variant.major(s, c, style)) : null, style ? StateColor.generate(s, c, s.variant.minor(s, c, style)) : null, StateColor.generate(s, c, s.variant.flat(s, c, style), true));
212
+ /*
213
+ if (!style) {
214
+ return new MannerColor(null, null, StateColor.generate(s, c, c, true));
215
+ }
216
+ return new MannerColor(
217
+ StateColor.generate(s, c, s.variant.major(s, c, style)),
218
+ StateColor.generate(s, c, s.variant.minor(s, c, style)),
219
+ StateColor.generate(s, c, s.variant.flat(s, c, style), true)
220
+ );
221
+ */
222
+ }
223
+ }
224
+ exports.MannerColor = MannerColor;
225
+ class KindColor extends MannerColor {
226
+ plain;
227
+ accent;
228
+ info;
229
+ success;
230
+ warning;
231
+ error;
232
+ constructor(plain, accent, info, success, warning, error) {
233
+ super(plain.major, plain.minor, plain.flat);
234
+ this.plain = plain;
235
+ this.accent = accent;
236
+ this.info = info;
237
+ this.success = success;
238
+ this.warning = warning;
239
+ this.error = error;
240
+ }
241
+ asCss() {
242
+ return (`${this.plain.asCss()}\n` +
243
+ `${this.accent.raisedCss()}\n` +
244
+ `.plain {${this.plain.asCss()}}\n` +
245
+ `.accent { ${this.accent.asCss()} }\n` +
246
+ `.info { ${this.info.asCss()} }\n` +
247
+ `.success { ${this.success.asCss()} }\n` +
248
+ `.warning { ${this.warning.asCss()} }\n` +
249
+ `.error { ${this.error.asCss()} }`);
250
+ }
251
+ static generate(s, c) {
252
+ return new KindColor(MannerColor.generate(s, c), MannerColor.generate(s, c, s.style.accent(s, c, s.accent)), MannerColor.generate(s, c, s.style.info(s, c, s.info)), MannerColor.generate(s, c, s.style.success(s, c, s.success)), MannerColor.generate(s, c, s.style.warning(s, c, s.warning)), MannerColor.generate(s, c, s.style.error(s, c, s.error)));
253
+ }
254
+ }
255
+ exports.KindColor = KindColor;
256
+ class SchemeColor extends KindColor {
257
+ primary;
258
+ secondary;
259
+ inverse;
260
+ constructor(primary, secondary, inverse) {
261
+ super(primary.plain, primary.accent, primary.info, primary.success, primary.warning, primary.error);
262
+ this.primary = primary;
263
+ this.secondary = secondary;
264
+ this.inverse = inverse;
265
+ }
266
+ asCss() {
267
+ return (`${this.primary.asCss()}\n` +
268
+ `.primary { ${this.primary.asCss()}} \n` +
269
+ `.secondary { ${this.secondary.asCss()} }\n` +
270
+ `.inverse { ${this.inverse.asCss()} }`);
271
+ }
272
+ static generate(seed, c) {
273
+ const m = seed.scheme;
274
+ return new SchemeColor(KindColor.generate(seed, m.primary(seed, c)), KindColor.generate(seed, m.secondary(seed, c)), KindColor.generate(seed, m.inverse(seed, c)));
275
+ }
276
+ }
277
+ exports.SchemeColor = SchemeColor;
278
+ class ModeColor extends SchemeColor {
279
+ light;
280
+ dark;
281
+ constructor(light, dark) {
282
+ super(light.primary, light.secondary, light.inverse);
283
+ this.light = light;
284
+ this.dark = dark;
285
+ }
286
+ asCss() {
287
+ return (`.elbe { ${this.light.asCss()}}` + `.elbe.dark { ${this.dark.asCss()}}`);
288
+ }
289
+ static generate(seed) {
290
+ return new ModeColor(SchemeColor.generate(seed, seed.base), SchemeColor.generate(seed, seed.mode.dark(seed, seed.base)));
291
+ }
292
+ }
293
+ exports.ModeColor = ModeColor;
294
+ class ColorTheme {
295
+ colors;
296
+ color;
297
+ constructor(colors, color) {
298
+ this.colors = colors;
299
+ this.color = color;
300
+ }
301
+ asCss() {
302
+ return (":root {" +
303
+ `--c-accent: ${this.colors.accent.back.asCss()};` +
304
+ `--c-info: ${this.colors.info.back.asCss()};` +
305
+ `--c-success: ${this.colors.success.back.asCss()};` +
306
+ `--c-warning: ${this.colors.warning.back.asCss()};` +
307
+ `--c-error: ${this.colors.error.back.asCss()};` +
308
+ "}\n" +
309
+ this.color.asCss());
310
+ }
311
+ static generate(seed) {
312
+ const s = (0, color_theme_1.colorThemePreset)(seed);
313
+ return new ColorTheme(s, ModeColor.generate(s));
314
+ }
315
+ }
316
+ exports.ColorTheme = ColorTheme;
317
+ //Bun.write("./example.css", ColorTheme.generate().asCss());
@@ -0,0 +1,16 @@
1
+ export interface GeometryThemeSeed {
2
+ size: number;
3
+ radius: number;
4
+ padding: number;
5
+ borderWidth: number;
6
+ }
7
+ export declare class GeometryTheme {
8
+ readonly size: number;
9
+ readonly radius: number;
10
+ readonly padding: number;
11
+ readonly borderWidth: number;
12
+ constructor(size: number, radius: number, padding: number, borderWidth: number);
13
+ asCss(): string;
14
+ static generate(seed?: Partial<GeometryTheme>): GeometryTheme;
15
+ }
16
+ export declare function geometryThemePreset(merge?: Partial<GeometryThemeSeed>): GeometryThemeSeed;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeometryTheme = void 0;
4
+ exports.geometryThemePreset = geometryThemePreset;
5
+ class GeometryTheme {
6
+ size;
7
+ radius;
8
+ padding;
9
+ borderWidth;
10
+ constructor(size, radius, padding, borderWidth) {
11
+ this.size = size;
12
+ this.radius = radius;
13
+ this.padding = padding;
14
+ this.borderWidth = borderWidth;
15
+ }
16
+ asCss() {
17
+ return (`:root{` +
18
+ `--g-size: ${this.size}px;` +
19
+ `--g-radius: ${this.radius}rem;` +
20
+ `--g-padding: ${this.padding}rem;` +
21
+ `--g-border-width: ${this.borderWidth}rem;` +
22
+ "}");
23
+ }
24
+ static generate(seed) {
25
+ const s = geometryThemePreset(seed);
26
+ return new GeometryTheme(s.size, s.radius, s.padding, s.borderWidth);
27
+ }
28
+ }
29
+ exports.GeometryTheme = GeometryTheme;
30
+ function geometryThemePreset(merge) {
31
+ const seed = merge ?? {};
32
+ return {
33
+ size: seed.size ?? 16,
34
+ radius: seed.radius ?? 0.75,
35
+ padding: seed.padding ?? 1,
36
+ borderWidth: seed.borderWidth ?? 0.125,
37
+ };
38
+ }
@@ -0,0 +1,28 @@
1
+ import { ColorTheme, type ColorThemeSeed } from "./colors";
2
+ import { GeometryTheme, type GeometryThemeSeed } from "./geometry_theme";
3
+ import { TypeTheme, type TypeThemeSeed } from "./type_theme";
4
+ export * from "./color_theme";
5
+ export * from "./colors";
6
+ export * from "./geometry_theme";
7
+ export * from "./type_theme";
8
+ export interface ElbeThemeSeed {
9
+ color?: Partial<ColorThemeSeed>;
10
+ type?: Partial<TypeThemeSeed>;
11
+ geometry?: Partial<GeometryThemeSeed>;
12
+ }
13
+ export declare class ElbeThemeData {
14
+ readonly color: ColorTheme;
15
+ readonly type: TypeTheme;
16
+ readonly geometry: GeometryTheme;
17
+ constructor(color: ColorTheme, type: TypeTheme, geometry: GeometryTheme);
18
+ asCss(): string;
19
+ static fromSeed(seed: ElbeThemeSeed): ElbeThemeData;
20
+ }
21
+ export declare function ElbeTheme(p: {
22
+ children: any;
23
+ dark?: boolean;
24
+ } & ({
25
+ seed: ElbeThemeSeed;
26
+ } | {
27
+ theme: ElbeThemeData;
28
+ })): import("preact").JSX.Element;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ElbeThemeData = void 0;
18
+ exports.ElbeTheme = ElbeTheme;
19
+ const jsx_runtime_1 = require("preact/jsx-runtime");
20
+ const colors_1 = require("./colors");
21
+ const geometry_theme_1 = require("./geometry_theme");
22
+ const type_theme_1 = require("./type_theme");
23
+ __exportStar(require("./color_theme"), exports);
24
+ __exportStar(require("./colors"), exports);
25
+ __exportStar(require("./geometry_theme"), exports);
26
+ __exportStar(require("./type_theme"), exports);
27
+ class ElbeThemeData {
28
+ color;
29
+ type;
30
+ geometry;
31
+ constructor(color, type, geometry) {
32
+ this.color = color;
33
+ this.type = type;
34
+ this.geometry = geometry;
35
+ }
36
+ asCss() {
37
+ return [this.color, this.type, this.geometry]
38
+ .map((s) => s.asCss())
39
+ .join("\n");
40
+ }
41
+ static fromSeed(seed) {
42
+ return new ElbeThemeData(colors_1.ColorTheme.generate(seed.color), type_theme_1.TypeTheme.generate(seed.type), geometry_theme_1.GeometryTheme.generate(seed.geometry));
43
+ }
44
+ }
45
+ exports.ElbeThemeData = ElbeThemeData;
46
+ function ElbeTheme(p) {
47
+ const theme = "seed" in p ? ElbeThemeData.fromSeed(p.seed) : p.theme;
48
+ return ((0, jsx_runtime_1.jsxs)("div", { class: `elbe ${p.dark ? "dark" : ""}`, children: [(0, jsx_runtime_1.jsx)("style", { children: theme.asCss() }), p.children] }));
49
+ }
@@ -0,0 +1,38 @@
1
+ interface TypeStyle {
2
+ bold?: boolean;
3
+ italic?: boolean;
4
+ underline?: boolean;
5
+ family: string[];
6
+ size: number;
7
+ }
8
+ export type ElbeTypeVariants = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "body-l" | "body-m" | "body-s" | "code";
9
+ export declare const tVariants: readonly ["h1", "h2", "h3", "h4", "h5", "h6", "body-l", "body-m", "body-s", "code"];
10
+ export type VariantSelector<T> = (style: TypeStyle, variant: T) => TypeStyle;
11
+ export interface TypeThemeSeed {
12
+ /**
13
+ * the base style for headings. Refers to h1
14
+ */
15
+ heading: TypeStyle;
16
+ body: TypeStyle;
17
+ code: TypeStyle;
18
+ headingVariants: VariantSelector<2 | 3 | 4 | 5 | 6>;
19
+ bodyVariants: VariantSelector<"s" | "l">;
20
+ }
21
+ export declare class TypeTheme {
22
+ h1: TypeStyle;
23
+ h2: TypeStyle;
24
+ h3: TypeStyle;
25
+ h4: TypeStyle;
26
+ h5: TypeStyle;
27
+ h6: TypeStyle;
28
+ bodyL: TypeStyle;
29
+ body: TypeStyle;
30
+ bodyS: TypeStyle;
31
+ code: TypeStyle;
32
+ constructor(h1: TypeStyle, h2: TypeStyle, h3: TypeStyle, h4: TypeStyle, h5: TypeStyle, h6: TypeStyle, bodyL: TypeStyle, body: TypeStyle, bodyS: TypeStyle, code: TypeStyle);
33
+ private get headers();
34
+ asCss(): string;
35
+ static generate(seed?: Partial<TypeThemeSeed>): TypeTheme;
36
+ }
37
+ export declare function typeThemePreset(merge?: Partial<TypeThemeSeed>): TypeThemeSeed;
38
+ export {};
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeTheme = exports.tVariants = void 0;
4
+ exports.typeThemePreset = typeThemePreset;
5
+ exports.tVariants = [
6
+ "h1",
7
+ "h2",
8
+ "h3",
9
+ "h4",
10
+ "h5",
11
+ "h6",
12
+ "body-l",
13
+ "body-m",
14
+ "body-s",
15
+ "code",
16
+ ];
17
+ function _typeStyleAsCss(t) {
18
+ return (`font-family: ${t.family};\n` +
19
+ `font-size: ${t.size}rem;\n` +
20
+ `font-weight: ${t.bold ? "bold" : "normal"};\n` +
21
+ `font-style: ${t.italic ? "italic" : "normal"};\n` +
22
+ `text-decoration: ${t.underline ? "underline" : "none"};\n`);
23
+ }
24
+ class TypeTheme {
25
+ h1;
26
+ h2;
27
+ h3;
28
+ h4;
29
+ h5;
30
+ h6;
31
+ bodyL;
32
+ body;
33
+ bodyS;
34
+ code;
35
+ constructor(h1, h2, h3, h4, h5, h6, bodyL, body, bodyS, code) {
36
+ this.h1 = h1;
37
+ this.h2 = h2;
38
+ this.h3 = h3;
39
+ this.h4 = h4;
40
+ this.h5 = h5;
41
+ this.h6 = h6;
42
+ this.bodyL = bodyL;
43
+ this.body = body;
44
+ this.bodyS = bodyS;
45
+ this.code = code;
46
+ }
47
+ get headers() {
48
+ return [this.h1, this.h2, this.h3, this.h4, this.h5, this.h6];
49
+ }
50
+ asCss() {
51
+ return (this.headers
52
+ .map((v, i) => `h${i + 1}, .h${i + 1} {${_typeStyleAsCss(v)}}`)
53
+ .join("\n") +
54
+ `body, .body, .body-m {${_typeStyleAsCss(this.body)}}\n` +
55
+ `large, .body-l {${_typeStyleAsCss(this.bodyL)}}\n` +
56
+ `small, .body-s {${_typeStyleAsCss(this.bodyS)}}\n` +
57
+ `.code {${_typeStyleAsCss(this.code)}}\n`);
58
+ }
59
+ static generate(seed) {
60
+ const s = typeThemePreset(seed);
61
+ return new TypeTheme(s.heading, s.headingVariants(s.heading, 2), s.headingVariants(s.heading, 3), s.headingVariants(s.heading, 4), s.headingVariants(s.heading, 5), s.headingVariants(s.heading, 6), s.bodyVariants(s.body, "l"), s.body, s.bodyVariants(s.body, "s"), s.code);
62
+ }
63
+ }
64
+ exports.TypeTheme = TypeTheme;
65
+ function typeThemePreset(merge) {
66
+ return {
67
+ heading: {
68
+ bold: true,
69
+ family: ["Calistoga", "Arial", "sans-serif"],
70
+ size: 2.2,
71
+ },
72
+ body: {
73
+ bold: false,
74
+ family: ["Helvetica", "Arial", "sans-serif"],
75
+ size: 1,
76
+ },
77
+ code: {
78
+ bold: false,
79
+ family: ["Courier", "monospace"],
80
+ size: 1,
81
+ },
82
+ headingVariants: (style, variant) => {
83
+ const size = style.size * (1 - (variant - 1) * 0.1);
84
+ return {
85
+ ...style,
86
+ size,
87
+ };
88
+ },
89
+ bodyVariants: (style, variant) => {
90
+ const size = style.size * (variant === "s" ? 0.8 : 1.2);
91
+ return {
92
+ ...style,
93
+ size,
94
+ };
95
+ },
96
+ ...merge,
97
+ };
98
+ }
@@ -0,0 +1,10 @@
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 declare function showConfirmDialog({ title, message, okay, }: {
7
+ message: string;
8
+ title: string;
9
+ okay?: boolean;
10
+ }): Promise<boolean>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.showConfirmDialog = showConfirmDialog;
4
+ /**
5
+ * show a simple confirm dialog
6
+ * @param param0 the title and message of the dialog
7
+ * @returns a promise that resolves to true if the user clicks "yes" or "okay" and false if the user clicks "no"
8
+ */
9
+ function showConfirmDialog({ title, message, okay = false, }) {
10
+ return new Promise((resolve, reject) => {
11
+ const dialog = document.createElement("div");
12
+ dialog.classList.add("dialog");
13
+ dialog.innerHTML = `<dialog open>
14
+ <div
15
+ class="elbe card primary"
16
+ style="max-width: 30rem; min-width: 10rem"
17
+ >
18
+ <div class="row cross-center">
19
+ <div class="flex-1 body-l b">
20
+ ${title}
21
+ </div>
22
+ <button class="plain round" style="width: 3rem" onclick="conf_resolve(false)">
23
+ <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>
24
+ </button>
25
+ </div>
26
+ <div style="margin-top: 1rem; margin-bottom: 1rem">
27
+ ${message}
28
+ </div>
29
+ <div class="row main-end gap">
30
+
31
+ ${okay
32
+ ? '<button class="accent" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(true)">okay</button>'
33
+ : '<button class="minor" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(false)">no</button>' +
34
+ '<button class="accent" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(true)">yes</button>'}
35
+ </div>
36
+
37
+ </div>
38
+ </dialog>
39
+ `;
40
+ document.body.appendChild(dialog);
41
+ window["conf_resolve"] = (v) => {
42
+ document.body.removeChild(dialog);
43
+ resolve(v);
44
+ };
45
+ });
46
+ }
@@ -0,0 +1 @@
1
+ export declare function _ElbeErr(msg: string): import("preact").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._ElbeErr = _ElbeErr;
4
+ const jsx_runtime_1 = require("preact/jsx-runtime");
5
+ const __1 = require("../..");
6
+ function _ElbeErr(msg) {
7
+ return ((0, jsx_runtime_1.jsxs)("div", { class: "row text-s gap-half", style: "background: #ee0044; color: white; border-radius: 4px; text-align: left; padding: .5rem", children: [(0, jsx_runtime_1.jsx)(__1.Icons.CircleX, {}), (0, jsx_runtime_1.jsxs)("div", { class: "column gap-none cross-stretch", children: [(0, jsx_runtime_1.jsx)("b", { class: "text-s", children: "elbe error" }), (0, jsx_runtime_1.jsx)("span", { style: "margin-top: -.125rem", children: msg })] })] }));
8
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * show a toast message at the bottom of the screen
3
+ * @param message the message to show
4
+ */
5
+ export declare function showToast(message: string): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * show a toast message at the bottom of the screen
4
+ * @param message the message to show
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.showToast = showToast;
8
+ function showToast(message) {
9
+ const toast = document.createElement("div");
10
+ toast.classList.add("toast");
11
+ toast.classList.add("inverse");
12
+ toast.innerText = message;
13
+ document.body.appendChild(toast);
14
+ setTimeout(() => {
15
+ toast.remove();
16
+ }, 3000);
17
+ }