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

report-component-toolkit

v1.0.1

Published

```js import React, { useEffect, useState } from "react" import _ from "lodash" import { Grid, Box } from "@mui/material" import { ExcelReader } from "excel-reader-toolkit" import "./App.css" import RUIDropDown from "./Shared/RUIDropDown" import RUIErrorD

Readme

วิธีใช้งาน

import React, { useEffect, useState } from "react"
import _ from "lodash"
import { Grid, Box } from "@mui/material"
import { ExcelReader } from "excel-reader-toolkit"
import "./App.css"
import RUIDropDown from "./Shared/RUIDropDown"
import RUIErrorDialog from "./Shared/RUIErrorDialog"
import RUIFieldArray from "./Shared/RUIFieldArray"
import RUIForm from "./Shared/RUIForm"
import RUIMultiTextFields from "./Shared/RUIMultiTextFields"
import RUITextField from "./Shared/RUITextField"
import RUITitle from "./Shared/RUITitle"
import { Computer } from "@mui/icons-material"
import { ruiTheme } from "./Shared/theme"
import { RUIThemeProvider } from "./Shared/ThemeContext"

const INITIAL_DATA = {
  deviceName: { label: "Device name", value: "", placeholder: "Device name" },
  os: { label: "OS", value: "Android 9", options: ["Android 9", "Android 10", "Android 11"] },
  model: { label: "Model", value: "", placeholder: "Model" },
  iccids: { label: "ICCID", value: [] },
  imsis: { label: "IMSI", value: [] },
  sims: {
    label: "SIM",
    members: [
      { name: "ISP", label: "ISP", size: 4 },
      { name: "ICCID", label: "ICCID", size: 4 },
      { name: "IMSI", label: "IMSI", size: 4 },
    ],
    value: [],
  },
}

export default function App() {
  const [isError, setIsError] = useState(false)
  const [excelData, setExcelData] = useState([])

  const loadFormData = () => {
    try {
      const saved = localStorage.getItem("formData")
      if (!saved) return INITIAL_DATA
      const parsed = JSON.parse(saved)
      return _.mapValues(INITIAL_DATA, (field, key) => ({
        ...field,
        value: _.get(parsed, [key, "value"], field.value),
      }))
    } catch {
      return INITIAL_DATA
    }
  }

  const [formData, setFormData] = useState(loadFormData)

  const saveFormData = (updated) => {
    localStorage.setItem("formData", JSON.stringify(updated))
    return updated
  }

  useEffect(() => {
    if (!excelData?.length) return

    const managedData = _.chain(excelData)
      .map((item) => ({
        name: item.__EMPTY_1,
        value: item.__EMPTY_2,
      }))
      .groupBy("name")
      .value()

    const deviceName = _.chain(managedData).get("Device Name", []).map("value").first().value()
    const os = _.chain(managedData).get("OS", []).map("value").first().value()
    const iccids = _.chain(managedData).get("ICCID", []).map("value").filter(Boolean).uniq().value()
    const imsis = _.chain(managedData).get("IMSI", []).map("value").filter(Boolean).uniq().value()

    setFormData((prev) => {
      const updated = {
        ...prev,
        deviceName: { ...prev.deviceName, value: deviceName || prev.deviceName.value },
        os: { ...prev.os, value: os || prev.os.value },
        iccids: { ...prev.iccids, value: _.uniq([...prev.iccids.value, ...iccids]) },
        imsis: { ...prev.imsis, value: _.uniq([...prev.imsis.value, ...imsis]) },
      }
      return saveFormData(updated)
    })
  }, [excelData])

  const handleChange = (target) => (e) => {
    setFormData((prev) => {
      const updated = _.set({ ...prev }, [target, "value"], e.target.value)
      return saveFormData(updated)
    })
  }

  const handleReset = () => {
    localStorage.removeItem("formData")
    setFormData(_.cloneDeep(INITIAL_DATA))
  }

  const handleSubmit = () => {
    try {
      console.log(formData)
      alert("Submit Success")
    } catch (error) {
      console.error(error)
      setIsError(true)
    }
  }

  return (
    <Box sx={{ p: 3 }}>
      <RUIThemeProvider defaultTheme="light">
        <RUIForm title="User Information" icon={<Computer />} color="#fff" onReset={handleReset} onSubmit={handleSubmit}>
          <RUITitle title="Sample Form" subtitle="Report Component Toolkit Demo" />
          <Grid item xs={12}>
            <ExcelReader text="กรุณาเลือกไฟล์ Excel" setData={setExcelData} />
          </Grid>
          <RUITextField sm={6} {...formData.deviceName} handleChange={handleChange("deviceName")} />
          <RUIDropDown sm={6} {...formData.os} handleChange={handleChange("os")} />
          <RUITextField sm={12} {...formData.model} handleChange={handleChange("model")} />
          <RUIMultiTextFields sm={12} {...formData.iccids} handleChange={handleChange("iccids")} />
          <RUIMultiTextFields sm={12} {...formData.imsis} handleChange={handleChange("imsis")} />
          <RUIFieldArray sm={12} {...formData.sims} handleChange={handleChange("sims")} />
          <RUIErrorDialog isDialogOpen={isError} error="An error has occurred." setIsDialogOpen={setIsError} />
        </RUIForm>
      </RUIThemeProvider>
    </Box>
  )
}