elbe-ui 0.2.26 → 0.2.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bit/bit.js +83 -0
- package/dist/bit/ctrl_bit.js +89 -0
- package/dist/elbe.css +621 -0
- package/dist/elbe.css.map +1 -0
- package/dist/index.d.ts +1549 -17
- package/dist/index.js +64 -18577
- package/dist/service/s_api.js +89 -0
- package/dist/ui/components/badge.d.ts +5 -5
- package/dist/ui/components/badge.js +53 -0
- package/dist/ui/components/base/box.d.ts +2564 -0
- package/dist/ui/components/base/box.js +30 -0
- package/dist/ui/components/base/card.d.ts +14 -0
- package/dist/ui/components/base/card.js +11 -0
- package/dist/ui/components/base/padded.js +28 -0
- package/dist/ui/components/button/button.d.ts +21 -0
- package/dist/ui/components/button/button.js +27 -0
- package/dist/ui/components/button/choose_button.d.ts +14 -0
- package/dist/ui/components/button/choose_button.js +11 -0
- package/dist/ui/components/button/icon_button.d.ts +17 -0
- package/dist/ui/components/button/icon_button.js +31 -0
- package/dist/ui/components/button/toggle_button.d.ts +10 -0
- package/dist/ui/components/button/toggle_button.js +11 -0
- package/dist/ui/components/dialog.js +14 -0
- package/dist/ui/components/error_view.js +26 -0
- package/dist/ui/components/input/checkbox.d.ts +1 -1
- package/dist/ui/components/input/checkbox.js +12 -0
- package/dist/ui/components/input/input_field.d.ts +1 -1
- package/dist/ui/components/input/input_field.js +31 -0
- package/dist/ui/components/input/range.d.ts +1 -1
- package/dist/ui/components/input/range.js +14 -0
- package/dist/ui/components/input/select.d.ts +1 -1
- package/dist/ui/components/input/select.js +8 -0
- package/dist/ui/components/input/text_area.d.ts +1 -1
- package/dist/ui/components/input/text_area.js +13 -0
- package/dist/ui/components/{flex.d.ts → layout/flex.d.ts} +1 -1
- package/dist/ui/components/layout/flex.js +23 -0
- package/dist/ui/components/{scaffold.d.ts → layout/scaffold.d.ts} +7 -3
- package/dist/ui/components/layout/scaffold.js +44 -0
- package/dist/ui/components/layout/scroll.d.ts +18 -0
- package/dist/ui/components/layout/scroll.js +20 -0
- package/dist/ui/components/layout/spaced.js +7 -0
- package/dist/ui/components/spinner.d.ts +10 -2
- package/dist/ui/components/spinner.js +48 -0
- package/dist/ui/components/text.d.ts +5 -5
- package/dist/ui/components/text.js +42 -0
- package/dist/ui/theme/color_theme.d.ts +2 -0
- package/dist/ui/theme/color_theme.js +63 -0
- package/dist/ui/theme/colors.d.ts +142 -0
- package/dist/ui/theme/colors.js +317 -0
- package/dist/ui/theme/geometry_theme.d.ts +16 -0
- package/dist/ui/theme/geometry_theme.js +38 -0
- package/dist/ui/theme/theme.d.ts +28 -0
- package/dist/ui/theme/theme.js +49 -0
- package/dist/ui/theme/type_theme.d.ts +38 -0
- package/dist/ui/theme/type_theme.js +98 -0
- package/dist/ui/util/confirm_dialog.js +46 -0
- package/dist/ui/util/error_view.js +8 -0
- package/dist/ui/util/toast.js +17 -0
- package/dist/ui/util/util.d.ts +2 -0
- package/dist/ui/util/util.js +39 -0
- package/package.json +14 -15
- package/dist/ui/color_theme.d.ts +0 -5
- package/dist/ui/components/box.d.ts +0 -1027
- package/dist/ui/components/button.d.ts +0 -23
- package/dist/ui/components/card.d.ts +0 -14
- package/dist/ui/components/icon_button.d.ts +0 -19
- package/dist/ui/components/toggle_button.d.ts +0 -12
- package/elbe.scss +0 -100
- package/src/bit/bit.tsx +0 -128
- package/src/bit/ctrl_bit.tsx +0 -112
- package/src/index.tsx +0 -29
- package/src/service/s_api.ts +0 -102
- package/src/ui/color_theme.ts +0 -24
- package/src/ui/components/badge.tsx +0 -78
- package/src/ui/components/box.tsx +0 -49
- package/src/ui/components/button.tsx +0 -61
- package/src/ui/components/card.tsx +0 -45
- package/src/ui/components/dialog.tsx +0 -51
- package/src/ui/components/error_view.tsx +0 -72
- package/src/ui/components/flex.tsx +0 -64
- package/src/ui/components/icon_button.tsx +0 -56
- package/src/ui/components/input/checkbox.tsx +0 -32
- package/src/ui/components/input/input_field.tsx +0 -57
- package/src/ui/components/input/range.tsx +0 -37
- package/src/ui/components/input/select.tsx +0 -29
- package/src/ui/components/input/text_area.tsx +0 -45
- package/src/ui/components/padded.tsx +0 -62
- package/src/ui/components/scaffold.tsx +0 -79
- package/src/ui/components/spinner.tsx +0 -11
- package/src/ui/components/text.tsx +0 -78
- package/src/ui/components/toggle_button.tsx +0 -52
- package/src/ui/components/util.tsx +0 -3
- package/src/ui/util/confirm_dialog.ts +0 -53
- package/src/ui/util/error_view.tsx +0 -16
- package/src/ui/util/toast.ts +0 -14
- package/src/ui/util/util.ts +0 -36
- package/style/color_style.scss +0 -149
- package/style/components.scss +0 -476
- package/style/root.scss +0 -50
- package/style/type_style.scss +0 -22
- /package/dist/ui/components/{padded.d.ts → base/padded.d.ts} +0 -0
- /package/dist/ui/components/{util.d.ts → layout/spaced.d.ts} +0 -0
package/dist/bit/bit.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeBit = makeBit;
|
|
4
|
+
exports.ProvideBit = ProvideBit;
|
|
5
|
+
exports.useBit = useBit;
|
|
6
|
+
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
7
|
+
const signals_1 = require("@preact/signals");
|
|
8
|
+
const preact_1 = require("preact");
|
|
9
|
+
const hooks_1 = require("preact/hooks");
|
|
10
|
+
const error_view_1 = require("../ui/components/error_view");
|
|
11
|
+
const spinner_1 = require("../ui/components/spinner");
|
|
12
|
+
function makeBit(name) {
|
|
13
|
+
const c = (0, preact_1.createContext)(null);
|
|
14
|
+
c.displayName = name;
|
|
15
|
+
return c;
|
|
16
|
+
}
|
|
17
|
+
function ProvideBit(context, parameters, worker, ctrl, children) {
|
|
18
|
+
const s = (0, signals_1.useSignal)({ loading: true });
|
|
19
|
+
const _set = (n) => {
|
|
20
|
+
try {
|
|
21
|
+
if (JSON.stringify(n) === JSON.stringify(s.peek()))
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
catch (e) { }
|
|
25
|
+
s.value = n;
|
|
26
|
+
};
|
|
27
|
+
const emit = (data) => _set({ data });
|
|
28
|
+
const emitLoading = () => _set({ loading: true });
|
|
29
|
+
const emitError = (error) => {
|
|
30
|
+
console.warn(`BIT: ${context.displayName} emitted ERROR`, error);
|
|
31
|
+
return _set({ error });
|
|
32
|
+
};
|
|
33
|
+
function map(m) {
|
|
34
|
+
const st = s.value;
|
|
35
|
+
if (st.loading)
|
|
36
|
+
return m.onLoading();
|
|
37
|
+
if (st.error)
|
|
38
|
+
return m.onError(st.error);
|
|
39
|
+
return m.onData(st.data ?? null);
|
|
40
|
+
}
|
|
41
|
+
const c = ctrl(parameters, { emit, emitLoading, emitError, map, signal: s });
|
|
42
|
+
worker(parameters, { emit, emitLoading, emitError, map, signal: s }, c);
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(context.Provider, { value: { ctrl: c, state: s }, children: children }));
|
|
44
|
+
}
|
|
45
|
+
function useBit(context) {
|
|
46
|
+
try {
|
|
47
|
+
const { ctrl, state } = (0, hooks_1.useContext)(context);
|
|
48
|
+
const v = state.value;
|
|
49
|
+
function map(m) {
|
|
50
|
+
if (v.loading)
|
|
51
|
+
return (m.onLoading || (() => (0, jsx_runtime_1.jsx)(spinner_1.Spinner, {})))();
|
|
52
|
+
if (v.error)
|
|
53
|
+
return (m.onError ||
|
|
54
|
+
((e) => (0, jsx_runtime_1.jsx)(error_view_1.ErrorView, { error: e, retry: ctrl.reload ?? null })))(v.error);
|
|
55
|
+
return m.onData(v.data ?? null);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
signal: state,
|
|
59
|
+
ctrl,
|
|
60
|
+
map,
|
|
61
|
+
/**
|
|
62
|
+
* this is a quality of life function that allows
|
|
63
|
+
* you to chain the map function with the onData function
|
|
64
|
+
* @param f the builder function
|
|
65
|
+
* @returns the built component
|
|
66
|
+
*/
|
|
67
|
+
onData: (f) => map({ onData: f }),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
const err = `BIT ERROR: NO ${context.displayName} PROVIDED`;
|
|
72
|
+
console.error(err, e);
|
|
73
|
+
return {
|
|
74
|
+
map: (_) => (0, jsx_runtime_1.jsx)("div", { children: err }),
|
|
75
|
+
ctrl: null,
|
|
76
|
+
signal: null,
|
|
77
|
+
onData: () => (0, jsx_runtime_1.jsx)("div", { children: err }),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function BitSpinner({ name }) {
|
|
82
|
+
return (0, jsx_runtime_1.jsx)(spinner_1.Spinner, {});
|
|
83
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamControl = exports.WorkerControl = void 0;
|
|
4
|
+
exports.CtrlBit = CtrlBit;
|
|
5
|
+
const hooks_1 = require("preact/hooks");
|
|
6
|
+
const bit_1 = require("./bit");
|
|
7
|
+
class BitControl {
|
|
8
|
+
p;
|
|
9
|
+
bit;
|
|
10
|
+
constructor(p, bit) {
|
|
11
|
+
this.bit = bit;
|
|
12
|
+
this.p = p;
|
|
13
|
+
}
|
|
14
|
+
act(fn) {
|
|
15
|
+
this.bit.map({
|
|
16
|
+
onData: async (d) => {
|
|
17
|
+
try {
|
|
18
|
+
await fn(d);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
if (e && e.code && e.message)
|
|
22
|
+
console.error(`[BitERROR] act: ${e.code} (${e.message})`);
|
|
23
|
+
else
|
|
24
|
+
console.error("[BitERROR] act: ", e);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Clean up resources. This is called once
|
|
31
|
+
* the element is removed from the DOM.
|
|
32
|
+
*/
|
|
33
|
+
dispose() { }
|
|
34
|
+
}
|
|
35
|
+
class WorkerControl extends BitControl {
|
|
36
|
+
reload = null;
|
|
37
|
+
}
|
|
38
|
+
exports.WorkerControl = WorkerControl;
|
|
39
|
+
class StreamControl extends BitControl {
|
|
40
|
+
stream = null;
|
|
41
|
+
dispose() {
|
|
42
|
+
if (this.stream)
|
|
43
|
+
this.disposeStream(this.stream);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.StreamControl = StreamControl;
|
|
47
|
+
function make(name) {
|
|
48
|
+
return (0, bit_1.makeBit)(name);
|
|
49
|
+
}
|
|
50
|
+
function use(b) {
|
|
51
|
+
return (0, bit_1.useBit)(b);
|
|
52
|
+
}
|
|
53
|
+
function CtrlBit(ctrl, name) {
|
|
54
|
+
const context = make((name || "Unknown") + "Bit");
|
|
55
|
+
function Provide({ children, ...p }) {
|
|
56
|
+
return (0, bit_1.ProvideBit)(context, p, async (p, b, c) => {
|
|
57
|
+
b.emitLoading();
|
|
58
|
+
try {
|
|
59
|
+
if (c instanceof WorkerControl) {
|
|
60
|
+
if (c.reload)
|
|
61
|
+
await c.reload();
|
|
62
|
+
}
|
|
63
|
+
if (c instanceof StreamControl) {
|
|
64
|
+
c.stream = c.listen();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
b.emitError(e);
|
|
69
|
+
}
|
|
70
|
+
}, (p, b) => {
|
|
71
|
+
const c = ctrl(p, b);
|
|
72
|
+
// clean up on unmount
|
|
73
|
+
(0, hooks_1.useEffect)(() => () => c.dispose(), []);
|
|
74
|
+
if (c instanceof WorkerControl) {
|
|
75
|
+
c.reload = async () => {
|
|
76
|
+
b.emitLoading();
|
|
77
|
+
try {
|
|
78
|
+
b.emit(await c.worker());
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
b.emitError(e);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return c;
|
|
86
|
+
}, children);
|
|
87
|
+
}
|
|
88
|
+
return { Provide: Provide, use: () => use(context) };
|
|
89
|
+
}
|