npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bithero/react-entity-components

v1.1.0

Published

React components to build UI's for entities

Readme

react-entity-components

React components to build UI's for entities

License

This project is licensed under AGPL-3.0. See the LICENSE file for more informations.

Usage

EntitySystemContext

First, your application (or atleast the components that should use the components provided by this library) needs to be wrapped inside an EntitySystemContext.Provider:

import { EntitySystemContext, IEntitySystemCtx } from '@bithero/react-entity-components';

const MyApp = () => {
    const sysCtx: IEntitySystemCtx = {
        fetchEntities(entityName: string): Promise<any[]> {
            // Async-callback to query all available entities of the type <entityName>
        },
        fetchEntity(entityName: string, id: string): Promise<any> {
            // Async-callback to query an entity of the type <entityName>, identitfied by <id>.
        },
        createEntity(entityName: string, entity: Object): Promise<any> {
            // Async-callback for the creation of an entity of the type <entityName> with the given content (<entity>).
            // Returns the entity once completed.
        },
        updateEntity(entityName: string, id: string, entity: Object): Promise<any> {
            // Async-callback to update an entity of the type <entityName> with the given content (<entity>),
            // identitfied by <id>. Returns the updated entity once completed.
        },
        tr(key: string, data?: Object): string {
            // Callback to translate the given <key> with additional data present in <data>.
        },

        // If this is set to true, the EntityDetail component prints out the current entity as json at the end of the component.
        debugPrint: true,
    }

    return (
        <EntitySystemContext.Provider value={sysCtx}>
            {/* ... */}
        </EntitySystemContext.Provider>
    );
}

EntityList

This component aids in displaying a list of entities:

import { EntityList } from '@bithero/react-entity-components';

const MyEntityList = () => {
    return (
        <div>
            <EntityList
                {/* The headers of the table; required */}
                header={[
                    {/* See desciption of IEntityListHeadConfig below */}
                    {label: 'ID', field: 'id'},
                    {label: 'Name', field: 'name'},
                ]}
                {/* Name of the entity which will be given to the entity callbacks in the EntitySystemContext; required */}
                entityName='myEntity'
                {/*
                    If set, the list shows an add button to create entities.
                    When the button is pressed, it navigates to the current location + the suffix '/new'.
                    Example:
                        List is displayed at route '/myEntities'. When the add button is pressed, the router
                        navigates to '/myEntities/new'.
                */}
                enableAdding
                {/* A render function to render a component when the list is in an loading state */}
                renderLoading={() => (<span>Is loading myEntity...</span>)}
            />
        </div>
    )
}

An heading entry has following structure:

type AsyncFieldGetter = (val: any) => Promise<string>;
type SyncFieldGetter = (val: any) => string;

interface IEntityListHeadConfig {
    // Label for the colum; displayed in the table's header.
    label: string

    // Provide an namespace for @bithero/simple-search-lib to map to the column.
    searchNamespace?: string

    // Used to lookup the value to display in the cells.
    //  - If an string: simply use as key into the object (i.e. `entity[field]`).
    //  - If an *FieldGetter: called with the current entity and expects it
    //    to return the value to display in the cell.
    field: string | AsyncFieldGetter | SyncFieldGetter
}

EntityDetail

This component is the "heart" of the library: here you build your form to display & modify entites. It can also be used as an creation dialog!

import { EntityDetail, FInput, FSelect, FSelectBox, FTextarea } from '@bithero/react-entity-components';

const MyEntityDetail = () => {
    const renderOption = (opt: any): JSX.Element => {
        return <option value={opt.id} key={opt.id}>{opt.name}</option>;
    }

    return (
        <EntityDetail
            title='New Entity'
            parentTitle='MyEntity'
            parentHref='/myEntity'
            {/* With this you can set an default entity; optional */}
            defaultEntity={{}}
            {/* Name of the entity which will be given to the entity callbacks in the EntitySystemContext; required */}
            entityName='myEntity'
            {/* If set, the entire form is readonly */}
            readonly
            {/* A render function to render a component when the list is in an loading state */}
            renderLoading={() => (<span>Is loading myEntity...</span>)}
        >
            {/*
                All components starting with F are components that provide some
                bootstrap components, wrapped so it works with the entity system.
                For more informations about them, see the documentation about field components (link below).
            */}
            <FInput attr="name" label="Name" defaultValue={'John'} required/>
            <FInput attr="pass" label="Password" type="password"/>
            <FTextarea attr="desc" label="Description" defaultValue={"Some fancy text"}/>
            <FCheck attr="enabled" label='Enabled' default={true}></FCheck>
            <FSelect attr="sel" label="Selection" entityName='refEntity' renderOption={renderOption}/>
            <FSelectBox attr="ref" label="Reference" entityName='refEntity' entityLabelAttr='name' required></FSelectBox>
        </EntityDetail>
    );
};

Link to the documentation about field-components: see here