@dugongjs/cli
Version:
28 lines (27 loc) • 1.85 kB
JavaScript
import { Box, Spacer, Text } from "ink";
import SelectInput from "ink-select-input";
import TextInput from "ink-text-input";
import React from "react";
import { Pane } from "../components/pane.js";
export const AggregateIdSelectPane = (props) => {
const { isFocused, isLoading, selectedType, ids, selectedId, setSelectedId } = props;
const [filter, setFilter] = React.useState("");
const filteredItems = React.useMemo(() => {
return ids
.filter((id) => id.toLowerCase().includes(filter.toLowerCase()))
.map((id) => ({ label: id, value: id }));
}, [ids, filter]);
return (React.createElement(Pane, { isFocused: isFocused, isLoading: isLoading },
React.createElement(Text, { bold: true }, "Aggregate instances"),
!selectedType && React.createElement(Text, { color: "gray" }, "No aggregate type selected"),
React.createElement(Box, { flexDirection: "column", width: "100%", marginTop: 1 }, selectedType && (React.createElement(React.Fragment, null,
isFocused && (React.createElement(Box, null,
React.createElement(Text, null,
React.createElement(Text, { color: "gray" }, "Search:"),
" ",
React.createElement(TextInput, { value: filter, onChange: setFilter, showCursor: false })))),
filteredItems.length === 0 ? (React.createElement(Text, { color: "gray" }, "No instances found")) : (React.createElement(SelectInput, { items: filteredItems, onSelect: (item) => setSelectedId(item.value), initialIndex: selectedId ? ids.indexOf(selectedId) : 0, isFocused: isFocused }))))),
React.createElement(Spacer, null),
React.createElement(Box, { marginTop: 1 },
React.createElement(Text, { color: "gray" }, "\u2191/\u2193 : navigate \u2022 \u21B5 : select"))));
};