@@ -2,6 +2,7 @@ import { COMPONENT_REGEXES } from './regex-helpers.js';
2
2
3
3
/**
4
4
* Validates that a component name is a valid Design System component name
5
+ * Accepts both formats: "Button" and "DsButton"
5
6
* @param componentName The component name to validate
6
7
* @throws Error if the component name is invalid
7
8
*/
@@ -14,22 +15,22 @@ export function validateComponentName(
14
15
! COMPONENT_REGEXES . isValidDsComponent ( componentName )
15
16
) {
16
17
throw new Error (
17
- 'Invalid component name. Must be a string starting with "Ds" .' ,
18
+ 'Invalid component name. Must be a valid PascalCase string (e.g., "Button" or "DsButton") .' ,
18
19
) ;
19
20
}
20
21
}
21
22
22
23
/**
23
24
* Converts a Design System component name to kebab case
24
- * @param componentName The component name (e.g., "DsButton")
25
+ * @param componentName The component name (e.g., "DsButton" or "Button" )
25
26
* @returns The kebab case name (e.g., "button")
26
27
*/
27
28
export function componentNameToKebabCase ( componentName : string ) : string {
28
29
const kebabCase = COMPONENT_REGEXES . toKebabCase ( componentName ) ;
29
30
30
31
if ( ! kebabCase ?. trim ( ) ?. length ) {
31
32
throw new Error (
32
- 'Invalid component name. Must be a string starting with "Ds" .' ,
33
+ 'Invalid component name. Must be a valid PascalCase string (e.g., "Button" or "DsButton") .' ,
33
34
) ;
34
35
}
35
36
@@ -38,7 +39,7 @@ export function componentNameToKebabCase(componentName: string): string {
38
39
39
40
/**
40
41
* Creates a tag name from a component name
41
- * @param componentName The component name (e.g., "DsButton")
42
+ * @param componentName The component name (e.g., "DsButton" or "Button" )
42
43
* @returns The tag name (e.g., "ds-button")
43
44
*/
44
45
export function componentNameToTagName ( componentName : string ) : string {
0 commit comments