@@ -2,6 +2,7 @@ import { COMPONENT_REGEXES } from './regex-helpers.js';
22
33/**
44 * Validates that a component name is a valid Design System component name
5+ * Accepts both formats: "Button" and "DsButton"
56 * @param componentName The component name to validate
67 * @throws Error if the component name is invalid
78 */
@@ -14,22 +15,22 @@ export function validateComponentName(
1415 ! COMPONENT_REGEXES . isValidDsComponent ( componentName )
1516 ) {
1617 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") .' ,
1819 ) ;
1920 }
2021}
2122
2223/**
2324 * 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" )
2526 * @returns The kebab case name (e.g., "button")
2627 */
2728export function componentNameToKebabCase ( componentName : string ) : string {
2829 const kebabCase = COMPONENT_REGEXES . toKebabCase ( componentName ) ;
2930
3031 if ( ! kebabCase ?. trim ( ) ?. length ) {
3132 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") .' ,
3334 ) ;
3435 }
3536
@@ -38,7 +39,7 @@ export function componentNameToKebabCase(componentName: string): string {
3839
3940/**
4041 * 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" )
4243 * @returns The tag name (e.g., "ds-button")
4344 */
4445export function componentNameToTagName ( componentName : string ) : string {
0 commit comments