elbe-ui 0.2.37 → 0.2.44

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 (41) hide show
  1. package/README.md +6 -0
  2. package/dist/bit/bit.d.ts +4 -1
  3. package/dist/bit/bit.js +24 -28
  4. package/dist/bit/ctrl_bit.js +47 -28
  5. package/dist/elbe.css +71 -30
  6. package/dist/elbe.css.map +1 -1
  7. package/dist/index.js +33 -62
  8. package/dist/service/s_api.js +62 -49
  9. package/dist/ui/components/badge.js +13 -34
  10. package/dist/ui/components/base/box.js +21 -23
  11. package/dist/ui/components/base/card.js +19 -10
  12. package/dist/ui/components/base/padded.js +25 -16
  13. package/dist/ui/components/button/button.js +30 -22
  14. package/dist/ui/components/button/choose_button.js +7 -10
  15. package/dist/ui/components/button/icon_button.js +36 -26
  16. package/dist/ui/components/button/toggle_button.js +19 -10
  17. package/dist/ui/components/dialog.js +7 -10
  18. package/dist/ui/components/error_view.js +14 -16
  19. package/dist/ui/components/input/checkbox.js +17 -8
  20. package/dist/ui/components/input/input_field.js +28 -23
  21. package/dist/ui/components/input/range.js +26 -9
  22. package/dist/ui/components/input/select.js +16 -7
  23. package/dist/ui/components/input/text_area.js +17 -8
  24. package/dist/ui/components/layout/flex.js +24 -16
  25. package/dist/ui/components/layout/scaffold.d.ts +4 -3
  26. package/dist/ui/components/layout/scaffold.js +28 -18
  27. package/dist/ui/components/layout/scroll.js +10 -14
  28. package/dist/ui/components/layout/spaced.js +3 -6
  29. package/dist/ui/components/spinner.js +16 -19
  30. package/dist/ui/components/text.js +42 -37
  31. package/dist/ui/theme/color_theme.js +36 -42
  32. package/dist/ui/theme/colors.d.ts +2 -3
  33. package/dist/ui/theme/colors.js +42 -78
  34. package/dist/ui/theme/geometry_theme.js +8 -16
  35. package/dist/ui/theme/theme.js +12 -34
  36. package/dist/ui/theme/type_theme.js +11 -39
  37. package/dist/ui/util/confirm_dialog.js +1 -4
  38. package/dist/ui/util/error_view.js +4 -7
  39. package/dist/ui/util/toast.js +1 -4
  40. package/dist/ui/util/util.js +8 -13
  41. package/package.json +3 -2
@@ -1,31 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.colorThemePreset = colorThemePreset;
4
- const colors_1 = require("./colors");
5
- function colorThemePreset(merge) {
1
+ import { colors, LayerColor, } from "./colors";
2
+ export function colorThemePreset(merge) {
3
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
6
4
  const styleSel = (_, b, s) => {
7
5
  const bL = b.luminance;
8
6
  if (bL === 1)
9
7
  return s;
10
- return s.inter(colors_1.LayerColor.fromBack(bL > 0.5 ? colors_1.colors.black : colors_1.colors.white), 0.1);
8
+ return s.inter(LayerColor.fromBack(bL > 0.5 ? colors.black : colors.white), 0.1);
11
9
  };
12
- const seed = merge ?? {};
10
+ const seed = merge !== null && merge !== void 0 ? merge : {};
13
11
  return {
14
- base: seed.base ?? colors_1.LayerColor.fromBack(colors_1.colors.white),
15
- accent: seed.accent ?? colors_1.LayerColor.fromBack(colors_1.colors.blueAccent),
16
- info: seed.info ?? colors_1.LayerColor.fromBack(colors_1.colors.blue),
17
- success: seed.success ?? colors_1.LayerColor.fromBack(colors_1.colors.green),
18
- warning: seed.warning ?? colors_1.LayerColor.fromBack(colors_1.colors.yellow),
19
- error: seed.error ?? colors_1.LayerColor.fromBack(colors_1.colors.red),
12
+ base: (_a = seed.base) !== null && _a !== void 0 ? _a : LayerColor.fromBack(colors.white),
13
+ accent: (_b = seed.accent) !== null && _b !== void 0 ? _b : LayerColor.fromBack(colors.blueAccent),
14
+ info: (_c = seed.info) !== null && _c !== void 0 ? _c : LayerColor.fromBack(colors.blue),
15
+ success: (_d = seed.success) !== null && _d !== void 0 ? _d : LayerColor.fromBack(colors.green),
16
+ warning: (_e = seed.warning) !== null && _e !== void 0 ? _e : LayerColor.fromBack(colors.yellow),
17
+ error: (_f = seed.error) !== null && _f !== void 0 ? _f : LayerColor.fromBack(colors.red),
20
18
  mode: {
21
- light: seed.mode?.light ?? ((_, b) => b),
22
- dark: seed.mode?.dark ?? ((_, b) => b.mirrorBrightness()),
19
+ light: (_h = (_g = seed.mode) === null || _g === void 0 ? void 0 : _g.light) !== null && _h !== void 0 ? _h : ((_, b) => b),
20
+ dark: (_k = (_j = seed.mode) === null || _j === void 0 ? void 0 : _j.dark) !== null && _k !== void 0 ? _k : ((_, b) => b.mirrorBrightness()),
23
21
  },
24
22
  scheme: {
25
- primary: seed.scheme?.primary ?? ((_, b) => b),
26
- secondary: seed.scheme?.secondary ??
27
- ((c, b) => new colors_1.LayerColor(b.back.inter(c.accent.back, 0.1).desaturated(0.5), b.front, b.border)),
28
- inverse: seed.scheme?.inverse ?? ((_, b) => b.mirrorBrightness()),
23
+ primary: (_m = (_l = seed.scheme) === null || _l === void 0 ? void 0 : _l.primary) !== null && _m !== void 0 ? _m : ((_, b) => b),
24
+ secondary: (_p = (_o = seed.scheme) === null || _o === void 0 ? void 0 : _o.secondary) !== null && _p !== void 0 ? _p : ((c, b) => new LayerColor(b.back.inter(c.accent.back, 0.1).desaturated(0.5), b.front, b.border)),
25
+ inverse: (_r = (_q = seed.scheme) === null || _q === void 0 ? void 0 : _q.inverse) !== null && _r !== void 0 ? _r : ((_, b) => b.mirrorBrightness()),
29
26
  },
30
27
  style: {
31
28
  accent: styleSel,
@@ -35,29 +32,26 @@ function colorThemePreset(merge) {
35
32
  error: styleSel,
36
33
  },
37
34
  variant: {
38
- major: seed.variant?.major ??
39
- ((_, b, s) => colors_1.LayerColor.fromBack(s.back, { border: s.back })),
40
- minor: seed.variant?.minor ??
41
- ((_, b, s) => {
42
- const back = b.back;
43
- const backIn = back.mirrorBrightness();
44
- const major = s.back;
45
- const minor = s.back.inter(back, 0.8);
46
- const minorFront = minor.hasWCAGContrast(major) ? major : null;
47
- return new colors_1.LayerColor(s.back.withAlpha(0.25), minorFront ?? major.inter(backIn, 0.6), minorFront ?? major.inter(backIn, 0.3));
48
- }),
49
- flat: seed.variant?.flat ??
50
- ((_, b, s) => {
51
- //return new LayerColor(b.back, s?.back ?? b.front, b.front);
52
- //calculate front brightness
53
- const front = !s
54
- ? b.front
55
- : b.back.hasWCAGContrast(s?.back)
56
- ? s?.back
57
- : s?.back.inter(b.front, 0.6);
58
- return new colors_1.LayerColor(b.back, //.withAlpha(0),
59
- front, null, !s ? b.front.withAlpha(0.3) : b.front);
60
- }),
35
+ major: (_t = (_s = seed.variant) === null || _s === void 0 ? void 0 : _s.major) !== null && _t !== void 0 ? _t : ((_, __, s) => LayerColor.fromBack(s.back, { border: s.back })),
36
+ minor: (_v = (_u = seed.variant) === null || _u === void 0 ? void 0 : _u.minor) !== null && _v !== void 0 ? _v : ((_, b, s) => {
37
+ const back = b.back;
38
+ const backIn = back.mirrorBrightness();
39
+ const major = s.back;
40
+ const minor = s.back.inter(back, 0.8);
41
+ const minorFront = minor.hasWCAGContrast(major) ? major : null;
42
+ return new LayerColor(s.back.withAlpha(0.25), minorFront !== null && minorFront !== void 0 ? minorFront : major.inter(backIn, 0.6), minorFront !== null && minorFront !== void 0 ? minorFront : major.inter(backIn, 0.3));
43
+ }),
44
+ flat: (_x = (_w = seed.variant) === null || _w === void 0 ? void 0 : _w.flat) !== null && _x !== void 0 ? _x : ((_, b, s) => {
45
+ //return new LayerColor(b.back, s?.back ?? b.front, b.front);
46
+ //calculate front brightness
47
+ const front = !s
48
+ ? b.front
49
+ : b.back.hasWCAGContrast(s === null || s === void 0 ? void 0 : s.back)
50
+ ? s === null || s === void 0 ? void 0 : s.back
51
+ : s === null || s === void 0 ? void 0 : s.back.inter(b.front, 0.6);
52
+ return new LayerColor(b.back, //.withAlpha(0),
53
+ front, null, !s ? b.front.withAlpha(0.3) : b.front);
54
+ }),
61
55
  },
62
56
  };
63
57
  }
@@ -42,7 +42,7 @@ export type ColorThemeSeed = ColorSeedColors & {
42
42
  flat: SeedFlatSelector;
43
43
  };
44
44
  };
45
- declare class RGBAColor {
45
+ export declare class RGBAColor {
46
46
  r: number;
47
47
  g: number;
48
48
  b: number;
@@ -52,7 +52,7 @@ declare class RGBAColor {
52
52
  get isDark(): boolean;
53
53
  get luminance(): number;
54
54
  get hex(): string;
55
- static _fromHex(hex: string | null): RGBAColor;
55
+ static fromHex(hex: string | null): RGBAColor;
56
56
  desaturated(f?: number): RGBAColor;
57
57
  withAlpha(a: number): RGBAColor;
58
58
  inter(other: RGBAColor, factor: number): RGBAColor;
@@ -139,4 +139,3 @@ export declare class ColorTheme {
139
139
  asCss(): string;
140
140
  static generate(seed?: Partial<ColorThemeSeed>): ColorTheme;
141
141
  }
142
- export {};
@@ -1,12 +1,9 @@
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 = [
1
+ import { hslToRgb, rgbToHsl } from "colors-convert";
2
+ import { clamp } from "../util/util";
3
+ import { colorThemePreset } from "./color_theme";
4
+ export const cModes = ["light", "dark"];
5
+ export const cSchemes = ["primary", "secondary", "inverse"];
6
+ export const cKinds = [
10
7
  "plain",
11
8
  "accent",
12
9
  "info",
@@ -14,14 +11,10 @@ exports.cKinds = [
14
11
  "warning",
15
12
  "error",
16
13
  ];
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;
14
+ export const cManners = ["major", "minor", "flat", "plain"];
15
+ export const cStates = ["neutral", "hover", "active", "disabled"];
16
+ export const cLayers = ["back", "front", "border"];
17
+ export class RGBAColor {
25
18
  constructor(r, g, b, a) {
26
19
  this.r = r;
27
20
  this.g = g;
@@ -48,7 +41,7 @@ class RGBAColor {
48
41
  .padStart(2, "0");
49
42
  return `#${c.join("")}${a}`;
50
43
  }
51
- static _fromHex(hex) {
44
+ static fromHex(hex) {
52
45
  if (!hex)
53
46
  return new RGBAColor(0, 0, 0, 0);
54
47
  const c = hex.replace("#", "").padEnd(6, "0").padEnd(8, "f").toLowerCase();
@@ -66,14 +59,9 @@ class RGBAColor {
66
59
  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
60
  }
68
61
  mirrorBrightness(factor = 1) {
69
- const hsl = (0, colors_convert_1.rgbToHsl)({ r: this.r, g: this.g, b: this.b });
62
+ const hsl = rgbToHsl({ r: this.r, g: this.g, b: this.b });
70
63
  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
- });
64
+ const rgb = hslToRgb(Object.assign(Object.assign({}, hsl), { l: clamp(newL, 0, 100), s: clamp(hsl.s, 0, 100) }));
77
65
  return new RGBAColor(rgb.r, rgb.g, rgb.b, this.a);
78
66
  }
79
67
  get values() {
@@ -88,7 +76,7 @@ class RGBAColor {
88
76
  return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
89
77
  }
90
78
  }
91
- exports.colors = {
79
+ export const colors = {
92
80
  transparent: new RGBAColor(0, 0, 0, 0),
93
81
  white: new RGBAColor(255, 255, 255, 1),
94
82
  black: new RGBAColor(0, 0, 0, 1),
@@ -98,56 +86,53 @@ exports.colors = {
98
86
  yellow: new RGBAColor(240, 221, 21, 1),
99
87
  red: new RGBAColor(243, 67, 67, 1),
100
88
  };
101
- class LayerColor extends RGBAColor {
102
- back;
103
- border;
104
- borderContext;
105
- front;
89
+ export class LayerColor extends RGBAColor {
106
90
  constructor(back, front, border, borderContext) {
107
91
  super(back.r, back.g, back.b, back.a);
108
92
  this.back = back;
109
93
  this.border = border;
110
94
  this.borderContext = borderContext;
111
- this.front = front ?? (back.isDark ? exports.colors.white : exports.colors.black);
95
+ this.front = front !== null && front !== void 0 ? front : (back.isDark ? colors.white : colors.black);
112
96
  }
113
97
  asCss() {
98
+ var _a, _b;
114
99
  return (`background-color: ${this.back.asCss()};\n` +
115
100
  `color: ${this.front.asCss()};\n` +
116
- `border-color: ${this.border?.asCss() ?? "transparent"};\n` +
101
+ `border-color: ${(_b = (_a = this.border) === null || _a === void 0 ? void 0 : _a.asCss()) !== null && _b !== void 0 ? _b : "transparent"};\n` +
117
102
  //`border-color: ${this.border?.asCss() ?? "transparent"};\n` +
118
103
  this.contextCss());
119
104
  }
120
105
  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));
106
+ var _a, _b, _c, _d;
107
+ return new LayerColor(this.back.inter(other.back, factor), this.front.inter(other.front, factor), (_a = this.border) === null || _a === void 0 ? void 0 : _a.inter((_b = other.border) !== null && _b !== void 0 ? _b : colors.transparent, factor), (_c = this.borderContext) === null || _c === void 0 ? void 0 : _c.inter((_d = other.borderContext) !== null && _d !== void 0 ? _d : colors.transparent, factor));
122
108
  }
123
109
  mirrorBrightness(factor) {
124
- return new LayerColor(this.back.mirrorBrightness(factor), this.front.mirrorBrightness(factor), this.border?.mirrorBrightness(factor), this.borderContext?.mirrorBrightness(factor));
110
+ var _a, _b;
111
+ return new LayerColor(this.back.mirrorBrightness(factor), this.front.mirrorBrightness(factor), (_a = this.border) === null || _a === void 0 ? void 0 : _a.mirrorBrightness(factor), (_b = this.borderContext) === null || _b === void 0 ? void 0 : _b.mirrorBrightness(factor));
125
112
  }
126
113
  desaturated() {
127
- return new LayerColor(this.back.desaturated(), this.front.desaturated(), this.border?.desaturated(), this.borderContext?.desaturated());
114
+ var _a, _b;
115
+ return new LayerColor(this.back.desaturated(), this.front.desaturated(), (_a = this.border) === null || _a === void 0 ? void 0 : _a.desaturated(), (_b = this.borderContext) === null || _b === void 0 ? void 0 : _b.desaturated());
128
116
  }
129
117
  static fromHex(back, front, border) {
130
118
  if (front === undefined && border === undefined) {
131
- return LayerColor.fromBack(RGBAColor._fromHex(back));
119
+ return LayerColor.fromBack(RGBAColor.fromHex(back));
132
120
  }
133
- return new LayerColor(RGBAColor._fromHex(back), RGBAColor._fromHex(front ?? null), RGBAColor._fromHex(border ?? null));
121
+ return new LayerColor(RGBAColor.fromHex(back), RGBAColor.fromHex(front !== null && front !== void 0 ? front : null), RGBAColor.fromHex(border !== null && border !== void 0 ? border : null));
134
122
  }
135
123
  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);
124
+ var _a, _b;
125
+ const front = back.isDark ? colors.white : colors.black;
126
+ return new LayerColor(back, (_a = c === null || c === void 0 ? void 0 : c.front) !== null && _a !== void 0 ? _a : front, (_b = c === null || c === void 0 ? void 0 : c.border) !== null && _b !== void 0 ? _b : front);
138
127
  }
139
128
  contextCss() {
129
+ var _a, _b, _c;
140
130
  return (`--c-context-back: ${this.back.asCss()};\n` +
141
131
  `--c-context-front: ${this.front.asCss()};` +
142
- `--c-context-border: ${(this.borderContext ?? this.border)?.asCss() ?? "transparent"};`);
132
+ `--c-context-border: ${(_c = (_b = ((_a = this.borderContext) !== null && _a !== void 0 ? _a : this.border)) === null || _b === void 0 ? void 0 : _b.asCss()) !== null && _c !== void 0 ? _c : "transparent"};`);
143
133
  }
144
134
  }
145
- exports.LayerColor = LayerColor;
146
- class StateColor extends LayerColor {
147
- neutral;
148
- hover;
149
- active;
150
- disabled;
135
+ export class StateColor extends LayerColor {
151
136
  constructor(neutral, hover, active, disabled) {
152
137
  super(neutral.back, neutral.front, neutral.border);
153
138
  this.neutral = neutral;
@@ -181,21 +166,18 @@ class StateColor extends LayerColor {
181
166
  return new StateColor(style, _make(0.075), _make(0.25), style.desaturated());
182
167
  }
183
168
  }
184
- exports.StateColor = StateColor;
185
- class MannerColor extends StateColor {
186
- major;
187
- minor;
188
- flat;
169
+ export class MannerColor extends StateColor {
189
170
  constructor(major, minor, flat) {
190
- const m = major ?? flat;
171
+ const m = major !== null && major !== void 0 ? major : flat;
191
172
  super(m.neutral, m.hover, m.active, m.disabled);
192
173
  this.major = major;
193
174
  this.minor = minor;
194
175
  this.flat = flat;
195
176
  }
196
177
  asCss(fallback) {
197
- const maj = this.major ?? fallback?.major;
198
- const min = this.minor ?? fallback?.minor;
178
+ var _a, _b;
179
+ const maj = (_a = this.major) !== null && _a !== void 0 ? _a : fallback === null || fallback === void 0 ? void 0 : fallback.major;
180
+ const min = (_b = this.minor) !== null && _b !== void 0 ? _b : fallback === null || fallback === void 0 ? void 0 : fallback.minor;
199
181
  return (`${this.flat.asCss()}\n` +
200
182
  (maj ? `&.major { ${maj.asCss()} } \n` : "") +
201
183
  (min ? `&.minor { ${min.asCss()} } \n` : "") +
@@ -221,14 +203,7 @@ class MannerColor extends StateColor {
221
203
  */
222
204
  }
223
205
  }
224
- exports.MannerColor = MannerColor;
225
- class KindColor extends MannerColor {
226
- plain;
227
- accent;
228
- info;
229
- success;
230
- warning;
231
- error;
206
+ export class KindColor extends MannerColor {
232
207
  constructor(plain, accent, info, success, warning, error) {
233
208
  super(plain.major, plain.minor, plain.flat);
234
209
  this.plain = plain;
@@ -252,11 +227,7 @@ class KindColor extends MannerColor {
252
227
  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
228
  }
254
229
  }
255
- exports.KindColor = KindColor;
256
- class SchemeColor extends KindColor {
257
- primary;
258
- secondary;
259
- inverse;
230
+ export class SchemeColor extends KindColor {
260
231
  constructor(primary, secondary, inverse) {
261
232
  super(primary.plain, primary.accent, primary.info, primary.success, primary.warning, primary.error);
262
233
  this.primary = primary;
@@ -274,10 +245,7 @@ class SchemeColor extends KindColor {
274
245
  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
246
  }
276
247
  }
277
- exports.SchemeColor = SchemeColor;
278
- class ModeColor extends SchemeColor {
279
- light;
280
- dark;
248
+ export class ModeColor extends SchemeColor {
281
249
  constructor(light, dark) {
282
250
  super(light.primary, light.secondary, light.inverse);
283
251
  this.light = light;
@@ -290,10 +258,7 @@ class ModeColor extends SchemeColor {
290
258
  return new ModeColor(SchemeColor.generate(seed, seed.base), SchemeColor.generate(seed, seed.mode.dark(seed, seed.base)));
291
259
  }
292
260
  }
293
- exports.ModeColor = ModeColor;
294
- class ColorTheme {
295
- colors;
296
- color;
261
+ export class ColorTheme {
297
262
  constructor(colors, color) {
298
263
  this.colors = colors;
299
264
  this.color = color;
@@ -309,9 +274,8 @@ class ColorTheme {
309
274
  this.color.asCss());
310
275
  }
311
276
  static generate(seed) {
312
- const s = (0, color_theme_1.colorThemePreset)(seed);
277
+ const s = colorThemePreset(seed);
313
278
  return new ColorTheme(s, ModeColor.generate(s));
314
279
  }
315
280
  }
316
- exports.ColorTheme = ColorTheme;
317
281
  //Bun.write("./example.css", ColorTheme.generate().asCss());
@@ -1,12 +1,4 @@
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;
1
+ export class GeometryTheme {
10
2
  constructor(size, radius, padding, borderWidth) {
11
3
  this.size = size;
12
4
  this.radius = radius;
@@ -26,13 +18,13 @@ class GeometryTheme {
26
18
  return new GeometryTheme(s.size, s.radius, s.padding, s.borderWidth);
27
19
  }
28
20
  }
29
- exports.GeometryTheme = GeometryTheme;
30
- function geometryThemePreset(merge) {
31
- const seed = merge ?? {};
21
+ export function geometryThemePreset(merge) {
22
+ var _a, _b, _c, _d;
23
+ const seed = merge !== null && merge !== void 0 ? merge : {};
32
24
  return {
33
- size: seed.size ?? 16,
34
- radius: seed.radius ?? 0.75,
35
- padding: seed.padding ?? 1,
36
- borderWidth: seed.borderWidth ?? 0.125,
25
+ size: (_a = seed.size) !== null && _a !== void 0 ? _a : 16,
26
+ radius: (_b = seed.radius) !== null && _b !== void 0 ? _b : 0.75,
27
+ padding: (_c = seed.padding) !== null && _c !== void 0 ? _c : 1,
28
+ borderWidth: (_d = seed.borderWidth) !== null && _d !== void 0 ? _d : 0.125,
37
29
  };
38
30
  }
@@ -1,33 +1,12 @@
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;
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { ColorTheme } from "./colors";
3
+ import { GeometryTheme } from "./geometry_theme";
4
+ import { TypeTheme } from "./type_theme";
5
+ export * from "./color_theme";
6
+ export * from "./colors";
7
+ export * from "./geometry_theme";
8
+ export * from "./type_theme";
9
+ export class ElbeThemeData {
31
10
  constructor(color, type, geometry) {
32
11
  this.color = color;
33
12
  this.type = type;
@@ -39,11 +18,10 @@ class ElbeThemeData {
39
18
  .join("\n");
40
19
  }
41
20
  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));
21
+ return new ElbeThemeData(ColorTheme.generate(seed.color), TypeTheme.generate(seed.type), GeometryTheme.generate(seed.geometry));
43
22
  }
44
23
  }
45
- exports.ElbeThemeData = ElbeThemeData;
46
- function ElbeTheme(p) {
24
+ export function ElbeTheme(p) {
47
25
  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] }));
26
+ return (_jsxs("div", { class: `elbe ${p.dark ? "dark" : ""}`, children: [_jsx("style", { children: theme.asCss() }), p.children] }));
49
27
  }
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeTheme = exports.tVariants = void 0;
4
- exports.typeThemePreset = typeThemePreset;
5
- exports.tVariants = [
1
+ export const tVariants = [
6
2
  "h1",
7
3
  "h2",
8
4
  "h3",
@@ -21,17 +17,7 @@ function _typeStyleAsCss(t) {
21
17
  `font-style: ${t.italic ? "italic" : "normal"};\n` +
22
18
  `text-decoration: ${t.underline ? "underline" : "none"};\n`);
23
19
  }
24
- class TypeTheme {
25
- h1;
26
- h2;
27
- h3;
28
- h4;
29
- h5;
30
- h6;
31
- bodyL;
32
- body;
33
- bodyS;
34
- code;
20
+ export class TypeTheme {
35
21
  constructor(h1, h2, h3, h4, h5, h6, bodyL, body, bodyS, code) {
36
22
  this.h1 = h1;
37
23
  this.h2 = h2;
@@ -61,38 +47,24 @@ class TypeTheme {
61
47
  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
48
  }
63
49
  }
64
- exports.TypeTheme = TypeTheme;
65
- function typeThemePreset(merge) {
66
- return {
67
- heading: {
50
+ export function typeThemePreset(merge) {
51
+ return Object.assign({ heading: {
68
52
  bold: true,
69
53
  family: ["Calistoga", "Arial", "sans-serif"],
70
54
  size: 2.2,
71
- },
72
- body: {
55
+ }, body: {
73
56
  bold: false,
74
57
  family: ["Helvetica", "Arial", "sans-serif"],
75
58
  size: 1,
76
- },
77
- code: {
59
+ }, code: {
78
60
  bold: false,
79
61
  family: ["Courier", "monospace"],
80
62
  size: 1,
81
- },
82
- headingVariants: (style, variant) => {
63
+ }, headingVariants: (style, variant) => {
83
64
  const size = style.size * (1 - (variant - 1) * 0.1);
84
- return {
85
- ...style,
86
- size,
87
- };
88
- },
89
- bodyVariants: (style, variant) => {
65
+ return Object.assign(Object.assign({}, style), { size });
66
+ }, bodyVariants: (style, variant) => {
90
67
  const size = style.size * (variant === "s" ? 0.8 : 1.2);
91
- return {
92
- ...style,
93
- size,
94
- };
95
- },
96
- ...merge,
97
- };
68
+ return Object.assign(Object.assign({}, style), { size });
69
+ } }, merge);
98
70
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.showConfirmDialog = showConfirmDialog;
4
1
  /**
5
2
  * show a simple confirm dialog
6
3
  * @param param0 the title and message of the dialog
7
4
  * @returns a promise that resolves to true if the user clicks "yes" or "okay" and false if the user clicks "no"
8
5
  */
9
- function showConfirmDialog({ title, message, okay = false, }) {
6
+ export function showConfirmDialog({ title, message, okay = false, }) {
10
7
  return new Promise((resolve, reject) => {
11
8
  const dialog = document.createElement("div");
12
9
  dialog.classList.add("dialog");
@@ -1,8 +1,5 @@
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 })] })] }));
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ import { Icons } from "../..";
3
+ export function _ElbeErr(msg) {
4
+ return (_jsxs("div", { class: "row text-s gap-half", style: "background: #ee0044; color: white; border-radius: 4px; text-align: left; padding: .5rem", children: [_jsx(Icons.CircleX, {}), _jsxs("div", { class: "column gap-none cross-stretch", children: [_jsx("b", { class: "text-s", children: "elbe error" }), _jsx("span", { style: "margin-top: -.125rem", children: msg })] })] }));
8
5
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * show a toast message at the bottom of the screen
4
3
  * @param message the message to show
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.showToast = showToast;
8
- function showToast(message) {
5
+ export function showToast(message) {
9
6
  const toast = document.createElement("div");
10
7
  toast.classList.add("toast");
11
8
  toast.classList.add("inverse");
@@ -1,11 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clamp = clamp;
4
- exports.share = share;
5
- exports.copyToClipboard = copyToClipboard;
6
- exports.scrollToId = scrollToId;
7
- const toast_1 = require("./toast");
8
- function clamp(value, min, max) {
1
+ import { showToast } from "./toast";
2
+ export function clamp(value, min, max) {
9
3
  return Math.min(Math.max(value, min), max);
10
4
  }
11
5
  /**
@@ -13,8 +7,9 @@ function clamp(value, min, max) {
13
7
  * @param data the data you want to share
14
8
  * @param toastMsg the message to show in the toast if the share api is not available
15
9
  */
16
- function share(data, toastMsg = "copied to clipboard. Share it with others.") {
17
- const msg = `${data.title}\n${data.text ?? ""}\n\n${data.url}`;
10
+ export function share(data, toastMsg = "copied to clipboard. Share it with others.") {
11
+ var _a;
12
+ const msg = `${data.title}\n${(_a = data.text) !== null && _a !== void 0 ? _a : ""}\n\n${data.url}`;
18
13
  if (navigator.share) {
19
14
  navigator.share(data).catch(() => copyToClipboard(msg, toastMsg));
20
15
  }
@@ -27,12 +22,12 @@ function share(data, toastMsg = "copied to clipboard. Share it with others.") {
27
22
  * @param text the text to copy to the clipboard
28
23
  * @param toastMsg the message to show in the toast
29
24
  */
30
- function copyToClipboard(text, toastMsg = "copied to clipboard") {
25
+ export function copyToClipboard(text, toastMsg = "copied to clipboard") {
31
26
  navigator.clipboard.writeText(text);
32
27
  if (toastMsg)
33
- (0, toast_1.showToast)(toastMsg);
28
+ showToast(toastMsg);
34
29
  }
35
- function scrollToId(id) {
30
+ export function scrollToId(id) {
36
31
  const el = document.getElementById(id);
37
32
  if (el)
38
33
  el.scrollIntoView({ behavior: "smooth" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elbe-ui",
3
- "version": "0.2.37",
3
+ "version": "0.2.44",
4
4
  "author": "Robin Naumann",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,7 +21,8 @@
21
21
  "build:ts": "tsc",
22
22
  "build:dts": "tsc --declaration",
23
23
  "build:css": "sass -q style/elbe.scss dist/elbe.css",
24
- "build": "rm -rf ./dist && bun run build:ts && bun run build:dts && bun run build:css"
24
+ "build": "rm -rf ./dist && bun run build:ts && bun run build:dts && bun run build:css",
25
+ "pub": "bun run build && npm publish"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@types/bun": "latest",