Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.
This repository was archived by the owner on Dec 25, 2025. It is now read-only.

Custom component interface #79

@IzumiSy

Description

@IzumiSy

Currently, no interface available to pass props to the component registered on the component registry.

This PR is a design proposal to implement a feature to get a custom React component that internally composes FabrixComponent with interface that can accept props that the corresponding custom component requires.

Design

// table.tsx

type MyTableProps = {
  onClickRow: (rowID: string) => void;
}

export MyTable = (props: TableComponentProps<MyTableProps>) => {
  const columnDefs = props.headers.map((header) => {
    return {
      headerName: header.key,
      field: header.label,
      enableValue: true,
      enableRowGroup: true,
      enablePivot: true,
    };
  }); 

  return (
    <Datagrid 
      columns={columnDefs} 
      onClickRow={(row: Row) => {
        props.onClickRow(row.id)
      }} 
    />
  ) 
}
// components.tsx

const customComponents = new ComponentRegistry({
  custom: [
    {
      type: "table",
      name: "myCustomTable",     
      table: (props: TableComponentProps<MyTableProps>) => {
        return (
          <Datagrid onClickRow={props.onClickRow} />
        )
      }
    }
  ]
})
// page.tsx

const MyCustomTable = customComponents.getComponent("myCustomTable")

const Page = () => {
  return (
    <MyCustomTable 
      query={gql`
        manufacturingOrders {
          collection {
            name
            id
          }
        }
      `}
      props={{
        onClickRow: (rowID) => {
          // implement handler here
        }
      }} 
    />
  )
}

Metadata

Metadata

Assignees

Labels

featureNew feature or requestpackage:coreRelated to @fabrix-framework/fabrix

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions