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

@lee-cha-dev/lc-components

v1.0.8

Published

A set of reusable React UI Components

Readme

LC Components

TimeRangeSlider React Component

A highly customizable and themeable time range slider component for React, designed to select a date range from a given time-series dataset. It features a mini-chart for data visualization, dual-handle sliders, and direct date inputs for a seamless user experience.


Installation

To use this component in your project, install it via npm or yarn:

npm install @lee-cha-dev/lc-components

or

yarn add @lee-cha-dev/lc-components

Usage

First, you need to import the TimeRangeSlider component and its required stylesheet into your React component file. Then, manage the selected range using React's state.

Here is a complete example of how to implement the component:

import React, {useState, useMemo} from 'react';

// 1. Import the component and its CSS from the package
import {TimeRangeSlider} from '@lee-cha-dev/lc-components';
import '@lee-cha-dev/lc-components/dist/index.css';

function App() {
    // 2. Set up state to manage the selected range
    const [range, setRange] = useState({startIndex: 10, endIndex: 80});

    // 3. Provide your time-series data
    // Each object needs a `date` (YYYY-MM-DD) and an optional `value` for the chart
    const myData = useMemo(() => {
        const data = [];
        const startDate = new Date('2023-01-01');
        for (let i = 0; i < 100; i++) {
            const newDate = new Date(startDate);
            newDate.setDate(startDate.getDate() + i);
            data.push({
                date: newDate.toISOString().split('T')[0],
                value: 50 + Math.sin(i / 10) * 25 + Math.random() * 20,
            });
        }
        return data;
    }, []);

    // 4. Create a handler to update the state when the range changes
    const handleRangeChange = (newStartIndex, newEndIndex) => {
        setRange({startIndex: newStartIndex, endIndex: newEndIndex});
    };

    return (
        <div style={{padding: '2rem'}}>
            <TimeRangeSlider
                data={myData}
                startIndex={range.startIndex}
                endIndex={range.endIndex}
                onRangeChange={handleRangeChange}
                theme="dark" // or "light"
            />

            {/* Optional: Display the selected data */}
            <div style={{marginTop: '2rem', color: '#fff'}}>
                <h3>Selected Range:</h3>
                <p>
                    From {myData[range.startIndex].date} to {myData[range.endIndex].date}
                </p>
            </div>
        </div>
    );
}

export default App;

API Reference (Props)

The TimeRangeSlider component accepts the following props:

| Prop | Type | Required | Default | Description | |-----------------|------------------------|----------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------| | data | Array<Object> | Yes | [] | An array of data points. Each object must conform to the data structure below. The array should be pre-sorted by date in ascending order. | | startIndex | number | Yes | 0 | The starting index of the selected range within the data array. | | endIndex | number | Yes | 0 | The ending index of the selected range within the data array. | | onRangeChange | (start, end) => void | No | 'en-US' | A string representing the locale for formatting dates (e.g., 'en-GB', 'de-DE'). | | theme | string | No | 'dark' | A string representing the color theme to be used. | | className | string | No | '' | A string of custom CSS classes to apply to the component's root element for further styling. |

Data Structure

The data prop expects an array of objects, where each object has the following structure:

interface DataPoint {
  /**
   * The date for the data point.
   * @format 'YYYY-MM-DD'
   */
  date: string;

  /**
   * The numerical value for the data point, used to render the mini-chart.
   * If not provided, the chart will render as a flat line.
   */
  value?: number;
}