/
aqa
/
claude-code
Обзор
Документация
Войти
/
aqa
/
claude-code
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
components/agents/ColorPicker.tsx
112 строк
14 KB
kuberwastaken
new initial commit (history rewritten)
01 апр 2026, 14:57
01 апр 2026, 14:57
c1996f2
Код
Авторство
О чём код?
import { c as _c } from "react/compiler-runtime"; import figures from 'figures'; import React, { useState } from 'react'; import type { KeyboardEvent } from '../../ink/events/keyboard-event.js'; import { Box, Text } from '../../ink.js'; import { AGENT_COLOR_TO_THEME_COLOR, AGENT_COLORS, type AgentColorName } from '../../tools/AgentTool/agentColorManager.js'; import { capitalize } from '../../utils/stringUtils.js'; type ColorOption = AgentColorName | 'automatic'; const COLOR_OPTIONS: ColorOption[] = ['automatic', ...AGENT_COLORS]; type Props = { agentName: string; currentColor?: AgentColorName | 'automatic'; onConfirm: (color: AgentColorName | undefined) => void; }; export function ColorPicker(t0) { const $ = _c(17); const { agentName, currentColor: t1, onConfirm } = t0; const currentColor = t1 === undefined ? "automatic" : t1; let t2; if ($[0] !== currentColor) { t2 = COLOR_OPTIONS.findIndex(opt => opt === currentColor); $[0] = currentColor; $[1] = t2; } else { t2 = $[1]; } const [selectedIndex, setSelectedIndex] = useState(Math.max(0, t2)); let t3; if ($[2] !== onConfirm || $[3] !== selectedIndex) { t3 = e => { if (e.key === "up") { e.preventDefault(); setSelectedIndex(_temp); } else { if (e.key === "down") { e.preventDefault(); setSelectedIndex(_temp2); } else { if (e.key === "return") { e.preventDefault(); const selected = COLOR_OPTIONS[selectedIndex]; onConfirm(selected === "automatic" ? undefined : selected); } } } }; $[2] = onConfirm; $[3] = selectedIndex; $[4] = t3; } else { t3 = $[4]; } const handleKeyDown = t3; const selectedValue = COLOR_OPTIONS[selectedIndex]; let t4; if ($[5] !== selectedIndex) { t4 = COLOR_OPTIONS.map((option, index) => { const isSelected = index === selectedIndex; return <Box key={option} flexDirection="row" gap={1}><Text color={isSelected ? "suggestion" : undefined}>{isSelected ? figures.pointer : " "}</Text>{option === "automatic" ? <Text bold={isSelected}>Automatic color</Text> : <Box gap={1}><Text backgroundColor={AGENT_COLOR_TO_THEME_COLOR[option]} color="inverseText">{" "}</Text><Text bold={isSelected}>{capitalize(option)}</Text></Box>}</Box>; }); $[5] = selectedIndex; $[6] = t4; } else { t4 = $[6]; } let t5; if ($[7] !== t4) { t5 = <Box flexDirection="column">{t4}</Box>; $[7] = t4; $[8] = t5; } else { t5 = $[8]; } let t6; if ($[9] === Symbol.for("react.memo_cache_sentinel")) { t6 = <Text>Preview: </Text>; $[9] = t6; } else { t6 = $[9]; } let t7; if ($[10] !== agentName || $[11] !== selectedValue) { t7 = <Box marginTop={1}>{t6}{selectedValue === undefined || selectedValue === "automatic" ? <Text inverse={true} bold={true}>{" "}@{agentName}{" "}</Text> : <Text backgroundColor={AGENT_COLOR_TO_THEME_COLOR[selectedValue]} color="inverseText" bold={true}>{" "}@{agentName}{" "}</Text>}</Box>; $[10] = agentName; $[11] = selectedValue; $[12] = t7; } else { t7 = $[12]; } let t8; if ($[13] !== handleKeyDown || $[14] !== t5 || $[15] !== t7) { t8 = <Box flexDirection="column" gap={1} tabIndex={0} autoFocus={true} onKeyDown={handleKeyDown}>{t5}{t7}</Box>; $[13] = handleKeyDown; $[14] = t5; $[15] = t7; $[16] = t8; } else { t8 = $[16]; } return t8; } function _temp2(prev_0) { return prev_0 < COLOR_OPTIONS.length - 1 ? prev_0 + 1 : 0; } function _temp(prev) { return prev > 0 ? prev - 1 : COLOR_OPTIONS.length - 1; } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJmaWd1cmVzIiwiUmVhY3QiLCJ1c2VTdGF0ZSIsIktleWJvYXJkRXZlbnQiLCJCb3giLCJUZXh0IiwiQUdFTlRfQ09MT1JfVE9fVEhFTUVf … [Строка слишком длинная. Вы можете скачать файл]