elbe-ui 0.2.14 → 0.2.19

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.
@@ -0,0 +1,34 @@
1
+ import { Signal } from "@preact/signals";
2
+ import { type PreactContext } from "preact";
3
+ export interface BitUseInterface<C, T> {
4
+ signal: Signal<BitState<T>>;
5
+ ctrl: C;
6
+ map: <D>(m: TriMap<T, D>) => D | preact.JSX.Element;
7
+ onData: (f: (d: T) => any) => any;
8
+ }
9
+ interface BitData<C, T> {
10
+ ctrl: C;
11
+ state: Signal<BitState<T>>;
12
+ }
13
+ export interface BitState<T> {
14
+ loading?: boolean;
15
+ error?: any;
16
+ data?: T;
17
+ }
18
+ export type BitContext<T, C> = PreactContext<BitData<T, C> | null>;
19
+ export interface TriMap<T, D> {
20
+ onLoading?: () => D;
21
+ onError?: (e: string) => D;
22
+ onData?: (value: T) => D;
23
+ }
24
+ export interface TWParams<T> {
25
+ emit: (t: T) => void;
26
+ emitLoading: () => void;
27
+ emitError: (e: any) => void;
28
+ map: <D>(m: TriMap<T, D>) => D;
29
+ signal: Signal<BitState<T>>;
30
+ }
31
+ export declare function makeBit<C, T>(name: string): BitContext<C, T>;
32
+ export declare function ProvideBit<I, C, T>(context: BitContext<C, T>, parameters: I, worker: (p: I, d: TWParams<T>, ctrl: C) => void, ctrl: (p: I, d: TWParams<T>) => C, children: any): import("preact").JSX.Element;
33
+ export declare function useBit<C, T>(context: BitContext<C, T>): BitUseInterface<C, T>;
34
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { JSX } from "preact/jsx-runtime";
2
+ import type { BitUseInterface, TWParams } from "./bit";
3
+ declare abstract class BitControl<I, DT> {
4
+ p: I;
5
+ bit: TWParams<DT>;
6
+ constructor(p: I, bit: TWParams<DT>);
7
+ act(fn: (b: DT) => Promise<void>): void;
8
+ /**
9
+ * Clean up resources. This is called once
10
+ * the element is removed from the DOM.
11
+ */
12
+ dispose(): void;
13
+ }
14
+ export declare abstract class WorkerControl<I, DT> extends BitControl<I, DT> {
15
+ reload: (() => Promise<void>) | null;
16
+ abstract worker(): Promise<DT>;
17
+ }
18
+ export declare abstract class StreamControl<I, DT, Stream> extends BitControl<I, DT> {
19
+ protected stream: Stream | null;
20
+ abstract listen(): Stream;
21
+ dispose(): void;
22
+ abstract disposeStream(stream: Stream): void;
23
+ }
24
+ export declare function CtrlBit<I, DT, C extends BitControl<I, DT>>(ctrl: (p: I, d: TWParams<DT>) => C, name?: string): {
25
+ Provide: (props: I & {
26
+ children: React.ReactNode;
27
+ }) => JSX.Element;
28
+ use: () => BitUseInterface<C, DT>;
29
+ };
30
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import * as Lucide from "lucide-react";
2
+ export * from "./bit/bit";
3
+ export * from "./bit/ctrl_bit";
4
+ export * from "./service/s_api";
2
5
  export * from "./ui/color_theme";
3
6
  export * from "./ui/components/badge";
4
7
  export * from "./ui/components/box";
@@ -12,6 +15,7 @@ export * from "./ui/components/input/input_field";
12
15
  export * from "./ui/components/input/range";
13
16
  export * from "./ui/components/input/select";
14
17
  export * from "./ui/components/padded";
18
+ export * from "./ui/components/spinner";
15
19
  export * from "./ui/components/text";
16
20
  export * from "./ui/components/toggle_button";
17
21
  export * from "./ui/components/util";