Điểm qua clauderic/react-autocompletely: 16 sao trên GitHub, viết chủ yếu bằng JavaScript. 🔮 Primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components
The problem
You need an autocomplete experience in your application and you want it to be
accessible. You also want it to be simple and flexible to account for your use
cases.
This solution
This is a collection of primitive components that you can compose together to
create an autocomplete component which you can reuse in your application. It's
based on ideas from the talk "Compound Components"
which effectively gives you maximum flexibility with a minimal API because you
are responsible for the rendering of the autocomplete components.
This differs from other solutions which render things for their use case and
then expose many options to allow for extensibility causing an API that is less
easy to use and less flexible as well as making the implementation more
complicated and harder to contribute to.
Installation
This component is currently under development and is not yet released...
This module is distributed via npm which is bundled with node and
should be installed as one of your project's dependencies:
npm install --save react-autocompletely
This package also depends on react and prop-types. Please make sure you have
those installed as well.
Usage
Things are still in flux a little bit (looking for feedback).
import Autocomplete from 'react-autocompletely'
// use components together here.
Available components and relevant props:
Autocomplete
This is the main component. It renders a div and forwards props. Wrap
everything in this.
onChange
function(item: any) | required
Called when the user selects an item
Autocomplete.Input
This is the input component. It renders an input and forwards props.
defaultValue
string / null | defaults to null
The initial value the input should have when it's mounted.
getValue
function(item: any) | defaults to an identity function (i => String(i))
Used to determine the inputValue for the selected item.
Autocomplete.Controller
This component allows you to receive and interact with the state of the
autocomplete component.
children
function({}) | required
This is called with an object with the properties listed below:
property
type
description
highlightedIndex
number / null
the currently highlighted item
setHighlightedIndex
function(index: number)
call to set a new highlighted index
inputValue
string / null
the current value of the input
isOpen
boolean
the menu open state
toggleMenu
function(state: boolean)
toggle the menu open state (if state is not provided, then it will be set to the inverse of the current state)
openMenu
function()
opens the menu
closeMenu
function()
closes the menu
selectedItem
any
the currently selected item
clearSelection
function()
clears the selection
selectItem
function(item: any)
selects the given item
selectItemAtIndex
function(index: number)
selects the item at the given index
selectHighlightedItem
function()
selects the item that is currently highlighted
Autocomplete.Menu
This component allows you to render the items based on the user input. It
renders a div with another div for your items and a div for the menu
status (for accessibility purposes)
defaultHighlightedIndex
number/null | defaults to null
This is the initial index to highlight when the menu first opens.
children
function({}) | required
This is called with the same things that the children prop is called with for
Autocomplete.Controller
Autocomplete.Item
Render your items inside this component. This renders a div and forwards all
props.
index
number | required
this is how react-autocompletely keeps track of your item when updating the
highlightedIndex as the user keys around.
value
any | required
This is the item data that will be selected when the user selects a particular
item.
Examples
Examples exist on codesandbox.io:
react-autocompletely Apollo example
If you would like to add an example, follow these steps:
Fork this codesandbox
Update the code for your example (add some form of documentation to explain what it is)
Update the title and description
Add the tag: react-autocompletely:example
Inspiration
I was heavily inspired by Ryan Florence and his talk entitled:
"Compound Components". I also took a few ideas from
the code in react-autocomplete and
jQuery UI's Autocomplete.
You can watch me build the first iteration of react-autocompletely on YouTube:
Part 1
Part 2
Other Solutions
You can implement these other solutions using react-autocompletely, but if
you'd prefer to use these out of the box solutions, then that's fine too:
react-select
react-autocomplete
Contributors
Thanks goes to these people (emoji key):
Kent C. Dodds 💻 📖 🚇 ⚠️
Jack Moore 💡
Travis Arnold 💻 📖
Jeremy Gayed 💡
Haroen Viaene 💡
monssef 💡
Federico Zivolo 📖
Divyendu Singh 💡
Muhammad Salman 💻
This project follows the all-contributors specification.
Contributions of any kind welcome!
clauderic/react-autocompletely có phải mã nguồn mở không?
Có — clauderic/react-autocompletely phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/clauderic/react-autocompletely.
clauderic/react-autocompletely có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho clauderic/react-autocompletely. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
clauderic/react-autocompletely dùng license gì?
clauderic/react-autocompletely phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
clauderic/react-autocompletely là gì?
clauderic/react-autocompletely (clauderic/react-autocompletely) là dự án JavaScript trên GitHub. Theo mô tả gốc: 🔮 Primitives to build simple, flexible, WAI-ARIA compliant React autocomplete components
Đọc thêm về clauderic/react-autocompletely ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/clauderic/react-autocompletely là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
react-autocompletely có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về react-autocompletely.