All Projects → maticzav → Ink Autocomplete

maticzav / Ink Autocomplete

🧠 An autocomplete component for Ink.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ink Autocomplete

Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (+4528.17%)
Mutual labels:  cli, autocomplete
Graphqurl
curl for GraphQL with autocomplete, subscriptions and GraphiQL. Also a dead-simple universal javascript GraphQL client.
Stars: ✭ 3,012 (+4142.25%)
Mutual labels:  cli, autocomplete
Vcli
Vertica CLI with auto-completion and syntax highlighting
Stars: ✭ 75 (+5.63%)
Mutual labels:  cli, autocomplete
Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-25.35%)
Mutual labels:  cli, autocomplete
Bit
Bit is a modern Git CLI
Stars: ✭ 5,723 (+7960.56%)
Mutual labels:  cli, autocomplete
Caporal.js
A full-featured framework for building command line applications (cli) with node.js
Stars: ✭ 3,279 (+4518.31%)
Mutual labels:  cli, autocomplete
Gql
Very simple CLI for many GraphQL schemas in the cloud. Provides autocompletion for GraphQL queries
Stars: ✭ 101 (+42.25%)
Mutual labels:  cli, autocomplete
Autocomplete
Autocomplete for terminals on MacOS
Stars: ✭ 569 (+701.41%)
Mutual labels:  cli, autocomplete
Influx Prompt
An interactive command-line InfluxDB cli with auto completion.
Stars: ✭ 42 (-40.85%)
Mutual labels:  cli, autocomplete
Http Prompt
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
Stars: ✭ 8,329 (+11630.99%)
Mutual labels:  cli, autocomplete
Pyinquirer
A Python module for common interactive command line user interfaces
Stars: ✭ 1,151 (+1521.13%)
Mutual labels:  cli
Kju
Kju — Improved waiting time for the adidas.com splash page ❯❯❯_
Stars: ✭ 68 (-4.23%)
Mutual labels:  cli
Hopp Doc Gen
📔 API documentation generator CLI for https://hoppscotch.io
Stars: ✭ 70 (-1.41%)
Mutual labels:  cli
Vbb Cli
A CLI for Berlin & Brandenburg public transport.
Stars: ✭ 70 (-1.41%)
Mutual labels:  cli
Pillager
Pillage filesystems for sensitive information with Go.
Stars: ✭ 64 (-9.86%)
Mutual labels:  cli
Tent
Podman (https://podman.io/) based development-only dependency manager for Linux
Stars: ✭ 69 (-2.82%)
Mutual labels:  cli
Toc
🚩 TOC, zero configuration table of content generator for Markdown files, create table of contents from any Markdown file with ease.
Stars: ✭ 66 (-7.04%)
Mutual labels:  cli
Node Installed Check
Checks that all dependencies in your package.json have supported versions installed and complies with your specified node engine version range
Stars: ✭ 67 (-5.63%)
Mutual labels:  cli
Supremedropbot
A supreme web bot, written in python, to grab a list of specified products, and checkout before they sell out!
Stars: ✭ 66 (-7.04%)
Mutual labels:  autocomplete
Zap
A CLI for cleaning up after .apps
Stars: ✭ 70 (-1.41%)
Mutual labels:  cli

ink-autocomplete Build Status

Autocomplete component for Ink.

Install

$ npm install ink-autocomplete

Usage

Use arrows to navigate up and down and press enter to submit.

import {h, render, Component, Text} from 'ink'
import AutoComplete from 'ink-autocomplete'

// Demo
class Demo extends Component {
  constructor() {
    super()

    this.state = {
      value: '',
      selected: null
    }

    this.handleChange = this.handleChange.bind(this)
    this.handleSubmit = this.handleSubmit.bind(this)
  }

  render(props, {value, selected}) {
    const countries = [
      {
        label: 'United Kingdom',
        value: {country: 'United Kingdom', capital: 'London'}
      },
      {
        label: 'United States',
        value: {country: 'United States', capital: 'Washington DC'}
      },
      {
        label: 'United Arab Emirates',
        value: {country: 'United Arab Emirates', capital: 'Abu Dhabi'}
      }
    ]

    return (
      <div>
        <Text green>{'Enter your country: '}</Text>
        <AutoComplete
          value={value}
          placeholder={'Type a country'}
          items={countries}
          onChange={this.handleChange}
          onSubmit={this.handleSubmit}
        />
        { selected && (
          <span>
            <Text>The capital of your country is: </Text>
            <Text red>{selected.value.capital}</Text>
          </span>
        )}
      </div>
    )
  }

  handleChange(value) {
    this.setState({
      value,
      selected: null
    })
  }

  handleSubmit(selected) {
    this.setState({
      selected
    })
  }
}

// Ink
render(<Demo/>)

Props

value string

Value of the input.

placeholder string

String displayed when the input is empty.

items array<item>

A list of all items. Each item must include label and value property.

getMatch string => item => bool

Called to determine which items satisfy the input.

onChange function string => ()

Called each time input is changed.

onSubmit function (item) => ()

Called once suggestion is selected.

indicatorComponent Component

Custom component to override the default item component.

itemComponent Component

Custom component to override the default item component.

License

MIT © Matic Zavadlal

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].