Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alexkuz/react-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alexkuz/react-autocomplete - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

65

lib/combobox.js

@@ -10,2 +10,4 @@ 'use strict';

var sizerContainerEl = null;
module.exports = React.createClass({

@@ -127,5 +129,24 @@ displayName: 'Combobox',

componentWillMount: function componentWillMount() {
if (!sizerContainerEl) {
sizerContainerEl = document.createElement('div');
document.body.appendChild(sizerContainerEl);
}
this.sizerEl = document.createElement('span');
this.sizerEl.style.position = 'absolute';
this.sizerEl.style.visibility = 'hidden';
this.sizerEl.style.whiteSpace = 'nowrap';
this.sizerEl.style.fontSize = '16px';
sizerContainerEl.appendChild(this.sizerEl);
this.setState({ menu: this.makeMenu() });
},
componentWillUnmount: function componentWillUnmount() {
sizerContainerEl.removeChild(this.sizerEl);
this.sizerEl = null;
clearTimeout(this.blurTimer);
},
componentDidMount: function componentDidMount() {

@@ -160,14 +181,16 @@ this.updateWidth();

var props = {};
if (this.state.value === child.props.value) {
// need an ID for WAI-ARIA
props.id = child.props.id || 'rf-combobox-selected-' + ++guid;
props.isSelected = true;
props.className = [child.props.className, appearance.option, appearance.selected].join(' ');
activedescendant = child.props.id;
if (!child.props.disabled) {
if (this.state.value === child.props.value) {
// need an ID for WAI-ARIA
props.id = child.props.id || 'rf-combobox-selected-' + ++guid;
props.isSelected = true;
props.className = [child.props.className, appearance.option, appearance.selected].join(' ');
activedescendant = child.props.id;
}
props.onBlur = this.handleOptionBlur;
props.onClick = this.selectOption.bind(this, child);
props.onFocus = this.handleOptionFocus;
props.onKeyDown = this.handleOptionKeyDown.bind(this, child);
props.onMouseEnter = this.handleOptionMouseEnter.bind(this, index);
}
props.onBlur = this.handleOptionBlur;
props.onClick = this.selectOption.bind(this, child);
props.onFocus = this.handleOptionFocus;
props.onKeyDown = this.handleOptionKeyDown.bind(this, child);
props.onMouseEnter = this.handleOptionMouseEnter.bind(this, index);
return React.cloneElement(child, props);

@@ -424,8 +447,2 @@ }).bind(this));

style: _Object$assign(wrapperStyle, this.props.wrapperStyle) },
this.props.shrink && React.createElement('span', { ref: 'sizer', style: {
position: 'absolute',
visibility: 'hidden',
whiteSpace: 'nowrap',
fontSize: '16px'
} }),
this.props.label && React.createElement(

@@ -439,2 +456,3 @@ 'label',

ref: 'input',
type: 'text',
className: appearance.input,

@@ -480,2 +498,4 @@ defaultValue: this.props.value,

updateWidth: function updateWidth() {
var _this = this;
if (!this.props.shrink) {

@@ -485,10 +505,11 @@ return;

var sizer = React.findDOMNode(this.refs.sizer);
var input = React.findDOMNode(this.refs.input);
var button = React.findDOMNode(this.refs.button);
sizer.innerText = input.value;
this.setState({
shrinkWidth: sizer.offsetWidth + button.offsetWidth + 2
});
this.sizerEl.innerText = input.value;
setTimeout(function () {
return _this.setState({
shrinkWidth: _this.sizerEl.offsetWidth + button.offsetWidth + 2
});
}, 0);
}

@@ -495,0 +516,0 @@ });

{
"name": "@alexkuz/react-autocomplete",
"version": "0.1.1",
"version": "0.1.2",
"description": "",
"main": "lib/main.js",
"scripts": {
"build": "babel src --out-dir lib --optional runtime && cp src/styles.css lib/styles.css",
"build": "./node_modules/.bin/babel src --out-dir lib --optional runtime && cp src/styles.css lib/styles.css",
"test": "echo \"no tests yet, just trust me\" && exit 0",
"prepublish": "npm run build"
"prepublish": "npm run build",
"version": "npm run build && git add -A .",
"postversion": "git push"
},

@@ -11,0 +13,0 @@ "author": "",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc