mirror of
https://github.com/zoriya/v10.git
synced 2026-08-09 23:58:06 +00:00
feat(site): extract api reference from components (#464)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { PropDef } from './types.js';
|
||||
|
||||
export function kebabToPascal(str: string): string {
|
||||
return str
|
||||
.split('-')
|
||||
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
||||
.join('');
|
||||
}
|
||||
|
||||
export function sortProps(props: Record<string, PropDef>): Record<string, PropDef> {
|
||||
const entries = Object.entries(props);
|
||||
|
||||
entries.sort((a, b) => {
|
||||
// Required first
|
||||
const aRequired = a[1].required ?? false;
|
||||
const bRequired = b[1].required ?? false;
|
||||
|
||||
if (aRequired && !bRequired) return -1;
|
||||
if (!aRequired && bRequired) return 1;
|
||||
|
||||
// Then alphabetical
|
||||
return a[0].localeCompare(b[0]);
|
||||
});
|
||||
|
||||
return Object.fromEntries(entries);
|
||||
}
|
||||
Reference in New Issue
Block a user