ethagent 4.3.0 → 4.3.1
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/package.json +1 -1
- package/src/ui/Select.tsx +12 -7
package/package.json
CHANGED
package/src/ui/Select.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react'
|
|
2
2
|
import { Box, Text } from 'ink'
|
|
3
|
-
import { theme, PANEL_WIDTH } from './theme.js'
|
|
3
|
+
import { theme, PANEL_WIDTH, gradientColor } from './theme.js'
|
|
4
4
|
import { useAppInput } from '../app/input/AppInputProvider.js'
|
|
5
5
|
|
|
6
6
|
const CONTENT_WIDTH = PANEL_WIDTH - 4
|
|
@@ -11,6 +11,10 @@ function fitHint(hint: string, budget: number): string {
|
|
|
11
11
|
return `${hint.slice(0, budget - 1)}…`
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
function rainbowColor(index: number, total: number): string {
|
|
15
|
+
return gradientColor(total <= 1 ? 0 : index / (total - 1))
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
export type SelectOption<T> = {
|
|
15
19
|
value: T
|
|
16
20
|
label: string
|
|
@@ -135,17 +139,18 @@ export function Select<T>({
|
|
|
135
139
|
const belowHintText = belowHint
|
|
136
140
|
? fitHint(option.hint ?? '', CONTENT_WIDTH - rowIndent - 2)
|
|
137
141
|
: ''
|
|
138
|
-
const
|
|
142
|
+
const showActiveGradient = isActive && selectable && !isSection && option.label.length > 0
|
|
139
143
|
return (
|
|
140
144
|
<Box key={absoluteIndex} flexDirection="column">
|
|
141
145
|
<Box flexDirection="row" marginLeft={rowIndent}>
|
|
142
146
|
<Text color={prefixColor}>{cursor} </Text>
|
|
143
147
|
{prefix ? <Text color={prefixColor}>{prefix}</Text> : null}
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
{showActiveGradient ? (
|
|
149
|
+
<Text>
|
|
150
|
+
{option.label.split('').map((ch, ci) => (
|
|
151
|
+
<Text key={ci} color={rainbowColor(ci, option.label.length)}>{ch}</Text>
|
|
152
|
+
))}
|
|
153
|
+
</Text>
|
|
149
154
|
) : (
|
|
150
155
|
<Text color={labelColor} bold={bold}>{option.label}</Text>
|
|
151
156
|
)}
|