├── .npmrc ├── .gitattributes ├── .eslintignore ├── src ├── index.js ├── constants.js ├── controller.js ├── __tests__ │ └── index.js ├── item.js ├── utils.js ├── menu-status.js ├── input.js ├── menu.js └── autocomplete.js ├── examples ├── pages │ ├── react-select │ │ └── index.js │ ├── react-autocomplete │ │ └── index.js │ ├── index.js │ ├── _document.js │ ├── react-instantsearch │ │ └── index.js │ ├── axios-request │ │ └── index.js │ ├── apollo │ │ └── index.js │ ├── react-popper │ │ └── index.js │ ├── basic │ │ └── index.js │ └── semantic-ui │ │ └── index.js ├── .babelrc ├── .eslintrc ├── next.config.js ├── README.md ├── package.json └── other │ └── countries.js ├── CHANGELOG.md ├── .gitignore ├── .eslintrc ├── .babelrc ├── .travis.yml ├── jest.config.js ├── other ├── USERS.md ├── manual-releases.md ├── MAINTAINING.md └── CODE_OF_CONDUCT.md ├── LICENSE ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── package-scripts.js ├── package.json ├── .all-contributorsrc ├── CONTRIBUTING.md └── README.md /.npmrc: -------------------------------------------------------------------------------- 1 | registry=http://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | dist 4 | examples/other/react-autocompletely 5 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import Autocomplete from './autocomplete' 2 | 3 | export default Autocomplete 4 | -------------------------------------------------------------------------------- /src/constants.js: -------------------------------------------------------------------------------- 1 | export const AUTOCOMPLETE_CONTEXT = '__autocomplete__' 2 | export const MENU_CONTEXT = '__autocomplete_menu__' 3 | -------------------------------------------------------------------------------- /examples/pages/react-select/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default Examples 4 | 5 | function Examples() { 6 | return
react-select examples
7 | } 8 | -------------------------------------------------------------------------------- /examples/pages/react-autocomplete/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default Examples 4 | 5 | function Examples() { 6 | return
react-autocomplete examples
7 | } 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | The changelog is automatically updated using [semantic-release](https://github.com/semantic-release/semantic-release). 4 | You can see it on the [releases page](../../releases). 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | dist 4 | .opt-in 5 | .opt-out 6 | .DS_Store 7 | .next 8 | examples/other/react-autocompletely 9 | 10 | # these cause more harm than good 11 | # when working with contributors 12 | package-lock.json 13 | yarn.lock 14 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "kentcdodds", 4 | "kentcdodds/react", 5 | "kentcdodds/jest", 6 | "kentcdodds/prettier", 7 | ], 8 | "rules": { 9 | "max-len": "off", 10 | "max-lines": "off", 11 | "func-style": "off" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "targets": { 7 | "node": "4.5" 8 | } 9 | } 10 | ], 11 | "react" 12 | ], 13 | "plugins": ["transform-class-properties", "transform-object-rest-spread"] 14 | } 15 | -------------------------------------------------------------------------------- /examples/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "targets": { 7 | "node": "4.5" 8 | } 9 | } 10 | ], 11 | "react" 12 | ], 13 | "plugins": [ 14 | "babel-macros", 15 | "transform-class-properties", 16 | "transform-object-rest-spread" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | cache: 4 | directories: 5 | - node_modules 6 | notifications: 7 | email: false 8 | node_js: 9 | - '8' 10 | script: 11 | - npm start validate 12 | after_success: 13 | - npx codecov 14 | # uncomment this when we're ready to auto-release 15 | # - npx semantic-release pre && npm publish && npx semantic-release post 16 | branches: 17 | only: 18 | - master 19 | -------------------------------------------------------------------------------- /examples/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "../node_modules/eslint-config-kentcdodds/possible-errors.js", 4 | "../node_modules/eslint-config-kentcdodds/es6/possible-errors.js", 5 | "../node_modules/eslint-config-kentcdodds/react.js", 6 | "../node_modules/eslint-config-kentcdodds/prettier.js", 7 | ], 8 | "root": true, 9 | "rules": { 10 | "max-len": "off", 11 | "no-console": "off", 12 | "no-alert": "off", 13 | "react/prop-types": "off", 14 | "react/jsx-closing-bracket-location": "off" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'jsdom', 3 | collectCoverageFrom: ['src/**/*.js'], 4 | testPathIgnorePatterns: ['/node_modules/', '/fixtures/'], 5 | coveragePathIgnorePatterns: ['/node_modules/', '/fixtures/'], 6 | // enable this once we're ready for it... 7 | // coverageThreshold: { 8 | // global: { 9 | // branches: 100, 10 | // functions: 100, 11 | // lines: 100, 12 | // statements: 100, 13 | // }, 14 | // }, 15 | snapshotSerializers: ['enzyme-to-json/serializer'], 16 | } 17 | -------------------------------------------------------------------------------- /examples/next.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | webpack: config => { 5 | config.module.rules.push({ 6 | test: /\.js(\?[^?]*)?$/, 7 | loader: 'babel-loader', 8 | include: [path.join(__dirname, '../src')], 9 | options: {cacheDirectory: false, babelrc: true}, 10 | }) 11 | 12 | // this is useful if you want to see the transpiled 13 | // version of the code (like if you're working on the 14 | // babel plugin or something). 15 | // config.devtool = 'eval' 16 | 17 | return config 18 | }, 19 | } 20 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # react-autocompletely examples 2 | 3 | This is a Next.js app for the examples. This library is a library of primitives 4 | and that's hard to communicate the value of with regular docs. We need examples 5 | and lots of them. Each folder in the `pages` directory is a page for examples 6 | of `react-autocompletely`. We could really use help adding more and more of 7 | these examples! 8 | 9 | **Note**: Unfortunately there were some problems trying to import directly 10 | from `../src`, so as a pre-build/start script we copy the `../src` to 11 | `./other/react-autocompletely`. 12 | -------------------------------------------------------------------------------- /other/USERS.md: -------------------------------------------------------------------------------- 1 | # Users 2 | 3 | 4 | 5 | 6 | 7 | If you or your company uses this project, add your name to this list! Eventually 8 | we may have a website to showcase these (wanna build it!?) 9 | 10 | > No users have been added yet! 11 | 12 | 17 | -------------------------------------------------------------------------------- /src/controller.js: -------------------------------------------------------------------------------- 1 | import {Component} from 'react' 2 | import PropTypes from 'prop-types' 3 | 4 | import {AUTOCOMPLETE_CONTEXT} from './constants' 5 | 6 | class Controller extends Component { 7 | static contextTypes = { 8 | [AUTOCOMPLETE_CONTEXT]: PropTypes.object.isRequired, 9 | } 10 | static propTypes = { 11 | children: PropTypes.func.isRequired, 12 | } 13 | 14 | constructor(props, context) { 15 | super(props, context) 16 | this.autocomplete = this.context[AUTOCOMPLETE_CONTEXT] 17 | } 18 | 19 | render() { 20 | return this.props.children( 21 | this.autocomplete.getControllerStateAndHelpers(), 22 | ) 23 | } 24 | } 25 | 26 | export default Controller 27 | -------------------------------------------------------------------------------- /examples/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Link from 'next/link' 3 | import preval from 'preval.macro' 4 | 5 | const routes = preval` 6 | const fs = require('fs') 7 | const path = require('path') 8 | 9 | module.exports = fs.readdirSync(__dirname) 10 | .filter(file => { 11 | return fs 12 | .lstatSync(path.join(__dirname, file)) 13 | .isDirectory() 14 | }) 15 | ` 16 | 17 | export default Index 18 | 19 | function Index() { 20 | return ( 21 |
22 | See the examples: 23 | 34 |
35 | ) 36 | } 37 | -------------------------------------------------------------------------------- /src/__tests__/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import {mount} from 'enzyme' 3 | import Autocomplete from '../' 4 | 5 | function BasicAutocomplete() { 6 | const items = ['Red', 'Green', 'Blue', 'Orange', 'Purple'] 7 | return ( 8 | {}}> 9 | 10 | 11 | {() => 12 | // prettier is doing weeeeird things to this 13 | // prettier-ignore 14 | items 15 | .map((item, index) => ( 16 | 21 | {item} 22 | 23 | ))} 24 | 25 | 26 | ) 27 | } 28 | 29 | test('renders', () => { 30 | expect(() => mount()).not.toThrow() 31 | }) 32 | -------------------------------------------------------------------------------- /examples/pages/_document.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Document, { Head, Main, NextScript } from "next/document"; 3 | import { renderStatic } from "glamor/server"; 4 | 5 | export default class MyDocument extends Document { 6 | static getInitialProps({ renderPage }) { 7 | const page = renderPage(); 8 | const styles = renderStatic(() => page.html); 9 | return Promise.resolve({ ...page, ...styles }); 10 | } 11 | 12 | constructor(props) { 13 | super(props); 14 | const { __NEXT_DATA__, ids } = props; 15 | if (ids) { 16 | __NEXT_DATA__.ids = this.props.ids; 17 | } 18 | } 19 | 20 | render() { 21 | return ( 22 | 23 | 24 | react-autocompletely examples 25 |