elbe-ui 1.0.8 → 2.0.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 (149) hide show
  1. package/dist/bit/_bit_provider.d.ts +1 -1
  2. package/dist/bit/_bit_provider.js +4 -4
  3. package/dist/bit/bit.d.ts +1 -1
  4. package/dist/bit/bit.js +1 -0
  5. package/dist/elbe.css +150 -562
  6. package/dist/elbe.css.map +1 -1
  7. package/dist/index.d.ts +188 -46
  8. package/dist/index.js +8 -6
  9. package/dist/ui/app/app.d.ts +13 -0
  10. package/dist/ui/app/app.js +81 -0
  11. package/dist/ui/app/app_ctxt.d.ts +35 -0
  12. package/dist/ui/app/app_ctxt.js +10 -0
  13. package/dist/ui/components/badge.d.ts +3 -3
  14. package/dist/ui/components/badge.js +16 -5
  15. package/dist/ui/components/banner.d.ts +3 -3
  16. package/dist/ui/components/banner.js +1 -1
  17. package/dist/ui/components/base/box.d.ts +82 -35
  18. package/dist/ui/components/base/box.js +56 -8
  19. package/dist/ui/components/base/card.d.ts +11 -12
  20. package/dist/ui/components/base/card.js +41 -19
  21. package/dist/ui/components/base/padded.d.ts +2 -4
  22. package/dist/ui/components/base/state_builder.d.ts +9 -0
  23. package/dist/ui/components/base/state_builder.js +33 -0
  24. package/dist/ui/components/button/button.d.ts +8 -6
  25. package/dist/ui/components/button/button.js +27 -16
  26. package/dist/ui/components/button/choose_button.d.ts +5 -3
  27. package/dist/ui/components/button/choose_button.js +9 -6
  28. package/dist/ui/components/button/icon_button.d.ts +6 -5
  29. package/dist/ui/components/button/icon_button.js +33 -23
  30. package/dist/ui/components/button/toggle_button.d.ts +5 -5
  31. package/dist/ui/components/button/toggle_button.js +13 -7
  32. package/dist/ui/components/dialog/dialog.d.ts +13 -0
  33. package/dist/ui/components/dialog/dialog.js +69 -0
  34. package/dist/ui/components/dialog/dialog_ctx.d.ts +34 -0
  35. package/dist/ui/components/dialog/dialog_ctx.js +44 -0
  36. package/dist/ui/components/dialog/dialogs/_alert.d.ts +7 -0
  37. package/dist/ui/components/dialog/dialogs/_alert.js +9 -0
  38. package/dist/ui/components/dialog/dialogs/_confirm.d.ts +9 -0
  39. package/dist/ui/components/dialog/dialogs/_confirm.js +21 -0
  40. package/dist/ui/components/error_view.js +3 -3
  41. package/dist/ui/components/footer.js +7 -7
  42. package/dist/ui/components/input/_labeled_input.d.ts +21 -0
  43. package/dist/ui/components/input/_labeled_input.js +21 -0
  44. package/dist/ui/components/input/checkbox.d.ts +4 -2
  45. package/dist/ui/components/input/checkbox.js +16 -8
  46. package/dist/ui/components/input/range.d.ts +5 -3
  47. package/dist/ui/components/input/range.js +19 -18
  48. package/dist/ui/components/input/select.d.ts +4 -3
  49. package/dist/ui/components/input/select.js +13 -40
  50. package/dist/ui/components/input/switch.d.ts +4 -2
  51. package/dist/ui/components/input/switch.js +30 -40
  52. package/dist/ui/components/input/text/input_field.d.ts +14 -19
  53. package/dist/ui/components/input/text/input_field.js +59 -61
  54. package/dist/ui/components/input/text/single_line.d.ts +11 -9
  55. package/dist/ui/components/input/text/single_line.js +15 -21
  56. package/dist/ui/components/layout/flex.d.ts +7 -3
  57. package/dist/ui/components/layout/flex.js +15 -12
  58. package/dist/ui/components/layout/header.d.ts +2 -2
  59. package/dist/ui/components/layout/header.js +26 -18
  60. package/dist/ui/components/layout/menu.d.ts +1 -1
  61. package/dist/ui/components/layout/menu.js +80 -49
  62. package/dist/ui/components/layout/scroll.d.ts +1 -0
  63. package/dist/ui/components/layout/scroll.js +3 -1
  64. package/dist/ui/components/layout/toolbar.js +9 -6
  65. package/dist/ui/components/link.d.ts +4 -2
  66. package/dist/ui/components/link.js +24 -11
  67. package/dist/ui/components/progress_bar.d.ts +2 -2
  68. package/dist/ui/components/progress_bar.js +12 -9
  69. package/dist/ui/components/spinner.d.ts +2 -7
  70. package/dist/ui/components/spinner.js +15 -16
  71. package/dist/ui/components/text.d.ts +5 -6
  72. package/dist/ui/components/text.js +34 -21
  73. package/dist/ui/components/tooltip.d.ts +5 -0
  74. package/dist/ui/components/tooltip.js +48 -0
  75. package/dist/ui/theme/subthemes/_theme_geometry.d.ts +9 -0
  76. package/dist/ui/theme/subthemes/_theme_geometry.js +22 -0
  77. package/dist/ui/theme/subthemes/_theme_menu.d.ts +9 -0
  78. package/dist/ui/theme/subthemes/_theme_menu.js +12 -0
  79. package/dist/ui/theme/subthemes/_theme_motion.d.ts +9 -0
  80. package/dist/ui/theme/subthemes/_theme_motion.js +13 -0
  81. package/dist/ui/theme/subthemes/_theme_toast.d.ts +8 -0
  82. package/dist/ui/theme/subthemes/_theme_toast.js +11 -0
  83. package/dist/ui/theme/subthemes/_theme_type.d.ts +49 -0
  84. package/dist/ui/theme/subthemes/_theme_type.js +73 -0
  85. package/dist/ui/theme/subthemes/color/_seed.d.ts +2 -0
  86. package/dist/ui/theme/subthemes/color/_seed.js +105 -0
  87. package/dist/ui/theme/subthemes/color/_theme_color.d.ts +865 -0
  88. package/dist/ui/theme/subthemes/color/_theme_color.js +83 -0
  89. package/dist/ui/theme/subthemes/color/colors/_color_contrast.d.ts +284 -0
  90. package/dist/ui/theme/subthemes/color/colors/_color_contrast.js +17 -0
  91. package/dist/ui/theme/subthemes/color/colors/_color_kind.d.ts +242 -0
  92. package/dist/ui/theme/subthemes/color/colors/_color_kind.js +45 -0
  93. package/dist/ui/theme/subthemes/color/colors/_color_layer.d.ts +226 -0
  94. package/dist/ui/theme/subthemes/color/colors/_color_layer.js +95 -0
  95. package/dist/ui/theme/subthemes/color/colors/_color_manner.d.ts +280 -0
  96. package/dist/ui/theme/subthemes/color/colors/_color_manner.js +17 -0
  97. package/dist/ui/theme/subthemes/color/colors/_color_mode.d.ts +269 -0
  98. package/dist/ui/theme/subthemes/color/colors/_color_mode.js +16 -0
  99. package/dist/ui/theme/subthemes/color/colors/_color_rgba.d.ts +166 -0
  100. package/dist/ui/theme/subthemes/color/colors/_color_rgba.js +86 -0
  101. package/dist/ui/theme/subthemes/color/colors/_color_scheme.d.ts +256 -0
  102. package/dist/ui/theme/subthemes/color/colors/_color_scheme.js +17 -0
  103. package/dist/ui/theme/subthemes/color/colors/_color_state.d.ts +252 -0
  104. package/dist/ui/theme/subthemes/color/colors/_color_state.js +49 -0
  105. package/dist/ui/theme/subthemes/color/colors/_colordef.d.ts +22 -0
  106. package/dist/ui/theme/subthemes/color/colors/_colordef.js +34 -0
  107. package/dist/ui/theme/subthemes/color/colors/colors.d.ts +511 -0
  108. package/dist/ui/theme/subthemes/color/colors/colors.js +24 -0
  109. package/dist/ui/theme/theme.d.ts +984 -30
  110. package/dist/ui/theme/theme.js +14 -82
  111. package/dist/ui/theme/theme_context.d.ts +15 -17
  112. package/dist/ui/theme/theme_context.js +79 -18
  113. package/dist/ui/util/_util.d.ts +8 -0
  114. package/dist/ui/util/_util.js +42 -0
  115. package/dist/ui/util/error_view.js +3 -3
  116. package/dist/ui/util/merge_deep.d.ts +1 -0
  117. package/dist/ui/util/merge_deep.js +18 -0
  118. package/dist/ui/util/root.d.ts +17 -0
  119. package/dist/ui/util/root.js +23 -0
  120. package/dist/ui/util/toast/_toast.d.ts +5 -0
  121. package/dist/ui/util/toast/_toast.js +7 -0
  122. package/dist/ui/util/toast/toast_ctx.d.ts +28 -0
  123. package/dist/ui/util/toast/toast_ctx.js +62 -0
  124. package/dist/ui/util/toast/toast_legacy.d.ts +5 -0
  125. package/dist/ui/util/{toast.js → toast/toast_legacy.js} +4 -4
  126. package/dist/ui/util/util.d.ts +15 -0
  127. package/dist/ui/util/util.js +69 -1
  128. package/package.json +11 -9
  129. package/dist/ui/components/dialog.d.ts +0 -10
  130. package/dist/ui/components/dialog.js +0 -35
  131. package/dist/ui/components/layout/app_base.d.ts +0 -15
  132. package/dist/ui/components/layout/app_base.js +0 -76
  133. package/dist/ui/components/layout/ctx_app_base.d.ts +0 -19
  134. package/dist/ui/components/layout/ctx_app_base.js +0 -12
  135. package/dist/ui/theme/color_theme.d.ts +0 -2
  136. package/dist/ui/theme/color_theme.js +0 -92
  137. package/dist/ui/theme/colors.d.ts +0 -133
  138. package/dist/ui/theme/colors.js +0 -309
  139. package/dist/ui/theme/geometry_theme.d.ts +0 -16
  140. package/dist/ui/theme/geometry_theme.js +0 -28
  141. package/dist/ui/theme/seed.d.ts +0 -53
  142. package/dist/ui/theme/seed.js +0 -4
  143. package/dist/ui/theme/type_theme.d.ts +0 -38
  144. package/dist/ui/theme/type_theme.js +0 -73
  145. package/dist/ui/util/confirm_dialog.d.ts +0 -10
  146. package/dist/ui/util/confirm_dialog.js +0 -46
  147. package/dist/ui/util/toast.d.ts +0 -5
  148. /package/dist/bit/{_bit_utils.d.ts → _bit_types.d.ts} +0 -0
  149. /package/dist/bit/{_bit_utils.js → _bit_types.js} +0 -0
@@ -1,309 +0,0 @@
1
- import { hslToRgb, rgbToHsl } from "colors-convert";
2
- import { clamp } from "../util/util";
3
- import { colorThemePreset } from "./color_theme";
4
- import { lColor, } from "./seed";
5
- export const cContrasts = ["normal", "highvis"];
6
- export const cModes = ["light", "dark"];
7
- export const cSchemes = ["primary", "secondary", "inverse"];
8
- export const cKinds = [
9
- "plain",
10
- "accent",
11
- "info",
12
- "success",
13
- "warning",
14
- "error",
15
- ];
16
- export const cManners = ["major", "minor", "flat", "plain"];
17
- export const cStates = ["neutral", "hover", "active", "disabled"];
18
- export const cLayers = ["back", "front", "border"];
19
- export class RGBAColor {
20
- constructor(r, g, b, a) {
21
- this.r = r;
22
- this.g = g;
23
- this.b = b;
24
- this.a = a;
25
- }
26
- asCss() {
27
- return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`;
28
- }
29
- get isDark() {
30
- return this.luminance < 0.5;
31
- }
32
- get luminance() {
33
- const [r, g, b] = [this.r, this.g, this.b].map((v) => {
34
- v /= 255;
35
- return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
36
- });
37
- return r * 0.2126 + g * 0.7152 + b * 0.0722;
38
- }
39
- get hex() {
40
- const c = [this.r, this.g, this.b].map((v) => Math.round(v).toString(16).padStart(2, "0"));
41
- const a = Math.round(this.a * 255)
42
- .toString(16)
43
- .padStart(2, "0");
44
- return `#${c.join("")}${a}`;
45
- }
46
- static fromHex(hex) {
47
- if (!hex)
48
- return new RGBAColor(0, 0, 0, 0);
49
- const c = hex.replace("#", "").padEnd(6, "0").padEnd(8, "f").toLowerCase();
50
- 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);
51
- }
52
- desaturated(f = 1) {
53
- const avg = (this.r + this.g + this.b) / 3;
54
- return new RGBAColor(this.r + (avg - this.r) * f, this.g + (avg - this.g) * f, this.b + (avg - this.b) * f, this.a);
55
- }
56
- withAlpha(a) {
57
- return new RGBAColor(this.r, this.g, this.b, a);
58
- }
59
- inter(other, factor) {
60
- 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);
61
- }
62
- mirrorBrightness(factor = 1) {
63
- const hsl = rgbToHsl({ r: this.r, g: this.g, b: this.b });
64
- const newL = (50 - hsl.l) * (factor * 2 - 1) + 50;
65
- const rgb = hslToRgb(Object.assign(Object.assign({}, hsl), { l: clamp(newL, 0, 100), s: clamp(hsl.s, 0, 100) }));
66
- return new RGBAColor(rgb.r, rgb.g, rgb.b, this.a);
67
- }
68
- get values() {
69
- return [this.r, this.g, this.b, this.a];
70
- }
71
- hasWCAGContrast(color) {
72
- return this.contrastRatio(color) >= 3;
73
- }
74
- contrastRatio(color) {
75
- const l1 = this.luminance;
76
- const l2 = color.luminance;
77
- return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
78
- }
79
- }
80
- export const colors = {
81
- transparent: new RGBAColor(0, 0, 0, 0),
82
- white: new RGBAColor(255, 255, 255, 1),
83
- black: new RGBAColor(0, 0, 0, 1),
84
- blueAccent: new RGBAColor(60, 119, 246, 1),
85
- blue: new RGBAColor(32, 89, 153, 1),
86
- green: new RGBAColor(35, 144, 78, 1),
87
- yellow: new RGBAColor(240, 221, 21, 1),
88
- red: new RGBAColor(243, 67, 67, 1),
89
- };
90
- export class LayerColor extends RGBAColor {
91
- constructor(back, front, border, borderContext) {
92
- super(back.r, back.g, back.b, back.a);
93
- this.back = back;
94
- this.border = border;
95
- this.borderContext = borderContext;
96
- this.front = front !== null && front !== void 0 ? front : (back.isDark ? colors.white : colors.black);
97
- }
98
- asCss() {
99
- var _a, _b;
100
- return (`background-color: ${this.back.asCss()};\n` +
101
- `color: ${this.front.asCss()};\n` +
102
- `border-color: ${(_b = (_a = this.border) === null || _a === void 0 ? void 0 : _a.asCss()) !== null && _b !== void 0 ? _b : "transparent"};\n` +
103
- //`border-color: ${this.border?.asCss() ?? "transparent"};\n` +
104
- this.contextCss());
105
- }
106
- inter(other, factor) {
107
- var _a, _b, _c, _d;
108
- 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));
109
- }
110
- mirrorBrightness(factor) {
111
- var _a, _b;
112
- 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));
113
- }
114
- desaturated() {
115
- var _a, _b;
116
- 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());
117
- }
118
- static fromHex(back, front, border) {
119
- if (front === undefined && border === undefined) {
120
- return LayerColor.fromBack(RGBAColor.fromHex(back));
121
- }
122
- return new LayerColor(RGBAColor.fromHex(back), RGBAColor.fromHex(front !== null && front !== void 0 ? front : null), RGBAColor.fromHex(border !== null && border !== void 0 ? border : null));
123
- }
124
- withBorder(border) {
125
- return new LayerColor(this.back, this.front, border);
126
- }
127
- static fromBack(back, c) {
128
- var _a, _b;
129
- const front = back.isDark ? colors.white : colors.black;
130
- 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);
131
- }
132
- contextCss() {
133
- var _a, _b, _c;
134
- return (`--c-context-back: ${this.back.asCss()};\n` +
135
- `--c-context-front: ${this.front.asCss()};` +
136
- `--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"};`);
137
- }
138
- }
139
- export class StateColor extends LayerColor {
140
- constructor(neutral, hover, active, disabled) {
141
- super(neutral.back, neutral.front, neutral.border);
142
- this.neutral = neutral;
143
- this.hover = hover;
144
- this.active = active;
145
- this.disabled = disabled;
146
- }
147
- asCss() {
148
- const els = [
149
- ".action",
150
- ":is(button)",
151
- ":is(a)",
152
- ":is(input)",
153
- ":is(select)",
154
- ];
155
- const disS = "&.disabled, & :disabled, &:disabled";
156
- const hoverS = els.map((e) => `&${e}:hover:not(${disS})`).join(", ");
157
- const activeS = els.map((e) => `&${e}:active:not(${disS})`).join(", ");
158
- return (`${this.neutral.asCss()} \n` +
159
- `${hoverS} { ${this.hover.asCss()} }\n` +
160
- `${activeS} { ${this.active.asCss()} }\n` +
161
- `${disS} { ${this.disabled.asCss()} }`);
162
- }
163
- static generate(p, _, context, style, fromFront) {
164
- function _make(factor) {
165
- const front = style.front;
166
- return new LayerColor((fromFront
167
- ? context.back.inter(front, factor)
168
- : style.back.inter(context.back.mirrorBrightness(), factor)).withAlpha(Math.max(style.back.a, 0.2)), front, style.border, style.borderContext);
169
- }
170
- return new StateColor(style, _make(0.075), _make(0.25), style.desaturated());
171
- }
172
- }
173
- export class MannerColor extends StateColor {
174
- constructor(major, minor, flat) {
175
- const m = major !== null && major !== void 0 ? major : flat;
176
- super(m.neutral, m.hover, m.active, m.disabled);
177
- this.major = major;
178
- this.minor = minor;
179
- this.flat = flat;
180
- }
181
- asCss(fallback) {
182
- var _a, _b;
183
- const maj = (_a = this.major) !== null && _a !== void 0 ? _a : fallback === null || fallback === void 0 ? void 0 : fallback.major;
184
- const min = (_b = this.minor) !== null && _b !== void 0 ? _b : fallback === null || fallback === void 0 ? void 0 : fallback.minor;
185
- return (`${this.flat.asCss()}\n` +
186
- (maj ? `&.major { ${maj.asCss()} } \n` : "") +
187
- (min ? `&.minor { ${min.asCss()} } \n` : "") +
188
- `&.flat { ${this.flat.asCss()} }\n`);
189
- }
190
- raisedCss() {
191
- const maj = this.major;
192
- const min = this.minor;
193
- return ((maj ? ` .major { ${maj.asCss()} } \n` : "") +
194
- (min ? ` .minor { ${min.asCss()} } \n` : ""));
195
- }
196
- static generate(path, seed, base, style) {
197
- return new MannerColor(style
198
- ? StateColor.generate([...path, "major"], seed, base, seed.variant.major({ path, seed, base, style }))
199
- : null, style
200
- ? StateColor.generate([...path, "minor"], seed, base, seed.variant.minor({ path, seed, base, style }))
201
- : null, StateColor.generate([...path, "flat"], seed, base, seed.variant.flat({ path, seed, base, style }), true));
202
- /*
203
- if (!style) {
204
- return new MannerColor(null, null, StateColor.generate(s, c, c, true));
205
- }
206
- return new MannerColor(
207
- StateColor.generate(s, c, s.variant.major(s, c, style)),
208
- StateColor.generate(s, c, s.variant.minor(s, c, style)),
209
- StateColor.generate(s, c, s.variant.flat(s, c, style), true)
210
- );
211
- */
212
- }
213
- }
214
- export class KindColor extends MannerColor {
215
- constructor(plain, accent, info, success, warning, error) {
216
- super(plain.major, plain.minor, plain.flat);
217
- this.plain = plain;
218
- this.accent = accent;
219
- this.info = info;
220
- this.success = success;
221
- this.warning = warning;
222
- this.error = error;
223
- }
224
- asCss() {
225
- return (`${this.plain.asCss()}\n` +
226
- `${this.accent.raisedCss()}\n` +
227
- `.plain {${this.plain.asCss()}}\n` +
228
- `.accent { ${this.accent.asCss()} }\n` +
229
- `.info { ${this.info.asCss()} }\n` +
230
- `.success { ${this.success.asCss()} }\n` +
231
- `.warning { ${this.warning.asCss()} }\n` +
232
- `.error { ${this.error.asCss()} }`);
233
- }
234
- static generate(path, seed, base) {
235
- return new KindColor(MannerColor.generate([...path, "plain"], seed, base), MannerColor.generate([...path, "accent"], seed, base, seed.style.accent({ path, seed, base, style: lColor(seed.accent) })), MannerColor.generate([...path, "info"], seed, base, seed.style.info({ path, seed, base, style: lColor(seed.info) })), MannerColor.generate([...path, "success"], seed, base, seed.style.success({ path, seed, base, style: lColor(seed.success) })), MannerColor.generate([...path, "warning"], seed, base, seed.style.warning({ path, seed, base, style: lColor(seed.warning) })), MannerColor.generate([...path, "error"], seed, base, seed.style.error({ path, seed, base, style: lColor(seed.error) })));
236
- }
237
- }
238
- export class SchemeColor extends KindColor {
239
- constructor(primary, secondary, inverse) {
240
- super(primary.plain, primary.accent, primary.info, primary.success, primary.warning, primary.error);
241
- this.primary = primary;
242
- this.secondary = secondary;
243
- this.inverse = inverse;
244
- }
245
- asCss() {
246
- return (`${this.primary.asCss()}\n` +
247
- `.primary { ${this.primary.asCss()}} \n` +
248
- `.secondary { ${this.secondary.asCss()} }\n` +
249
- `.inverse { ${this.inverse.asCss()} }`);
250
- }
251
- static generate(path, seed, base) {
252
- const m = seed.scheme;
253
- return new SchemeColor(KindColor.generate([...path, "primary"], seed, m.primary({ path, seed, base })), KindColor.generate([...path, "secondary"], seed, m.secondary({ path, seed, base })), KindColor.generate([...path, "inverse"], seed, m.inverse({ path, seed, base })));
254
- }
255
- }
256
- export class ModeColor extends SchemeColor {
257
- constructor(light, dark) {
258
- super(light.primary, light.secondary, light.inverse);
259
- this.light = light;
260
- this.dark = dark;
261
- }
262
- asCss() {
263
- return `&{ ${this.light.asCss()}}` + `&.dark { ${this.dark.asCss()}}`;
264
- }
265
- static generate(path, seed) {
266
- return new ModeColor(SchemeColor.generate(path, seed, lColor(seed.base)), SchemeColor.generate([...path, "dark"], seed, seed.mode.dark({ path, seed, base: lColor(seed.base) })));
267
- }
268
- }
269
- export class ContrastColor extends ModeColor {
270
- constructor(normal, highvis) {
271
- super(normal.light, normal.dark);
272
- this.normal = normal;
273
- this.highvis = highvis;
274
- }
275
- asCss() {
276
- return (`& { ${this.normal.asCss()}}` + `&.highvis { ${this.highvis.asCss()}}`);
277
- }
278
- static generate(path, seed) {
279
- const p = { path, base: lColor(seed.base), seed };
280
- return new ContrastColor(ModeColor.generate(path, seed.contrast.normal(p)), ModeColor.generate([...path, "highvis"], seed.contrast.highvis(p)));
281
- }
282
- }
283
- export class ColorTheme {
284
- constructor(colors, color) {
285
- this.colors = colors;
286
- this.color = color;
287
- }
288
- asCss() {
289
- return `
290
- --c-accent: ${this.colors.accent.back.asCss()};
291
- --c-info: ${this.colors.info.back.asCss()};
292
- --c-success: ${this.colors.success.back.asCss()};
293
- --c-warning: ${this.colors.warning.back.asCss()};
294
- --c-error: ${this.colors.error.back.asCss()};
295
- ${this.color.asCss()}`;
296
- }
297
- static generate(seed) {
298
- const s = colorThemePreset(seed);
299
- return new ColorTheme({
300
- base: lColor(s.base),
301
- accent: lColor(s.accent),
302
- info: lColor(s.info),
303
- success: lColor(s.success),
304
- warning: lColor(s.warning),
305
- error: lColor(s.error),
306
- }, ContrastColor.generate([], s));
307
- }
308
- }
309
- //Bun.write("./example.css", ColorTheme.generate().asCss());
@@ -1,16 +0,0 @@
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;
@@ -1,28 +0,0 @@
1
- export class GeometryTheme {
2
- constructor(size, radius, padding, borderWidth) {
3
- this.size = size;
4
- this.radius = radius;
5
- this.padding = padding;
6
- this.borderWidth = borderWidth;
7
- }
8
- asCss() {
9
- return (`--g-size: ${this.size}px;` +
10
- `--g-radius: ${this.radius}rem;` +
11
- `--g-padding: ${this.padding}rem;` +
12
- `--g-border-width: ${this.borderWidth}rem;`);
13
- }
14
- static generate(seed) {
15
- const s = geometryThemePreset(seed);
16
- return new GeometryTheme(s.size, s.radius, s.padding, s.borderWidth);
17
- }
18
- }
19
- export function geometryThemePreset(merge) {
20
- var _a, _b, _c, _d;
21
- const seed = merge !== null && merge !== void 0 ? merge : {};
22
- return {
23
- size: (_a = seed.size) !== null && _a !== void 0 ? _a : 16,
24
- radius: (_b = seed.radius) !== null && _b !== void 0 ? _b : 0.75,
25
- padding: (_c = seed.padding) !== null && _c !== void 0 ? _c : 1,
26
- borderWidth: (_d = seed.borderWidth) !== null && _d !== void 0 ? _d : 0.125,
27
- };
28
- }
@@ -1,53 +0,0 @@
1
- import { LayerColor, SeedFlatSelector, SeedModifier, SeedSelector, SeedStyleSelector } from "../..";
2
- export type HexColor = `#${string}`;
3
- export type ColorSeedColors = _Colors<LayerColor | HexColor>;
4
- export type ThemeColors = _Colors<LayerColor>;
5
- type _Colors<T> = {
6
- base: T;
7
- accent: T;
8
- info: T;
9
- success: T;
10
- warning: T;
11
- error: T;
12
- };
13
- type _ContrastSeed = {
14
- highvis: SeedModifier;
15
- normal: SeedModifier;
16
- };
17
- type _ModeSeed = {
18
- light: SeedSelector;
19
- dark: SeedSelector;
20
- };
21
- type _SchemeSeed = {
22
- primary: SeedSelector;
23
- secondary: SeedSelector;
24
- inverse: SeedSelector;
25
- };
26
- type _StyleSeed = {
27
- accent: SeedStyleSelector;
28
- info: SeedStyleSelector;
29
- success: SeedStyleSelector;
30
- warning: SeedStyleSelector;
31
- error: SeedStyleSelector;
32
- };
33
- type _VariantSeed = {
34
- major: SeedStyleSelector;
35
- minor: SeedStyleSelector;
36
- flat: SeedFlatSelector;
37
- };
38
- export type ColorThemeSeed = ColorSeedColors & {
39
- contrast: _ContrastSeed;
40
- mode: _ModeSeed;
41
- scheme: _SchemeSeed;
42
- style: _StyleSeed;
43
- variant: _VariantSeed;
44
- };
45
- export type PartialColorThemeSeed = Partial<ColorSeedColors> & {
46
- contrast?: Partial<_ContrastSeed>;
47
- mode?: Partial<_ModeSeed>;
48
- scheme?: Partial<_SchemeSeed>;
49
- style?: Partial<_StyleSeed>;
50
- variant?: Partial<_VariantSeed>;
51
- };
52
- export declare function lColor(color: LayerColor | HexColor): LayerColor;
53
- export {};
@@ -1,4 +0,0 @@
1
- import { LayerColor, } from "../..";
2
- export function lColor(color) {
3
- return typeof color === "string" ? LayerColor.fromHex(color) : color;
4
- }
@@ -1,38 +0,0 @@
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 {};
@@ -1,73 +0,0 @@
1
- export const tVariants = [
2
- "h1",
3
- "h2",
4
- "h3",
5
- "h4",
6
- "h5",
7
- "h6",
8
- "body-l",
9
- "body-m",
10
- "body-s",
11
- "code",
12
- ];
13
- function _typeStyleAsCss(t) {
14
- return (`font-family: ${t.family};\n` +
15
- `font-size: ${t.size}rem;\n` +
16
- `font-weight: ${t.bold ? "bold" : "normal"};\n` +
17
- `font-style: ${t.italic ? "italic" : "normal"};\n` +
18
- `text-decoration: ${t.underline ? "underline" : "none"};\n`);
19
- }
20
- export class TypeTheme {
21
- constructor(h1, h2, h3, h4, h5, h6, bodyL, body, bodyS, code) {
22
- this.h1 = h1;
23
- this.h2 = h2;
24
- this.h3 = h3;
25
- this.h4 = h4;
26
- this.h5 = h5;
27
- this.h6 = h6;
28
- this.bodyL = bodyL;
29
- this.body = body;
30
- this.bodyS = bodyS;
31
- this.code = code;
32
- }
33
- get headers() {
34
- return [this.h1, this.h2, this.h3, this.h4, this.h5, this.h6];
35
- }
36
- asCss() {
37
- return (this.headers
38
- .map((v, i) => `h${i + 1}, .h${i + 1} {${_typeStyleAsCss(v)}}`)
39
- .join("\n") +
40
- `body, .body, .body-m {${_typeStyleAsCss(this.body)}}\n` +
41
- `large, .body-l {${_typeStyleAsCss(this.bodyL)}}\n` +
42
- `small, .body-s {${_typeStyleAsCss(this.bodyS)}}\n` +
43
- `.code {${_typeStyleAsCss(this.code)}}\n`);
44
- }
45
- static generate(seed) {
46
- const s = typeThemePreset(seed);
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);
48
- }
49
- }
50
- export function typeThemePreset(merge) {
51
- return Object.assign({ heading: {
52
- bold: true,
53
- family: ["Calistoga", "Arial", "sans-serif"],
54
- size: 2,
55
- }, body: {
56
- bold: false,
57
- family: ["Helvetica", "Arial", "sans-serif"],
58
- size: 1,
59
- }, code: {
60
- bold: false,
61
- family: ["Courier", "monospace"],
62
- size: 1,
63
- }, headingVariants: (style, variant) => {
64
- const reg = 1;
65
- const diff = style.size - reg;
66
- const varFac = (4 - (variant - 2)) / 6;
67
- const size = reg + diff * Math.pow(varFac, 1.5);
68
- return Object.assign(Object.assign({}, style), { size });
69
- }, bodyVariants: (style, variant) => {
70
- const size = style.size * (variant === "s" ? 0.8 : 1.2);
71
- return Object.assign(Object.assign({}, style), { size });
72
- } }, merge);
73
- }
@@ -1,10 +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 declare function showConfirmDialog({ title, message, okay, }: {
7
- message: string;
8
- title: string;
9
- okay?: boolean;
10
- }): Promise<boolean>;
@@ -1,46 +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({ title, message, okay = false, }) {
7
- return new Promise((resolve, reject) => {
8
- var _a;
9
- const dialog = document.createElement("div");
10
- dialog.classList.add("dialog");
11
- dialog.innerHTML = `<dialog open>
12
- <div
13
- class="card primary"
14
- style="max-width: 30rem; min-width: 10rem"
15
- >
16
- <div class="row cross-center">
17
- <div class="flex-1 body-l b">
18
- ${title}
19
- </div>
20
- <button class="plain round" style="width: 3rem" onclick="conf_resolve(false)">
21
- <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>
22
- </button>
23
- </div>
24
- <div style="margin-top: 1rem; margin-bottom: 1rem">
25
- ${message}
26
- </div>
27
- <div class="row main-end gap">
28
-
29
- ${okay
30
- ? '<button class="accent" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(true)">okay</button>'
31
- : '<button class="minor" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(false)">no</button>' +
32
- '<button class="accent" style="padding-left:1rem; padding-right:1rem" onclick="conf_resolve(true)">yes</button>'}
33
- </div>
34
-
35
- </div>
36
- </dialog>
37
- `;
38
- (_a = document.getElementsByClassName("elbe")[0]) === null || _a === void 0 ? void 0 : _a.appendChild(dialog);
39
- //document.body.appendChild(dialog);
40
- window["conf_resolve"] = (v) => {
41
- var _a;
42
- (_a = document.getElementsByClassName("elbe")[0]) === null || _a === void 0 ? void 0 : _a.removeChild(dialog);
43
- resolve(v);
44
- };
45
- });
46
- }
@@ -1,5 +0,0 @@
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;
File without changes
File without changes