@firecms/core 3.0.0-tw4.1 → 3.0.0-tw4.14
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.
- package/dist/components/VirtualTable/VirtualTable.performance.test.d.ts +1 -0
- package/dist/hooks/useProjectLog.d.ts +1 -1
- package/dist/index.es.js +25 -8
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +25 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/util/entity_cache.d.ts +0 -1
- package/dist/util/strings.d.ts +1 -0
- package/dist/util/strings.test.d.ts +1 -0
- package/package.json +6 -5
- package/src/components/VirtualTable/VirtualTable.performance.test.tsx +386 -0
- package/src/components/VirtualTable/VirtualTable.tsx +3 -3
- package/src/core/SideDialogs.tsx +19 -8
- package/src/hooks/useProjectLog.tsx +1 -1
- package/src/util/entity_cache.ts +0 -5
- package/src/util/strings.test.ts +101 -0
- package/src/util/strings.ts +21 -0
package/src/util/strings.ts
CHANGED
|
@@ -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
|
+
}
|