Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Javi Arques committed May 17, 2017
1 parent 4399d47 commit 29e6a1e
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 43 deletions.
2 changes: 1 addition & 1 deletion dist/flycomponents.js

Large diffs are not rendered by default.

122 changes: 81 additions & 41 deletions docs/dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
/******/
/******/
/******/ var hotApplyOnUpdate = true;
/******/ var hotCurrentHash = "29f90ba3cede2f053c16"; // eslint-disable-line no-unused-vars
/******/ var hotCurrentHash = "75dffd41f5ebeb319bde"; // eslint-disable-line no-unused-vars
/******/ var hotCurrentModuleData = {};
/******/ var hotCurrentChildModule; // eslint-disable-line no-unused-vars
/******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars
Expand Down Expand Up @@ -12746,7 +12746,7 @@ exports.i(__webpack_require__(446), "");
exports.i(__webpack_require__(447), "");

// module
exports.push([module.i, ".Docs {\n display: flex;\n min-height: 100%;\n flex-direction: row;\n}\n\n.Docs-nav {\n width: 160px;\n padding: 2rem 1rem;\n border-right: 1px solid #eee;\n}\n.Docs-content {\n width: calc(100% - 160px);\n}\n\n@media (min-width: 500px) {\n .Docs-nav {\n width: 180px;\n }\n .Docs-content {\n width: calc(100% - 180px);\n }\n}\n\n.Docs-navMenu {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.Docs-navTitle {\n margin-bottom: 2rem;\n font-size: 1rem;\n font-weight: 600;\n}\n\n.Docs-navVersion {\n font-size: .5rem;\n}\n\n@media (min-width: 500px) {\n font-size: 1.2rem;\n}\n\n.MenuLink {\n margin-bottom: .6rem;\n font-weight: 400;\n font-size: .96rem;\n transition: all 200ms;\n}\n\n.MenuLink.is-active a, .MenuLink:hover a {\n text-decoration: underline;\n}\n\n.fullHeight {\n height: 100%;\n min-height: 100%;\n}\n", ""]);
exports.push([module.i, ".Docs {\n display: flex;\n min-height: 100%;\n flex-direction: row;\n}\n\n.Docs-nav {\n width: 160px;\n padding: 2rem 1rem;\n border-right: 1px solid #eee;\n}\n.Docs-content {\n width: calc(100% - 160px);\n}\n\n@media (min-width: 500px) {\n .Docs-nav {\n width: 180px;\n }\n .Docs-content {\n width: calc(100% - 180px);\n }\n}\n\n.Docs-navMenu {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.Docs-navTitle {\n margin-bottom: 2rem;\n font-size: 1rem;\n font-weight: 600;\n}\n\n.Docs-navVersion {\n font-size: .5rem;\n}\n\n@media (min-width: 500px) {\n font-size: 1.2rem;\n}\n\n.MenuLink {\n margin-bottom: .6rem;\n font-weight: 400;\n font-size: .96rem;\n transition: all 200ms;\n}\n\n.MenuLink.is-active a, .MenuLink:hover a {\n text-decoration: underline;\n}\n\n.fullHeight {\n height: 100%;\n min-height: 100%;\n}\n\n.Autocomplete-options {\n transition: none;\n}\n", ""]);

// exports

Expand Down Expand Up @@ -31900,7 +31900,7 @@ var _README2 = _interopRequireDefault(_README);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = function () {
var countries = [{ label: 'Spain', value: 'ES' }, { label: 'United States', value: 'US' }, { label: 'China', value: 'CN' }];
var countries = [{ label: 'Spain', value: 'ES' }, { label: 'United States', value: 'US' }, { label: 'China', value: 'CN' }, { label: 'France', value: 'FR' }, { label: 'Italy', value: 'IT' }, { label: 'Germany', value: 'DEU' }, { label: 'United Kingdom', value: 'GB' }, { label: 'Andorra', value: 'AN' }, { label: 'Greece', value: 'GR' }, { label: 'Morocco', value: 'MOR' }, { label: 'Cuba', value: 'CUB' }, { label: 'Korea', value: 'KO' }, { label: 'Japan', value: 'JP' }];

return _react2.default.createElement(
_Component2.default,
Expand Down Expand Up @@ -32856,11 +32856,12 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var INITIAL_INDEX = -1;
var KEYS = [13, 27, 38, 40];
var KEYS = [13, 27, 38, 40, 9];
var ENTER = KEYS[0],
ESC = KEYS[1],
ARROW_UP = KEYS[2],
ARROW_DOWN = KEYS[3];
ARROW_DOWN = KEYS[3],
TAB = KEYS[4];

var Autocomplete = exports.Autocomplete = function (_Component) {
_inherits(Autocomplete, _Component);
Expand Down Expand Up @@ -32927,14 +32928,22 @@ var Autocomplete = exports.Autocomplete = function (_Component) {
}, {
key: 'showOptions',
value: function showOptions() {
var isOpen = this.state.isOpen;
var readOnly = this.props.readOnly;
var _state = this.state,
isOpen = _state.isOpen,
selectedIndex = _state.selectedIndex,
selectedValue = _state.selectedValue;
var _props2 = this.props,
options = _props2.options,
readOnly = _props2.readOnly;


if (isOpen || readOnly) {
return;
}
this.setState({ isOpen: true });
this.setState({
isOpen: true,
selectedIndex: this.getOptionIndexByValue(options, selectedValue)
}, this.adjustOffset);
}
}, {
key: 'loadOptions',
Expand Down Expand Up @@ -32968,6 +32977,23 @@ var Autocomplete = exports.Autocomplete = function (_Component) {

return selectedOption ? selectedOption.label.toString() : NO_LABEL;
}
}, {
key: 'getOptionIndexByValue',
value: function getOptionIndexByValue(options, value) {
var selectedOptionIndex = options.findIndex(function (option) {
return option.value === value;
});
return selectedOptionIndex === -1 ? INITIAL_INDEX : selectedOptionIndex;
}
}, {
key: 'resetSearchQuery',
value: function resetSearchQuery() {
return this.setState(function () {
return {
searchQuery: ''
};
});
}
}, {
key: 'handleOptionHover',
value: function handleOptionHover(value) {
Expand Down Expand Up @@ -33015,14 +33041,17 @@ var Autocomplete = exports.Autocomplete = function (_Component) {

this.setState(function (prevState) {
return { selectedIndex: normalize(prevState.selectedIndex + offset) };
}, this.adjustOffet);
}, this.adjustOffset);
}
}, {
key: 'adjustOffet',
value: function adjustOffet() {
key: 'adjustOffset',
value: function adjustOffset() {
var selectedIndex = this.state.selectedIndex;

var optionSelected = (0, _reactDom.findDOMNode)(this.refs['option-' + selectedIndex]);

if (!optionSelected) return;

var optionList = (0, _reactDom.findDOMNode)(this.refs.optionList);

if (selectedIndex === INITIAL_INDEX) return;
Expand All @@ -33035,7 +33064,7 @@ var Autocomplete = exports.Autocomplete = function (_Component) {
var selectedIndex = this.state.selectedIndex;


if (selectedIndex === INITIAL_INDEX || options.length === 0) {
if (selectedIndex === INITIAL_INDEX || !options[selectedIndex]) {
return;
}

Expand All @@ -33046,28 +33075,28 @@ var Autocomplete = exports.Autocomplete = function (_Component) {
}, {
key: 'sendBlur',
value: function sendBlur() {
var _props2 = this.props,
name = _props2.name,
onBlur = _props2.onBlur;
var _props3 = this.props,
name = _props3.name,
onBlur = _props3.onBlur;

onBlur(name);
}
}, {
key: 'sendChange',
value: function sendChange(value) {
var _props3 = this.props,
name = _props3.name,
onChange = _props3.onChange;
var _props4 = this.props,
name = _props4.name,
onChange = _props4.onChange;

onChange(name, value);
}
}, {
key: 'searchOn',
value: function searchOn() {
var _props4 = this.props,
minOptionsForSearch = _props4.minOptionsForSearch,
options = _props4.options,
readOnly = _props4.readOnly;
var _props5 = this.props,
minOptionsForSearch = _props5.minOptionsForSearch,
options = _props5.options,
readOnly = _props5.readOnly;


if (readOnly) return false;
Expand All @@ -33076,23 +33105,29 @@ var Autocomplete = exports.Autocomplete = function (_Component) {
}
return minOptionsForSearch < options.length;
}
}, {
key: 'blurSearchInput',
value: function blurSearchInput() {
this.searchInput.blur();
}
}, {
key: 'render',
value: function render() {
var _this3 = this;

var _props5 = this.props,
name = _props5.name,
placeholder = _props5.placeholder,
readOnly = _props5.readOnly;
var _props6 = this.props,
name = _props6.name,
onFocus = _props6.onFocus,
placeholder = _props6.placeholder,
readOnly = _props6.readOnly;

var options = this.loadOptions();
var searchOn = this.searchOn();
var _state = this.state,
isOpen = _state.isOpen,
searchQuery = _state.searchQuery,
selectedIndex = _state.selectedIndex,
selectedValue = _state.selectedValue;
var _state2 = this.state,
isOpen = _state2.isOpen,
searchQuery = _state2.searchQuery,
selectedIndex = _state2.selectedIndex,
selectedValue = _state2.selectedValue;


var optionList = options.map(function (option, i) {
Expand Down Expand Up @@ -33120,13 +33155,17 @@ var Autocomplete = exports.Autocomplete = function (_Component) {
ref: 'autocomplete',
className: (0, _classnames2.default)('Autocomplete', { 'is-searching': isOpen }, { 'Autocomplete--noReadOnly': !readOnly })
},
_react2.default.createElement(_Input2.default, {
_react2.default.createElement('input', {
className: 'Autocomplete-search',
id: name,
name: name,
onChange: this.handleSearchQueryChange,
onClick: this.handleSearchClick,
onFocus: this.props.onFocus,
onFocus: onFocus,
onKeyDown: this.handleSearchKeyDown,
ref: function ref(input) {
return _this3.searchInput = input;
},
placeholder: placeholder,
readOnly: !searchOn,
type: 'text',
Expand All @@ -33152,21 +33191,20 @@ var _initialiseProps = function _initialiseProps() {
var options = _this4.props.options;


if (previousSelectedValue === value) {
return _this4.hideOptions();
}

_this4.setState(function () {
return {
isOpen: false,
searchQuery: _this4.getOptionLabelByValue(options, value),
selectedIndex: INITIAL_INDEX,
selectedValue: value
};
}, _this4.sendChange(value));
}, function () {
_this4.sendChange(value);
_this4.blurSearchInput();
});
};

this.handleSearchClick = function () {
_this4.resetSearchQuery();
_this4.showOptions();
};

Expand All @@ -33183,6 +33221,8 @@ var _initialiseProps = function _initialiseProps() {
return _this4.moveIndexDown();
case ENTER:
return _this4.selectCurrentOption();
case TAB:
return _this4.selectCurrentOption();
case ESC:
return _this4.hideOptions();
}
Expand Down Expand Up @@ -51641,7 +51681,7 @@ if(true) {

module.exports = {
"name": "Flycomponents",
"version": "1.0.5",
"version": "1.0.6",
"description": "Flywire React components",
"main": "./dist/flycomponents.js",
"scripts": {
Expand All @@ -51653,7 +51693,7 @@ module.exports = {
"test": "mocha --opts tests/helpers/mocha.opts",
"test:watch": "mocha -w --opts tests/helpers/mocha.opts",
"lint": "eslint --fix src docs/src",
"version": "npm run build && git add -A dist",
"version": "npm run build && npm run build:docs && git add -A dist docs/dist",
"postversion": "git push && git push --tags"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Flycomponents",
"version": "1.0.5",
"version": "1.0.6",
"description": "Flywire React components",
"main": "./dist/flycomponents.js",
"scripts": {
Expand Down

0 comments on commit 29e6a1e

Please sign in to comment.