diff --git a/dist/aframe-inspector.js b/dist/aframe-inspector.js index 80748ad7..bb9cf4ee 100644 --- a/dist/aframe-inspector.js +++ b/dist/aframe-inspector.js @@ -71,25 +71,25 @@ var _Sidebar2 = _interopRequireDefault(_Sidebar); - var _ModalTextures = __webpack_require__(239); + var _ModalTextures = __webpack_require__(240); var _ModalTextures2 = _interopRequireDefault(_ModalTextures); - var _ModalHelp = __webpack_require__(243); + var _ModalHelp = __webpack_require__(244); var _ModalHelp2 = _interopRequireDefault(_ModalHelp); - var _SceneGraph = __webpack_require__(244); + var _SceneGraph = __webpack_require__(245); var _SceneGraph2 = _interopRequireDefault(_SceneGraph); - var _ToolBar = __webpack_require__(247); + var _ToolBar = __webpack_require__(248); var _ToolBar2 = _interopRequireDefault(_ToolBar); - var _utils = __webpack_require__(205); + var _utils = __webpack_require__(206); - __webpack_require__(248); + __webpack_require__(249); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -100,8 +100,8 @@ 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; } /* global VERSION BUILD_TIMESTAMP COMMIT_HASH */ - __webpack_require__(250); - var INSPECTOR = __webpack_require__(200); + __webpack_require__(251); + var INSPECTOR = __webpack_require__(201); THREE.ImageUtils.crossOrigin = ''; @@ -273,7 +273,7 @@ window.addEventListener('inspector-loaded', function () { _reactDom2.default.render(_react2.default.createElement(Main, null), div); }); - console.log('A-Frame Inspector Version:', ("0.5.3"), '(' + ("15-06-2017") + ' Commit: ' + ("6e6df091846801d6fccae679f166bdb67414ea66\n").substr(0, 7) + ')'); + console.log('A-Frame Inspector Version:', ("0.5.3"), '(' + ("29-06-2017") + ' Commit: ' + ("0c92ecd9177cd0059928dead3411b72d22c66177\n").substr(0, 7) + ')'); })(); /***/ }, @@ -382,8 +382,15 @@ /* 4 */ /***/ function(module, exports) { + /* + object-assign + (c) Sindre Sorhus + @license MIT + */ + 'use strict'; /* eslint-disable no-unused-vars */ + var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; @@ -404,7 +411,7 @@ // Detect buggy property enumeration order in older V8 versions. // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; @@ -433,7 +440,7 @@ } return true; - } catch (e) { + } catch (err) { // We don't expect any of the above to throw, but better to be safe. return false; } @@ -453,8 +460,8 @@ } } - if (Object.getOwnPropertySymbols) { - symbols = Object.getOwnPropertySymbols(from); + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; @@ -734,17 +741,6 @@ } }; - var fiveArgumentPooler = function (a1, a2, a3, a4, a5) { - var Klass = this; - if (Klass.instancePool.length) { - var instance = Klass.instancePool.pop(); - Klass.call(instance, a1, a2, a3, a4, a5); - return instance; - } else { - return new Klass(a1, a2, a3, a4, a5); - } - }; - var standardReleaser = function (instance) { var Klass = this; !(instance instanceof Klass) ? (undefined) !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : _prodInvariant('25') : void 0; @@ -784,8 +780,7 @@ oneArgumentPooler: oneArgumentPooler, twoArgumentPooler: twoArgumentPooler, threeArgumentPooler: threeArgumentPooler, - fourArgumentPooler: fourArgumentPooler, - fiveArgumentPooler: fiveArgumentPooler + fourArgumentPooler: fourArgumentPooler }; module.exports = PooledClass; @@ -860,12 +855,18 @@ * will remain to ensure logic does not differ in production. */ - function invariant(condition, format, a, b, c, d, e, f) { - if ((undefined) !== 'production') { + var validateFormat = function validateFormat(format) {}; + + if ((undefined) !== 'production') { + validateFormat = function validateFormat(format) { if (format === undefined) { throw new Error('invariant requires an error message argument'); } - } + }; + } + + function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); if (!condition) { var error; @@ -3107,7 +3108,14 @@ // We warn in this case but don't throw. We expect the element creation to // succeed and there will likely be errors in render. if (!validType) { - (undefined) !== 'production' ? warning(false, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : void 0; + if (typeof type !== 'function' && typeof type !== 'string') { + var info = ''; + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { + info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.'; + } + info += getDeclarationErrorAddendum(); + (undefined) !== 'production' ? warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info) : void 0; + } } var element = ReactElement.createElement.apply(this, arguments); @@ -3225,30 +3233,38 @@ // Set.prototype.keys Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys); + var setItem; + var getItem; + var removeItem; + var getItemIDs; + var addRoot; + var removeRoot; + var getRootIDs; + if (canUseCollections) { var itemMap = new Map(); var rootIDSet = new Set(); - var setItem = function (id, item) { + setItem = function (id, item) { itemMap.set(id, item); }; - var getItem = function (id) { + getItem = function (id) { return itemMap.get(id); }; - var removeItem = function (id) { + removeItem = function (id) { itemMap['delete'](id); }; - var getItemIDs = function () { + getItemIDs = function () { return Array.from(itemMap.keys()); }; - var addRoot = function (id) { + addRoot = function (id) { rootIDSet.add(id); }; - var removeRoot = function (id) { + removeRoot = function (id) { rootIDSet['delete'](id); }; - var getRootIDs = function () { + getRootIDs = function () { return Array.from(rootIDSet.keys()); }; } else { @@ -3264,31 +3280,31 @@ return parseInt(key.substr(1), 10); }; - var setItem = function (id, item) { + setItem = function (id, item) { var key = getKeyFromID(id); itemByKey[key] = item; }; - var getItem = function (id) { + getItem = function (id) { var key = getKeyFromID(id); return itemByKey[key]; }; - var removeItem = function (id) { + removeItem = function (id) { var key = getKeyFromID(id); delete itemByKey[key]; }; - var getItemIDs = function () { + getItemIDs = function () { return Object.keys(itemByKey).map(getIDFromKey); }; - var addRoot = function (id) { + addRoot = function (id) { var key = getKeyFromID(id); rootByKey[key] = true; }; - var removeRoot = function (id) { + removeRoot = function (id) { var key = getKeyFromID(id); delete rootByKey[key]; }; - var getRootIDs = function () { + getRootIDs = function () { return Object.keys(rootByKey).map(getIDFromKey); }; } @@ -4253,7 +4269,7 @@ 'use strict'; - module.exports = '15.4.0'; + module.exports = '15.4.2'; /***/ }, /* 32 */ @@ -4449,6 +4465,13 @@ var internalInstanceKey = '__reactInternalInstance$' + Math.random().toString(36).slice(2); + /** + * Check if a given node should be cached. + */ + function shouldPrecacheNode(node, nodeID) { + return node.nodeType === 1 && node.getAttribute(ATTR_NAME) === String(nodeID) || node.nodeType === 8 && node.nodeValue === ' react-text: ' + nodeID + ' ' || node.nodeType === 8 && node.nodeValue === ' react-empty: ' + nodeID + ' '; + } + /** * Drill down (through composites and empty components) until we get a host or * host text component. @@ -4514,7 +4537,7 @@ } // We assume the child nodes are in the same order as the child instances. for (; childNode !== null; childNode = childNode.nextSibling) { - if (childNode.nodeType === 1 && childNode.getAttribute(ATTR_NAME) === String(childID) || childNode.nodeType === 8 && childNode.nodeValue === ' react-text: ' + childID + ' ' || childNode.nodeType === 8 && childNode.nodeValue === ' react-empty: ' + childID + ' ') { + if (shouldPrecacheNode(childNode, childID)) { precacheNode(childInst, childNode); continue outer; } @@ -5653,6 +5676,28 @@ return '.' + inst._rootNodeID; }; + function isInteractive(tag) { + return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; + } + + function shouldPreventMouseEvent(name, type, props) { + switch (name) { + case 'onClick': + case 'onClickCapture': + case 'onDoubleClick': + case 'onDoubleClickCapture': + case 'onMouseDown': + case 'onMouseDownCapture': + case 'onMouseMove': + case 'onMouseMoveCapture': + case 'onMouseUp': + case 'onMouseUpCapture': + return !!(props.disabled && isInteractive(type)); + default: + return false; + } + } + /** * This is a unified interface for event plugins to be installed and configured. * @@ -5721,7 +5766,12 @@ * @return {?function} The stored callback. */ getListener: function (inst, registrationName) { + // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not + // live here; needs to be moved to a better place soon var bankForRegistrationName = listenerBank[registrationName]; + if (shouldPreventMouseEvent(registrationName, inst._currentElement.type, inst._currentElement.props)) { + return null; + } var key = getDictionaryKey(inst); return bankForRegistrationName && bankForRegistrationName[key]; }, @@ -6720,17 +6770,6 @@ } }; - var fiveArgumentPooler = function (a1, a2, a3, a4, a5) { - var Klass = this; - if (Klass.instancePool.length) { - var instance = Klass.instancePool.pop(); - Klass.call(instance, a1, a2, a3, a4, a5); - return instance; - } else { - return new Klass(a1, a2, a3, a4, a5); - } - }; - var standardReleaser = function (instance) { var Klass = this; !(instance instanceof Klass) ? (undefined) !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : _prodInvariant('25') : void 0; @@ -6770,8 +6809,7 @@ oneArgumentPooler: oneArgumentPooler, twoArgumentPooler: twoArgumentPooler, threeArgumentPooler: threeArgumentPooler, - fourArgumentPooler: fourArgumentPooler, - fiveArgumentPooler: fiveArgumentPooler + fourArgumentPooler: fourArgumentPooler }; module.exports = PooledClass; @@ -11574,12 +11612,18 @@ } else { var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null; var childrenToUse = contentToUse != null ? null : props.children; + // TODO: Validate that text is allowed as a child of this node if (contentToUse != null) { - // TODO: Validate that text is allowed as a child of this node - if ((undefined) !== 'production') { - setAndValidateContentChildDev.call(this, contentToUse); + // Avoid setting textContent when the text is empty. In IE11 setting + // textContent on a text area will cause the placeholder to not + // show within the textarea until it has been focused and blurred again. + // https://github.com/facebook/react/issues/6731#issuecomment-254874553 + if (contentToUse !== '') { + if ((undefined) !== 'production') { + setAndValidateContentChildDev.call(this, contentToUse); + } + DOMLazyTree.queueText(lazyTree, contentToUse); } - DOMLazyTree.queueText(lazyTree, contentToUse); } else if (childrenToUse != null) { var mountImages = this.mountChildren(childrenToUse, transaction, context); for (var i = 0; i < mountImages.length; i++) { @@ -13495,7 +13539,17 @@ } } else { if (props.value == null && props.defaultValue != null) { - node.defaultValue = '' + props.defaultValue; + // In Chrome, assigning defaultValue to certain input types triggers input validation. + // For number inputs, the display value loses trailing decimal points. For email inputs, + // Chrome raises "The specified value is not a valid email address". + // + // Here we check to see if the defaultValue has actually changed, avoiding these problems + // when the user is inputting text + // + // https://github.com/facebook/react/issues/7253 + if (node.defaultValue !== '' + props.defaultValue) { + node.defaultValue = '' + props.defaultValue; + } } if (props.checked == null && props.defaultChecked != null) { node.defaultChecked = !!props.defaultChecked; @@ -14238,9 +14292,15 @@ // This is in postMount because we need access to the DOM node, which is not // available until after the component has mounted. var node = ReactDOMComponentTree.getNodeFromInstance(inst); + var textContent = node.textContent; - // Warning: node.value may be the empty string at this point (IE11) if placeholder is set. - node.value = node.textContent; // Detach value from defaultValue + // Only set node.value if textContent is equal to the expected + // initial value. In IE10/IE11 there is a bug where the placeholder attribute + // will populate textContent as well. + // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ + if (textContent === inst._wrapperState.initialValue) { + node.value = textContent; + } } }; @@ -15039,7 +15099,17 @@ instance = ReactEmptyComponent.create(instantiateReactComponent); } else if (typeof node === 'object') { var element = node; - !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? (undefined) !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : _prodInvariant('130', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : void 0; + var type = element.type; + if (typeof type !== 'function' && typeof type !== 'string') { + var info = ''; + if ((undefined) !== 'production') { + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { + info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.'; + } + } + info += getDeclarationErrorAddendum(element._owner); + true ? (undefined) !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info) : _prodInvariant('130', type == null ? type : typeof type, info) : void 0; + } // Special case string values if (typeof element.type === 'string') { @@ -15328,7 +15398,7 @@ // Since plain JS classes are defined without any special initialization // logic, we can not catch common errors early. Therefore, we have to // catch them here, at initialization time, instead. - (undefined) !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : void 0; + (undefined) !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved || inst.state, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : void 0; (undefined) !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : void 0; (undefined) !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : void 0; (undefined) !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : void 0; @@ -16329,14 +16399,11 @@ 'use strict'; - var _prodInvariant = __webpack_require__(36), - _assign = __webpack_require__(4); + var _prodInvariant = __webpack_require__(36); var invariant = __webpack_require__(8); var genericComponentClass = null; - // This registry keeps track of wrapper classes around host tags. - var tagToComponentClass = {}; var textComponentClass = null; var ReactHostComponentInjection = { @@ -16349,11 +16416,6 @@ // rendered as props. injectTextComponentClass: function (componentClass) { textComponentClass = componentClass; - }, - // This accepts a keyed object with classes as values. Each key represents a - // tag. That particular tag will use this class instead of the generic one. - injectComponentClasses: function (componentClasses) { - _assign(tagToComponentClass, componentClasses); } }; @@ -19766,18 +19828,6 @@ return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; } - function shouldPreventMouseEvent(inst) { - if (inst) { - var disabled = inst._currentElement && inst._currentElement.props.disabled; - - if (disabled) { - return isInteractive(inst._tag); - } - } - - return false; - } - var SimpleEventPlugin = { eventTypes: eventTypes, @@ -19848,10 +19898,7 @@ case 'topMouseDown': case 'topMouseMove': case 'topMouseUp': - // Disabled elements should not respond to mouse events - if (shouldPreventMouseEvent(targetInst)) { - return null; - } + // TODO: Disabled elements should not respond to mouse events /* falls through */ case 'topMouseOut': case 'topMouseOver': @@ -21210,7 +21257,7 @@ 'use strict'; - module.exports = '15.4.0'; + module.exports = '15.4.2'; /***/ }, /* 173 */ @@ -21720,15 +21767,15 @@ var _AddComponent2 = _interopRequireDefault(_AddComponent); - var _Component = __webpack_require__(214); + var _Component = __webpack_require__(215); var _Component2 = _interopRequireDefault(_Component); - var _CommonComponents = __webpack_require__(235); + var _CommonComponents = __webpack_require__(236); var _CommonComponents2 = _interopRequireDefault(_CommonComponents); - var _DefaultComponents = __webpack_require__(237); + var _DefaultComponents = __webpack_require__(238); var _DefaultComponents2 = _interopRequireDefault(_DefaultComponents); @@ -21814,7 +21861,7 @@ var _reactSelect2 = _interopRequireDefault(_reactSelect); - __webpack_require__(196); + __webpack_require__(197); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -21824,7 +21871,7 @@ 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 INSPECTOR = __webpack_require__(200); + var INSPECTOR = __webpack_require__(201); var DELIMITER = ' '; @@ -22387,23 +22434,27 @@ var _utilsDefaultMenuRenderer2 = _interopRequireDefault(_utilsDefaultMenuRenderer); - var _Async = __webpack_require__(191); + var _utilsDefaultClearRenderer = __webpack_require__(191); + + var _utilsDefaultClearRenderer2 = _interopRequireDefault(_utilsDefaultClearRenderer); + + var _Async = __webpack_require__(192); var _Async2 = _interopRequireDefault(_Async); - var _AsyncCreatable = __webpack_require__(192); + var _AsyncCreatable = __webpack_require__(193); var _AsyncCreatable2 = _interopRequireDefault(_AsyncCreatable); - var _Creatable = __webpack_require__(193); + var _Creatable = __webpack_require__(194); var _Creatable2 = _interopRequireDefault(_Creatable); - var _Option = __webpack_require__(194); + var _Option = __webpack_require__(195); var _Option2 = _interopRequireDefault(_Option); - var _Value = __webpack_require__(195); + var _Value = __webpack_require__(196); var _Value2 = _interopRequireDefault(_Value); @@ -22440,8 +22491,10 @@ backspaceToRemoveMessage: _react2['default'].PropTypes.string, // Message to use for screenreaders to press backspace to remove the current item - {label} is replaced with the item label className: _react2['default'].PropTypes.string, // className for the outer element clearAllText: stringOrNode, // title for the "clear" control when multi: true + clearRenderer: _react2['default'].PropTypes.func, // create clearable x element clearValueText: stringOrNode, // title for the "clear" control clearable: _react2['default'].PropTypes.bool, // should it be possible to reset value + deleteRemoves: _react2['default'].PropTypes.bool, // whether backspace removes an item if there is no text input delimiter: _react2['default'].PropTypes.string, // delimiter to use to join multiple values for the hidden field value disabled: _react2['default'].PropTypes.bool, // whether the Select is disabled or not escapeClearsValue: _react2['default'].PropTypes.bool, // whether escape clears the value when the menu is closed @@ -22509,7 +22562,9 @@ backspaceToRemoveMessage: 'Press backspace to remove {label}', clearable: true, clearAllText: 'Clear all', + clearRenderer: _utilsDefaultClearRenderer2['default'], clearValueText: 'Clear value', + deleteRemoves: true, delimiter: ',', disabled: false, escapeClearsValue: true, @@ -22621,14 +22676,26 @@ }, componentWillUnmount: function componentWillUnmount() { - document.removeEventListener('touchstart', this.handleTouchOutside); + if (!document.removeEventListener && document.detachEvent) { + document.detachEvent('ontouchstart', this.handleTouchOutside); + } else { + document.removeEventListener('touchstart', this.handleTouchOutside); + } }, toggleTouchOutsideEvent: function toggleTouchOutsideEvent(enabled) { if (enabled) { - document.addEventListener('touchstart', this.handleTouchOutside); + if (!document.addEventListener && document.attachEvent) { + document.attachEvent('ontouchstart', this.handleTouchOutside); + } else { + document.addEventListener('touchstart', this.handleTouchOutside); + } } else { - document.removeEventListener('touchstart', this.handleTouchOutside); + if (!document.removeEventListener && document.detachEvent) { + document.detachEvent('ontouchstart', this.handleTouchOutside); + } else { + document.removeEventListener('touchstart', this.handleTouchOutside); + } } }, @@ -22903,6 +22970,13 @@ } this.focusStartOption(); break; + case 46: + // backspace + if (!this.state.inputValue && this.props.deleteRemoves) { + event.preventDefault(); + this.popValue(); + } + return; default: return; } @@ -23020,7 +23094,18 @@ addValue: function addValue(value) { var valueArray = this.getValueArray(this.props.value); + var visibleOptions = this._visibleOptions.filter(function (val) { + return !val.disabled; + }); + var lastValueIndex = visibleOptions.indexOf(value); this.setValue(valueArray.concat(value)); + if (visibleOptions.length - 1 === lastValueIndex) { + // the last option was selected; focus the second-last one + this.focusOption(visibleOptions[lastValueIndex - 1]); + } else if (visibleOptions.length > lastValueIndex) { + // focus the option below the selected one + this.focusOption(visibleOptions[lastValueIndex + 1]); + } }, popValue: function popValue() { @@ -23104,7 +23189,7 @@ this.setState({ isOpen: true, inputValue: '', - focusedOption: this._focusedOption || options[dir === 'next' ? 0 : options.length - 1].option + focusedOption: this._focusedOption || (options.length ? options[dir === 'next' ? 0 : options.length - 1].option : null) }); return; } @@ -23228,74 +23313,75 @@ }, renderInput: function renderInput(valueArray, focusedOptionIndex) { - var _this5 = this; + var _classNames, + _this5 = this; + + var className = (0, _classnames2['default'])('Select-input', this.props.inputProps.className); + var isOpen = !!this.state.isOpen; + + var ariaOwns = (0, _classnames2['default'])((_classNames = {}, _defineProperty(_classNames, this._instancePrefix + '-list', isOpen), _defineProperty(_classNames, this._instancePrefix + '-backspace-remove-message', this.props.multi && !this.props.disabled && this.state.isFocused && !this.state.inputValue), _classNames)); + + // TODO: Check how this project includes Object.assign() + var inputProps = _extends({}, this.props.inputProps, { + role: 'combobox', + 'aria-expanded': '' + isOpen, + 'aria-owns': ariaOwns, + 'aria-haspopup': '' + isOpen, + 'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value', + 'aria-labelledby': this.props['aria-labelledby'], + 'aria-label': this.props['aria-label'], + className: className, + tabIndex: this.props.tabIndex, + onBlur: this.handleInputBlur, + onChange: this.handleInputChange, + onFocus: this.handleInputFocus, + ref: function ref(_ref) { + return _this5.input = _ref; + }, + required: this.state.required, + value: this.state.inputValue + }); if (this.props.inputRenderer) { - return this.props.inputRenderer(); - } else { - var _classNames; + return this.props.inputRenderer(inputProps); + } - var className = (0, _classnames2['default'])('Select-input', this.props.inputProps.className); - var isOpen = !!this.state.isOpen; + if (this.props.disabled || !this.props.searchable) { + var _props$inputProps = this.props.inputProps; + var inputClassName = _props$inputProps.inputClassName; - var ariaOwns = (0, _classnames2['default'])((_classNames = {}, _defineProperty(_classNames, this._instancePrefix + '-list', isOpen), _defineProperty(_classNames, this._instancePrefix + '-backspace-remove-message', this.props.multi && !this.props.disabled && this.state.isFocused && !this.state.inputValue), _classNames)); + var divProps = _objectWithoutProperties(_props$inputProps, ['inputClassName']); - // TODO: Check how this project includes Object.assign() - var inputProps = _extends({}, this.props.inputProps, { + return _react2['default'].createElement('div', _extends({}, divProps, { role: 'combobox', - 'aria-expanded': '' + isOpen, - 'aria-owns': ariaOwns, - 'aria-haspopup': '' + isOpen, + 'aria-expanded': isOpen, + 'aria-owns': isOpen ? this._instancePrefix + '-list' : this._instancePrefix + '-value', 'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value', - 'aria-labelledby': this.props['aria-labelledby'], - 'aria-label': this.props['aria-label'], className: className, - tabIndex: this.props.tabIndex, + tabIndex: this.props.tabIndex || 0, onBlur: this.handleInputBlur, - onChange: this.handleInputChange, onFocus: this.handleInputFocus, - ref: function ref(_ref) { - return _this5.input = _ref; + ref: function (ref) { + return _this5.input = ref; }, - required: this.state.required, - value: this.state.inputValue - }); - - if (this.props.disabled || !this.props.searchable) { - var _props$inputProps = this.props.inputProps; - var inputClassName = _props$inputProps.inputClassName; - - var divProps = _objectWithoutProperties(_props$inputProps, ['inputClassName']); - - return _react2['default'].createElement('div', _extends({}, divProps, { - role: 'combobox', - 'aria-expanded': isOpen, - 'aria-owns': isOpen ? this._instancePrefix + '-list' : this._instancePrefix + '-value', - 'aria-activedescendant': isOpen ? this._instancePrefix + '-option-' + focusedOptionIndex : this._instancePrefix + '-value', - className: className, - tabIndex: this.props.tabIndex || 0, - onBlur: this.handleInputBlur, - onFocus: this.handleInputFocus, - ref: function (ref) { - return _this5.input = ref; - }, - 'aria-readonly': '' + !!this.props.disabled, - style: { border: 0, width: 1, display: 'inline-block' } })); - } + 'aria-readonly': '' + !!this.props.disabled, + style: { border: 0, width: 1, display: 'inline-block' } })); + } - if (this.props.autosize) { - return _react2['default'].createElement(_reactInputAutosize2['default'], _extends({}, inputProps, { minWidth: '5px' })); - } - return _react2['default'].createElement( - 'div', - { className: className }, - _react2['default'].createElement('input', inputProps) - ); + if (this.props.autosize) { + return _react2['default'].createElement(_reactInputAutosize2['default'], _extends({}, inputProps, { minWidth: '5' })); } + return _react2['default'].createElement( + 'div', + { className: className }, + _react2['default'].createElement('input', inputProps) + ); }, renderClear: function renderClear() { if (!this.props.clearable || !this.props.value || this.props.value === 0 || this.props.multi && !this.props.value.length || this.props.disabled || this.props.isLoading) return; + var clear = this.props.clearRenderer(); + return _react2['default'].createElement( 'span', { className: 'Select-clear-zone', title: this.props.multi ? this.props.clearAllText : this.props.clearValueText, @@ -23305,13 +23391,14 @@ onTouchMove: this.handleTouchMove, onTouchEnd: this.handleTouchEndClearValue }, - _react2['default'].createElement('span', { className: 'Select-clear', dangerouslySetInnerHTML: { __html: '×' } }) + clear ); }, renderArrow: function renderArrow() { var onMouseDown = this.handleMouseDownOnArrow; - var arrow = this.props.arrowRenderer({ onMouseDown: onMouseDown }); + var isOpen = this.state.isOpen; + var arrow = this.props.arrowRenderer({ onMouseDown: onMouseDown, isOpen: isOpen }); return _react2['default'].createElement( 'span', @@ -23878,6 +23965,33 @@ 'use strict'; + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports['default'] = clearRenderer; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + function clearRenderer() { + return _react2['default'].createElement('span', { + className: 'Select-clear', + dangerouslySetInnerHTML: { __html: '×' } + }); + } + + ; + module.exports = exports['default']; + +/***/ }, +/* 192 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + Object.defineProperty(exports, '__esModule', { value: true }); @@ -23914,18 +24028,26 @@ children: _react2['default'].PropTypes.func.isRequired, // Child function responsible for creating the inner Select component; (props: Object): PropTypes.element ignoreAccents: _react2['default'].PropTypes.bool, // strip diacritics when filtering; defaults to true ignoreCase: _react2['default'].PropTypes.bool, // perform case-insensitive filtering; defaults to true - loadingPlaceholder: _react.PropTypes.string.isRequired, // replaces the placeholder while options are loading + loadingPlaceholder: _react2['default'].PropTypes.oneOfType([// replaces the placeholder while options are loading + _react2['default'].PropTypes.string, _react2['default'].PropTypes.node]), loadOptions: _react2['default'].PropTypes.func.isRequired, // callback to load options asynchronously; (inputValue: string, callback: Function): ?Promise options: _react.PropTypes.array.isRequired, // array of options placeholder: _react2['default'].PropTypes.oneOfType([// field placeholder, displayed when there's no value (shared with Select) _react2['default'].PropTypes.string, _react2['default'].PropTypes.node]), + noResultsText: _react2['default'].PropTypes.oneOfType([// field noResultsText, displayed when no options come back from the server + _react2['default'].PropTypes.string, _react2['default'].PropTypes.node]), + onChange: _react2['default'].PropTypes.func, // onChange handler: function (newValue) {} searchPromptText: _react2['default'].PropTypes.oneOfType([// label to prompt for search input - _react2['default'].PropTypes.string, _react2['default'].PropTypes.node]) - }; + _react2['default'].PropTypes.string, _react2['default'].PropTypes.node]), + onInputChange: _react2['default'].PropTypes.func, // optional for keeping track of what is being typed + value: _react2['default'].PropTypes.any }; + + // initial field value + var defaultCache = {}; var defaultProps = { autoload: true, - cache: {}, + cache: defaultCache, children: defaultChildren, ignoreAccents: true, ignoreCase: true, @@ -23942,6 +24064,8 @@ _get(Object.getPrototypeOf(Async.prototype), 'constructor', this).call(this, props, context); + this._cache = props.cache === defaultCache ? {} : props.cache; + this.state = { isLoading: false, options: props.options @@ -23971,14 +24095,19 @@ } }); } + }, { + key: 'clearOptions', + value: function clearOptions() { + this.setState({ options: [] }); + } }, { key: 'loadOptions', value: function loadOptions(inputValue) { var _this2 = this; - var _props = this.props; - var cache = _props.cache; - var loadOptions = _props.loadOptions; + var loadOptions = this.props.loadOptions; + + var cache = this._cache; if (cache && cache.hasOwnProperty(inputValue)) { this.setState({ @@ -24028,9 +24157,10 @@ }, { key: '_onInputChange', value: function _onInputChange(inputValue) { - var _props2 = this.props; - var ignoreAccents = _props2.ignoreAccents; - var ignoreCase = _props2.ignoreCase; + var _props = this.props; + var ignoreAccents = _props.ignoreAccents; + var ignoreCase = _props.ignoreCase; + var onInputChange = _props.onInputChange; if (ignoreAccents) { inputValue = (0, _utilsStripDiacritics2['default'])(inputValue); @@ -24040,24 +24170,70 @@ inputValue = inputValue.toLowerCase(); } + if (onInputChange) { + onInputChange(inputValue); + } + return this.loadOptions(inputValue); } + }, { + key: 'inputValue', + value: function inputValue() { + if (this.select) { + return this.select.state.inputValue; + } + return ''; + } + }, { + key: 'noResultsText', + value: function noResultsText() { + var _props2 = this.props; + var loadingPlaceholder = _props2.loadingPlaceholder; + var noResultsText = _props2.noResultsText; + var searchPromptText = _props2.searchPromptText; + var isLoading = this.state.isLoading; + + var inputValue = this.inputValue(); + + if (isLoading) { + return loadingPlaceholder; + } + if (inputValue && noResultsText) { + return noResultsText; + } + return searchPromptText; + } + }, { + key: 'focus', + value: function focus() { + this.select.focus(); + } }, { key: 'render', value: function render() { + var _this3 = this; + var _props3 = this.props; var children = _props3.children; var loadingPlaceholder = _props3.loadingPlaceholder; var placeholder = _props3.placeholder; - var searchPromptText = _props3.searchPromptText; var _state = this.state; var isLoading = _state.isLoading; var options = _state.options; var props = { - noResultsText: isLoading ? loadingPlaceholder : searchPromptText, + noResultsText: this.noResultsText(), placeholder: isLoading ? loadingPlaceholder : placeholder, - options: isLoading ? [] : options + options: isLoading && loadingPlaceholder ? [] : options, + ref: function ref(_ref) { + return _this3.select = _ref; + }, + onChange: function onChange(newValues) { + if (_this3.props.multi && _this3.props.value && newValues.length > _this3.props.value.length) { + _this3.clearOptions(); + } + _this3.props.onChange(newValues); + } }; return children(_extends({}, this.props, props, { @@ -24081,7 +24257,7 @@ module.exports = exports['default']; /***/ }, -/* 192 */ +/* 193 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -24098,6 +24274,16 @@ var _Select2 = _interopRequireDefault(_Select); + function reduce(obj) { + var props = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + return Object.keys(obj).reduce(function (props, key) { + var value = obj[key]; + if (value !== undefined) props[key] = value; + return props; + }, props); + } + var AsyncCreatable = _react2['default'].createClass({ displayName: 'AsyncCreatableSelect', @@ -24112,10 +24298,14 @@ _Select2['default'].Creatable, _this.props, function (creatableProps) { - return _react2['default'].createElement(_Select2['default'], _extends({}, asyncProps, creatableProps, { + return _react2['default'].createElement(_Select2['default'], _extends({}, reduce(asyncProps, reduce(creatableProps, {})), { onInputChange: function (input) { creatableProps.onInputChange(input); return asyncProps.onInputChange(input); + }, + ref: function (ref) { + creatableProps.ref(ref); + asyncProps.ref(ref); } })); } @@ -24128,7 +24318,7 @@ module.exports = AsyncCreatable; /***/ }, -/* 193 */ +/* 194 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -24183,6 +24373,15 @@ // ({ label: string, labelKey: string, valueKey: string }): Object newOptionCreator: _react2['default'].PropTypes.func, + // input change handler: function (inputValue) {} + onInputChange: _react2['default'].PropTypes.func, + + // input keyDown handler: function (event) {} + onInputKeyDown: _react2['default'].PropTypes.func, + + // new option click handler: function (option) {} + onNewOptionClick: _react2['default'].PropTypes.func, + // See Select.propTypes.options options: _react2['default'].PropTypes.array, @@ -24219,6 +24418,7 @@ var _props = this.props; var isValidNewOption = _props.isValidNewOption; var newOptionCreator = _props.newOptionCreator; + var onNewOptionClick = _props.onNewOptionClick; var _props$options = _props.options; var options = _props$options === undefined ? [] : _props$options; var shouldKeyDownEventCreateNewOption = _props.shouldKeyDownEventCreateNewOption; @@ -24229,9 +24429,13 @@ // Don't add the same option twice. if (_isOptionUnique) { - options.unshift(option); + if (onNewOptionClick) { + onNewOptionClick(option); + } else { + options.unshift(option); - this.select.selectValue(option); + this.select.selectValue(option); + } } } }, @@ -24301,17 +24505,26 @@ var menuRenderer = this.props.menuRenderer; return menuRenderer(_extends({}, params, { - onSelect: this.onOptionSelect + onSelect: this.onOptionSelect, + selectValue: this.onOptionSelect })); }, onInputChange: function onInputChange(input) { + var onInputChange = this.props.onInputChange; + + if (onInputChange) { + onInputChange(input); + } + // This value may be needed in between Select mounts (when this.select is null) this.inputValue = input; }, onInputKeyDown: function onInputKeyDown(event) { - var shouldKeyDownEventCreateNewOption = this.props.shouldKeyDownEventCreateNewOption; + var _props3 = this.props; + var shouldKeyDownEventCreateNewOption = _props3.shouldKeyDownEventCreateNewOption; + var onInputKeyDown = _props3.onInputKeyDown; var focusedOption = this.select.getFocusedOption(); @@ -24320,6 +24533,8 @@ // Prevent decorated Select from doing anything additional with this keyDown event event.preventDefault(); + } else if (onInputKeyDown) { + onInputKeyDown(event); } }, @@ -24334,13 +24549,20 @@ render: function render() { var _this = this; - var _props3 = this.props; - var _props3$children = _props3.children; - var children = _props3$children === undefined ? defaultChildren : _props3$children; - var newOptionCreator = _props3.newOptionCreator; - var shouldKeyDownEventCreateNewOption = _props3.shouldKeyDownEventCreateNewOption; + var _props4 = this.props; + var newOptionCreator = _props4.newOptionCreator; + var shouldKeyDownEventCreateNewOption = _props4.shouldKeyDownEventCreateNewOption; + + var restProps = _objectWithoutProperties(_props4, ['newOptionCreator', 'shouldKeyDownEventCreateNewOption']); - var restProps = _objectWithoutProperties(_props3, ['children', 'newOptionCreator', 'shouldKeyDownEventCreateNewOption']); + var children = this.props.children; + + // We can't use destructuring default values to set the children, + // because it won't apply work if `children` is null. A falsy check is + // more reliable in real world use-cases. + if (!children) { + children = defaultChildren; + } var props = _extends({}, restProps, { allowCreate: true, @@ -24417,7 +24639,7 @@ module.exports = Creatable; /***/ }, -/* 194 */ +/* 195 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -24533,7 +24755,7 @@ module.exports = Option; /***/ }, -/* 195 */ +/* 196 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -24644,16 +24866,16 @@ module.exports = Value; /***/ }, -/* 196 */ +/* 197 */ /***/ function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a