groupItemsByType() — ui Function Reference
Architecture documentation for the groupItemsByType() function in utils.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 7a7155c4_57ed_9955_622b_f5a915b31aa2["groupItemsByType()"] 5184ab03_2431_56f4_72a9_fd720da38646["utils.ts"] 7a7155c4_57ed_9955_622b_f5a915b31aa2 -->|defined in| 5184ab03_2431_56f4_72a9_fd720da38646 style 7a7155c4_57ed_9955_622b_f5a915b31aa2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/v4/app/(create)/lib/utils.ts lines 8–44
export function groupItemsByType(
items: Pick<RegistryItem, "name" | "title" | "type">[]
) {
const grouped = items.reduce(
(acc, item) => {
acc[item.type] = [...(acc[item.type] || []), item]
return acc
},
{} as Record<string, Pick<RegistryItem, "name" | "title" | "type">[]>
)
return Object.entries(grouped)
.map(([type, items]) => ({
type,
title: mapping[type as keyof typeof mapping] || type,
items,
}))
.sort((a, b) => {
const aIndex = Object.keys(mapping).indexOf(a.type)
const bIndex = Object.keys(mapping).indexOf(b.type)
// If both are in mapping, sort by their order.
if (aIndex !== -1 && bIndex !== -1) {
return aIndex - bIndex
}
// If only a is in mapping, it comes first.
if (aIndex !== -1) {
return -1
}
// If only b is in mapping, it comes first.
if (bIndex !== -1) {
return 1
}
// If neither is in mapping, maintain original order.
return 0
})
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does groupItemsByType() do?
groupItemsByType() is a function in the ui codebase, defined in apps/v4/app/(create)/lib/utils.ts.
Where is groupItemsByType() defined?
groupItemsByType() is defined in apps/v4/app/(create)/lib/utils.ts at line 8.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free