( nodeName: string | undefined, className: string, nodeType: string, )
| 101 | |
| 102 | // Get proper component name from node info |
| 103 | export function getComponentName( |
| 104 | nodeName: string | undefined, |
| 105 | className: string, |
| 106 | nodeType: string, |
| 107 | ): string { |
| 108 | // Start with Styled prefix |
| 109 | let name = "Styled"; |
| 110 | |
| 111 | // Try to use node name first |
| 112 | if (nodeName && nodeName.length > 0) { |
| 113 | // Clean up the node name and capitalize first letter |
| 114 | const cleanName = nodeName |
| 115 | .replace(/[^a-zA-Z0-9]/g, "") |
| 116 | .replace(/^[a-z]/, (match) => match.toUpperCase()); |
| 117 | |
| 118 | name += cleanName || nodeType.charAt(0).toUpperCase() + nodeType.slice(1); |
| 119 | } |
| 120 | // Fall back to className if provided |
| 121 | else if (className) { |
| 122 | const parts = className.split("-"); |
| 123 | if (parts.length > 0 && parts[0]) { |
| 124 | name += parts[0].charAt(0).toUpperCase() + parts[0].slice(1); |
| 125 | } else { |
| 126 | name += nodeType.charAt(0).toUpperCase() + nodeType.slice(1); |
| 127 | } |
| 128 | } |
| 129 | // Last resort |
| 130 | else { |
| 131 | name += nodeType.charAt(0).toUpperCase() + nodeType.slice(1); |
| 132 | } |
| 133 | |
| 134 | return name; |
| 135 | } |
| 136 | |
| 137 | // Get the collected CSS as a string with improved formatting |
| 138 | export function getCollectedCSS(): string { |
no outgoing calls
no test coverage detected