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 🙏

© 2024 – Pkg Stats / Ryan Hefner

caver-react-select

v1.0.4

Published

A select input which can be styled without sacrificing accessibility.

Downloads

3

Readme

coverage coverage coverage

React Custom Select Input

This package is part of a student project, translating an original idea by Sandrina Pereira.

This library aims to provide a select input which can be styled without sacrificing accessibility. To achieve this, a custom element is superimposed on a native input. When users interact with the component using assistive technologies, they face the native selecti. If they use a mouse, they will face the custom element.

My contribution lies in porting the code to a reusable React component as well as adding TypeScript support, and complete coverage of the component by integration tests (vitest).

Setup

This is a controlled input component.

props :

  • inputsState - A state in the form of an object containing all the inputs values;
  • inputState - A string representing the state property which will be assigned;
  • setInputsState - The state setter;
  • id : string;
  • label : string;
  • placeholder : string;
  • options - An array of objects representing the values and names of the proposed options : { value: string; labor: string; };
  • showValidation - A boolean to know whenever the warning message should be displayed or not;
  • validationMsg - A string representing the warning message.
import { useState } from "react";
import Select from "caver-react-select";

import "caver-react-select/src/stylesheets/select.css";

function Example() {
  const [state, setState] = useState({ number: "" });
  const [showValidation, setShowValidation] = useState({ number: false });

  const validation = () => {
    if (state.number === "") setShowValidation((state) => ({ ...state, number: true }));
    else setShowValidation((state) => ({ ...state, number: false }));
  };

  const options = [
    { value: "1", labor: "One" },
    { value: "2", labor: "Two" },
    { value: "3", labor: "Three" },
    { value: "4", labor: "Four" },
    { value: "5", labor: "Five" },
    { value: "6", labor: "Six" },
  ];

  return (
    <>
      <form
        onSubmit={(e) => {
          e.preventDefault();
          validation();
        }}
      >
        <Select
          inputsState={state}
          inputState="number"
          setInputsState={setState}
          id="number"
          label="Select a number"
          placeholder="Choose"
          options={options}
          showValidation={showValidation.number}
          validationMsg="Please select a number."
        />
        <button type="submit">Submit</button>
      </form>
    </>
  );
}