Home / File/ utils.ts — ui Source File

utils.ts — ui Source File

Architecture documentation for utils.ts, a typescript file in the ui codebase. 1 imports, 0 dependents.

File typescript DesignEngine Transformers 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  5184ab03_2431_56f4_72a9_fd720da38646["utils.ts"]
  ceec689a_1334_a657_3c35_094070222b09["schema"]
  5184ab03_2431_56f4_72a9_fd720da38646 --> ceec689a_1334_a657_3c35_094070222b09
  style 5184ab03_2431_56f4_72a9_fd720da38646 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { type RegistryItem } from "shadcn/schema"

const mapping = {
  "registry:block": "Blocks",
  "registry:example": "Components",
}

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

Functions

Dependencies

  • schema

Frequently Asked Questions

What does utils.ts do?
utils.ts is a source file in the ui codebase, written in typescript. It belongs to the DesignEngine domain, Transformers subdomain.
What functions are defined in utils.ts?
utils.ts defines 1 function(s): groupItemsByType.
What does utils.ts depend on?
utils.ts imports 1 module(s): schema.
Where is utils.ts in the architecture?
utils.ts is located at apps/v4/app/(create)/lib/utils.ts (domain: DesignEngine, subdomain: Transformers, directory: apps/v4/app/(create)/lib).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free