@visulima/tui 2.0.0 → 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.
- package/CHANGELOG.md +2 -0
- package/dist/components/box.d.ts +25 -25
- package/dist/components/canvas.d.ts +26 -31
- package/dist/components/cursor.d.ts +39 -44
- package/dist/components/error-overview.d.ts +1 -3
- package/dist/components/error-overview.js +1 -1
- package/dist/components/newline.d.ts +6 -8
- package/dist/components/spacer.d.ts +4 -4
- package/dist/components/static-render.d.ts +9 -40
- package/dist/components/static.d.ts +13 -13
- package/dist/components/text.d.ts +34 -47
- package/dist/components/transform.d.ts +7 -11
- package/dist/core/index.d.ts +11 -11
- package/dist/core/index.js +1 -1
- package/dist/ink/canvas/index.d.ts +10 -10
- package/dist/ink/hooks/use-animation.d.ts +22 -22
- package/dist/ink/hooks/use-app.d.ts +3 -3
- package/dist/ink/hooks/use-box-metrics.d.ts +16 -16
- package/dist/ink/hooks/use-clipboard.d.ts +16 -16
- package/dist/ink/hooks/use-color-blindness.d.ts +16 -16
- package/dist/ink/hooks/use-console-capture.d.ts +19 -19
- package/dist/ink/hooks/use-cursor.d.ts +6 -6
- package/dist/ink/hooks/use-focus-manager.d.ts +25 -25
- package/dist/ink/hooks/use-focus.d.ts +14 -18
- package/dist/ink/hooks/use-form.d.ts +32 -32
- package/dist/ink/hooks/use-hotkey.d.ts +17 -17
- package/dist/ink/hooks/use-input.d.ts +92 -92
- package/dist/ink/hooks/use-input.js +2 -2
- package/dist/ink/hooks/use-interval.d.ts +14 -14
- package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +3 -3
- package/dist/ink/hooks/use-key-bindings.d.ts +32 -32
- package/dist/ink/hooks/use-key-chord.d.ts +15 -15
- package/dist/ink/hooks/use-paste.d.ts +38 -38
- package/dist/ink/hooks/use-paste.js +1 -1
- package/dist/ink/hooks/use-persistent-state.d.ts +46 -46
- package/dist/ink/hooks/use-persistent-state.js +2 -2
- package/dist/ink/hooks/use-scroll-acceleration.d.ts +24 -24
- package/dist/ink/hooks/use-scroll-input.d.ts +15 -15
- package/dist/ink/hooks/use-stderr.d.ts +6 -6
- package/dist/ink/hooks/use-stderr.js +1 -1
- package/dist/ink/hooks/use-stdin.d.ts +10 -10
- package/dist/ink/hooks/use-stdin.js +1 -1
- package/dist/ink/hooks/use-stdout.d.ts +6 -6
- package/dist/ink/hooks/use-stdout.js +1 -1
- package/dist/ink/hooks/use-stopwatch.d.ts +12 -12
- package/dist/ink/hooks/use-terminal-palette.d.ts +11 -11
- package/dist/ink/hooks/use-text-buffer.d.ts +2 -2
- package/dist/ink/hooks/use-text-selection.d.ts +18 -18
- package/dist/ink/hooks/use-timeout.d.ts +11 -11
- package/dist/ink/hooks/use-timer.d.ts +19 -19
- package/dist/ink/hooks/use-window-size.d.ts +8 -8
- package/dist/ink/hooks/use-window-size.js +1 -1
- package/dist/ink/index.d.ts +109 -122
- package/dist/ink/index.js +1 -1
- package/dist/ink/mouse/use-element-position.d.ts +6 -6
- package/dist/ink/mouse/use-mouse-action.d.ts +1 -1
- package/dist/ink/mouse/use-mouse-position.d.ts +1 -1
- package/dist/ink/mouse/use-mouse.d.ts +1 -1
- package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -3
- package/dist/ink/mouse/use-on-mouse-hover.d.ts +2 -2
- package/dist/ink/mouse/use-on-mouse-state.d.ts +2 -2
- package/dist/ink/public/cursor.d.ts +21 -21
- package/dist/ink/public/dom.d.ts +2 -2
- package/dist/ink/public/highlighter.d.ts +16 -26
- package/dist/ink/public/input.d.ts +6 -6
- package/dist/ink/public/styles.d.ts +1 -1
- package/dist/ink/public/utils.d.ts +2 -2
- package/dist/packem_shared/{DevTools-D9tfChBc.js → DevTools-BxD3PYAN.js} +1 -1
- package/dist/packem_shared/MouseProvider-DOcWCRVq.js +1 -0
- package/dist/packem_shared/{Renderer-DsskdkUd.js → Renderer-BeS49FNq.js} +1 -1
- package/dist/packem_shared/{TuiApp-DjIgv5Sk.js → TuiApp-CCVaiKbf.js} +1 -1
- package/dist/packem_shared/app-context.d-DMLw5Nxy.d.ts +56 -0
- package/dist/packem_shared/{buffer.d-j_dP5JyC.d.ts → buffer.d-CttIC480.d.ts} +26 -26
- package/dist/packem_shared/clipboard.d-nDPQkZ2H.d.ts +23 -0
- package/dist/packem_shared/color-matrix.d-sTqnJ23h.d.ts +50 -0
- package/dist/packem_shared/{createInlineLoop-BT40Wpmx.js → createInlineLoop-DnEvE2eM.js} +1 -1
- package/dist/packem_shared/{dom.d-g-nsYquD.d.ts → dom.d-CLGlidfI.d.ts} +138 -151
- package/dist/packem_shared/{input.d-D-Yxqha8.d.ts → input.d-Bb8pWHvp.d.ts} +24 -24
- package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +1 -0
- package/dist/packem_shared/{mouse-context.d-BfL9xGk_.d.ts → mouse-context.d-W-nszUps.d.ts} +8 -8
- package/dist/packem_shared/reconciler-DkwOtC5B.js +1 -0
- package/dist/packem_shared/{render-D7aV_hO1.js → render-CuCo-R-l.js} +17 -17
- package/dist/packem_shared/{render-DMcWfI6-.js → render-DtQd8qQq.js} +1 -1
- package/dist/packem_shared/render.d-DjQhFsiN.d.ts +435 -0
- package/dist/packem_shared/{renderToString-DqLFFPvO.js → renderToString-B1LgWcJe.js} +1 -1
- package/dist/packem_shared/{selection.d-KWphH--_.d.ts → selection.d-BSAWa4ey.d.ts} +16 -16
- package/dist/packem_shared/stderr-context-CR2LLec6.js +1 -0
- package/dist/packem_shared/stdin-context-BjMA9Sbi.js +1 -0
- package/dist/packem_shared/stdout-context-DAAlQct2.js +1 -0
- package/dist/packem_shared/styles.d-CKGQFfm4.d.ts +485 -0
- package/dist/packem_shared/{terminal-palette.d-D2SQjfn-.d.ts → terminal-palette.d-JbWHISW-.d.ts} +7 -7
- package/dist/packem_shared/utils-CVgM8kTn.js +1 -0
- package/dist/react/index.d.ts +160 -178
- package/dist/react/index.js +1 -1
- package/dist/testing/index.d.ts +151 -151
- package/dist/testing/index.js +1 -1
- package/index.js +52 -52
- package/package.json +9 -9
- package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +0 -1
- package/dist/packem_shared/app-context.d-CG88lgkg.d.ts +0 -56
- package/dist/packem_shared/clipboard.d-D6lZTQ21.d.ts +0 -23
- package/dist/packem_shared/color-matrix.d-DSXLsB64.d.ts +0 -50
- package/dist/packem_shared/load-native-root-binding-DDikxNox.js +0 -1
- package/dist/packem_shared/reconciler-DhUGYWCr.js +0 -1
- package/dist/packem_shared/render.d-BvfwvSCx.d.ts +0 -435
- package/dist/packem_shared/stderr-context-Bvnik0hL.js +0 -1
- package/dist/packem_shared/stdin-context-88AhuztD.js +0 -1
- package/dist/packem_shared/stdout-context-BnblEPez.js +0 -1
- package/dist/packem_shared/styles.d-D7iZuNC-.d.ts +0 -492
- package/dist/packem_shared/utils-C8l_3Dzw.js +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { C as CanvasContext, b as CellStyle } from "../../packem_shared/buffer.d-
|
|
2
|
-
export { type c as CanvasBuffer, type a as CanvasColor, d as createCanvasBuffer, s as serializeRow } from "../../packem_shared/buffer.d-
|
|
1
|
+
import { C as CanvasContext, b as CellStyle } from "../../packem_shared/buffer.d-CttIC480.js";
|
|
2
|
+
export { type c as CanvasBuffer, type a as CanvasColor, d as createCanvasBuffer, s as serializeRow } from "../../packem_shared/buffer.d-CttIC480.js";
|
|
3
3
|
type BrailleGrid = {
|
|
4
4
|
readonly cellHeight: number;
|
|
5
5
|
readonly cellWidth: number;
|
|
6
6
|
readonly clear: () => void;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
* Flush the accumulated pixels into the canvas, one braille character per
|
|
9
|
+
* dirtied cell. Pass a color via `style` to apply it uniformly (mixing
|
|
10
|
+
* colors across overlapping series requires a separate grid per series).
|
|
11
|
+
*/
|
|
12
12
|
readonly flush: (context: CanvasContext, style?: CellStyle) => void;
|
|
13
13
|
readonly pixelHeight: number;
|
|
14
14
|
readonly pixelWidth: number;
|
|
@@ -16,9 +16,9 @@ type BrailleGrid = {
|
|
|
16
16
|
readonly plotPoint: (x: number, y: number) => void;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Accumulator for braille-rendered charts. Tracks which sub-pixels are lit
|
|
20
|
-
* and emits a braille character per dirtied cell on `flush`. Designed to be
|
|
21
|
-
* allocated per chart render and thrown away.
|
|
22
|
-
*/
|
|
19
|
+
* Accumulator for braille-rendered charts. Tracks which sub-pixels are lit
|
|
20
|
+
* and emits a braille character per dirtied cell on `flush`. Designed to be
|
|
21
|
+
* allocated per chart render and thrown away.
|
|
22
|
+
*/
|
|
23
23
|
declare const createBrailleGrid: (cellWidth: number, cellHeight: number) => BrailleGrid;
|
|
24
24
|
export { type BrailleGrid, type CanvasContext, type CellStyle, createBrailleGrid };
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
type Options = {
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Time between ticks in milliseconds.
|
|
4
|
+
* @default 100
|
|
5
|
+
*/
|
|
6
6
|
readonly interval?: number;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
* Whether the animation is running. When set to `false`, the animation stops.
|
|
9
|
+
* When toggled back to `true`, all values reset to `0`.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
12
|
readonly isActive?: boolean;
|
|
13
13
|
};
|
|
14
14
|
type AnimationResult = {
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
* Time in milliseconds since the previous rendered tick. Accounts for throttled renders.
|
|
17
|
+
* Useful for physics-based or velocity-driven motion: `position += speed * delta`.
|
|
18
|
+
*/
|
|
19
19
|
readonly delta: number;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
* Discrete counter that increments by 1 each interval.
|
|
22
|
+
* Useful for indexed sequences like spinner frames.
|
|
23
|
+
*/
|
|
24
24
|
readonly frame: number;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
* Resets `frame`, `time`, and `delta` to `0` and restarts timing from the current moment.
|
|
27
|
+
* Useful for one-shot animations triggered by events.
|
|
28
|
+
*/
|
|
29
29
|
readonly reset: () => void;
|
|
30
30
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
* Total elapsed time in milliseconds since the animation started or was last reset.
|
|
32
|
+
* Useful for continuous math-based animations like sine waves: `Math.sin(time / 1000 * Math.PI * 2)`.
|
|
33
|
+
*/
|
|
34
34
|
readonly time: number;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
* A React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function.
|
|
38
|
-
* All animations share a single timer internally, so multiple animated components consolidate into one render cycle.
|
|
39
|
-
*/
|
|
37
|
+
* A React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function.
|
|
38
|
+
* All animations share a single timer internally, so multiple animated components consolidate into one render cycle.
|
|
39
|
+
*/
|
|
40
40
|
declare function useAnimation(options?: Options): AnimationResult;
|
|
41
41
|
export { AnimationResult, useAnimation as default, useAnimation };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as Props } from "../../packem_shared/app-context.d-
|
|
1
|
+
import { P as Props } from "../../packem_shared/app-context.d-DMLw5Nxy.js";
|
|
2
2
|
import 'react';
|
|
3
3
|
/**
|
|
4
|
-
* A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
|
|
5
|
-
*/
|
|
4
|
+
* A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
|
|
5
|
+
*/
|
|
6
6
|
declare const useApp: () => Props;
|
|
7
7
|
export { type Props as AppProps, useApp as default, useApp };
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
import { D as DOMElement } from "../../packem_shared/dom.d-
|
|
2
|
+
import { D as DOMElement } from "../../packem_shared/dom.d-CLGlidfI.js";
|
|
3
3
|
import 'yoga-layout';
|
|
4
4
|
import "../public/cursor.js";
|
|
5
5
|
import '@visulima/colorize';
|
|
6
|
-
import "../../packem_shared/styles.d-
|
|
6
|
+
import "../../packem_shared/styles.d-CKGQFfm4.js";
|
|
7
7
|
import 'type-fest';
|
|
8
8
|
/**
|
|
9
|
-
* Metrics of a box element.
|
|
10
|
-
*
|
|
11
|
-
* All positions are relative to the element's parent.
|
|
12
|
-
*/
|
|
9
|
+
* Metrics of a box element.
|
|
10
|
+
*
|
|
11
|
+
* All positions are relative to the element's parent.
|
|
12
|
+
*/
|
|
13
13
|
type BoxMetrics = {
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
* Element height.
|
|
16
|
+
*/
|
|
17
17
|
readonly height: number;
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
* Distance from the left edge of the parent.
|
|
20
|
+
*/
|
|
21
21
|
readonly left: number;
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
* Distance from the top edge of the parent.
|
|
24
|
+
*/
|
|
25
25
|
readonly top: number;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
* Element width.
|
|
28
|
+
*/
|
|
29
29
|
readonly width: number;
|
|
30
30
|
};
|
|
31
31
|
type UseBoxMetricsResult = BoxMetrics & {
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
* Whether the currently tracked element has been measured in the latest layout pass.
|
|
34
|
+
*/
|
|
35
35
|
readonly hasMeasured: boolean;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { C as ClipboardTarget } from "../../packem_shared/clipboard.d-
|
|
1
|
+
import { C as ClipboardTarget } from "../../packem_shared/clipboard.d-nDPQkZ2H.js";
|
|
2
2
|
import 'node:stream';
|
|
3
3
|
type UseClipboardOptions = {
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* The clipboard target to write to.
|
|
6
|
+
* @default "c"
|
|
7
|
+
*/
|
|
8
8
|
readonly target?: ClipboardTarget;
|
|
9
9
|
};
|
|
10
10
|
type UseClipboardResult = {
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
* Copy text to the system clipboard.
|
|
13
|
+
* No-op if the terminal does not support OSC 52.
|
|
14
|
+
*/
|
|
15
15
|
readonly copy: (text: string) => void;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* Whether the current terminal supports OSC 52 clipboard operations.
|
|
18
|
+
*/
|
|
19
19
|
readonly isSupported: boolean;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Hook that provides clipboard write access via OSC 52.
|
|
23
|
-
*
|
|
24
|
-
* ```tsx
|
|
25
|
-
* const { copy, isSupported } = useClipboard();
|
|
26
|
-
* copy("Hello, clipboard!");
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
22
|
+
* Hook that provides clipboard write access via OSC 52.
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const { copy, isSupported } = useClipboard();
|
|
26
|
+
* copy("Hello, clipboard!");
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
29
|
declare const useClipboard: (options?: UseClipboardOptions) => UseClipboardResult;
|
|
30
30
|
export { UseClipboardOptions, UseClipboardResult, useClipboard as default, useClipboard };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { C as ColorBlindnessType, a as ColorMatrix } from "../../packem_shared/color-matrix.d-
|
|
1
|
+
import { C as ColorBlindnessType, a as ColorMatrix } from "../../packem_shared/color-matrix.d-sTqnJ23h.js";
|
|
2
2
|
type UseColorBlindnessOptions = {
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
* Use compensation mode (shift colors to distinguishable range)
|
|
5
|
+
* instead of simulation mode (show how colors appear to affected users).
|
|
6
|
+
* Not available for achromatopsia.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
9
|
readonly compensate?: boolean;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
* Type of color vision deficiency to simulate or compensate for.
|
|
12
|
+
* @default "none"
|
|
13
|
+
*/
|
|
14
14
|
readonly mode?: ColorBlindnessType | "none";
|
|
15
15
|
};
|
|
16
16
|
type UseColorBlindnessResult = {
|
|
@@ -22,12 +22,12 @@ type UseColorBlindnessResult = {
|
|
|
22
22
|
readonly transformColor: (hex: string) => string;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
* Hook for color blindness simulation and compensation.
|
|
26
|
-
*
|
|
27
|
-
* ```tsx
|
|
28
|
-
* const { transformColor } = useColorBlindness({ mode: "deuteranopia" });
|
|
29
|
-
* <Text color={transformColor("#ff0000")}>This text</Text>
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
25
|
+
* Hook for color blindness simulation and compensation.
|
|
26
|
+
*
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const { transformColor } = useColorBlindness({ mode: "deuteranopia" });
|
|
29
|
+
* <Text color={transformColor("#ff0000")}>This text</Text>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
32
|
declare const useColorBlindness: (options?: UseColorBlindnessOptions) => UseColorBlindnessResult;
|
|
33
33
|
export { UseColorBlindnessOptions, UseColorBlindnessResult, useColorBlindness as default, useColorBlindness };
|
|
@@ -7,19 +7,19 @@ type ConsoleEntry = {
|
|
|
7
7
|
};
|
|
8
8
|
type UseConsoleCaptureOptions = {
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
* Which console levels to capture.
|
|
11
|
+
* @default ["log", "info", "warn", "error", "debug"]
|
|
12
|
+
*/
|
|
13
13
|
readonly filter?: ReadonlyArray<ConsoleLevel>;
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
* Enable or disable capture.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
18
|
readonly isActive?: boolean;
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
* Maximum number of entries to keep in the buffer.
|
|
21
|
+
* @default 200
|
|
22
|
+
*/
|
|
23
23
|
readonly maxEntries?: number;
|
|
24
24
|
};
|
|
25
25
|
type UseConsoleCaptureResult = {
|
|
@@ -29,15 +29,15 @@ type UseConsoleCaptureResult = {
|
|
|
29
29
|
readonly entries: ReadonlyArray<ConsoleEntry>;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
|
-
* Hook that captures console output into a React state buffer.
|
|
33
|
-
*
|
|
34
|
-
* **Note:** Only one active `useConsoleCapture` instance should exist at a time.
|
|
35
|
-
* The `ConsoleOverlay` component uses this hook internally — do not use both
|
|
36
|
-
* simultaneously unless the hook instance has `isActive: false`.
|
|
37
|
-
*
|
|
38
|
-
* ```tsx
|
|
39
|
-
* const { entries, clear } = useConsoleCapture({ maxEntries: 100 });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
32
|
+
* Hook that captures console output into a React state buffer.
|
|
33
|
+
*
|
|
34
|
+
* **Note:** Only one active `useConsoleCapture` instance should exist at a time.
|
|
35
|
+
* The `ConsoleOverlay` component uses this hook internally — do not use both
|
|
36
|
+
* simultaneously unless the hook instance has `isActive: false`.
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const { entries, clear } = useConsoleCapture({ maxEntries: 100 });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
42
|
declare const useConsoleCapture: (options?: UseConsoleCaptureOptions) => UseConsoleCaptureResult;
|
|
43
43
|
export { ConsoleEntry, ConsoleLevel, UseConsoleCaptureOptions, UseConsoleCaptureResult, useConsoleCapture as default, useConsoleCapture };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import 'node:stream';
|
|
2
2
|
import { CursorPosition } from "../public/cursor.js";
|
|
3
3
|
/**
|
|
4
|
-
* A React hook that returns methods to control the terminal cursor position.
|
|
5
|
-
*
|
|
6
|
-
* Setting a cursor position makes the cursor visible at the specified coordinates (relative to the Ink output origin). This is useful for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.
|
|
7
|
-
*
|
|
8
|
-
* Pass `undefined` to hide the cursor.
|
|
9
|
-
*/
|
|
4
|
+
* A React hook that returns methods to control the terminal cursor position.
|
|
5
|
+
*
|
|
6
|
+
* Setting a cursor position makes the cursor visible at the specified coordinates (relative to the Ink output origin). This is useful for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.
|
|
7
|
+
*
|
|
8
|
+
* Pass `undefined` to hide the cursor.
|
|
9
|
+
*/
|
|
10
10
|
declare const useCursor: () => {
|
|
11
11
|
setCursorPosition: (position: CursorPosition | undefined) => void;
|
|
12
12
|
};
|
|
@@ -15,43 +15,43 @@ type Props = {
|
|
|
15
15
|
};
|
|
16
16
|
type Output = {
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
* The ID of the currently focused component, or `undefined` if no component is focused.
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import {Text} from '@visulima/tui/components/text';
|
|
22
|
+
* import {useFocusManager} from '@visulima/tui/hooks/use-focus-manager';
|
|
23
|
+
*
|
|
24
|
+
* const Example = () => {
|
|
25
|
+
* const {activeId} = useFocusManager();
|
|
26
|
+
*
|
|
27
|
+
* return <Text>Focused: {activeId ?? 'none'}</Text>;
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
31
|
activeId: Props["activeId"];
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
* Disable focus management for all components. The currently active component (if there's one) will lose its focus.
|
|
34
|
+
*/
|
|
35
35
|
disableFocus: Props["disableFocus"];
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
* Enable focus management for all components.
|
|
38
|
+
*/
|
|
39
39
|
enableFocus: Props["enableFocus"];
|
|
40
40
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
* Switch focus to the element with provided `id`. If there's no element with that `id`, focus is not changed.
|
|
42
|
+
*/
|
|
43
43
|
focus: Props["focus"];
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
* Switch focus to the next focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the last in the list of focusable components, focus will be switched to the first focusable component.
|
|
46
|
+
*/
|
|
47
47
|
focusNext: Props["focusNext"];
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
* Switch focus to the previous focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the first in the list of focusable components, focus will be switched to the last focusable component.
|
|
50
|
+
*/
|
|
51
51
|
focusPrevious: Props["focusPrevious"];
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
* A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
|
|
55
|
-
*/
|
|
54
|
+
* A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
|
|
55
|
+
*/
|
|
56
56
|
declare const useFocusManager: () => Output;
|
|
57
57
|
export { useFocusManager as default, useFocusManager };
|
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
type Input = {
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
* Auto-focus this component if there's no active (focused) component right now.
|
|
4
|
+
*/
|
|
5
5
|
autoFocus?: boolean;
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* Assign an ID to this component, so it can be programmatically focused with `focus(id)`.
|
|
8
|
+
*/
|
|
9
9
|
id?: string;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Enable or disable this component's focus, while still maintaining its position in the list of focusable components.
|
|
12
|
+
*/
|
|
13
13
|
isActive?: boolean;
|
|
14
14
|
};
|
|
15
15
|
type Output = {
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* Allows focusing a specific element with the provided `id`.
|
|
18
|
+
*/
|
|
19
19
|
focus: (id: string) => void;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
* Determines whether this component is focused.
|
|
22
|
+
*/
|
|
23
23
|
isFocused: boolean;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
* A React hook that returns focus state and focus controls for the current component.
|
|
27
|
-
* A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
|
|
28
|
-
*/
|
|
29
|
-
declare const useFocus: ({
|
|
30
|
-
autoFocus,
|
|
31
|
-
id: customId,
|
|
32
|
-
isActive
|
|
33
|
-
}?: Input) => Output;
|
|
26
|
+
* A React hook that returns focus state and focus controls for the current component.
|
|
27
|
+
* A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
|
|
28
|
+
*/
|
|
29
|
+
declare const useFocus: ({ autoFocus, id: customId, isActive }?: Input) => Output;
|
|
34
30
|
export { useFocus as default, useFocus };
|
|
@@ -2,67 +2,67 @@ type ValidationResult = string | undefined;
|
|
|
2
2
|
type FieldValidator<V> = (value: V, values: Readonly<Record<string, unknown>>) => ValidationResult;
|
|
3
3
|
type FieldConfig<V = unknown> = {
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* Initial value.
|
|
6
|
+
*/
|
|
7
7
|
readonly initialValue: V;
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
* Optional validator. Return a string to indicate an error; return
|
|
10
|
+
* `undefined` for valid.
|
|
11
|
+
*/
|
|
12
12
|
readonly validate?: FieldValidator<V>;
|
|
13
13
|
};
|
|
14
14
|
type FormSchema = Readonly<Record<string, FieldConfig<never>>>;
|
|
15
|
-
type FormValues<S extends Readonly<Record<string, FieldConfig>>> = { [K in keyof S]: S[K] extends FieldConfig<infer V> ? V : never };
|
|
15
|
+
type FormValues<S extends Readonly<Record<string, FieldConfig>>> = { [K in keyof S]: S[K] extends FieldConfig<infer V> ? V : never; };
|
|
16
16
|
type UseFormOptions<S extends Readonly<Record<string, FieldConfig>>> = {
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* Field declarations.
|
|
19
|
+
*/
|
|
20
20
|
readonly fields: S;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* Called on submit if all fields validate.
|
|
23
|
+
*/
|
|
24
24
|
readonly onSubmit?: (values: FormValues<S>) => void | Promise<void>;
|
|
25
25
|
};
|
|
26
26
|
type UseFormResult<S extends Readonly<Record<string, FieldConfig>>> = {
|
|
27
27
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
* Map of fieldName -> validation error (if any).
|
|
29
|
+
*/
|
|
30
30
|
readonly errors: Readonly<Partial<Record<keyof S, string>>>;
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
* True while the last `submit()` is in-flight.
|
|
33
|
+
*/
|
|
34
34
|
readonly isSubmitting: boolean;
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* Reset all fields back to their initial values and clear errors / touched.
|
|
37
|
+
*/
|
|
38
38
|
readonly reset: () => void;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Mark a field as touched. Useful on blur.
|
|
41
|
+
*/
|
|
42
42
|
readonly setTouched: <K extends keyof S>(name: K, touched?: boolean) => void;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* Update a single field.
|
|
45
|
+
*/
|
|
46
46
|
readonly setValue: <K extends keyof S>(name: K, value: FormValues<S>[K]) => void;
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
* Trigger validation and call the `onSubmit` option. Returns true if
|
|
49
|
+
* submission succeeded (all fields valid).
|
|
50
|
+
*/
|
|
51
51
|
readonly submit: () => Promise<boolean>;
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
* Map of fieldName -> boolean. Field is considered touched after the
|
|
54
|
+
* first `setTouched(name)` or `submit()` invocation.
|
|
55
|
+
*/
|
|
56
56
|
readonly touched: Readonly<Partial<Record<keyof S, boolean>>>;
|
|
57
57
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
* Current values.
|
|
59
|
+
*/
|
|
60
60
|
readonly values: FormValues<S>;
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
|
-
* Minimal headless form state machine. Tracks values, touched state, errors,
|
|
64
|
-
* and submission in-flight. Pair with `<Form />` for default layout, or wire
|
|
65
|
-
* up your own inputs directly.
|
|
66
|
-
*/
|
|
63
|
+
* Minimal headless form state machine. Tracks values, touched state, errors,
|
|
64
|
+
* and submission in-flight. Pair with `<Form />` for default layout, or wire
|
|
65
|
+
* up your own inputs directly.
|
|
66
|
+
*/
|
|
67
67
|
declare const useForm: <S extends Readonly<Record<string, FieldConfig>>>(options: UseFormOptions<S>) => UseFormResult<S>;
|
|
68
68
|
export { FieldConfig, FieldValidator, FormSchema, FormValues, UseFormOptions, UseFormResult, ValidationResult, useForm as default, useForm };
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { Key } from "./use-input.js";
|
|
2
2
|
type HotkeyDescriptor = {
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
* Whether Ctrl must be held.
|
|
5
|
+
*/
|
|
6
6
|
readonly ctrl?: boolean;
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
* Character(s) to match after modifiers, e.g. `"s"`, `"?"`, `"k"`.
|
|
9
|
+
* Ignored if `name` is set.
|
|
10
|
+
*/
|
|
11
11
|
readonly input?: string;
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
* Whether Meta must be held.
|
|
14
|
+
*/
|
|
15
15
|
readonly meta?: boolean;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* Named special key, e.g. `"escape"`, `"return"`, `"tab"`, `"upArrow"`.
|
|
18
|
+
*/
|
|
19
19
|
readonly name?: keyof Key;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
* Whether Shift must be held.
|
|
22
|
+
*/
|
|
23
23
|
readonly shift?: boolean;
|
|
24
24
|
};
|
|
25
25
|
type UseHotkeyOptions = {
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
* Disable the binding while keeping the component rendered.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
30
|
readonly isActive?: boolean;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
* Bind a keyboard shortcut to a callback. Accepts either a short string
|
|
34
|
-
* (`"ctrl+s"`, `"?"`, `"escape"`) or a structured descriptor.
|
|
35
|
-
*/
|
|
33
|
+
* Bind a keyboard shortcut to a callback. Accepts either a short string
|
|
34
|
+
* (`"ctrl+s"`, `"?"`, `"escape"`) or a structured descriptor.
|
|
35
|
+
*/
|
|
36
36
|
declare const useHotkey: (shortcut: HotkeyDescriptor | string, callback: () => void, options?: UseHotkeyOptions) => void;
|
|
37
37
|
export { HotkeyDescriptor, UseHotkeyOptions, useHotkey as default, useHotkey };
|