@sigx/runtime-terminal 0.1.0
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/README.md +40 -0
- package/dist/components/Button.d.ts +7 -0
- package/dist/components/Checkbox.d.ts +12 -0
- package/dist/components/Input.d.ts +11 -0
- package/dist/components/ProgressBar.d.ts +13 -0
- package/dist/focus.d.ts +8 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +1356 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard.d.ts +4 -0
- package/dist/types.d.ts +12 -0
- package/dist/utils.d.ts +3 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @sigx/runtime-terminal
|
|
2
|
+
|
|
3
|
+
Terminal UI components for the Sigx runtime (demo/experimental).
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
- `Button` - a focusable, clickable control.
|
|
8
|
+
- `Input` - a focusable text input with two-way `sync` binding via `value`.
|
|
9
|
+
- `ProgressBar` - a read-only progress indicator.
|
|
10
|
+
- `Checkbox` - a focusable checkbox with two-way `sync` binding via `value`.
|
|
11
|
+
|
|
12
|
+
## `Checkbox` Usage
|
|
13
|
+
|
|
14
|
+
The `Checkbox` component uses two-way `sync` binding. That means you can write:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
/** @jsxImportSource @sigx/terminal */
|
|
18
|
+
import { signal, renderTerminal, Checkbox } from '@sigx/terminal';
|
|
19
|
+
|
|
20
|
+
const state = signal({ enabled: true });
|
|
21
|
+
|
|
22
|
+
renderTerminal(
|
|
23
|
+
<Checkbox sync={() => state.enabled} label="Enabled" />,
|
|
24
|
+
{ clearConsole: true }
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
When the user presses Space or Enter while the `Checkbox` is focused, it will emit `update:value` and `change` events in addition to toggling the visual state.
|
|
29
|
+
|
|
30
|
+
Props:
|
|
31
|
+
|
|
32
|
+
- `value` (sync) - boolean - current value (two-way binding via `sync`).
|
|
33
|
+
- `label` - string - optional label to display.
|
|
34
|
+
- `autofocus` - boolean - focus on mount.
|
|
35
|
+
- `disabled` - boolean - disable interaction.
|
|
36
|
+
|
|
37
|
+
Events:
|
|
38
|
+
|
|
39
|
+
- `update:value` - emitted when the value changes (used by `sync`).
|
|
40
|
+
- `change` - emitted with the new value when toggled.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @jsxImportSource @sigx/runtime-core */
|
|
2
|
+
import { type DefineEvent } from '@sigx/runtime-core';
|
|
3
|
+
export declare const Button: import("@sigx/runtime-core").ComponentFactory<{
|
|
4
|
+
label?: string | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
dropShadow?: boolean | undefined;
|
|
7
|
+
} & DefineEvent<"click">, void, {}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsxImportSource @sigx/runtime-core */
|
|
2
|
+
import { type DefineEvent } from '@sigx/runtime-core';
|
|
3
|
+
export declare const Checkbox: import("@sigx/runtime-core").ComponentFactory<{
|
|
4
|
+
value?: boolean | undefined;
|
|
5
|
+
} & DefineEvent<"update:value", boolean> & {
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
autofocus?: boolean | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
} & DefineEvent<"change", boolean>, void, {}>;
|
|
12
|
+
export default Checkbox;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @jsxImportSource @sigx/runtime-core */
|
|
2
|
+
import { type DefineEvent } from '@sigx/runtime-core';
|
|
3
|
+
export declare const Input: import("@sigx/runtime-core").ComponentFactory<{
|
|
4
|
+
value?: string | undefined;
|
|
5
|
+
} & DefineEvent<"update:value", string> & {
|
|
6
|
+
placeholder?: string | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
autofocus?: boolean | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
} & DefineEvent<"input", string> & DefineEvent<"submit", string>, void, {}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const ProgressBar: import("@sigx/runtime-core").ComponentFactory<{
|
|
2
|
+
value?: number | undefined;
|
|
3
|
+
} & {
|
|
4
|
+
max?: number | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
width?: number | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
char?: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
emptyChar?: string | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
color?: string | undefined;
|
|
13
|
+
}, void, {}>;
|
package/dist/focus.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const focusState: import("@sigx/reactivity").Signal<{
|
|
2
|
+
activeId: string | null;
|
|
3
|
+
}>;
|
|
4
|
+
export declare function registerFocusable(id: string): void;
|
|
5
|
+
export declare function unregisterFocusable(id: string): void;
|
|
6
|
+
export declare function focus(id: string): void;
|
|
7
|
+
export declare function focusNext(): void;
|
|
8
|
+
export declare function focusPrev(): void;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import './types.js';
|
|
2
|
+
export * from './focus';
|
|
3
|
+
export * from './components/Input';
|
|
4
|
+
export * from './components/ProgressBar';
|
|
5
|
+
export * from './components/Button';
|
|
6
|
+
export * from './components/Checkbox';
|
|
7
|
+
export interface TerminalNode {
|
|
8
|
+
type: 'root' | 'element' | 'text' | 'comment';
|
|
9
|
+
tag?: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
props: Record<string, any>;
|
|
12
|
+
children: TerminalNode[];
|
|
13
|
+
parentNode?: TerminalNode | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const render: (element: import("@sigx/runtime-core").JSXElement, container: TerminalNode, appContext?: import("@sigx/runtime-core").AppContext) => void, createApp: (rootComponent: any) => {
|
|
16
|
+
mount(selectorOrContainer: string | TerminalNode): void;
|
|
17
|
+
};
|
|
18
|
+
export declare function renderNodeToLines(node: TerminalNode): string[];
|
|
19
|
+
type KeyHandler = (key: string) => void;
|
|
20
|
+
export declare function onKey(handler: KeyHandler): () => boolean;
|
|
21
|
+
export interface RenderTerminalOptions {
|
|
22
|
+
clearConsole?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function renderTerminal(app: any, options?: RenderTerminalOptions): {
|
|
25
|
+
unmount: () => void;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Mount function for Terminal environments.
|
|
29
|
+
* Use this with defineApp().mount() to render to the terminal.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import { defineApp } from '@sigx/runtime-core';
|
|
34
|
+
* import { terminalMount } from '@sigx/runtime-terminal';
|
|
35
|
+
*
|
|
36
|
+
* const app = defineApp(<Counter />);
|
|
37
|
+
* app.use(loggingPlugin)
|
|
38
|
+
* .mount({ clearConsole: true }, terminalMount);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const terminalMount: (component: any, options: RenderTerminalOptions, appContext?: any) => (() => void);
|
|
42
|
+
declare global {
|
|
43
|
+
namespace JSX {
|
|
44
|
+
interface IntrinsicElements {
|
|
45
|
+
box: TerminalAttributes;
|
|
46
|
+
text: TerminalAttributes;
|
|
47
|
+
br: TerminalAttributes;
|
|
48
|
+
}
|
|
49
|
+
interface TerminalAttributes {
|
|
50
|
+
color?: 'red' | 'green' | 'blue' | 'yellow' | 'cyan' | 'white' | 'black' | string;
|
|
51
|
+
backgroundColor?: 'red' | 'green' | 'blue' | 'yellow' | 'cyan' | 'white' | 'black' | string;
|
|
52
|
+
border?: 'single' | 'double' | 'rounded' | 'none';
|
|
53
|
+
borderColor?: 'red' | 'green' | 'blue' | 'yellow' | 'cyan' | 'white' | 'black' | string;
|
|
54
|
+
dropShadow?: boolean;
|
|
55
|
+
label?: string;
|
|
56
|
+
children?: any;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|