Files
oh-my-pi/packages/coding-agent/src/modes/components/show-images-selector.ts
T
2026-02-10 07:39:39 +01:00

46 lines
1.2 KiB
TypeScript

import { Container, type SelectItem, SelectList } from "@oh-my-pi/pi-tui";
import { getSelectListTheme } from "../../modes/theme/theme";
import { DynamicBorder } from "./dynamic-border";
/**
* Component that renders a show images selector with borders
*/
export class ShowImagesSelectorComponent extends Container {
#selectList: SelectList;
constructor(currentValue: boolean, onSelect: (show: boolean) => void, onCancel: () => void) {
super();
const items: SelectItem[] = [
{ value: "yes", label: "Yes", description: "Show images inline in terminal" },
{ value: "no", label: "No", description: "Show text placeholder instead" },
];
// Add top border
this.addChild(new DynamicBorder());
// Create selector
this.#selectList = new SelectList(items, 5, getSelectListTheme());
// Preselect current value
this.#selectList.setSelectedIndex(currentValue ? 0 : 1);
this.#selectList.onSelect = item => {
onSelect(item.value === "yes");
};
this.#selectList.onCancel = () => {
onCancel();
};
this.addChild(this.#selectList);
// Add bottom border
this.addChild(new DynamicBorder());
}
getSelectList(): SelectList {
return this.#selectList;
}
}