Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
simple-search-dropdown
Advanced tools
Componente com sistema de pesquisa e dropdown imbutidos em um só. É possível listar todos os itens duma lista e filtrar por aquilo que você está buscando, sendo compativel até mesmo com requisições de APIs.
Instalando simple-search-dropdown
:
npm install simple-search-dropdown
# OU
yarn add simple-search-dropdown
# OU
pnpm add simple-search-dropdown
[!IMPORTANT]
Caso queira usar somente o componenteSearchSelect
, é necessário importar o CSS como mostrado abaixo:
@import url('../node_modules/simple-search-dropdown/dist/style.css');
import { SearchSelect } from 'simple-search-dropdown'
function App() {
const data = [
{value: 1, label: "Abacaxi"},
{value: 2, label: "Banana"},
{value: 3, label: "Avião"},
{value: 4, label: "Bola"},
{value: 5, label: "Lula"},
{value: 6, label: "Faca"},
{value: 7, label: "Magnus"},
{value: 8, label: "Xadrez"},
]
return (
<main className="flex flex-col justify-center items-center ">
<div className="flex flex-col mt-2">
<SearchSelect data={data} placeholder="Pesquisar"} />
</div>
</main>
)
}
export default App
import { SearchSelect } from 'simple-search-dropdown'
function App() {
const promiseOptions = () =>
new Promise((resolve) => {
setTimeout(() => {
const data = [
{value: 1, label: "Abacaxi"},
{value: 2, label: "Banana"},
{value: 3, label: "Avião"},
{value: 4, label: "Bola"},
{value: 5, label: "Lula"},
{value: 6, label: "Faca"},
{value: 7, label: "Magnus"},
{value: 8, label: "Xadrez"},
]
resolve(data);
}, 1000);
});
return (
<main className="flex flex-col justify-center items-center ">
<div className="flex flex-col mt-2">
<SearchSelect data={promiseOptions} placeholder="Pesquisar"} />
</div>
</main>
)
}
export default App
import { useForm } from 'react-hook-form'
import { SearchSelect } from 'simple-search-dropdown'
function App() {
const { handleSubmit, register } = useForm()
const promiseOptions = () =>
new Promise((resolve) => {
setTimeout(() => {
const data = [
{ value: 1, label: 'Abacaxi' },
{ value: 2, label: 'Banana' },
{ value: 3, label: 'Avião' },
{ value: 4, label: 'Bola' },
{ value: 5, label: 'Lula' },
{ value: 6, label: 'Faca' },
{ value: 7, label: 'Magnus' },
{ value: 8, label: 'Xadrez' },
]
resolve(data)
}, 1000)
})
return (
<main className="flex flex-col justify-center items-center ">
<form className="flex flex-col mt-2" onSubmit={handleSubmit((data) => console.log(data))}>
<SearchSelect data={promiseOptions} placeholder="Pesquisar" {...register('abc')} />
<button type="submit" className="p-2 bg-blue-500 text-white mt-2">
Submit
</button>
</form>
</main>
)
}
export default App
É possível fazer seu próprio componente usando o Select
e useDataSearch
do pacote.
[!NOTE]
O uso do CSS presente na dependência se torna totalmente OPCIONAL aqui.
import { Select, useDataSearch } from 'simple-search-dropdown'
function YourSelectComponent({ data, name }) {
const itemFiltered = useDataSearch(data, name)
return (
<Select name={name}>
<Select.Trigger>
<Select.Search />
</Select.Trigger>
<Select.Panel>
{itemFiltered.length > 0 &&
itemFiltered.map((item, idx) => <Select.Item key={idx} value={item.value} label={item.label} />)}
</Select.Panel>
</Select>
)
}
export default YourSelectComponent
[!WARNING]
Os dados vindo do parâmetrodata
precisa ser uma lista com o seguinte formato:{ label: "", value: 0 || "" }
. E o parâmetroname
servirá para vincular o campo com os dados filtrados.
Contribuições são sempre bem-vindas!
É necessário o entendimento de TypeScript para contribuições envolvendo os componentes. Além do TypeScript, entender como funciona o react e ref são essenciais.
Clone o projeto
git clone https://github.com/KingTimer12/simple-search-dropdown.git
Entre no diretório do projeto
cd simple-search-dropdown
Instale as dependências
pnpm install
Para rodar os testes, rode o seguinte comando
npm run test
# OU
yarn test
# OU
pnpm test
0.2.0 (2024-08-22)
FAQs
Simple Search Dropdown
The npm package simple-search-dropdown receives a total of 0 weekly downloads. As such, simple-search-dropdown popularity was classified as not popular.
We found that simple-search-dropdown demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.