@firecms/core 3.0.0-tw4.1 → 3.0.0-tw4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,3 +61,24 @@ export function unslugify(slug?: string): string {
61
61
  return slug.trim();
62
62
  }
63
63
  }
64
+
65
+ export function prettifyIdentifier(input: string) {
66
+ if (!input) return "";
67
+
68
+ let text = input;
69
+
70
+ // 1. Handle camelCase and Acronyms
71
+ // Group 1 ($1 $2): Lowercase followed by Uppercase (e.g., imageURL -> image URL)
72
+ // Group 2 ($3 $4): Uppercase followed by Uppercase+lowercase (e.g., XMLParser -> XML Parser)
73
+ text = text.replace(/([a-z])([A-Z])|([A-Z])([A-Z][a-z])/g, "$1$3 $2$4");
74
+
75
+ // 2. Replace hyphens/underscores with spaces
76
+ text = text.replace(/[_-]+/g, " ");
77
+
78
+ // 3. Capitalize first letter of each word (Title Case)
79
+ const s = text
80
+ .trim()
81
+ .replace(/\b\w/g, (char) => char.toUpperCase());
82
+ console.log("Prettified identifier:", { input,s });
83
+ return s;
84
+ }