| 60 | * Groups and displays validation errors using treeify with deduplication |
| 61 | */ |
| 62 | export function ValidationErrorsList(t0) { |
| 63 | const $ = _c(9); |
| 64 | const { |
| 65 | errors |
| 66 | } = t0; |
| 67 | const [themeName] = useTheme(); |
| 68 | if (errors.length === 0) { |
| 69 | return null; |
| 70 | } |
| 71 | let T0; |
| 72 | let t1; |
| 73 | let t2; |
| 74 | if ($[0] !== errors || $[1] !== themeName) { |
| 75 | const errorsByFile = errors.reduce(_temp, {}); |
| 76 | const sortedFiles = Object.keys(errorsByFile).sort(); |
| 77 | T0 = Box; |
| 78 | t1 = "column"; |
| 79 | t2 = sortedFiles.map(file_0 => { |
| 80 | const fileErrors = errorsByFile[file_0] || []; |
| 81 | fileErrors.sort(_temp2); |
| 82 | const errorTree = buildNestedTree(fileErrors); |
| 83 | const suggestionPairs = new Map(); |
| 84 | fileErrors.forEach(error_0 => { |
| 85 | if (error_0.suggestion || error_0.docLink) { |
| 86 | const key = `${error_0.suggestion || ""}|${error_0.docLink || ""}`; |
| 87 | if (!suggestionPairs.has(key)) { |
| 88 | suggestionPairs.set(key, { |
| 89 | suggestion: error_0.suggestion, |
| 90 | docLink: error_0.docLink |
| 91 | }); |
| 92 | } |
| 93 | } |
| 94 | }); |
| 95 | const treeOutput = treeify(errorTree, { |
| 96 | showValues: true, |
| 97 | themeName, |
| 98 | treeCharColors: { |
| 99 | treeChar: "inactive", |
| 100 | key: "text", |
| 101 | value: "inactive" |
| 102 | } |
| 103 | }); |
| 104 | return <Box key={file_0} flexDirection="column"><Text>{file_0}</Text><Box marginLeft={1}><Text dimColor={true}>{treeOutput}</Text></Box>{suggestionPairs.size > 0 && <Box flexDirection="column" marginTop={1}>{Array.from(suggestionPairs.values()).map(_temp3)}</Box>}</Box>; |
| 105 | }); |
| 106 | $[0] = errors; |
| 107 | $[1] = themeName; |
| 108 | $[2] = T0; |
| 109 | $[3] = t1; |
| 110 | $[4] = t2; |
| 111 | } else { |
| 112 | T0 = $[2]; |
| 113 | t1 = $[3]; |
| 114 | t2 = $[4]; |
| 115 | } |
| 116 | let t3; |
| 117 | if ($[5] !== T0 || $[6] !== t1 || $[7] !== t2) { |
| 118 | t3 = <T0 flexDirection={t1}>{t2}</T0>; |
| 119 | $[5] = T0; |