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

react-material-selectable-inputtext

v1.0.3

Published

Material-ui textInput component that allow choose between several options.

Downloads

6

Readme

react-material-selectable-textinput

Material-ui textInput component that allow choose between several options and add more by writing and adding.

You can see a demo (here)[https://adrianfdez469.github.io/demo-material-selectable-input/] and the code of the demo (hete)[https://github.com/adrianfdez469/demo-material-selectable-input]

Code Example

import React from "react";
import InputSelect from "react-material-selectable-inputtext";

export default () => {
	const [allCountries, setAllCountries] = React.useState([]);
	const [selected, setSelected] = React.useState([]);

	// Populating all countries
	React.useEffect(() => {
		(async () => {
			const countriesResp = await fetch("https://restcountries.eu/rest/v2/all");
			if (countriesResp.ok) {
				const countries = await countriesResp.json();
				const mappedCountries = countries.map((c) => {
					return { id: c.name, text: c.name, population: c.population };
				});
				setAllCountries(mappedCountries);
			}
		})();
	}, []);

	const onAddHandler = (item) => {
		// Add more logic if you want
		setSelected([...selected, item]);
	};

	return (
		<div style={{ margin: "20px", fontSize: "20px" }}>
			<InputSelect
				optionsList={allCountries}
				excludedOptions={selected}
				onAdd={onAddHandler}
				textFieldProps={{
					variant: "outlined",
				}}
			/>
			{selected.map((item) => (
				<div
					key={item.text}
				>{`Country: ${item.text} |  Population: ${item.population}`}</div>
			))}
		</div>
	);
};

Motivation

This package arises from the non-existence in the material-ui library of a component that will merge the functionalities of TextField and Select into one single component. With this package you can have a TextField with the Select functionality. While you type on it, you can see and select one of the available options that pop up. It uses the material-ui (TextField)[https://material-ui.com/es/components/text-fields/] component, so it behaves as one.

Instalation

Pre-requisitos

Before yo use this pacakge be awere that it needs @material-ui/core@^4.11.3 and @material-ui/icons@^4.11.2 to work properly.

npm install @material-ui/core @material-ui/icons or yarn add @material-ui/core @material-ui/icons

Install

npm install react-material-selectable-inputtext or yarn add react-material-selectable-inputtext

API Reference

Types of props are important, be aware that the types that are passed to optionsList and excludedOptions must be array of objects with the shape of:

[
	{
		id: "id1",
		text: "Text to show",
		// any other properties you want
	},
];

| Prop | Type * | Required | Description | | ----------------- | -------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------- | | optionsList | { id: string, text: string }[] | true | Should contain the full list of posibles items to show for select | | excludedOptions | { id: text, text: string }[] | false | Should contain the items that you dont want to show anymore, could be the list of previous selected items. | | onAdd | (item: {id: string, text: string}) => void | false | Callback function to run when an item is added. | | textFieldProps | TextFieldProps from @material-ui/core lib | false | Object that recieves any property of the TextField component of @material-ui/core/TextField. |

Creator

License

This project is under MIT License - look the file LICENSE.md for more details.

Contributing 🖇️

Please read the CONTRIBUTING.md for more details of our conduct code, and the proccess to send pull requests.

Expressions of Gratitude 🎁

  • Tell others about this project 📢
  • Invite someone on the team to have a beer 🍺 or coffee ☕ or a coffe.
  • Give thanks publicly 🤓.

⌨️ with ❤️ by adrianfdez469 😊