iskills 0.2.41 → 0.2.45
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 +120 -26
- package/README.zh-CN.md +142 -0
- package/bin/iskills.js +77 -2
- package/bin/opentui-register.mjs +10 -0
- package/bin/opentui-resolve-hook.mjs +12 -0
- package/bin/patch-react-reconciler.mjs +71 -0
- package/dist/src/cli.js +7 -5
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/browser-actions.js +31 -31
- package/dist/src/commands/browser-actions.js.map +1 -1
- package/dist/src/commands/create.d.ts +1 -0
- package/dist/src/commands/create.js +36 -0
- package/dist/src/commands/create.js.map +1 -0
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +28 -9
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/library.js +15 -28
- package/dist/src/commands/library.js.map +1 -1
- package/dist/src/domain/collection-write.d.ts +2 -0
- package/dist/src/domain/collection-write.js +44 -2
- package/dist/src/domain/collection-write.js.map +1 -1
- package/dist/src/domain/core.d.ts +29 -1
- package/dist/src/domain/core.js +125 -8
- package/dist/src/domain/core.js.map +1 -1
- package/dist/src/domain/types.d.ts +2 -0
- package/dist/src/ui/browser/browser.d.ts +2 -1
- package/dist/src/ui/browser/browser.js +179 -44
- package/dist/src/ui/browser/browser.js.map +1 -1
- package/dist/src/ui/browser/detail.d.ts +1 -1
- package/dist/src/ui/browser/detail.js +3 -3
- package/dist/src/ui/browser/detail.js.map +1 -1
- package/dist/src/ui/browser/footer.js +2 -2
- package/dist/src/ui/browser/footer.js.map +1 -1
- package/dist/src/ui/browser/format.d.ts +8 -6
- package/dist/src/ui/browser/format.js +13 -10
- package/dist/src/ui/browser/format.js.map +1 -1
- package/dist/src/ui/browser/index.js +9 -9
- package/dist/src/ui/browser/index.js.map +1 -1
- package/dist/src/ui/browser/layout.d.ts +1 -1
- package/dist/src/ui/browser/layout.js +1 -1
- package/dist/src/ui/browser/shortcut-help.d.ts +2 -0
- package/dist/src/ui/browser/shortcut-help.js +32 -12
- package/dist/src/ui/browser/shortcut-help.js.map +1 -1
- package/dist/src/ui/browser/types.d.ts +1 -1
- package/dist/src/ui/collection-match.js +1 -1
- package/dist/src/ui/collection-match.js.map +1 -1
- package/dist/src/ui/components/colors.d.ts +55 -5
- package/dist/src/ui/components/colors.js +58 -6
- package/dist/src/ui/components/colors.js.map +1 -1
- package/dist/src/ui/components/confirm.js +2 -2
- package/dist/src/ui/components/confirm.js.map +1 -1
- package/dist/src/ui/components/framed-panel.d.ts +3 -3
- package/dist/src/ui/components/framed-panel.js +29 -11
- package/dist/src/ui/components/framed-panel.js.map +1 -1
- package/dist/src/ui/components/link.js +13 -8
- package/dist/src/ui/components/link.js.map +1 -1
- package/dist/src/ui/components/modal-panel.d.ts +9 -0
- package/dist/src/ui/components/modal-panel.js +8 -0
- package/dist/src/ui/components/modal-panel.js.map +1 -0
- package/dist/src/ui/components/modal.js +3 -3
- package/dist/src/ui/components/modal.js.map +1 -1
- package/dist/src/ui/components/mouse/bounds.d.ts +1 -6
- package/dist/src/ui/components/mouse/bounds.js +1 -22
- package/dist/src/ui/components/mouse/bounds.js.map +1 -1
- package/dist/src/ui/components/mouse/clickable.d.ts +6 -4
- package/dist/src/ui/components/mouse/clickable.js +26 -10
- package/dist/src/ui/components/mouse/clickable.js.map +1 -1
- package/dist/src/ui/components/mouse/index.d.ts +2 -2
- package/dist/src/ui/components/mouse/index.js +2 -2
- package/dist/src/ui/components/mouse/index.js.map +1 -1
- package/dist/src/ui/components/mouse/parse.d.ts +1 -1
- package/dist/src/ui/components/mouse/parse.js +3 -3
- package/dist/src/ui/components/mouse/parse.js.map +1 -1
- package/dist/src/ui/components/mouse/provider.d.ts +17 -15
- package/dist/src/ui/components/mouse/provider.js +29 -85
- package/dist/src/ui/components/mouse/provider.js.map +1 -1
- package/dist/src/ui/components/multi-select.js +23 -7
- package/dist/src/ui/components/multi-select.js.map +1 -1
- package/dist/src/ui/components/options.d.ts +2 -1
- package/dist/src/ui/components/options.js +2 -1
- package/dist/src/ui/components/options.js.map +1 -1
- package/dist/src/ui/components/select.d.ts +4 -0
- package/dist/src/ui/components/select.js +31 -34
- package/dist/src/ui/components/select.js.map +1 -1
- package/dist/src/ui/components/spinner.d.ts +16 -0
- package/dist/src/ui/components/spinner.js +45 -0
- package/dist/src/ui/components/spinner.js.map +1 -0
- package/dist/src/ui/components/tabs.js +10 -6
- package/dist/src/ui/components/tabs.js.map +1 -1
- package/dist/src/ui/components/tag-editor.js +8 -5
- package/dist/src/ui/components/tag-editor.js.map +1 -1
- package/dist/src/ui/components/termcn.d.ts +3 -1
- package/dist/src/ui/components/termcn.js +5 -3
- package/dist/src/ui/components/termcn.js.map +1 -1
- package/dist/src/ui/components/text-input.d.ts +4 -0
- package/dist/src/ui/components/text-input.js +29 -69
- package/dist/src/ui/components/text-input.js.map +1 -1
- package/dist/src/ui/components/use-input.d.ts +21 -7
- package/dist/src/ui/components/use-input.js +61 -9
- package/dist/src/ui/components/use-input.js.map +1 -1
- package/dist/src/ui/import/review.js +13 -7
- package/dist/src/ui/import/review.js.map +1 -1
- package/dist/src/ui/import/skill-select.js +37 -7
- package/dist/src/ui/import/skill-select.js.map +1 -1
- package/dist/src/ui/import/types.d.ts +1 -1
- package/dist/src/ui/install/review.js +15 -10
- package/dist/src/ui/install/review.js.map +1 -1
- package/dist/src/ui/install/types.d.ts +4 -6
- package/dist/src/ui/install/types.js +1 -1
- package/dist/src/ui/overlay/bridge.js +4 -0
- package/dist/src/ui/overlay/bridge.js.map +1 -1
- package/dist/src/ui/overlay/dialogs.js +1 -1
- package/dist/src/ui/overlay/host.js +4 -4
- package/dist/src/ui/overlay/host.js.map +1 -1
- package/dist/src/ui/prompts/present.d.ts +1 -1
- package/dist/src/ui/prompts/present.js +4 -3
- package/dist/src/ui/prompts/present.js.map +1 -1
- package/dist/src/ui/search/index.js +7 -6
- package/dist/src/ui/search/index.js.map +1 -1
- package/dist/src/ui/shell/app-shell.d.ts +1 -1
- package/dist/src/ui/shell/app-shell.js +4 -6
- package/dist/src/ui/shell/app-shell.js.map +1 -1
- package/dist/src/ui/shell/footer.js +5 -8
- package/dist/src/ui/shell/footer.js.map +1 -1
- package/dist/src/ui/shell/lifecycle.d.ts +12 -0
- package/dist/src/ui/shell/lifecycle.js +30 -0
- package/dist/src/ui/shell/lifecycle.js.map +1 -0
- package/dist/src/ui/shell/run.d.ts +35 -10
- package/dist/src/ui/shell/run.js +175 -88
- package/dist/src/ui/shell/run.js.map +1 -1
- package/dist/src/ui/shell/terminal.d.ts +1 -1
- package/dist/src/ui/shell/terminal.js +1 -1
- package/dist/src/ui/tui/hooks.d.ts +45 -0
- package/dist/src/ui/tui/hooks.js +79 -0
- package/dist/src/ui/tui/hooks.js.map +1 -0
- package/dist/src/ui/tui/index.d.ts +2 -0
- package/dist/src/ui/tui/index.js +3 -0
- package/dist/src/ui/tui/index.js.map +1 -0
- package/dist/src/ui/tui/primitives.d.ts +12 -0
- package/dist/src/ui/tui/primitives.js +56 -0
- package/dist/src/ui/tui/primitives.js.map +1 -0
- package/dist/src/util/open-path.d.ts +2 -0
- package/dist/src/util/open-path.js +27 -0
- package/dist/src/util/open-path.js.map +1 -0
- package/package.json +11 -8
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import type { DOMElement } from 'ink';
|
|
2
1
|
export type ElementBounds = {
|
|
3
2
|
left: number;
|
|
4
3
|
top: number;
|
|
5
4
|
width: number;
|
|
6
5
|
height: number;
|
|
7
6
|
};
|
|
8
|
-
/**
|
|
9
|
-
* Absolute terminal cell bounds (1-based, same as mouse reports).
|
|
10
|
-
* Walks yoga parents — Ink only stores relative layout.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getElementBounds(node: DOMElement | null | undefined): ElementBounds | null;
|
|
7
|
+
/** Half-open on the right and bottom edges (x in [left, left+width)). */
|
|
13
8
|
export declare function pointInBounds(x: number, y: number, bounds: ElementBounds): boolean;
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Absolute terminal cell bounds (1-based, same as mouse reports).
|
|
3
|
-
* Walks yoga parents — Ink only stores relative layout.
|
|
4
|
-
*/
|
|
5
|
-
export function getElementBounds(node) {
|
|
6
|
-
if (!node?.yogaNode)
|
|
7
|
-
return null;
|
|
8
|
-
let left = 1;
|
|
9
|
-
let top = 1;
|
|
10
|
-
let current = node;
|
|
11
|
-
while (current?.yogaNode) {
|
|
12
|
-
const layout = current.yogaNode.getComputedLayout();
|
|
13
|
-
left += layout.left;
|
|
14
|
-
top += layout.top;
|
|
15
|
-
current = current.parentNode;
|
|
16
|
-
}
|
|
17
|
-
const width = node.yogaNode.getComputedWidth();
|
|
18
|
-
const height = node.yogaNode.getComputedHeight();
|
|
19
|
-
if (width <= 0 || height <= 0)
|
|
20
|
-
return null;
|
|
21
|
-
return { left, top, width, height };
|
|
22
|
-
}
|
|
1
|
+
/** Half-open on the right and bottom edges (x in [left, left+width)). */
|
|
23
2
|
export function pointInBounds(x, y, bounds) {
|
|
24
3
|
return (x >= bounds.left &&
|
|
25
4
|
x < bounds.left + bounds.width &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/bounds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/bounds.ts"],"names":[],"mappings":"AAOA,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAC3B,CAAS,EACT,CAAS,EACT,MAAqB;IAErB,OAAO,CACL,CAAC,IAAI,MAAM,CAAC,IAAI;QAChB,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK;QAC9B,CAAC,IAAI,MAAM,CAAC,GAAG;QACf,CAAC,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
* Requires
|
|
2
|
+
* Click / hover target using OpenTUI native mouse handlers.
|
|
3
|
+
* Requires `createCliRenderer({ useMouse: true, enableMouseMovement: true })`.
|
|
5
4
|
*/
|
|
6
|
-
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
6
|
+
export declare function Clickable({ onClick, disabled, children, hover, }: {
|
|
7
7
|
onClick: () => void;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
children: ReactNode;
|
|
10
|
+
/** Soft solid background on mouse over (theme-aware; no alpha-on-black). */
|
|
11
|
+
hover?: boolean;
|
|
10
12
|
}): ReactNode;
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box } from 'ink';
|
|
3
|
-
import { useRef } from 'react';
|
|
4
|
-
import { useOnClick } from './provider.js';
|
|
1
|
+
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
5
2
|
/**
|
|
6
|
-
*
|
|
7
|
-
* Requires
|
|
3
|
+
* Click / hover target using OpenTUI native mouse handlers.
|
|
4
|
+
* Requires `createCliRenderer({ useMouse: true, enableMouseMovement: true })`.
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { useModalChrome } from '../../tui/hooks.js';
|
|
8
|
+
import { useMouseRegistry, usePointerSurfaceId, } from './provider.js';
|
|
9
|
+
export function Clickable({ onClick, disabled = false, children, hover = true, }) {
|
|
10
|
+
const surface = usePointerSurfaceId();
|
|
11
|
+
const registry = useMouseRegistry();
|
|
12
|
+
const chrome = useModalChrome();
|
|
13
|
+
const [hovered, setHovered] = useState(false);
|
|
14
|
+
const active = !disabled && (registry?.isTopSurface(surface) ?? true);
|
|
15
|
+
const showHover = hover && active && hovered;
|
|
16
|
+
if (disabled) {
|
|
17
|
+
return _jsx("box", { flexDirection: "row", children: children });
|
|
18
|
+
}
|
|
19
|
+
// Solid theme hover — low-alpha purple composites against black clear to #1b0d34.
|
|
20
|
+
const hoverBg = showHover ? { backgroundColor: chrome.hover } : {};
|
|
21
|
+
return (_jsx("box", { flexDirection: "row", ...hoverBg, onMouseOver: () => {
|
|
22
|
+
if (active)
|
|
23
|
+
setHovered(true);
|
|
24
|
+
}, onMouseOut: () => setHovered(false), onMouseDown: () => {
|
|
25
|
+
if (!active)
|
|
26
|
+
return;
|
|
27
|
+
onClick();
|
|
28
|
+
}, children: children }));
|
|
13
29
|
}
|
|
14
30
|
//# sourceMappingURL=clickable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickable.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/clickable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"clickable.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/clickable.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,SAAS,CAAC,EACxB,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,KAAK,GAAG,IAAI,GAOb;IACC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,MAAM,MAAM,GAAG,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,KAAK,IAAI,MAAM,IAAI,OAAO,CAAC;IAE7C,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,cAAK,aAAa,EAAC,KAAK,YAAE,QAAQ,GAAO,CAAC;IACnD,CAAC;IAED,kFAAkF;IAClF,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnE,OAAO,CACL,cAAK,aAAa,EAAC,KAAK,KAClB,OAAO,EACX,WAAW,EAAE,GAAG,EAAE;YAChB,IAAI,MAAM;gBAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,EACD,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EACnC,WAAW,EAAE,GAAG,EAAE;YAChB,IAAI,CAAC,MAAM;gBAAE,OAAO;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC,YAEA,QAAQ,GACL,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { pointInBounds, type ElementBounds } from './bounds.js';
|
|
2
2
|
export { Clickable } from './clickable.js';
|
|
3
3
|
export { isMouseInput, parseLeftPresses, type ParsedMousePress } from './parse.js';
|
|
4
|
-
export { MouseProvider, PointerSurface, POINTER_SURFACE_BASE, useOnClick, } from './provider.js';
|
|
4
|
+
export { MouseProvider, PointerSurface, POINTER_SURFACE_BASE, useOnClick, useMouseRegistry, usePointerSurfaceId, } from './provider.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { pointInBounds } from './bounds.js';
|
|
2
2
|
export { Clickable } from './clickable.js';
|
|
3
3
|
export { isMouseInput, parseLeftPresses } from './parse.js';
|
|
4
|
-
export { MouseProvider, PointerSurface, POINTER_SURFACE_BASE, useOnClick, } from './provider.js';
|
|
4
|
+
export { MouseProvider, PointerSurface, POINTER_SURFACE_BASE, useOnClick, useMouseRegistry, usePointerSurfaceId, } from './provider.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAyB,MAAM,YAAY,CAAC;AACnF,OAAO,EACL,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Terminal mouse report parsing (SGR + legacy).
|
|
3
|
-
*
|
|
3
|
+
* Mouse SGR parse; copy-owned.
|
|
4
4
|
*/
|
|
5
5
|
/** True when stdin chunk is (or contains) a mouse report — do not treat as key text. */
|
|
6
6
|
export declare function isMouseInput(input: string): boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Terminal mouse report parsing (SGR + legacy).
|
|
3
|
-
*
|
|
3
|
+
* Mouse SGR parse; copy-owned.
|
|
4
4
|
*/
|
|
5
5
|
/** True when stdin chunk is (or contains) a mouse report — do not treat as key text. */
|
|
6
6
|
export function isMouseInput(input) {
|
|
7
|
-
//
|
|
7
|
+
// Some consumers strip leading ESC; raw stdin keeps it.
|
|
8
8
|
return (/(?:\u001B)?\[<\d+;\d+;\d+[Mm]/.test(input) ||
|
|
9
9
|
/(?:\u001B)?\[M[\s\S]/.test(input) ||
|
|
10
10
|
input.startsWith('[<') ||
|
|
@@ -13,7 +13,7 @@ export function isMouseInput(input) {
|
|
|
13
13
|
/**
|
|
14
14
|
* SGR: CSI < button ; col ; row M/m
|
|
15
15
|
* Legacy: CSI M Cg Cx Cy (coords = byte - 32)
|
|
16
|
-
*
|
|
16
|
+
* Leading ESC may be stripped before handlers see the chunk.
|
|
17
17
|
*/
|
|
18
18
|
const SGR = /(?:\u001B)?\[<(\d+);(\d+);(\d+)([Mm])/g;
|
|
19
19
|
const LEGACY = /(?:\u001B)?\[M([\s\S]{3})/g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wFAAwF;AACxF,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wFAAwF;AACxF,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,wDAAwD;IACxD,OAAO,CACL,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3C,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC;QAClC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QACtB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CACvB,CAAC;AACJ,CAAC;AAQD;;;;GAIG;AACH,MAAM,GAAG,GAAG,wCAAwC,CAAC;AACrD,MAAM,MAAM,GAAG,4BAA4B,CAAC;AAE5C,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,0EAA0E;IAC1E,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC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C,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC;YAAE,SAAS;QAChD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import { type DOMElement } from 'ink';
|
|
2
1
|
import { type ReactNode, type RefObject } from 'react';
|
|
3
2
|
/** Root surface: main chrome (tabs, list hit targets). Always at stack bottom. */
|
|
4
3
|
export declare const POINTER_SURFACE_BASE = "base";
|
|
5
4
|
type ClickHandler = () => void;
|
|
5
|
+
type MouseRegistry = {
|
|
6
|
+
/** True when `surface` is the exclusive top of the stack (modal/filter). */
|
|
7
|
+
isTopSurface: (surface: string) => boolean;
|
|
8
|
+
pushSurface: (surface: string) => void;
|
|
9
|
+
popSurface: (surface: string) => void;
|
|
10
|
+
};
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* **Interaction surfaces** (stack, not z-index): only the top surface's
|
|
11
|
-
* targets receive clicks. Exclusive UI (modal, filter) pushes a surface so
|
|
12
|
-
* base chrome does not need per-component `mouseActive` flags.
|
|
12
|
+
* Tracks exclusive pointer surfaces (modal / filter). Hit testing itself is
|
|
13
|
+
* OpenTUI-native (`onMouse*` on boxes); this only gates product Clickable so
|
|
14
|
+
* base chrome does not steal clicks while a modal is open.
|
|
13
15
|
*/
|
|
14
|
-
export declare function MouseProvider({ children,
|
|
16
|
+
export declare function MouseProvider({ children, }: {
|
|
15
17
|
children: ReactNode;
|
|
18
|
+
/** @deprecated OpenTUI enables mouse on the renderer; ignored. */
|
|
16
19
|
autoEnable?: boolean;
|
|
17
20
|
}): ReactNode;
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
22
|
+
* Marks an exclusive interaction surface (modal / filter). While mounted,
|
|
23
|
+
* {@link Clickable} under base chrome will not fire.
|
|
21
24
|
*/
|
|
22
25
|
export declare function PointerSurface({ id, children, }: {
|
|
23
26
|
id: string;
|
|
24
27
|
children: ReactNode;
|
|
25
28
|
}): ReactNode;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export declare function useOnClick(ref: RefObject<DOMElement | null>, onClick: ClickHandler | null | undefined): void;
|
|
29
|
+
export declare function usePointerSurfaceId(): string;
|
|
30
|
+
export declare function useMouseRegistry(): MouseRegistry | null;
|
|
31
|
+
/** @deprecated Prefer {@link Clickable}; kept for API stability. */
|
|
32
|
+
export declare function useOnClick(_ref: RefObject<unknown>, _onClick: ClickHandler | null): void;
|
|
31
33
|
export {};
|
|
@@ -1,41 +1,25 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, } from 'react';
|
|
4
|
-
import { getElementBounds, pointInBounds } from './bounds.js';
|
|
5
|
-
import { parseLeftPresses } from './parse.js';
|
|
6
|
-
/** xterm button tracking + SGR coords (clicks only, no all-motion). */
|
|
7
|
-
const ENABLE = '\u001B[?1000h\u001B[?1006h';
|
|
8
|
-
const DISABLE = '\u001B[?1000l\u001B[?1006l';
|
|
1
|
+
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, } from 'react';
|
|
9
3
|
/** Root surface: main chrome (tabs, list hit targets). Always at stack bottom. */
|
|
10
4
|
export const POINTER_SURFACE_BASE = 'base';
|
|
11
5
|
const MouseRegistryContext = createContext(null);
|
|
12
|
-
/** Nearest {@link PointerSurface} id; registrations inherit this. */
|
|
13
6
|
const PointerSurfaceIdContext = createContext(POINTER_SURFACE_BASE);
|
|
14
7
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* **Interaction surfaces** (stack, not z-index): only the top surface's
|
|
19
|
-
* targets receive clicks. Exclusive UI (modal, filter) pushes a surface so
|
|
20
|
-
* base chrome does not need per-component `mouseActive` flags.
|
|
8
|
+
* Tracks exclusive pointer surfaces (modal / filter). Hit testing itself is
|
|
9
|
+
* OpenTUI-native (`onMouse*` on boxes); this only gates product Clickable so
|
|
10
|
+
* base chrome does not steal clicks while a modal is open.
|
|
21
11
|
*/
|
|
22
|
-
export function MouseProvider({ children,
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const register = useCallback((id, registration) => {
|
|
29
|
-
targets.current.set(id, registration);
|
|
30
|
-
return () => {
|
|
31
|
-
targets.current.delete(id);
|
|
32
|
-
};
|
|
33
|
-
}, []);
|
|
12
|
+
export function MouseProvider({ children, }) {
|
|
13
|
+
const surfaceStack = useMemo(() => ({ current: [POINTER_SURFACE_BASE] }), []);
|
|
14
|
+
const isTopSurface = useCallback((surface) => {
|
|
15
|
+
const stack = surfaceStack.current;
|
|
16
|
+
return stack[stack.length - 1] === surface;
|
|
17
|
+
}, [surfaceStack]);
|
|
34
18
|
const pushSurface = useCallback((surface) => {
|
|
35
19
|
if (surface === POINTER_SURFACE_BASE)
|
|
36
20
|
return;
|
|
37
21
|
surfaceStack.current.push(surface);
|
|
38
|
-
}, []);
|
|
22
|
+
}, [surfaceStack]);
|
|
39
23
|
const popSurface = useCallback((surface) => {
|
|
40
24
|
if (surface === POINTER_SURFACE_BASE)
|
|
41
25
|
return;
|
|
@@ -43,72 +27,32 @@ export function MouseProvider({ children, autoEnable = true, }) {
|
|
|
43
27
|
const index = stack.lastIndexOf(surface);
|
|
44
28
|
if (index > 0)
|
|
45
29
|
stack.splice(index, 1);
|
|
46
|
-
}, []);
|
|
47
|
-
const registry = useMemo(() => ({
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
const tty = Boolean(stdin?.isTTY && stdout?.isTTY);
|
|
50
|
-
// CI PTY suites and ink-testing-library inject sequences without real mouse;
|
|
51
|
-
// enabling tracking there can race alternate-screen frames under load.
|
|
52
|
-
const allowEnable = autoEnable && tty && process.env.ISKILLS_DISABLE_MOUSE !== '1';
|
|
53
|
-
if (allowEnable) {
|
|
54
|
-
stdout.write(ENABLE);
|
|
55
|
-
}
|
|
56
|
-
const onData = (chunk) => {
|
|
57
|
-
const input = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
58
|
-
const presses = parseLeftPresses(input);
|
|
59
|
-
if (!presses.length)
|
|
60
|
-
return;
|
|
61
|
-
const top = surfaceStack.current[surfaceStack.current.length - 1] ?? POINTER_SURFACE_BASE;
|
|
62
|
-
for (const press of presses) {
|
|
63
|
-
for (const { ref, onClick, surface } of targets.current.values()) {
|
|
64
|
-
if (surface !== top)
|
|
65
|
-
continue;
|
|
66
|
-
const bounds = getElementBounds(ref.current);
|
|
67
|
-
if (bounds && pointInBounds(press.x, press.y, bounds)) {
|
|
68
|
-
onClick();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
stdin?.on('data', onData);
|
|
75
|
-
return () => {
|
|
76
|
-
stdin?.off('data', onData);
|
|
77
|
-
if (allowEnable) {
|
|
78
|
-
stdout.write(DISABLE);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}, [autoEnable, stdin, stdout]);
|
|
30
|
+
}, [surfaceStack]);
|
|
31
|
+
const registry = useMemo(() => ({ isTopSurface, pushSurface, popSurface }), [isTopSurface, popSurface, pushSurface]);
|
|
82
32
|
return (_jsx(MouseRegistryContext.Provider, { value: registry, children: children }));
|
|
83
33
|
}
|
|
84
34
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
35
|
+
* Marks an exclusive interaction surface (modal / filter). While mounted,
|
|
36
|
+
* {@link Clickable} under base chrome will not fire.
|
|
87
37
|
*/
|
|
88
38
|
export function PointerSurface({ id, children, }) {
|
|
89
39
|
const registry = useContext(MouseRegistryContext);
|
|
90
40
|
useEffect(() => {
|
|
91
|
-
if (!registry)
|
|
92
|
-
return
|
|
41
|
+
if (!registry || id === POINTER_SURFACE_BASE)
|
|
42
|
+
return;
|
|
93
43
|
registry.pushSurface(id);
|
|
94
|
-
return () =>
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
}, [registry, id]);
|
|
44
|
+
return () => registry.popSurface(id);
|
|
45
|
+
}, [id, registry]);
|
|
98
46
|
return (_jsx(PointerSurfaceIdContext.Provider, { value: id, children: children }));
|
|
99
47
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (!registry || !onClick)
|
|
110
|
-
return undefined;
|
|
111
|
-
return registry.register(idRef.current, { ref, onClick, surface });
|
|
112
|
-
}, [registry, ref, onClick, surface]);
|
|
48
|
+
export function usePointerSurfaceId() {
|
|
49
|
+
return useContext(PointerSurfaceIdContext);
|
|
50
|
+
}
|
|
51
|
+
export function useMouseRegistry() {
|
|
52
|
+
return useContext(MouseRegistryContext);
|
|
53
|
+
}
|
|
54
|
+
/** @deprecated Prefer {@link Clickable}; kept for API stability. */
|
|
55
|
+
export function useOnClick(_ref, _onClick) {
|
|
56
|
+
// no-op — OpenTUI hit-testing replaces ref registration
|
|
113
57
|
}
|
|
114
58
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../../../src/ui/components/mouse/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,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xs } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { Text, useModalChrome, useStdout } from '../tui/index.js';
|
|
3
3
|
import { useInput } from './use-input.js';
|
|
4
4
|
import { useMemo, useState } from 'react';
|
|
5
5
|
import { termcnColors } from './colors.js';
|
|
6
|
-
import { resolveOptionValues,
|
|
6
|
+
import { resolveOptionValues, toListOptions, useScrollWindow, visibleOptionCount, } from './options.js';
|
|
7
7
|
import { isReturn } from './text.js';
|
|
8
8
|
function OptionMultiSelect({ options, visibleCount, defaultValue = [], onSubmit, onCancel, }) {
|
|
9
|
+
const chrome = useModalChrome();
|
|
9
10
|
const { count, focus, from, focusNext, focusPrevious } = useScrollWindow(options.length, visibleCount);
|
|
10
11
|
const [selected, setSelected] = useState(() => new Set(defaultValue));
|
|
11
12
|
useInput((input, key) => {
|
|
@@ -34,16 +35,31 @@ function OptionMultiSelect({ options, visibleCount, defaultValue = [], onSubmit,
|
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
const visible = options.slice(from, from + count);
|
|
37
|
-
return (_jsx(
|
|
38
|
+
return (_jsx("box", { flexDirection: "column", children: visible.map((option, index) => {
|
|
38
39
|
const isFocused = from + index === focus;
|
|
39
40
|
const isSelected = selected.has(option.value);
|
|
40
|
-
return (_jsxs(
|
|
41
|
+
return (_jsxs("box", { flexDirection: "row", gap: 1, paddingLeft: isFocused ? 0 : 2, ...(isFocused
|
|
42
|
+
? { backgroundColor: termcnColors.selectionBg }
|
|
43
|
+
: {}), children: [isFocused && (_jsx(Text, { color: termcnColors.selectionFg, backgroundColor: termcnColors.selectionBg, children: "\u276F" })), _jsx(Text, { color: isFocused
|
|
44
|
+
? termcnColors.selectionFg
|
|
45
|
+
: isSelected
|
|
46
|
+
? termcnColors.primary
|
|
47
|
+
: chrome.muted, ...(isFocused ? { backgroundColor: termcnColors.selectionBg } : {}), children: isSelected ? '●' : '○' }), _jsx(Text, { ...(isFocused
|
|
48
|
+
? {
|
|
49
|
+
color: termcnColors.selectionFg,
|
|
50
|
+
backgroundColor: termcnColors.selectionBg,
|
|
51
|
+
bold: true,
|
|
52
|
+
}
|
|
53
|
+
: isSelected
|
|
54
|
+
? { color: termcnColors.primary, bold: true }
|
|
55
|
+
: { color: chrome.body, bold: isSelected }), children: option.label })] }, option.value));
|
|
41
56
|
}) }));
|
|
42
57
|
}
|
|
43
58
|
export function MultiSelect({ label, options, defaultValues = [], onSubmit, onCancel, }) {
|
|
44
59
|
const { stdout } = useStdout();
|
|
45
|
-
const
|
|
60
|
+
const chrome = useModalChrome();
|
|
61
|
+
const listOptions = useMemo(() => toListOptions(options), [options]);
|
|
46
62
|
const defaultValue = options.flatMap((option, index) => defaultValues.includes(option.value) ? [String(index)] : []);
|
|
47
|
-
return (_jsxs(
|
|
63
|
+
return (_jsxs("box", { flexDirection: "column", children: [label && (_jsx(Text, { bold: true, color: chrome.body, children: label })), _jsx(OptionMultiSelect, { defaultValue: defaultValue, visibleCount: visibleOptionCount(stdout.rows ?? 24, label), options: listOptions, onSubmit: (values) => onSubmit(resolveOptionValues(options, values)), ...(onCancel ? { onCancel } : {}) }), _jsx(Text, { color: chrome.muted, children: "Space/\u7A7A\u683C \u52FE\u9009 \u00B7 Enter \u786E\u8BA4 \u00B7 Esc \u53D6\u6D88" })] }));
|
|
48
64
|
}
|
|
49
65
|
//# sourceMappingURL=multi-select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-select.js","sourceRoot":"","sources":["../../../../src/ui/components/multi-select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"multi-select.js","sourceRoot":"","sources":["../../../../src/ui/components/multi-select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,O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CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAC5D,CAAC;IACF,OAAO,CACL,eAAK,aAAa,EAAC,QAAQ,aACxB,KAAK,IAAI,CACR,KAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,MAAM,CAAC,IAAI,YAC1B,KAAK,GACD,CACR,EACD,KAAC,iBAAiB,IAChB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,kBAAkB,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,EAC1D,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,KAChE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAClC,EACF,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,KAAK,kGAAwC,IAC7D,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -8,7 +8,8 @@ export interface InternalOption {
|
|
|
8
8
|
label: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function visibleOptionCount(rows: number, label?: string): number;
|
|
11
|
-
|
|
11
|
+
/** Map product options to string-indexed list rows for MultiSelect. */
|
|
12
|
+
export declare function toListOptions<T>(options: Option<T>[], numbered?: boolean): InternalOption[];
|
|
12
13
|
export declare function resolveOptionValues<T>(options: Option<T>[], values: string[]): T[];
|
|
13
14
|
export declare function resolveOptionValue<T>(options: Option<T>[], value: string): T | undefined;
|
|
14
15
|
export declare function useScrollWindow(length: number, visibleCount: number): {
|
|
@@ -2,7 +2,8 @@ import { useReducer } from 'react';
|
|
|
2
2
|
export function visibleOptionCount(rows, label) {
|
|
3
3
|
return Math.max(3, rows - (label ? 5 : 4));
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
/** Map product options to string-indexed list rows for MultiSelect. */
|
|
6
|
+
export function toListOptions(options, numbered = false) {
|
|
6
7
|
return options.map((option, index) => ({
|
|
7
8
|
value: String(index),
|
|
8
9
|
label: `${numbered ? `${index + 1}. ` : ''}${option.label}${option.hint ? ` — ${option.hint}` : ''}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/ui/components/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAoBnC,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,KAAc;IAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/ui/components/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAoBnC,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,KAAc;IAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAAI,OAAoB,EAAE,QAAQ,GAAG,KAAK;IACrE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACrC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;QACpB,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CA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AAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Select — OpenTUI `<select>` with iskills Option<T> contract.
|
|
3
|
+
* Esc cancel + optional 1–9 shortcuts stay product-side.
|
|
4
|
+
*/
|
|
1
5
|
import { type ReactNode } from 'react';
|
|
2
6
|
import { type Option } from './options.js';
|
|
3
7
|
export declare function Select<T>({ label, options, onSubmit, onCancel, numbered, }: {
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Product Select — OpenTUI `<select>` with iskills Option<T> contract.
|
|
4
|
+
* Esc cancel + optional 1–9 shortcuts stay product-side.
|
|
5
|
+
*/
|
|
4
6
|
import { useMemo } from 'react';
|
|
7
|
+
import { Text, useModalChrome, useStdout } from '../tui/index.js';
|
|
5
8
|
import { termcnColors } from './colors.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
function OptionSelect({ options, visibleCount, onChange, onCancel, }) {
|
|
9
|
-
const { count, focus, from, focusNext, focusPrevious } = useScrollWindow(options.length, visibleCount);
|
|
10
|
-
useInput((input, key) => {
|
|
11
|
-
if (key.escape)
|
|
12
|
-
return onCancel?.();
|
|
13
|
-
if (key.downArrow)
|
|
14
|
-
return focusNext();
|
|
15
|
-
if (key.upArrow)
|
|
16
|
-
return focusPrevious();
|
|
17
|
-
if (isReturn(input, key.return)) {
|
|
18
|
-
const option = options[focus];
|
|
19
|
-
if (option)
|
|
20
|
-
onChange(option.value);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const visible = options.slice(from, from + count);
|
|
24
|
-
return (_jsx(Box, { flexDirection: "column", children: visible.map((option, index) => {
|
|
25
|
-
const isFocused = from + index === focus;
|
|
26
|
-
return (_jsxs(Box, { gap: 1, paddingLeft: isFocused ? 0 : 2, children: [isFocused && _jsx(Text, { color: termcnColors.primary, children: "\u276F" }), _jsx(Text, { ...(isFocused ? { color: termcnColors.primary } : {}), children: option.label })] }, option.value));
|
|
27
|
-
}) }));
|
|
28
|
-
}
|
|
9
|
+
import { resolveOptionValue, visibleOptionCount, } from './options.js';
|
|
10
|
+
import { useInput } from './use-input.js';
|
|
29
11
|
export function Select({ label, options, onSubmit, onCancel, numbered = false, }) {
|
|
30
12
|
const { stdout } = useStdout();
|
|
31
|
-
const
|
|
13
|
+
const chrome = useModalChrome();
|
|
14
|
+
const rows = stdout.rows ?? 24;
|
|
15
|
+
const visible = visibleOptionCount(rows, label);
|
|
16
|
+
const height = Math.max(3, Math.min(visible, Math.max(1, options.length)));
|
|
17
|
+
const selectOptions = useMemo(() => options.map((option, index) => ({
|
|
18
|
+
name: numbered ? `${index + 1}. ${option.label}` : option.label,
|
|
19
|
+
description: option.hint ?? '',
|
|
20
|
+
value: String(index),
|
|
21
|
+
})), [numbered, options]);
|
|
22
|
+
const showDescription = options.some((option) => Boolean(option.hint));
|
|
32
23
|
useInput((input, key) => {
|
|
33
|
-
if (key.escape)
|
|
34
|
-
|
|
24
|
+
if (key.escape) {
|
|
25
|
+
onCancel?.();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
35
28
|
if (!numbered || !/^[1-9]$/.test(input))
|
|
36
29
|
return;
|
|
37
30
|
const option = options[Number(input) - 1];
|
|
38
31
|
if (option)
|
|
39
32
|
onSubmit(option.value);
|
|
40
33
|
});
|
|
41
|
-
return (_jsxs(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
return (_jsxs("box", { flexDirection: "column", children: [label ? (_jsx(Text, { bold: true, color: chrome.body, children: label })) : null, _jsx("box", { height: height, flexDirection: "column", width: "100%", children: _jsx("select", { focused: true, options: selectOptions, showDescription: showDescription, showScrollIndicator: options.length > height, showSelectionIndicator: true, selectedTextColor: termcnColors.selectionFg, selectedBackgroundColor: termcnColors.selectionBg,
|
|
35
|
+
// Theme-aware idle text (not forced white / fixed mid-gray only).
|
|
36
|
+
textColor: chrome.body, focusedTextColor: chrome.body, descriptionColor: chrome.muted, selectedDescriptionColor: termcnColors.selectionFg, backgroundColor: "transparent", focusedBackgroundColor: "transparent", height: height, flexGrow: 1, onSelect: (_index, option) => {
|
|
37
|
+
if (!option)
|
|
38
|
+
return;
|
|
39
|
+
const resolved = resolveOptionValue(options, String(option.value));
|
|
40
|
+
if (resolved !== undefined)
|
|
41
|
+
onSubmit(resolved);
|
|
42
|
+
} }) }), _jsxs(Text, { color: chrome.muted, children: [numbered ? `1–${Math.min(options.length, 9)} 快选 · ` : '', "\u2191/\u2193 \u9009\u62E9 \u00B7 Enter \u786E\u8BA4 \u00B7 Esc \u53D6\u6D88"] })] }));
|
|
46
43
|
}
|
|
47
44
|
//# sourceMappingURL=select.js.map
|