Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cache:
directories: node_modules

before_script:
- npm rebuild node-sass
- npm install -g coveralls
- npm install -g codecov

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"lint-staged": "^10.0.8",
"lodash": "^4.17.11",
"marked": "^1.1.0",
"node-sass": "^4.5.3",
"raw-loader": "^4.0.0",
"react": "^16.8.0",
"react-axe": "^3.4.1",
Expand All @@ -107,6 +106,7 @@
"rollup": "^2.0.5",
"rollup-plugin-size-snapshot": "^0.12.0",
"rollup-plugin-terser": "^7.0.0",
"sass": "^1.28.0",
"sass-loader": "^9.0.3",
"style-loader": "^1.0.0",
"terser-webpack-plugin": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/buildCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const fs = require('fs');
const path = require('path');
const sass = require('node-sass');
const sass = require('sass');

const ROOT = path.join(__dirname, '..');
const OUT_DIR = path.join(ROOT, 'css');
Expand All @@ -12,7 +12,7 @@ const STYLES_DIR = path.join(ROOT, 'styles');
function buildCSS(options) {
// Get the base filename.
let filename = options.file
.split('/')
.split(/\/|\\/)
.pop()
.replace('.scss', '');

Expand Down
8 changes: 3 additions & 5 deletions src/components/Hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import type { Element } from 'react';
import { useTypeaheadContext } from '../core/Context';
import { isSelectable } from '../utils';
import { RETURN, RIGHT, TAB } from '../constants';

export type ShouldSelect = (
boolean,
SyntheticKeyboardEvent<HTMLInputElement>
) => boolean;
import type {
ShouldSelect,
} from '../types';

// IE doesn't seem to get the composite computed value (eg: 'padding',
// 'borderStyle', etc.), so generate these from the individual values.
Expand Down
11 changes: 9 additions & 2 deletions src/components/Typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class TypeaheadComponent extends React.Component<Props> {
renderInput,
renderToken,
size,
shouldSelectHint,
} = this.props;

if (isFunction(renderInput)) {
Expand All @@ -230,15 +231,21 @@ class TypeaheadComponent extends React.Component<Props> {
};

if (!multiple) {
return <TypeaheadInputSingle {...commonProps} />;
return (
<TypeaheadInputSingle
{...commonProps}
shouldSelectHint={shouldSelectHint}
/>
);
}

const { labelKey, onRemove, selected } = props;

return (
<TypeaheadInputMulti
{...commonProps}
selected={selected}>
selected={selected}
shouldSelectHint={shouldSelectHint}>
{selected.map((option, idx) => (
renderToken(option, { ...commonProps, labelKey, onRemove }, idx)
))}
Expand Down
4 changes: 2 additions & 2 deletions src/components/TypeaheadInputMulti.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import cx from 'classnames';
import React, { type Node } from 'react';

import Hint, { type ShouldSelect } from './Hint';
import Hint from './Hint';
import Input from './Input';

import { isSelectable } from '../utils';
import withClassNames from '../behaviors/classNames';

import { BACKSPACE } from '../constants';

import type { InputProps, Option, RefCallback, ReferenceElement } from '../types';
import type { InputProps, Option, RefCallback, ReferenceElement, ShouldSelect } from '../types';

type Props = {
...InputProps,
Expand Down
4 changes: 2 additions & 2 deletions src/components/TypeaheadInputSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import React from 'react';

import Hint, { type ShouldSelect } from './Hint';
import Hint from './Hint';
import Input from './Input';

import withClassNames from '../behaviors/classNames';

import type { RefCallback, ReferenceElement } from '../types';
import type { RefCallback, ReferenceElement, ShouldSelect } from '../types';

type Props = {
inputRef: RefCallback<HTMLInputElement>,
Expand Down
6 changes: 6 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export type MenuProps = {
style: Style,
};

export type ShouldSelect = (
boolean,
SyntheticKeyboardEvent<HTMLInputElement>
) => boolean;

export type TypeaheadProps = {
allowNew: boolean | (Option[], TypeaheadPropsAndState) => boolean,
autoFocus: boolean,
Expand All @@ -84,6 +89,7 @@ export type TypeaheadProps = {
options: Option[],
paginate: boolean,
selectHintOnEnter?: boolean,
shouldSelectHint?: ShouldSelect,
};

export type TypeaheadState = {|
Expand Down
Loading