Skip to content

Commit

Permalink
Merge pull request #4 from beeblebrox3/master
Browse files Browse the repository at this point in the history
add yarn.lock; using some es2015 features
  • Loading branch information
beeblebrox3 authored Oct 31, 2016
2 parents 305467e + 07bce9d commit 13913e2
Show file tree
Hide file tree
Showing 11 changed files with 4,794 additions and 63 deletions.
6 changes: 3 additions & 3 deletions dist/SuperSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ return /******/ (function(modules) { // webpackBootstrap
getValue: function getValue() {
"use strict";

var value;
var value = void 0;
if (this.props.valueLink) {
value = this.props.valueLink.value;
} else {
Expand Down Expand Up @@ -285,7 +285,7 @@ return /******/ (function(modules) { // webpackBootstrap
"use strict";

var value = this.getValue();
var current;
var current = void 0;

if (this.props.multiple) {
current = this.isChecked(item, true);
Expand Down Expand Up @@ -1000,7 +1000,6 @@ return /******/ (function(modules) { // webpackBootstrap
/**
* @todo support max display items
*/

var Button = React.createClass({
displayName: "SuperSelect.button",

Expand Down Expand Up @@ -1328,6 +1327,7 @@ return /******/ (function(modules) { // webpackBootstrap

return this.props.content || this.props.label;
},

render: function render() {
"use strict";

Expand Down
2 changes: 1 addition & 1 deletion example.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="container">
<header>
<h1>Super Select</h1>
<p>A replacement for selects (?) on web applications</p>
<p>A replacement for selects/datalists on web applications</p>
</header>

<div class="content">
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"keywords": [
"react-component",
"select",
"select-multiple"
"select-multiple",
"datalist"
],
"description": "",
"main": "lib/SuperSelect.js",
Expand Down
5 changes: 3 additions & 2 deletions src/Action.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var React = require("react");
const React = require("react");

var Action = React.createClass({
let Action = React.createClass({
displayName: "SuperSelect.Action",

getDefaultProps: function () {
Expand All @@ -20,6 +20,7 @@ var Action = React.createClass({

return this.props.content || this.props.label;
},

render: function () {
"use strict";

Expand Down
8 changes: 4 additions & 4 deletions src/Actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var React = require("react");
var Action = require("./Action");
const React = require("react");
const Action = require("./Action");

var Actions = React.createClass({
let Actions = React.createClass({
displayName: "SuperSelect.Actions",

getDefaultProps: function () {
Expand All @@ -22,7 +22,7 @@ var Actions = React.createClass({
return (
<ul className="super-select-actions">
{ this.props.actions.map(function (action, index) {
return <Action { ...action } key={ index } />;
return <Action { ...action } key={ index }/>;
}) }
</ul>
);
Expand Down
17 changes: 8 additions & 9 deletions src/Button.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
var React = require("react");
const React = require("react");

/**
* @todo support max display items
*/

var Button = React.createClass({
let Button = React.createClass({
displayName: "SuperSelect.button",

getDefaultProps: function () {
Expand Down Expand Up @@ -36,7 +35,7 @@ var Button = React.createClass({
getLabel: function () {
"use strict";

var label = this.props.label;
let label = this.props.label;
if (typeof this.props.contentLabelProvider === "function") {
label = this.props.contentLabelProvider();
}
Expand All @@ -55,11 +54,11 @@ var Button = React.createClass({
render: function () {
"use strict";

var self = this;
var className = this.getClassName();
var text = [];
var countValues = 0;
var value = this.props.value;
let self = this;
let className = this.getClassName();
let text = [];
let countValues = 0;
let value = this.props.value;

text.push(this.getLabel());

Expand Down
10 changes: 5 additions & 5 deletions src/Option.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var React = require("react");
const React = require("react");

var Option = React.createClass({
let Option = React.createClass({
displayName: "SuperSelect.Option",

getDefaultProps: function () {
Expand All @@ -25,8 +25,8 @@ var Option = React.createClass({
render: function () {
"use strict";

var className = "super-select-options-list-item";
var type = this.props.multiple ? "checkbox" : "radio";
let className = "super-select-options-list-item";
let type = this.props.multiple ? "checkbox" : "radio";

if (this.props.pseudoHover) {
className += " hover";
Expand All @@ -41,7 +41,7 @@ var Option = React.createClass({
onChange={ this.handleChange }
tabIndex="-1"
/>
{ this.props.option[this.props.labelKey] }
{ this.props.option[this.props.labelKey] }
</label>
</li>
);
Expand Down
14 changes: 7 additions & 7 deletions src/OptionsList.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var React = require("react");
const React = require("react");

var Option = require("./Option");
const Option = require("./Option");

var OptionsList = React.createClass({
let OptionsList = React.createClass({
displayName: "SuperSelect.OptionsList",

getDefaultProps: function () {
Expand All @@ -21,8 +21,8 @@ var OptionsList = React.createClass({
renderOptions: function () {
"use strict";

var self = this;
var options = this.props.options;
let self = this;
let options = this.props.options;
if (!options.length) {
return (
<li
Expand All @@ -35,7 +35,7 @@ var OptionsList = React.createClass({
}

return options.map(function (item, index) {
var optionProps = {
let optionProps = {
index: index,
pseudoHover: index === self.props.currentHover,
checked: self.props.isChecked(item),
Expand All @@ -50,7 +50,7 @@ var OptionsList = React.createClass({
}

return (
<Option { ...optionProps } key={ index } />
<Option { ...optionProps } key={ index }/>
);
});
},
Expand Down
4 changes: 2 additions & 2 deletions src/SearchBox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var React = require("react");
const React = require("react");

var SearchBox = React.createClass({
let SearchBox = React.createClass({
displayName: "SuperSelect.SearchBox",

getDefaultProps: function () {
Expand Down
58 changes: 29 additions & 29 deletions src/SuperSelect.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var React = require("react");
var Fuse = require("fuse.js");
const React = require("react");
const Fuse = require("fuse.js");

var Button = require("./Button");
var OptionsList = require("./OptionsList");
var Actions = require("./Actions");
var SearchBox = require("./SearchBox");
const Button = require("./Button");
const OptionsList = require("./OptionsList");
const Actions = require("./Actions");
const SearchBox = require("./SearchBox");

var SuperSelect = React.createClass({
let SuperSelect = React.createClass({
displayName: "SuperSelect",

propTypes: {
Expand Down Expand Up @@ -115,7 +115,7 @@ var SuperSelect = React.createClass({

closeOnClickOutside: function closeOnClickOutside(e) {
"use strict";
var eventSuperSelect = e.superSelect || false;
let eventSuperSelect = e.superSelect || false;
if (!eventSuperSelect || eventSuperSelect !== this) {
this.setState({
open: false,
Expand All @@ -134,9 +134,9 @@ var SuperSelect = React.createClass({
getOptions: function getOptions() {
"use strict";

var options = this.props.options || [];
var q = this.state.q;
var fuse = new Fuse(options, {
let options = this.props.options || [];
let q = this.state.q;
let fuse = new Fuse(options, {
keys: this.props.searchKeys
// threshold: 0.4
});
Expand All @@ -151,7 +151,7 @@ var SuperSelect = React.createClass({
getValue: function getValue() {
"use strict";

var value;
let value;
if (this.props.valueLink) {
value = this.props.valueLink.value;
} else {
Expand Down Expand Up @@ -193,7 +193,7 @@ var SuperSelect = React.createClass({
toggle: function toggle(forceState) {
"use strict";

var newState = typeof forceState === "boolean" ? forceState : !this.state.open;
let newState = typeof forceState === "boolean" ? forceState : !this.state.open;
this.setState({
open: newState,
q: newState ? this.state.q : "",
Expand All @@ -204,10 +204,10 @@ var SuperSelect = React.createClass({
isChecked: function isChecked(item, returnIndex) {
"use strict";

var index = false;
var value = this.getValue();
var found = false;
var valueKey = this.props.valueKey;
let index = false;
let value = this.getValue();
let found = false;
let valueKey = this.props.valueKey;

if (!value) {
return false;
Expand All @@ -230,8 +230,8 @@ var SuperSelect = React.createClass({
handleChange: function handleChange(item) {
"use strict";

var value = this.getValue();
var current;
let value = this.getValue();
let current;

if (this.props.multiple) {
current = this.isChecked(item, true);
Expand Down Expand Up @@ -291,20 +291,20 @@ var SuperSelect = React.createClass({
handleNavigationKeys: function handleNavigationKeys(e) {
"use strict";

var currentPosition = this.state.pseudoHover || 0;
var isEnter = e.key === "Enter";
var open = this.state.open;
var mustRetainFocus = false;
var self = this;
var container = self.refs.container;
var q = this.state.q;
let currentPosition = this.state.pseudoHover || 0;
let isEnter = e.key === "Enter";
let open = this.state.open;
let mustRetainFocus = false;
let self = this;
let container = self.refs.container;
let q = this.state.q;

if (isEnter) {
e.preventDefault();
}

if (isEnter && !isNaN(currentPosition) && open) {
var option = this.getOptions()[currentPosition] || false;
let option = this.getOptions()[currentPosition] || false;
if (option) {
this.handleChange(option);
}
Expand Down Expand Up @@ -374,7 +374,7 @@ var SuperSelect = React.createClass({
buildActions: function buildActions() {
"use strict";

var actions = [];
let actions = [];
if (this.props.options.length && this.props.multiple === true) {
actions.push({
label: this.props.selectAllLabel,
Expand All @@ -393,7 +393,7 @@ var SuperSelect = React.createClass({
buildContent: function buildContent() {
"use strict";

var content = [];
let content = [];

if (this.state.open) {
if (this.props.searchBox) {
Expand Down
Loading

0 comments on commit 13913e2

Please sign in to comment.