@flyingrobots/bijou-tui 0.10.0 → 1.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 +25 -0
- package/dist/accordion.d.ts +46 -5
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +41 -5
- package/dist/accordion.js.map +1 -1
- package/dist/animate.d.ts +30 -0
- package/dist/animate.d.ts.map +1 -1
- package/dist/animate.js +33 -0
- package/dist/animate.js.map +1 -1
- package/dist/browsable-list.d.ts +67 -4
- package/dist/browsable-list.d.ts.map +1 -1
- package/dist/browsable-list.js +49 -4
- package/dist/browsable-list.js.map +1 -1
- package/dist/canvas.d.ts +13 -4
- package/dist/canvas.d.ts.map +1 -1
- package/dist/canvas.js +9 -3
- package/dist/canvas.js.map +1 -1
- package/dist/command-palette.d.ts +67 -6
- package/dist/command-palette.d.ts.map +1 -1
- package/dist/command-palette.js +67 -6
- package/dist/command-palette.js.map +1 -1
- package/dist/commands.d.ts +32 -3
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +32 -3
- package/dist/commands.js.map +1 -1
- package/dist/dag-pane.d.ts +225 -0
- package/dist/dag-pane.d.ts.map +1 -0
- package/dist/dag-pane.js +510 -0
- package/dist/dag-pane.js.map +1 -0
- package/dist/driver.d.ts +14 -0
- package/dist/driver.d.ts.map +1 -1
- package/dist/driver.js +7 -0
- package/dist/driver.js.map +1 -1
- package/dist/eventbus.d.ts +43 -6
- package/dist/eventbus.d.ts.map +1 -1
- package/dist/eventbus.js +9 -0
- package/dist/eventbus.js.map +1 -1
- package/dist/file-picker.d.ts +56 -4
- package/dist/file-picker.d.ts.map +1 -1
- package/dist/file-picker.js +52 -4
- package/dist/file-picker.js.map +1 -1
- package/dist/flex.d.ts +17 -0
- package/dist/flex.d.ts.map +1 -1
- package/dist/flex.js +106 -12
- package/dist/flex.js.map +1 -1
- package/dist/focus-area.d.ts +179 -0
- package/dist/focus-area.d.ts.map +1 -0
- package/dist/focus-area.js +261 -0
- package/dist/focus-area.js.map +1 -0
- package/dist/help.d.ts +16 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +13 -0
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/inputstack.d.ts +32 -4
- package/dist/inputstack.d.ts.map +1 -1
- package/dist/inputstack.js +11 -0
- package/dist/inputstack.js.map +1 -1
- package/dist/keybindings.d.ts +106 -14
- package/dist/keybindings.d.ts.map +1 -1
- package/dist/keybindings.js +28 -2
- package/dist/keybindings.js.map +1 -1
- package/dist/keys.d.ts +24 -8
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +34 -9
- package/dist/keys.js.map +1 -1
- package/dist/layout.d.ts +26 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +25 -1
- package/dist/layout.js.map +1 -1
- package/dist/navigable-table.d.ts +48 -4
- package/dist/navigable-table.d.ts.map +1 -1
- package/dist/navigable-table.js +44 -4
- package/dist/navigable-table.js.map +1 -1
- package/dist/overlay.d.ts +110 -3
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +87 -7
- package/dist/overlay.js.map +1 -1
- package/dist/pager.d.ts +66 -7
- package/dist/pager.d.ts.map +1 -1
- package/dist/pager.js +56 -7
- package/dist/pager.js.map +1 -1
- package/dist/panels.d.ts +55 -0
- package/dist/panels.d.ts.map +1 -1
- package/dist/panels.js +11 -0
- package/dist/panels.js.map +1 -1
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -0
- package/dist/runtime.js.map +1 -1
- package/dist/screen.d.ts +37 -3
- package/dist/screen.d.ts.map +1 -1
- package/dist/screen.js +37 -3
- package/dist/screen.js.map +1 -1
- package/dist/spring.d.ts +56 -7
- package/dist/spring.d.ts.map +1 -1
- package/dist/spring.js +44 -7
- package/dist/spring.js.map +1 -1
- package/dist/status-bar.d.ts +15 -2
- package/dist/status-bar.d.ts.map +1 -1
- package/dist/status-bar.js +9 -0
- package/dist/status-bar.js.map +1 -1
- package/dist/timeline.d.ts +68 -5
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +33 -0
- package/dist/timeline.js.map +1 -1
- package/dist/types.d.ts +86 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +27 -3
- package/dist/types.js.map +1 -1
- package/dist/viewport.d.ts +71 -11
- package/dist/viewport.d.ts.map +1 -1
- package/dist/viewport.js +79 -11
- package/dist/viewport.js.map +1 -1
- package/package.json +2 -2
package/dist/canvas.d.ts
CHANGED
|
@@ -13,9 +13,12 @@ import { type BijouContext } from '@flyingrobots/bijou';
|
|
|
13
13
|
* @param cols Total number of columns.
|
|
14
14
|
* @param rows Total number of rows.
|
|
15
15
|
* @param time Animation time value.
|
|
16
|
-
* @returns A single character (or string — only the first
|
|
16
|
+
* @returns A single character (or string — only the first code point is used).
|
|
17
17
|
*/
|
|
18
18
|
export type ShaderFn = (x: number, y: number, cols: number, rows: number, time: number) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Options for the {@link canvas} renderer.
|
|
21
|
+
*/
|
|
19
22
|
export interface CanvasOptions {
|
|
20
23
|
/** Animation time value passed to the shader. Default: 0. */
|
|
21
24
|
time?: number;
|
|
@@ -24,10 +27,16 @@ export interface CanvasOptions {
|
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Render a character grid by calling `shader(x, y, cols, rows, time)` for
|
|
27
|
-
* every cell.
|
|
30
|
+
* every cell. Return a string of exactly `rows` lines, each `cols` chars wide.
|
|
31
|
+
*
|
|
32
|
+
* In pipe or accessible mode, return empty string (no visual noise).
|
|
33
|
+
* Return empty string when cols or rows are <= 0.
|
|
28
34
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
35
|
+
* @param cols - Number of columns (grid width).
|
|
36
|
+
* @param rows - Number of rows (grid height).
|
|
37
|
+
* @param shader - Function called once per cell to produce a character.
|
|
38
|
+
* @param options - Optional canvas settings (time, context).
|
|
39
|
+
* @returns Rendered grid string with lines joined by newlines, or empty string.
|
|
31
40
|
*/
|
|
32
41
|
export declare function canvas(cols: number, rows: number, shader: ShaderFn, options?: CanvasOptions): string;
|
|
33
42
|
//# sourceMappingURL=canvas.d.ts.map
|
package/dist/canvas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE3E;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG,CACrB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,KACT,MAAM,CAAC;AAEZ,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED
|
|
1
|
+
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE3E;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG,CACrB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,KACT,MAAM,CAAC;AAEZ;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAqBR"}
|
package/dist/canvas.js
CHANGED
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
import { getDefaultContext } from '@flyingrobots/bijou';
|
|
8
8
|
/**
|
|
9
9
|
* Render a character grid by calling `shader(x, y, cols, rows, time)` for
|
|
10
|
-
* every cell.
|
|
10
|
+
* every cell. Return a string of exactly `rows` lines, each `cols` chars wide.
|
|
11
11
|
*
|
|
12
|
-
* In pipe or accessible mode,
|
|
13
|
-
*
|
|
12
|
+
* In pipe or accessible mode, return empty string (no visual noise).
|
|
13
|
+
* Return empty string when cols or rows are <= 0.
|
|
14
|
+
*
|
|
15
|
+
* @param cols - Number of columns (grid width).
|
|
16
|
+
* @param rows - Number of rows (grid height).
|
|
17
|
+
* @param shader - Function called once per cell to produce a character.
|
|
18
|
+
* @param options - Optional canvas settings (time, context).
|
|
19
|
+
* @returns Rendered grid string with lines joined by newlines, or empty string.
|
|
14
20
|
*/
|
|
15
21
|
export function canvas(cols, rows, shader, options) {
|
|
16
22
|
if (cols <= 0 || rows <= 0)
|
package/dist/canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AA8B3E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CACpB,IAAY,EACZ,IAAY,EACZ,MAAgB,EAChB,OAAuB;IAEvB,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAEtC,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAChD,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,EAAE,CAAC;IAChE,mDAAmD;IAEnD,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC1C,2CAA2C;YAC3C,IAAI,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACpD,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -21,43 +21,96 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import type { BijouContext } from '@flyingrobots/bijou';
|
|
23
23
|
import { type KeyMap } from './keybindings.js';
|
|
24
|
+
/** A single item in the command palette. */
|
|
24
25
|
export interface CommandPaletteItem {
|
|
26
|
+
/** Unique identifier for the command. */
|
|
25
27
|
readonly id: string;
|
|
28
|
+
/** Display label shown in the list. */
|
|
26
29
|
readonly label: string;
|
|
30
|
+
/** Optional description displayed after the label. */
|
|
27
31
|
readonly description?: string;
|
|
32
|
+
/** Optional category shown in brackets before the label. */
|
|
28
33
|
readonly category?: string;
|
|
34
|
+
/** Optional keyboard shortcut hint displayed at the end. */
|
|
29
35
|
readonly shortcut?: string;
|
|
30
36
|
}
|
|
37
|
+
/** Immutable state for the command palette widget. */
|
|
31
38
|
export interface CommandPaletteState {
|
|
39
|
+
/** All registered command items (unfiltered). */
|
|
32
40
|
readonly items: readonly CommandPaletteItem[];
|
|
41
|
+
/** Items matching the current query. */
|
|
33
42
|
readonly filteredItems: readonly CommandPaletteItem[];
|
|
43
|
+
/** Current filter query string. */
|
|
34
44
|
readonly query: string;
|
|
45
|
+
/** Index of the focused item within `filteredItems`. */
|
|
35
46
|
readonly focusIndex: number;
|
|
47
|
+
/** Vertical scroll offset (first visible item index). */
|
|
36
48
|
readonly scrollY: number;
|
|
49
|
+
/** Maximum number of visible items. */
|
|
37
50
|
readonly height: number;
|
|
38
51
|
}
|
|
52
|
+
/** Options for rendering the command palette view. */
|
|
39
53
|
export interface CommandPaletteOptions {
|
|
54
|
+
/** Total width in columns. */
|
|
40
55
|
readonly width: number;
|
|
56
|
+
/** Show item categories in brackets (default: true). */
|
|
41
57
|
readonly showCategory?: boolean;
|
|
58
|
+
/** Show shortcut hints (default: true). */
|
|
42
59
|
readonly showShortcut?: boolean;
|
|
60
|
+
/** Bijou context for theming and styling. */
|
|
43
61
|
readonly ctx?: BijouContext;
|
|
44
62
|
}
|
|
45
63
|
/**
|
|
46
64
|
* Create initial command palette state from items and optional height.
|
|
47
65
|
* Focus starts at index 0 with empty query showing all items.
|
|
66
|
+
*
|
|
67
|
+
* @param items - Command items to populate the palette.
|
|
68
|
+
* @param height - Maximum number of visible items (default: 10).
|
|
69
|
+
* @returns Fresh command palette state with all items visible.
|
|
48
70
|
*/
|
|
49
71
|
export declare function createCommandPaletteState(items: readonly CommandPaletteItem[], height?: number): CommandPaletteState;
|
|
50
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Filter items by case-insensitive substring match. Resets focus to 0.
|
|
74
|
+
*
|
|
75
|
+
* @param state - Current command palette state.
|
|
76
|
+
* @param query - Search query (empty string shows all items).
|
|
77
|
+
* @returns Updated state with filtered items and focus reset.
|
|
78
|
+
*/
|
|
51
79
|
export declare function cpFilter(state: CommandPaletteState, query: string): CommandPaletteState;
|
|
52
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Move focus to the next item (wraps around on filteredItems).
|
|
82
|
+
*
|
|
83
|
+
* @param state - Current command palette state.
|
|
84
|
+
* @returns Updated state with focus on the next item.
|
|
85
|
+
*/
|
|
53
86
|
export declare function cpFocusNext(state: CommandPaletteState): CommandPaletteState;
|
|
54
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Move focus to the previous item (wraps around on filteredItems).
|
|
89
|
+
*
|
|
90
|
+
* @param state - Current command palette state.
|
|
91
|
+
* @returns Updated state with focus on the previous item.
|
|
92
|
+
*/
|
|
55
93
|
export declare function cpFocusPrev(state: CommandPaletteState): CommandPaletteState;
|
|
56
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Move focus down by half a page (vim Ctrl+D convention, clamps to last item).
|
|
96
|
+
*
|
|
97
|
+
* @param state - Current command palette state.
|
|
98
|
+
* @returns Updated state with focus advanced by half a page.
|
|
99
|
+
*/
|
|
57
100
|
export declare function cpPageDown(state: CommandPaletteState): CommandPaletteState;
|
|
58
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Move focus up by half a page (vim Ctrl+U convention, clamps to first item).
|
|
103
|
+
*
|
|
104
|
+
* @param state - Current command palette state.
|
|
105
|
+
* @returns Updated state with focus moved back by half a page.
|
|
106
|
+
*/
|
|
59
107
|
export declare function cpPageUp(state: CommandPaletteState): CommandPaletteState;
|
|
60
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Get the currently focused item, or undefined if no items match.
|
|
110
|
+
*
|
|
111
|
+
* @param state - Current command palette state.
|
|
112
|
+
* @returns The focused `CommandPaletteItem`, or `undefined` if empty.
|
|
113
|
+
*/
|
|
61
114
|
export declare function cpSelectedItem(state: CommandPaletteState): CommandPaletteItem | undefined;
|
|
62
115
|
/**
|
|
63
116
|
* Render the command palette — a search line followed by filtered items
|
|
@@ -68,6 +121,10 @@ export declare function cpSelectedItem(state: CommandPaletteState): CommandPalet
|
|
|
68
121
|
* - Lines 2+: filtered items in viewport
|
|
69
122
|
* - Each item: `[category] label description shortcut`
|
|
70
123
|
* - Focus indicator: `▸` on focused item
|
|
124
|
+
*
|
|
125
|
+
* @param state - Current command palette state.
|
|
126
|
+
* @param options - Width, display flags, and context for rendering.
|
|
127
|
+
* @returns Rendered command palette string with search line and item list.
|
|
71
128
|
*/
|
|
72
129
|
export declare function commandPalette(state: CommandPaletteState, options: CommandPaletteOptions): string;
|
|
73
130
|
/**
|
|
@@ -89,6 +146,10 @@ export declare function commandPalette(state: CommandPaletteState, options: Comm
|
|
|
89
146
|
* close: { type: 'cp-close' },
|
|
90
147
|
* });
|
|
91
148
|
* ```
|
|
149
|
+
*
|
|
150
|
+
* @template Msg - Application message type dispatched by key bindings.
|
|
151
|
+
* @param actions - Map of navigation and selection actions to message values.
|
|
152
|
+
* @returns Preconfigured key map with Ctrl+N/P, arrow, and page navigation bindings.
|
|
92
153
|
*/
|
|
93
154
|
export declare function commandPaletteKeyMap<Msg>(actions: {
|
|
94
155
|
focusNext: Msg;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../src/command-palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAO7D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EA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mBAAmB,GAAG,mBAAmB,CAI3E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAK1E;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAKxE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,kBAAkB,GAAG,SAAS,CAEzF;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,qBAAqB,GAC7B,MAAM,CAiDR;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE;IACjD,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,GAAG,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,GAAG,CAAC;CACZ,GAAG,MAAM,CAAC,GAAG,CAAC,CAcd"}
|
package/dist/command-palette.js
CHANGED
|
@@ -27,6 +27,10 @@ import { clipToWidth } from './viewport.js';
|
|
|
27
27
|
/**
|
|
28
28
|
* Create initial command palette state from items and optional height.
|
|
29
29
|
* Focus starts at index 0 with empty query showing all items.
|
|
30
|
+
*
|
|
31
|
+
* @param items - Command items to populate the palette.
|
|
32
|
+
* @param height - Maximum number of visible items (default: 10).
|
|
33
|
+
* @returns Fresh command palette state with all items visible.
|
|
30
34
|
*/
|
|
31
35
|
export function createCommandPaletteState(items, height = 10) {
|
|
32
36
|
const h = Math.max(1, height);
|
|
@@ -43,6 +47,15 @@ export function createCommandPaletteState(items, height = 10) {
|
|
|
43
47
|
// ---------------------------------------------------------------------------
|
|
44
48
|
// Filtering
|
|
45
49
|
// ---------------------------------------------------------------------------
|
|
50
|
+
/**
|
|
51
|
+
* Test whether an item matches a search query (case-insensitive substring).
|
|
52
|
+
*
|
|
53
|
+
* Checks label, description, category, id, and shortcut fields.
|
|
54
|
+
*
|
|
55
|
+
* @param item - Command palette item to test.
|
|
56
|
+
* @param query - Search query string.
|
|
57
|
+
* @returns True if any field contains the query.
|
|
58
|
+
*/
|
|
46
59
|
function matchesQuery(item, query) {
|
|
47
60
|
const q = query.toLowerCase();
|
|
48
61
|
if (item.label.toLowerCase().includes(q))
|
|
@@ -57,7 +70,13 @@ function matchesQuery(item, query) {
|
|
|
57
70
|
return true;
|
|
58
71
|
return false;
|
|
59
72
|
}
|
|
60
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Filter items by case-insensitive substring match. Resets focus to 0.
|
|
75
|
+
*
|
|
76
|
+
* @param state - Current command palette state.
|
|
77
|
+
* @param query - Search query (empty string shows all items).
|
|
78
|
+
* @returns Updated state with filtered items and focus reset.
|
|
79
|
+
*/
|
|
61
80
|
export function cpFilter(state, query) {
|
|
62
81
|
if (query === '') {
|
|
63
82
|
return {
|
|
@@ -80,6 +99,15 @@ export function cpFilter(state, query) {
|
|
|
80
99
|
// ---------------------------------------------------------------------------
|
|
81
100
|
// Focus navigation
|
|
82
101
|
// ---------------------------------------------------------------------------
|
|
102
|
+
/**
|
|
103
|
+
* Clamp scroll position so the focused item stays within the visible window.
|
|
104
|
+
*
|
|
105
|
+
* @param focusIndex - Index of the focused item.
|
|
106
|
+
* @param scrollY - Current scroll offset.
|
|
107
|
+
* @param height - Viewport height in items.
|
|
108
|
+
* @param total - Total number of items.
|
|
109
|
+
* @returns Adjusted scroll offset.
|
|
110
|
+
*/
|
|
83
111
|
function adjustScroll(focusIndex, scrollY, height, total) {
|
|
84
112
|
let s = scrollY;
|
|
85
113
|
if (focusIndex < s)
|
|
@@ -88,21 +116,36 @@ function adjustScroll(focusIndex, scrollY, height, total) {
|
|
|
88
116
|
s = focusIndex - height + 1;
|
|
89
117
|
return Math.min(s, Math.max(0, total - height));
|
|
90
118
|
}
|
|
91
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Move focus to the next item (wraps around on filteredItems).
|
|
121
|
+
*
|
|
122
|
+
* @param state - Current command palette state.
|
|
123
|
+
* @returns Updated state with focus on the next item.
|
|
124
|
+
*/
|
|
92
125
|
export function cpFocusNext(state) {
|
|
93
126
|
if (state.filteredItems.length === 0)
|
|
94
127
|
return state;
|
|
95
128
|
const focusIndex = (state.focusIndex + 1) % state.filteredItems.length;
|
|
96
129
|
return { ...state, focusIndex, scrollY: adjustScroll(focusIndex, state.scrollY, state.height, state.filteredItems.length) };
|
|
97
130
|
}
|
|
98
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Move focus to the previous item (wraps around on filteredItems).
|
|
133
|
+
*
|
|
134
|
+
* @param state - Current command palette state.
|
|
135
|
+
* @returns Updated state with focus on the previous item.
|
|
136
|
+
*/
|
|
99
137
|
export function cpFocusPrev(state) {
|
|
100
138
|
if (state.filteredItems.length === 0)
|
|
101
139
|
return state;
|
|
102
140
|
const focusIndex = (state.focusIndex - 1 + state.filteredItems.length) % state.filteredItems.length;
|
|
103
141
|
return { ...state, focusIndex, scrollY: adjustScroll(focusIndex, state.scrollY, state.height, state.filteredItems.length) };
|
|
104
142
|
}
|
|
105
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Move focus down by half a page (vim Ctrl+D convention, clamps to last item).
|
|
145
|
+
*
|
|
146
|
+
* @param state - Current command palette state.
|
|
147
|
+
* @returns Updated state with focus advanced by half a page.
|
|
148
|
+
*/
|
|
106
149
|
export function cpPageDown(state) {
|
|
107
150
|
if (state.filteredItems.length === 0)
|
|
108
151
|
return state;
|
|
@@ -110,7 +153,12 @@ export function cpPageDown(state) {
|
|
|
110
153
|
const focusIndex = Math.min(state.focusIndex + half, state.filteredItems.length - 1);
|
|
111
154
|
return { ...state, focusIndex, scrollY: adjustScroll(focusIndex, state.scrollY, state.height, state.filteredItems.length) };
|
|
112
155
|
}
|
|
113
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Move focus up by half a page (vim Ctrl+U convention, clamps to first item).
|
|
158
|
+
*
|
|
159
|
+
* @param state - Current command palette state.
|
|
160
|
+
* @returns Updated state with focus moved back by half a page.
|
|
161
|
+
*/
|
|
114
162
|
export function cpPageUp(state) {
|
|
115
163
|
if (state.filteredItems.length === 0)
|
|
116
164
|
return state;
|
|
@@ -118,7 +166,12 @@ export function cpPageUp(state) {
|
|
|
118
166
|
const focusIndex = Math.max(state.focusIndex - half, 0);
|
|
119
167
|
return { ...state, focusIndex, scrollY: adjustScroll(focusIndex, state.scrollY, state.height, state.filteredItems.length) };
|
|
120
168
|
}
|
|
121
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* Get the currently focused item, or undefined if no items match.
|
|
171
|
+
*
|
|
172
|
+
* @param state - Current command palette state.
|
|
173
|
+
* @returns The focused `CommandPaletteItem`, or `undefined` if empty.
|
|
174
|
+
*/
|
|
122
175
|
export function cpSelectedItem(state) {
|
|
123
176
|
return state.filteredItems[state.focusIndex];
|
|
124
177
|
}
|
|
@@ -134,6 +187,10 @@ export function cpSelectedItem(state) {
|
|
|
134
187
|
* - Lines 2+: filtered items in viewport
|
|
135
188
|
* - Each item: `[category] label description shortcut`
|
|
136
189
|
* - Focus indicator: `▸` on focused item
|
|
190
|
+
*
|
|
191
|
+
* @param state - Current command palette state.
|
|
192
|
+
* @param options - Width, display flags, and context for rendering.
|
|
193
|
+
* @returns Rendered command palette string with search line and item list.
|
|
137
194
|
*/
|
|
138
195
|
export function commandPalette(state, options) {
|
|
139
196
|
const { width, showCategory = true, showShortcut = true, ctx } = options;
|
|
@@ -194,6 +251,10 @@ export function commandPalette(state, options) {
|
|
|
194
251
|
* close: { type: 'cp-close' },
|
|
195
252
|
* });
|
|
196
253
|
* ```
|
|
254
|
+
*
|
|
255
|
+
* @template Msg - Application message type dispatched by key bindings.
|
|
256
|
+
* @param actions - Map of navigation and selection actions to message values.
|
|
257
|
+
* @returns Preconfigured key map with Ctrl+N/P, arrow, and page navigation bindings.
|
|
197
258
|
*/
|
|
198
259
|
export function commandPaletteKeyMap(actions) {
|
|
199
260
|
return createKeyMap()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-palette.js","sourceRoot":"","sources":["../src/command-palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"command-palette.js","sourceRoot":"","sources":["../src/command-palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgD5C,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAoC,EACpC,MAAM,GAAG,EAAE;IAEX,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAC1B,OAAO;QACL,KAAK,EAAE,MAAM;QACb,aAAa,EAAE,MAAM;QACrB,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,CAAC;KACV,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,IAAwB,EAAE,KAAa;IAC3D,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAC9B,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,C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C1B,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC;SAC9C,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC;SAC5C,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,CAAC,SAAS,CAAC;SAClD,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,SAAS,CAAC;SAC9C,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,CAAC,QAAQ,CAAC;SAClD,IAAI,CAAC,UAAU,EAAE,gBAAgB,EAAE,OAAO,CAAC,QAAQ,CAAC;SACpD,IAAI,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC;SAC9C,IAAI,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,CAChD;SACA,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC;SACvC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/commands.d.ts
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in command factories for the TEA runtime.
|
|
3
|
+
*
|
|
4
|
+
* Provide standard side effects: quitting the application, delayed message
|
|
5
|
+
* delivery, and batching multiple commands.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
1
9
|
import { type Cmd } from './types.js';
|
|
2
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Create a command that signals the runtime to quit.
|
|
12
|
+
*
|
|
13
|
+
* @template M - Application message type.
|
|
14
|
+
* @returns A command that resolves to the {@link QUIT} sentinel.
|
|
15
|
+
*/
|
|
3
16
|
export declare function quit<M>(): Cmd<M>;
|
|
4
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Create a command that delivers a message after a delay.
|
|
19
|
+
*
|
|
20
|
+
* @template M - Application message type.
|
|
21
|
+
* @param ms - Delay in milliseconds before delivering the message.
|
|
22
|
+
* @param msg - Message to deliver after the delay.
|
|
23
|
+
* @returns A one-shot timer command.
|
|
24
|
+
*/
|
|
5
25
|
export declare function tick<M>(ms: number, msg: M): Cmd<M>;
|
|
6
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Group multiple commands into an array.
|
|
28
|
+
*
|
|
29
|
+
* Convenience wrapper that collects variadic commands into a `Cmd<M>[]`
|
|
30
|
+
* suitable for returning from `init()` or `update()`.
|
|
31
|
+
*
|
|
32
|
+
* @template M - Application message type.
|
|
33
|
+
* @param cmds - Commands to batch.
|
|
34
|
+
* @returns Array of commands.
|
|
35
|
+
*/
|
|
7
36
|
export declare function batch<M>(...cmds: Cmd<M>[]): Cmd<M>[];
|
|
8
37
|
//# sourceMappingURL=commands.d.ts.map
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAmB,MAAM,YAAY,CAAC;AAE7D
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAQ,KAAK,GAAG,EAAmB,MAAM,YAAY,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAEhC;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAKlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAEpD"}
|
package/dist/commands.js
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in command factories for the TEA runtime.
|
|
3
|
+
*
|
|
4
|
+
* Provide standard side effects: quitting the application, delayed message
|
|
5
|
+
* delivery, and batching multiple commands.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
1
9
|
import { QUIT } from './types.js';
|
|
2
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Create a command that signals the runtime to quit.
|
|
12
|
+
*
|
|
13
|
+
* @template M - Application message type.
|
|
14
|
+
* @returns A command that resolves to the {@link QUIT} sentinel.
|
|
15
|
+
*/
|
|
3
16
|
export function quit() {
|
|
4
17
|
return async (_emit) => QUIT;
|
|
5
18
|
}
|
|
6
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Create a command that delivers a message after a delay.
|
|
21
|
+
*
|
|
22
|
+
* @template M - Application message type.
|
|
23
|
+
* @param ms - Delay in milliseconds before delivering the message.
|
|
24
|
+
* @param msg - Message to deliver after the delay.
|
|
25
|
+
* @returns A one-shot timer command.
|
|
26
|
+
*/
|
|
7
27
|
export function tick(ms, msg) {
|
|
8
28
|
return (_emit) => new Promise((resolve) => {
|
|
9
29
|
setTimeout(() => resolve(msg), ms);
|
|
10
30
|
});
|
|
11
31
|
}
|
|
12
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Group multiple commands into an array.
|
|
34
|
+
*
|
|
35
|
+
* Convenience wrapper that collects variadic commands into a `Cmd<M>[]`
|
|
36
|
+
* suitable for returning from `init()` or `update()`.
|
|
37
|
+
*
|
|
38
|
+
* @template M - Application message type.
|
|
39
|
+
* @param cmds - Commands to batch.
|
|
40
|
+
* @returns Array of commands.
|
|
41
|
+
*/
|
|
13
42
|
export function batch(...cmds) {
|
|
14
43
|
return cmds;
|
|
15
44
|
}
|
package/dist/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA6B,MAAM,YAAY,CAAC;AAE7D
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAA6B,MAAM,YAAY,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,UAAU,IAAI;IAClB,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAkB,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAI,EAAU,EAAE,GAAM;IACxC,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,EAAE;QACzB,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CAAI,GAAG,IAAc;IACxC,OAAO,IAAI,CAAC;AACd,CAAC"}
|