Home / File/ component-wrapper.tsx — ui Source File

component-wrapper.tsx — ui Source File

Architecture documentation for component-wrapper.tsx, a tsx file in the ui codebase. 2 imports, 0 dependents.

File tsx DocumentationAtlas SearchAPI 2 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  dc3130d7_85e4_d3f9_f827_dc97c3125a68["component-wrapper.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  dc3130d7_85e4_d3f9_f827_dc97c3125a68 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  7758fdd8_25c1_a333_03ce_5e171102a1ec["utils"]
  dc3130d7_85e4_d3f9_f827_dc97c3125a68 --> 7758fdd8_25c1_a333_03ce_5e171102a1ec
  style dc3130d7_85e4_d3f9_f827_dc97c3125a68 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"

import { cn } from "@/registry/new-york-v4/lib/utils"

export function ComponentWrapper({
  className,
  name,
  children,
  ...props
}: React.ComponentPropsWithoutRef<"div"> & { name: string }) {
  return (
    <ComponentErrorBoundary name={name}>
      <div
        id={name}
        data-name={name.toLowerCase()}
        className={cn(
          "flex w-full scroll-mt-16 flex-col rounded-lg border",
          className
        )}
        {...props}
      >
        <div className="border-b px-4 py-3">
          <div className="text-sm font-medium">{getComponentName(name)}</div>
        </div>
        <div className="flex flex-1 items-center gap-2 p-4">{children}</div>
      </div>
    </ComponentErrorBoundary>
  )
}

class ComponentErrorBoundary extends React.Component<
  { children: React.ReactNode; name: string },
  { hasError: boolean }
> {
  constructor(props: { children: React.ReactNode; name: string }) {
    super(props)
    this.state = { hasError: false }
  }

  static getDerivedStateFromError() {
    return { hasError: true }
  }

  componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
    console.error(`Error in component ${this.props.name}:`, error, errorInfo)
  }

  render() {
    if (this.state.hasError) {
      return (
        <div className="p-4 text-red-500">
          Something went wrong in component: {this.props.name}
        </div>
      )
    }

    return this.props.children
  }
}

function getComponentName(name: string) {
  // convert kebab-case to title case
  return name.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase())
}

Subdomains

Dependencies

  • react
  • utils

Frequently Asked Questions

What does component-wrapper.tsx do?
component-wrapper.tsx is a source file in the ui codebase, written in tsx. It belongs to the DocumentationAtlas domain, SearchAPI subdomain.
What functions are defined in component-wrapper.tsx?
component-wrapper.tsx defines 2 function(s): ComponentWrapper, getComponentName.
What does component-wrapper.tsx depend on?
component-wrapper.tsx imports 2 module(s): react, utils.
Where is component-wrapper.tsx in the architecture?
component-wrapper.tsx is located at apps/v4/app/(internal)/sink/components/component-wrapper.tsx (domain: DocumentationAtlas, subdomain: SearchAPI, directory: apps/v4/app/(internal)/sink/components).

Analyze Your Own Codebase

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

Try Supermodel Free