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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-softsheet

v1.0.387

Published

## Overview

Downloads

46

Readme

SoftSheet Library

Overview

SoftSheet is a comprehensive table library for React applications, providing powerful features for managing table state, keyboard navigation, filtering, and dynamic rendering of table content.

Installation

To install the SoftSheet library, use the following npm command:

npm install softsheet

Setup

Wrap your application with ThisProvider to provide SoftSheet to your app:

import { ThisProvider } from "react-usethis/thisProvider";

<ThisProvider>
  <App />
</ThisProvider>

Now SoftSheet is ready to use inside your App.

API Reference

Keyboard Navigation

The library provides several functions for managing keyboard navigation within tables:

  • setCellActive({ row, col, tableId }): Sets the active cell in the table.
  • left(tableId): Moves the active cell to the left.
  • right(tableId): Moves the active cell to the right.
  • down(tableId): Moves the active cell down.
  • up(tableId): Moves the active cell up.
  • keyEnabled(stat, tableId): Enables key navigation for the table.

Filter Options

The SoftSheet library includes components and interfaces for handling filtering:

export interface FILTER_DATA {
    selected: (string | number)[];
    hover: number;
    options: {
        label: string;
        value: string | number;
    }[];
    searchQuery: string;
    visible: boolean;
    multiple: boolean;
    placeholder: string | null;
}
export interface setter {
    data: FILTER_DATA;
    set: Dispatch>;
}
export interface FitlerOptions {
    label: string;
    value: string | number;
}
export interface FilterProps {
    name?: string;
    options: FitlerOptions[];
    onChange?: (selected: FILTER_DATA["selected"], name: string | null) => void;
    multiple?: boolean;
    defaultValue?: FitlerOptions["value"];
    placeholder?: string;
}

The SoftSelect component can be used to create filterable select inputs:

import { SoftSelect } from "softsheet";

function Example() {
    const options = [
        { label: "Option 1", value: 1 },
        { label: "Option 2", value: 2 },
    ];

    return (
        <SoftSelect
            name="example"
            options={options}
            onChange={(selected, name) => console.log(selected, name)}
        />
    );
}

Reflect Functions

The library allows you to dynamically render table cells and headers using reflect functions:

export interface ReflectFunction {
    cellClass?: string;
    cellStyle?: any;
    view?: ReactElement;
    props?: React.HTMLAttributes;
}
export interface ReflectHeaderProps {
    row: any;
    col: any;
    index: number;
}
export interface ReflectProps {
    row: any;
    col: any;
    row_no: number;
    index: number;
    keyboard: KeyboardProps;
    col_name: string;
}
export interface FilterProps {
    row: any;
    col: any;
    row_no: number;
    index: number;
    keyboard: KeyboardProps;
}
interface KeyboardProps {
    navigation: {
        up: () => void;
        down: () => void;
        left: () => void;
        right: () => void;
    };
    cursor: {
        setActive: (props: setCellActive) => void;
    };
}

Table Configuration

The main SoftsheetType interface defines the structure of a SoftSheet table:

export interface SoftsheetType {
    header: {
        [key: string]: string | ((data: ReflectHeaderProps) => ReflectFunction);
    };
    data: {
        [key: string]: string;
    }[];
    reflect?: {
        [key: string]: (data: ReflectProps) => ReflectFunction | ReactElement;
    };
    filter?: {
        data: {
            [key: string]: {
                name?: string;
                multiple?: boolean;
                defaultValue?: FitlerOptions["value"];
                placeholder?: string;
                type?: "select" | "search";
                options?: FitlerOptions[];
                view?: () => void;
            };
        };
        onChange?: (selected: FitlerOptions, name: string | null) => void;
    };
    serial_no?: {
        visible?: boolean;
        reflect?: {
            header?: (data: ReflectHeaderProps) => ReflectFunction;
            row?: (data: ReflectHeaderProps) => ReflectFunction;
        };
    };
    template?: string;
    style?: CSSProperties;
    autoFocus?: boolean;
    className?: string;
    props?: {
        mainContainer?: React.HTMLAttributes;
        mainTable?: any;
        tableHead?: React.HTMLAttributes;
        tableBody?: React.HTMLAttributes;
        tableRow?: React.HTMLAttributes;
    };
}

Example Usage

import { SoftSheet } from "softsheet";

const tableProps = {
    header: {
        name: "Name",
        email: "Email",
    },
    data: [
        { name: "Alice Johnson", email: "[email protected]" },
        { name: "Bob Smith", email: "[email protected]" },
        { name: "Charlie Brown", email: "[email protected]" },
    ],
    reflect: {
        name: (data) => ({
            view: <strong>{data.row.name}</strong>,
            cellStyle: { color: "blue" },
        }),
    },
    filter: {
        data: {
            name: {
                type: "search",
                options: [
                    { label: "Alice", value: "[email protected]" },
                    { label: "Bob", value: "[email protected]" },
                ],
            },
        },
        onChange: (selected, name) => console.log(selected, name),
    },
};

function App() {
    return <SoftSheet {...tableProps} />;
}

Conclusion

SoftSheet is a versatile and powerful library for managing tables in React applications. By leveraging its robust features for state management, filtering, and dynamic rendering, you can create highly interactive and customizable tables with ease.