|
5 | 5 | Popover, |
6 | 6 | RadioGroup, |
7 | 7 | Separator, |
| 8 | + Text, |
8 | 9 | Tooltip, |
9 | 10 | } from '@radix-ui/themes' |
10 | 11 | import { WholeWordIcon } from 'lucide-react' |
@@ -60,6 +61,12 @@ export function LocatorForm({ |
60 | 61 |
|
61 | 62 | const currentLocator = values[current] ?? initializeLocatorValues(current) |
62 | 63 |
|
| 64 | + const configuredTypes = new Set( |
| 65 | + Object.entries(values) |
| 66 | + .filter(([, locator]) => locator && isLocatorConfigured(locator)) |
| 67 | + .map(([type]) => type) |
| 68 | + ) |
| 69 | + |
63 | 70 | const handleChangeCurrent = (type: LocatorOptions['current']) => { |
64 | 71 | if (dirtyTypes.has(current)) { |
65 | 72 | setTouchedTypes((prev) => { |
@@ -131,7 +138,12 @@ export function LocatorForm({ |
131 | 138 | .filter(([type]) => type !== 'text') |
132 | 139 | .map(([type, label]) => ( |
133 | 140 | <RadioGroup.Item value={type} key={type}> |
134 | | - {label} |
| 141 | + <Text |
| 142 | + weight={configuredTypes.has(type) ? 'medium' : 'regular'} |
| 143 | + color={configuredTypes.has(type) ? undefined : 'gray'} |
| 144 | + > |
| 145 | + {label} |
| 146 | + </Text> |
135 | 147 | </RadioGroup.Item> |
136 | 148 | ))} |
137 | 149 | </RadioGroup.Root> |
@@ -365,6 +377,14 @@ function initializeLocatorValues(type: ActionLocator['type']): ActionLocator { |
365 | 377 | } |
366 | 378 | } |
367 | 379 |
|
| 380 | +function isLocatorConfigured(locator: ActionLocator | undefined): boolean { |
| 381 | + if (!locator) return false |
| 382 | + |
| 383 | + // Since validateLocator only checks for empty values, we re-use it to check if the locator is configured. |
| 384 | + // This isn't perfect, but it's a good enough approximation. |
| 385 | + return validateLocator(locator).isValid |
| 386 | +} |
| 387 | + |
368 | 388 | function addIfAbsent<T>(set: Set<T>, value: T) { |
369 | 389 | return set.has(value) ? set : new Set(set).add(value) |
370 | 390 | } |
0 commit comments