( subBlock: SubBlockConfig | undefined, rawValue: unknown )
| 350 | * Returns null if not a dropdown/combobox or no matching option is found. |
| 351 | */ |
| 352 | export function resolveDropdownLabel( |
| 353 | subBlock: SubBlockConfig | undefined, |
| 354 | rawValue: unknown |
| 355 | ): string | null { |
| 356 | if (!subBlock || (subBlock.type !== 'dropdown' && subBlock.type !== 'combobox')) return null |
| 357 | if (!rawValue || typeof rawValue !== 'string') return null |
| 358 | |
| 359 | const options = typeof subBlock.options === 'function' ? subBlock.options() : subBlock.options |
| 360 | if (!options) return null |
| 361 | |
| 362 | const option = options.find((opt) => |
| 363 | typeof opt === 'string' ? opt === rawValue : opt.id === rawValue |
| 364 | ) |
| 365 | |
| 366 | if (!option) return null |
| 367 | return typeof option === 'string' ? option : option.label |
| 368 | } |
| 369 | |
| 370 | /** Resolves a workflow-selector value to the workflow's name. */ |
| 371 | export function resolveWorkflowSelectionLabel( |
no outgoing calls
no test coverage detected