From 51d26c627a72b4e7f4b67f83b3745f72fa87394e Mon Sep 17 00:00:00 2001 From: Vasyl Purchel Date: Thu, 12 Jan 2017 16:36:21 +0000 Subject: [PATCH 1/4] Changing peerDependency to React 15 Change-Id: Ife88a16e46821e8a94c190458098a795209fc8b4 --- dist/react-select.min.js | 2 +- examples/dist/app.js | 565 ++++++++++++++++++++++----------------- examples/dist/common.js | 127 ++++++--- package.json | 6 +- src/Select.js | 4 +- test/Select-test.js | 4 +- 6 files changed, 421 insertions(+), 287 deletions(-) diff --git a/dist/react-select.min.js b/dist/react-select.min.js index 06436b124e..652d6d9a46 100644 --- a/dist/react-select.min.js +++ b/dist/react-select.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Select=e()}}(function(){return function e(t,s,o){function i(a,p){if(!s[a]){if(!t[a]){var r="function"==typeof require&&require;if(!p&&r)return r(a,!0);if(n)return n(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=s[a]={exports:{}};t[a][0].call(u.exports,function(e){var s=t[a][1][e];return i(s?s:e)},u,u.exports,e,t,s,o)}return s[a].exports}for(var n="function"==typeof require&&require,a=0;ai.bottom||o.top-1)return!1;if(this.props.filterOption)return this.props.filterOption.call(this,e,o);var t=String(e[this.props.valueKey]),s=String(e[this.props.labelKey]);return this.props.ignoreCase&&(t=t.toLowerCase(),s=s.toLowerCase(),o=o.toLowerCase()),o&&"start"!==this.props.matchPos?"label"!==this.props.matchProp&&t.indexOf(o)>=0||"value"!==this.props.matchProp&&s.indexOf(o)>=0:"label"!==this.props.matchProp&&t.substr(0,o.length)===o||"value"!==this.props.matchProp&&s.substr(0,o.length)===o};return(e||[]).filter(n,this)},selectFocusedOption:function(){return this.props.allowCreate&&!this.state.focusedOption?this.selectValue(this.state.inputValue):this.state.focusedOption?this.selectValue(this.state.focusedOption):void 0},focusOption:function(e){this.setState({focusedOption:e})},focusNextOption:function(){this.focusAdjacentOption("next")},focusPreviousOption:function(){this.focusAdjacentOption("previous")},focusAdjacentOption:function(e){this._focusedOptionReveal=!0;var t=this.state.filteredOptions.filter(function(e){return!e.disabled});if(!this.state.isOpen)return void this.setState({isOpen:!0,inputValue:"",focusedOption:this.state.focusedOption||t["next"===e?0:t.length-1]},this._bindCloseMenuIfClickedOutside);if(t.length){for(var s=-1,o=0;o-1&&s0?t[s-1]:t[t.length-1]),this.setState({focusedOption:i})}},unfocusOption:function(e){this.state.focusedOption===e&&this.setState({focusedOption:null})},renderOptionLabel:function(e){return e[this.props.labelKey]},buildMenu:function(){var e=this.state.focusedOption?this.state.focusedOption[this.props.valueKey]:null,t=this.props.optionRenderer||this.renderOptionLabel;this.state.filteredOptions.length>0&&(e=null==e?this.state.filteredOptions[0]:e);var s=this.state.filteredOptions;if(this.props.allowCreate&&this.state.inputValue.trim()){var o=this.state.inputValue;s=s.slice();var i=this.props.newOptionCreator?this.props.newOptionCreator(o):{value:o,label:o,create:!0};s.unshift(i)}var a=Object.keys(s).map(function(o){var i=s[o],a=this.state.value===i[this.props.valueKey],p=e===i[this.props.valueKey],l=r({"Select-option":!0,"is-selected":a,"is-focused":p,"is-disabled":i.disabled}),u=p?"focused":null,c=n.createElement(this.props.optionComponent,{key:"option-"+i[this.props.valueKey],className:l,renderFunc:t,mouseDown:this.selectValue,mouseEnter:this.focusOption,mouseLeave:this.unfocusOption,addLabelText:this.props.addLabelText,option:i,ref:u});return c},this);if(a.length)return a;var p,l;return this.isLoading()?(l="Select-searching",p=this.props.searchingText):this.state.inputValue||!this.props.asyncOptions?(l="Select-noresults",p=this.props.noResultsText):(l="Select-search-prompt",p=this.props.searchPromptText),n.createElement("div",{className:l},p)},handleOptionLabelClick:function(e,t){this.props.onOptionLabelClick&&this.props.onOptionLabelClick(e,t)},isLoading:function(){return this.props.isLoading||this.state.isLoading},render:function(){var e=r("Select",this.props.className,{"Select--multi":this.props.multi,"is-searchable":this.props.searchable,"is-open":this.state.isOpen,"is-focused":this.state.isFocused,"is-loading":this.isLoading(),"is-disabled":this.props.disabled,"has-value":this.state.value}),t=[];if(this.props.multi&&this.state.values.forEach(function(e){var s=this.props.valueRenderer||this.renderOptionLabel,o=this.handleOptionLabelClick.bind(this,e),i=this.removeValue.bind(this,e),a=n.createElement(this.props.valueComponent,{key:e[this.props.valueKey],option:e,renderer:s,optionLabelClick:!!this.props.onOptionLabelClick,onOptionLabelClick:o,onRemove:i,disabled:this.props.disabled});t.push(a)},this),!(this.state.inputValue||this.props.multi&&t.length)){var s=this.state.values[0]||null;if(this.props.valueRenderer&&this.state.values.length)t.push(n.createElement(l,{key:0,option:s,renderer:this.props.valueRenderer,disabled:this.props.disabled}));else{var o=n.createElement(this.props.singleValueComponent,{key:"placeholder",value:s,placeholder:this.state.placeholder});t.push(o)}}var a,u,c=this.isLoading()?n.createElement("span",{className:"Select-loading-zone","aria-hidden":"true"},n.createElement("span",{className:"Select-loading"})):null,h=this.props.clearable&&this.state.value&&!this.props.disabled&&!this.isLoading()?n.createElement("span",{className:"Select-clear-zone",title:this.props.multi?this.props.clearAllText:this.props.clearValueText,"aria-label":this.props.multi?this.props.clearAllText:this.props.clearValueText,onMouseDown:this.clearValue,onTouchEnd:this.clearValue,onClick:this.clearValue},n.createElement("span",{className:"Select-clear",dangerouslySetInnerHTML:{__html:"×"}})):null,d=n.createElement("span",{className:"Select-arrow-zone",onMouseDown:this.handleMouseDownOnArrow},n.createElement("span",{className:"Select-arrow",onMouseDown:this.handleMouseDownOnArrow}));this.state.isOpen&&(u={ref:"menu",className:"Select-menu",onMouseDown:this.handleMouseDownOnMenu},a=n.createElement("div",{ref:"selectMenuContainer",className:"Select-menu-outer"},n.createElement("div",u,this.buildMenu())));var f,v={ref:"input",className:"Select-input "+(this.props.inputProps.className||""),tabIndex:this.props.tabIndex||0,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur};for(var m in this.props.inputProps)this.props.inputProps.hasOwnProperty(m)&&"className"!==m&&(v[m]=this.props.inputProps[m]);return this.props.disabled?this.props.multi&&this.state.values.length||(f=n.createElement("div",{className:"Select-input"}," ")):f=this.props.searchable?n.createElement(p,i({value:this.state.inputValue,onChange:this.handleInputChange,minWidth:"5"},v)):n.createElement("div",v," "),n.createElement("div",{ref:"wrapper",className:e},n.createElement("input",{type:"hidden",ref:"value",name:this.props.name,value:this.state.value,disabled:this.props.disabled}),n.createElement("div",{className:"Select-control",ref:"control",onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onTouchEnd:this.handleMouseDown},t,f,c,h,d),a)}});t.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Option":1,"./SingleValue":3,"./Value":4,"react-dom":void 0}],3:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"SingleValue",propTypes:{placeholder:s.PropTypes.string,value:s.PropTypes.object},render:function(){var e=o("Select-placeholder",this.props.value&&this.props.value.className);return s.createElement("div",{className:e,style:this.props.value&&this.props.value.style,title:this.props.value&&this.props.value.title},this.props.placeholder)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"Value",propTypes:{disabled:s.PropTypes.bool,onOptionLabelClick:s.PropTypes.func,onRemove:s.PropTypes.func,option:s.PropTypes.object.isRequired,optionLabelClick:s.PropTypes.bool,renderer:s.PropTypes.func},blockEvent:function(e){e.stopPropagation()},handleOnRemove:function(e){this.props.disabled||this.props.onRemove(e)},render:function(){var e=this.props.option.label;return this.props.renderer&&(e=this.props.renderer(this.props.option)),this.props.onRemove||this.props.optionLabelClick?(this.props.optionLabelClick&&(e=s.createElement("a",{className:o("Select-item-label__a",this.props.option.className),onMouseDown:this.blockEvent,onTouchEnd:this.props.onOptionLabelClick,onClick:this.props.onOptionLabelClick,style:this.props.option.style,title:this.props.option.title},e)),s.createElement("div",{className:o("Select-item",this.props.option.className),style:this.props.option.style,title:this.props.option.title},s.createElement("span",{className:"Select-item-icon",onMouseDown:this.blockEvent,onClick:this.handleOnRemove,onTouchEnd:this.handleOnRemove},"×"),s.createElement("span",{className:"Select-item-label"},e))):s.createElement("div",{className:o("Select-value",this.props.option.className),style:this.props.option.style,title:this.props.option.title},e)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Select=e()}}(function(){return function e(t,s,o){function i(a,p){if(!s[a]){if(!t[a]){var r="function"==typeof require&&require;if(!p&&r)return r(a,!0);if(n)return n(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=s[a]={exports:{}};t[a][0].call(u.exports,function(e){var s=t[a][1][e];return i(s?s:e)},u,u.exports,e,t,s,o)}return s[a].exports}for(var n="function"==typeof require&&require,a=0;ai.bottom||o.top-1)return!1;if(this.props.filterOption)return this.props.filterOption.call(this,e,o);var t=String(e[this.props.valueKey]),s=String(e[this.props.labelKey]);return this.props.ignoreCase&&(t=t.toLowerCase(),s=s.toLowerCase(),o=o.toLowerCase()),o&&"start"!==this.props.matchPos?"label"!==this.props.matchProp&&t.indexOf(o)>=0||"value"!==this.props.matchProp&&s.indexOf(o)>=0:"label"!==this.props.matchProp&&t.substr(0,o.length)===o||"value"!==this.props.matchProp&&s.substr(0,o.length)===o};return(e||[]).filter(n,this)},selectFocusedOption:function(){return this.props.allowCreate&&!this.state.focusedOption?this.selectValue(this.state.inputValue):this.state.focusedOption?this.selectValue(this.state.focusedOption):void 0},focusOption:function(e){this.setState({focusedOption:e})},focusNextOption:function(){this.focusAdjacentOption("next")},focusPreviousOption:function(){this.focusAdjacentOption("previous")},focusAdjacentOption:function(e){this._focusedOptionReveal=!0;var t=this.state.filteredOptions.filter(function(e){return!e.disabled});if(!this.state.isOpen)return void this.setState({isOpen:!0,inputValue:"",focusedOption:this.state.focusedOption||t["next"===e?0:t.length-1]},this._bindCloseMenuIfClickedOutside);if(t.length){for(var s=-1,o=0;o-1&&s0?t[s-1]:t[t.length-1]),this.setState({focusedOption:i})}},unfocusOption:function(e){this.state.focusedOption===e&&this.setState({focusedOption:null})},renderOptionLabel:function(e){return e[this.props.labelKey]},buildMenu:function(){var e=this.state.focusedOption?this.state.focusedOption[this.props.valueKey]:null,t=this.props.optionRenderer||this.renderOptionLabel;this.state.filteredOptions.length>0&&(e=null==e?this.state.filteredOptions[0]:e);var s=this.state.filteredOptions;if(this.props.allowCreate&&this.state.inputValue.trim()){var o=this.state.inputValue;s=s.slice();var i=this.props.newOptionCreator?this.props.newOptionCreator(o):{value:o,label:o,create:!0};s.unshift(i)}var a=Object.keys(s).map(function(o){var i=s[o],a=this.state.value===i[this.props.valueKey],p=e===i[this.props.valueKey],l=r({"Select-option":!0,"is-selected":a,"is-focused":p,"is-disabled":i.disabled}),u=p?"focused":null,c=n.createElement(this.props.optionComponent,{key:"option-"+i[this.props.valueKey],className:l,renderFunc:t,mouseDown:this.selectValue,mouseEnter:this.focusOption,mouseLeave:this.unfocusOption,addLabelText:this.props.addLabelText,option:i,ref:u});return c},this);if(a.length)return a;var p,l;return this.isLoading()?(l="Select-searching",p=this.props.searchingText):this.state.inputValue||!this.props.asyncOptions?(l="Select-noresults",p=this.props.noResultsText):(l="Select-search-prompt",p=this.props.searchPromptText),n.createElement("div",{className:l},p)},handleOptionLabelClick:function(e,t){this.props.onOptionLabelClick&&this.props.onOptionLabelClick(e,t)},isLoading:function(){return this.props.isLoading||this.state.isLoading},render:function(){var e=r("Select",this.props.className,{"Select--multi":this.props.multi,"is-searchable":this.props.searchable,"is-open":this.state.isOpen,"is-focused":this.state.isFocused,"is-loading":this.isLoading(),"is-disabled":this.props.disabled,"has-value":this.state.value}),t=[];if(this.props.multi&&this.state.values.forEach(function(e){var s=this.props.valueRenderer||this.renderOptionLabel,o=this.handleOptionLabelClick.bind(this,e),i=this.removeValue.bind(this,e),a=n.createElement(this.props.valueComponent,{key:e[this.props.valueKey],option:e,renderer:s,optionLabelClick:!!this.props.onOptionLabelClick,onOptionLabelClick:o,onRemove:i,disabled:this.props.disabled});t.push(a)},this),!(this.state.inputValue||this.props.multi&&t.length)){var s=this.state.values[0]||null;if(this.props.valueRenderer&&this.state.values.length)t.push(n.createElement(l,{key:0,option:s,renderer:this.props.valueRenderer,disabled:this.props.disabled}));else{var o=n.createElement(this.props.singleValueComponent,{key:"placeholder",value:s,placeholder:this.state.placeholder});t.push(o)}}var a,u,c=this.isLoading()?n.createElement("span",{className:"Select-loading-zone","aria-hidden":"true"},n.createElement("span",{className:"Select-loading"})):null,h=this.props.clearable&&this.state.value&&!this.props.disabled&&!this.isLoading()?n.createElement("span",{className:"Select-clear-zone",title:this.props.multi?this.props.clearAllText:this.props.clearValueText,"aria-label":this.props.multi?this.props.clearAllText:this.props.clearValueText,onMouseDown:this.clearValue,onTouchEnd:this.clearValue,onClick:this.clearValue},n.createElement("span",{className:"Select-clear",dangerouslySetInnerHTML:{__html:"×"}})):null,d=n.createElement("span",{className:"Select-arrow-zone",onMouseDown:this.handleMouseDownOnArrow},n.createElement("span",{className:"Select-arrow",onMouseDown:this.handleMouseDownOnArrow}));this.state.isOpen&&(u={ref:"menu",className:"Select-menu",onMouseDown:this.handleMouseDownOnMenu},a=n.createElement("div",{ref:"selectMenuContainer",className:"Select-menu-outer"},n.createElement("div",u,this.buildMenu())));var f,v={ref:"input",className:"Select-input "+(this.props.inputProps.className||""),tabIndex:this.props.tabIndex||0,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur};for(var m in this.props.inputProps)this.props.inputProps.hasOwnProperty(m)&&"className"!==m&&(v[m]=this.props.inputProps[m]);return this.props.disabled?this.props.multi&&this.state.values.length||(f=n.createElement("div",{className:"Select-input"}," ")):f=this.props.searchable?n.createElement(p,i({value:this.state.inputValue,onChange:this.handleInputChange,minWidth:"5"},v)):n.createElement("div",v," "),n.createElement("div",{ref:"wrapper",className:e},n.createElement("input",{type:"hidden",ref:"value",name:this.props.name,value:this.state.value,disabled:this.props.disabled}),n.createElement("div",{className:"Select-control",ref:"control",onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onTouchEnd:this.handleMouseDown},t,f,c,h,d),a)}});t.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Option":1,"./SingleValue":3,"./Value":4,"react-dom":void 0}],3:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"SingleValue",propTypes:{placeholder:s.PropTypes.string,value:s.PropTypes.object},render:function(){var e=o("Select-placeholder",this.props.value&&this.props.value.className);return s.createElement("div",{className:e,style:this.props.value&&this.props.value.style,title:this.props.value&&this.props.value.title},this.props.placeholder)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"Value",propTypes:{disabled:s.PropTypes.bool,onOptionLabelClick:s.PropTypes.func,onRemove:s.PropTypes.func,option:s.PropTypes.object.isRequired,optionLabelClick:s.PropTypes.bool,renderer:s.PropTypes.func},blockEvent:function(e){e.stopPropagation()},handleOnRemove:function(e){this.props.disabled||this.props.onRemove(e)},render:function(){var e=this.props.option.label;return this.props.renderer&&(e=this.props.renderer(this.props.option)),this.props.onRemove||this.props.optionLabelClick?(this.props.optionLabelClick&&(e=s.createElement("a",{className:o("Select-item-label__a",this.props.option.className),onMouseDown:this.blockEvent,onTouchEnd:this.props.onOptionLabelClick,onClick:this.props.onOptionLabelClick,style:this.props.option.style,title:this.props.option.title},e)),s.createElement("div",{className:o("Select-item",this.props.option.className),style:this.props.option.style,title:this.props.option.title},s.createElement("span",{className:"Select-item-icon",onMouseDown:this.blockEvent,onClick:this.handleOnRemove,onTouchEnd:this.handleOnRemove},"×"),s.createElement("span",{className:"Select-item-label"},e))):s.createElement("div",{className:o("Select-value",this.props.option.className),style:this.props.option.style,title:this.props.option.title},e)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)}); \ No newline at end of file diff --git a/examples/dist/app.js b/examples/dist/app.js index 0300796f8c..52b092e8ac 100644 --- a/examples/dist/app.js +++ b/examples/dist/app.js @@ -293,7 +293,7 @@ var Option = _react2['default'].createClass({ module.exports = Option; -},{"react":undefined,"react-gravatar":25}],5:[function(require,module,exports){ +},{"react":undefined,"react-gravatar":24}],5:[function(require,module,exports){ 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -428,7 +428,7 @@ var SingleValue = _react2['default'].createClass({ module.exports = SingleValue; -},{"react":undefined,"react-gravatar":25}],7:[function(require,module,exports){ +},{"react":undefined,"react-gravatar":24}],7:[function(require,module,exports){ 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -1176,6 +1176,29 @@ module.exports = charenc; })(); },{}],19:[function(require,module,exports){ +/*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) +} + +function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} + +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) +} + +},{}],20:[function(require,module,exports){ module.exports = function() { var mediaQuery; if (typeof window !== "undefined" && window !== null) { @@ -1190,7 +1213,7 @@ module.exports = function() { return false; }; -},{}],20:[function(require,module,exports){ +},{}],21:[function(require,module,exports){ (function(){ var crypt = require('crypt'), utf8 = require('charenc').utf8, @@ -1341,8 +1364,8 @@ module.exports = function() { md5._digestsize = 16; module.exports = function (message, options) { - if(typeof message == 'undefined') - return; + if (message === undefined || message === null) + throw new Error('Illegal argument ' + message); var digestbytes = crypt.wordsToBytes(md5(message, options)); return options && options.asBytes ? digestbytes : @@ -1352,282 +1375,344 @@ module.exports = function() { })(); -},{"charenc":17,"crypt":18,"is-buffer":21}],21:[function(require,module,exports){ -/** - * Determine if an object is Buffer - * - * Author: Feross Aboukhadijeh - * License: MIT - * - * `npm install is-buffer` - */ +},{"charenc":17,"crypt":18,"is-buffer":19}],22:[function(require,module,exports){ +'use strict'; +/* eslint-disable no-unused-vars */ +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; -module.exports = function (obj) { - return !!( - obj != null && - obj.constructor && - typeof obj.constructor.isBuffer === 'function' && - obj.constructor.isBuffer(obj) - ) -} +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } -},{}],22:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. + return Object(val); +} -'use strict'; +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} + // Detect buggy property enumeration order in older V8 versions. -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } - var regexp = /\+/g; - qs = qs.split(sep); + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } + return true; + } catch (e) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; - - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } + if (Object.getOwnPropertySymbols) { + symbols = Object.getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } - return obj; + return to; }; -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; +},{}],23:[function(require,module,exports){ +'use strict'; +var strictUriEncode = require('strict-uri-encode'); +var objectAssign = require('object-assign'); + +function encode(value, opts) { + if (opts.encode) { + return opts.strict ? strictUriEncode(value) : encodeURIComponent(value); + } + + return value; +} + +exports.extract = function (str) { + return str.split('?')[1] || ''; }; -},{}],23:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +exports.parse = function (str) { + // Create an object with no prototype + // https://github.com/sindresorhus/query-string/issues/47 + var ret = Object.create(null); -'use strict'; + if (typeof str !== 'string') { + return ret; + } -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; + str = str.trim().replace(/^(\?|#|&)/, ''); - case 'boolean': - return v ? 'true' : 'false'; + if (!str) { + return ret; + } - case 'number': - return isFinite(v) ? v : ''; + str.split('&').forEach(function (param) { + var parts = param.replace(/\+/g, ' ').split('='); + // Firefox (pre 40) decodes `%3D` to `=` + // https://github.com/sindresorhus/query-string/pull/37 + var key = parts.shift(); + var val = parts.length > 0 ? parts.join('=') : undefined; + + key = decodeURIComponent(key); + + // missing `=` should be `null`: + // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters + val = val === undefined ? null : decodeURIComponent(val); + + if (ret[key] === undefined) { + ret[key] = val; + } else if (Array.isArray(ret[key])) { + ret[key].push(val); + } else { + ret[key] = [ret[key], val]; + } + }); - default: - return ''; - } + return ret; }; -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; - } +exports.stringify = function (obj, opts) { + var defaults = { + encode: true, + strict: true + }; - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); + opts = objectAssign(defaults, opts); - } + return obj ? Object.keys(obj).sort().map(function (key) { + var val = obj[key]; - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; + if (val === undefined) { + return ''; + } -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; + if (val === null) { + return encode(key, opts); + } -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); - } - return res; -} + if (Array.isArray(val)) { + var result = []; -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); - } - return res; + val.slice().forEach(function (val2) { + if (val2 === undefined) { + return; + } + + if (val2 === null) { + result.push(encode(key, opts)); + } else { + result.push(encode(key, opts) + '=' + encode(val2, opts)); + } + }); + + return result.join('&'); + } + + return encode(key, opts) + '=' + encode(val, opts); + }).filter(function (x) { + return x.length > 0; + }).join('&') : ''; }; -},{}],24:[function(require,module,exports){ +},{"object-assign":22,"strict-uri-encode":25}],24:[function(require,module,exports){ 'use strict'; -exports.decode = exports.parse = require('./decode'); -exports.encode = exports.stringify = require('./encode'); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -},{"./decode":22,"./encode":23}],25:[function(require,module,exports){ -// Generated by CoffeeScript 1.10.0 -var React, isRetina, md5, querystring; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -React = require('react'); +var _react = require('react'); -md5 = require('md5'); +var _react2 = _interopRequireDefault(_react); -querystring = require('querystring'); +var _md = require('md5'); -isRetina = require('is-retina'); +var _md2 = _interopRequireDefault(_md); -module.exports = React.createClass({ - displayName: 'Gravatar', - propTypes: { - email: React.PropTypes.string, - md5: React.PropTypes.string, - size: React.PropTypes.number, - rating: React.PropTypes.string, - https: React.PropTypes.bool, - "default": React.PropTypes.string, - className: React.PropTypes.string - }, - getDefaultProps: function() { - return { - size: 50, - rating: 'g', - https: false, - "default": "retro", - className: "" - }; - }, - render: function() { - var base, hash, modernBrowser, query, retinaQuery, retinaSrc, src; - base = this.props.https ? "https://secure.gravatar.com/avatar/" : 'http://www.gravatar.com/avatar/'; - query = querystring.stringify({ - s: this.props.size, - r: this.props.rating, - d: this.props["default"] - }); - retinaQuery = querystring.stringify({ - s: this.props.size * 2, - r: this.props.rating, - d: this.props["default"] - }); - if (this.props.md5) { - hash = this.props.md5; - } else if (this.props.email) { - hash = md5(this.props.email); - } else { - console.warn('Gravatar image can not be fetched. Either the "email" or "md5" prop must be specified.'); - return React.createElement("script", null); - } - src = base + hash + "?" + query; - retinaSrc = base + hash + "?" + retinaQuery; - modernBrowser = true; - if (typeof window !== "undefined" && window !== null) { - modernBrowser = 'srcset' in document.createElement('img'); - } - if (!modernBrowser && isRetina()) { - return React.createElement("img", { - "style": this.props.style, - "className": "react-gravatar " + this.props.className, - "src": retinaSrc, - "height": this.props.size, - "width": this.props.size +var _queryString = require('query-string'); + +var _queryString2 = _interopRequireDefault(_queryString); + +var _isRetina = require('is-retina'); + +var _isRetina2 = _interopRequireDefault(_isRetina); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +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 Gravatar = function (_React$Component) { + _inherits(Gravatar, _React$Component); + + function Gravatar() { + _classCallCheck(this, Gravatar); + + return _possibleConstructorReturn(this, Object.getPrototypeOf(Gravatar).apply(this, arguments)); + } + + _createClass(Gravatar, [{ + key: 'render', + value: function render() { + var base = this.props.protocol + 'www.gravatar.com/avatar/'; + + var query = _queryString2.default.stringify({ + s: this.props.size, + r: this.props.rating, + d: this.props.default }); - } else { - return React.createElement("img", { - "style": this.props.style, - "className": "react-gravatar " + this.props.className, - "src": src, - "srcSet": retinaSrc + " 2x", - "height": this.props.size, - "width": this.props.size + + var retinaQuery = _queryString2.default.stringify({ + s: this.props.size * 2, + r: this.props.rating, + d: this.props.default }); + + // Gravatar service currently trims and lowercases all registered emails + var formattedEmail = ('' + this.props.email).trim().toLowerCase(); + + var hash = void 0; + if (this.props.md5) { + hash = this.props.md5; + } else if (typeof this.props.email === 'string') { + hash = (0, _md2.default)(formattedEmail); + } else { + console.warn('Gravatar image can not be fetched. Either the "email" or "md5" prop must be specified.'); + return _react2.default.createElement('script', null); + } + + var src = '' + base + hash + '?' + query; + var retinaSrc = '' + base + hash + '?' + retinaQuery; + + var modernBrowser = true; // server-side, we render for modern browsers + + if (typeof window !== 'undefined') { + // this is not NodeJS + modernBrowser = 'srcset' in document.createElement('img'); + } + + var className = 'react-gravatar'; + if (this.props.className) { + className = className + ' ' + this.props.className; + } + + // Clone this.props and then delete Component specific props so we can + // spread the rest into the img. + + var rest = _objectWithoutProperties(this.props, []); + + delete rest.md5; + delete rest.email; + delete rest.protocol; + delete rest.rating; + delete rest.size; + delete rest.style; + delete rest.className; + delete rest.default; + if (!modernBrowser && (0, _isRetina2.default)()) { + return _react2.default.createElement('img', _extends({ + alt: 'Gravatar for ' + formattedEmail, + style: this.props.style, + src: retinaSrc, + height: this.props.size, + width: this.props.size + }, rest, { + className: className + })); + } + return _react2.default.createElement('img', _extends({ + alt: 'Gravatar for ' + formattedEmail, + style: this.props.style, + src: src, + srcSet: retinaSrc + ' 2x', + height: this.props.size, + width: this.props.size + }, rest, { + className: className + })); } - } -}); + }]); + + return Gravatar; +}(_react2.default.Component); + +Gravatar.displayName = 'Gravatar'; +Gravatar.propTypes = { + email: _react2.default.PropTypes.string, + md5: _react2.default.PropTypes.string, + size: _react2.default.PropTypes.number, + rating: _react2.default.PropTypes.string, + default: _react2.default.PropTypes.string, + className: _react2.default.PropTypes.string, + protocol: _react2.default.PropTypes.string, + style: _react2.default.PropTypes.object +}; +Gravatar.defaultProps = { + size: 50, + rating: 'g', + default: 'retro', + protocol: '//' +}; + + +module.exports = Gravatar; +},{"is-retina":20,"md5":21,"query-string":23,"react":undefined}],25:[function(require,module,exports){ +'use strict'; +module.exports = function (str) { + return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase(); + }); +}; -},{"is-retina":19,"md5":20,"querystring":24,"react":undefined}]},{},[1]); +},{}]},{},[1]); diff --git a/examples/dist/common.js b/examples/dist/common.js index c6ab2b1dc8..64dc13e3f9 100644 --- a/examples/dist/common.js +++ b/examples/dist/common.js @@ -521,11 +521,14 @@ module.exports = focusNode; * @typechecks */ +/* eslint-disable fb-www/typeof-undefined */ + /** * Same as document.activeElement but wraps in a try-catch block. In IE it is * not safe to call document.activeElement if there is nothing focused. * - * The activeElement will be null only if the document or document body is not yet defined. + * The activeElement will be null only if the document or document body is not + * yet defined. */ 'use strict'; @@ -533,7 +536,6 @@ function getActiveElement() /*?DOMElement*/{ if (typeof document === 'undefined') { return null; } - try { return document.activeElement || document.body; } catch (e) { @@ -776,7 +778,7 @@ module.exports = hyphenateStyleName; * will remain to ensure logic does not differ in production. */ -var invariant = function (condition, format, a, b, c, d, e, f) { +function invariant(condition, format, a, b, c, d, e, f) { if ("production" !== 'production') { if (format === undefined) { throw new Error('invariant requires an error message argument'); @@ -790,15 +792,16 @@ var invariant = function (condition, format, a, b, c, d, e, f) { } else { var args = [a, b, c, d, e, f]; var argIndex = 0; - error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () { + error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); + error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } -}; +} module.exports = invariant; },{}],17:[function(require,module,exports){ @@ -1060,19 +1063,24 @@ module.exports = performance || {}; 'use strict'; var performance = require('./performance'); -var curPerformance = performance; + +var performanceNow; /** * Detect if we can use `window.performance.now()` and gracefully fallback to * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now * because of Facebook's testing infrastructure. */ -if (!curPerformance || !curPerformance.now) { - curPerformance = Date; +if (performance.now) { + performanceNow = function () { + return performance.now(); + }; +} else { + performanceNow = function () { + return Date.now(); + }; } -var performanceNow = curPerformance.now.bind(curPerformance); - module.exports = performanceNow; },{"./performance":23}],25:[function(require,module,exports){ /** @@ -4456,6 +4464,7 @@ var HTMLDOMPropertyConfig = { icon: null, id: MUST_USE_PROPERTY, inputMode: MUST_USE_ATTRIBUTE, + integrity: null, is: MUST_USE_ATTRIBUTE, keyParams: MUST_USE_ATTRIBUTE, keyType: MUST_USE_ATTRIBUTE, @@ -4478,6 +4487,7 @@ var HTMLDOMPropertyConfig = { multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, name: null, + nonce: MUST_USE_ATTRIBUTE, noValidate: HAS_BOOLEAN_VALUE, open: HAS_BOOLEAN_VALUE, optimum: null, @@ -4489,6 +4499,7 @@ var HTMLDOMPropertyConfig = { readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, rel: null, required: HAS_BOOLEAN_VALUE, + reversed: HAS_BOOLEAN_VALUE, role: MUST_USE_ATTRIBUTE, rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, rowSpan: null, @@ -4539,8 +4550,8 @@ var HTMLDOMPropertyConfig = { */ // autoCapitalize and autoCorrect are supported in Mobile Safari for // keyboard hints. - autoCapitalize: null, - autoCorrect: null, + autoCapitalize: MUST_USE_ATTRIBUTE, + autoCorrect: MUST_USE_ATTRIBUTE, // autoSave allows WebKit/Blink to persist values of input fields on page reloads autoSave: null, // color is for Safari mask-icon link @@ -4571,9 +4582,7 @@ var HTMLDOMPropertyConfig = { httpEquiv: 'http-equiv' }, DOMPropertyNames: { - autoCapitalize: 'autocapitalize', autoComplete: 'autocomplete', - autoCorrect: 'autocorrect', autoFocus: 'autofocus', autoPlay: 'autoplay', autoSave: 'autosave', @@ -4930,6 +4939,7 @@ assign(React, { }); React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM; +React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOMServer; module.exports = React; },{"./Object.assign":49,"./ReactDOM":62,"./ReactDOMServer":72,"./ReactIsomorphic":90,"./deprecated":133}],52:[function(require,module,exports){ @@ -7512,6 +7522,7 @@ var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules; // For quickly matching children type, to test if can be treated as content. var CONTENT_TYPES = { 'string': true, 'number': true }; +var CHILDREN = keyOf({ children: null }); var STYLE = keyOf({ style: null }); var HTML = keyOf({ __html: null }); @@ -8002,7 +8013,9 @@ ReactDOMComponent.Mixin = { } var markup = null; if (this._tag != null && isCustomComponent(this._tag, props)) { - markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); + if (propKey !== CHILDREN) { + markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); + } } else { markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue); } @@ -8262,6 +8275,9 @@ ReactDOMComponent.Mixin = { if (!node) { node = ReactMount.getNode(this._rootNodeID); } + if (propKey === CHILDREN) { + nextProp = null; + } DOMPropertyOperations.setValueForAttribute(node, propKey, nextProp); } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) { if (!node) { @@ -8942,7 +8958,10 @@ var ReactDOMOption = { } }); - nativeProps.children = content; + if (content) { + nativeProps.children = content; + } + return nativeProps; } @@ -8980,7 +8999,7 @@ function updateOptionsIfPendingUpdateAndMounted() { var value = LinkedValueUtils.getValue(props); if (value != null) { - updateOptions(this, props, value); + updateOptions(this, Boolean(props.multiple), value); } } } @@ -10052,7 +10071,9 @@ var DOM_OPERATION_TYPES = { 'setValueForProperty': 'update attribute', 'setValueForAttribute': 'update attribute', 'deleteValueForProperty': 'remove attribute', - 'dangerouslyReplaceNodeWithMarkupByID': 'replace' + 'setValueForStyles': 'update styles', + 'replaceNodeWithMarkup': 'replace', + 'updateTextContent': 'set textContent' }; function getTotalTime(measurements) { @@ -10782,6 +10803,10 @@ var ReactEmptyComponentInjection = { } }; +function registerNullComponentID() { + ReactEmptyComponentRegistry.registerNullComponentID(this._rootNodeID); +} + var ReactEmptyComponent = function (instantiate) { this._currentElement = null; this._rootNodeID = null; @@ -10790,7 +10815,7 @@ var ReactEmptyComponent = function (instantiate) { assign(ReactEmptyComponent.prototype, { construct: function (element) {}, mountComponent: function (rootID, transaction, context) { - ReactEmptyComponentRegistry.registerNullComponentID(rootID); + transaction.getReactMountReady().enqueue(registerNullComponentID, this); this._rootNodeID = rootID; return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context); }, @@ -10922,11 +10947,12 @@ if ("production" !== 'production') { var fakeNode = document.createElement('react'); ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) { var boundFunc = func.bind(null, a, b); - fakeNode.addEventListener(name, boundFunc, false); + var evtType = 'react-' + name; + fakeNode.addEventListener(evtType, boundFunc, false); var evt = document.createEvent('Event'); - evt.initEvent(name, false, false); + evt.initEvent(evtType, false, false); fakeNode.dispatchEvent(evt); - fakeNode.removeEventListener(name, boundFunc, false); + fakeNode.removeEventListener(evtType, boundFunc, false); }; } } @@ -15069,7 +15095,7 @@ module.exports = ReactUpdates; 'use strict'; -module.exports = '0.14.1'; +module.exports = '0.14.8'; },{}],112:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. @@ -16161,6 +16187,7 @@ var warning = require('fbjs/lib/warning'); */ var EventInterface = { type: null, + target: null, // currentTarget is set when dispatching; no use in copying it here currentTarget: emptyFunction.thatReturnsNull, eventPhase: null, @@ -16194,8 +16221,6 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent this.dispatchConfig = dispatchConfig; this.dispatchMarker = dispatchMarker; this.nativeEvent = nativeEvent; - this.target = nativeEventTarget; - this.currentTarget = nativeEventTarget; var Interface = this.constructor.Interface; for (var propName in Interface) { @@ -16206,7 +16231,11 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent if (normalize) { this[propName] = normalize(nativeEvent); } else { - this[propName] = nativeEvent[propName]; + if (propName === 'target') { + this.target = nativeEventTarget; + } else { + this[propName] = nativeEvent[propName]; + } } } @@ -17093,7 +17122,7 @@ module.exports = adler32; var canDefineProperty = false; if ("production" !== 'production') { try { - Object.defineProperty({}, 'x', {}); + Object.defineProperty({}, 'x', { get: function () {} }); canDefineProperty = true; } catch (x) { // IE will fail on defineProperty @@ -18778,7 +18807,7 @@ if ("production" !== 'production') { module.exports = validateDOMNesting; },{"./Object.assign":49,"fbjs/lib/emptyFunction":8,"fbjs/lib/warning":27}],"classnames":[function(require,module,exports){ /*! - Copyright (c) 2015 Jed Watson. + Copyright (c) 2016 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ @@ -18790,7 +18819,7 @@ module.exports = validateDOMNesting; var hasOwn = {}.hasOwnProperty; function classNames () { - var classes = ''; + var classes = []; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; @@ -18799,26 +18828,26 @@ module.exports = validateDOMNesting; var argType = typeof arg; if (argType === 'string' || argType === 'number') { - classes += ' ' + arg; + classes.push(arg); } else if (Array.isArray(arg)) { - classes += ' ' + classNames.apply(null, arg); + classes.push(classNames.apply(null, arg)); } else if (argType === 'object') { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { - classes += ' ' + key; + classes.push(key); } } } } - return classes.substr(1); + return classes.join(' '); } if (typeof module !== 'undefined' && module.exports) { module.exports = classNames; } else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) { // register as 'classnames', consistent with npm package name - define('classnames', function () { + define('classnames', [], function () { return classNames; }); } else { @@ -18838,7 +18867,13 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var React = require('react'); -var sizerStyle = { position: 'absolute', visibility: 'hidden', height: 0, width: 0, overflow: 'scroll', whiteSpace: 'nowrap' }; +var sizerStyle = { position: 'absolute', visibility: 'hidden', height: 0, width: 0, overflow: 'scroll', whiteSpace: 'pre' }; + +var nextFrame = typeof window !== 'undefined' ? (function () { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) { + window.setTimeout(callback, 1000 / 60); + }; +})().bind(window) : undefined; // If window is undefined, then we can't define a nextFrame function var AutosizeInput = React.createClass({ displayName: 'AutosizeInput', @@ -18876,14 +18911,21 @@ var AutosizeInput = React.createClass({ return; } var inputStyle = window.getComputedStyle(this.refs.input); + if (!inputStyle) { + return; + } var widthNode = this.refs.sizer; widthNode.style.fontSize = inputStyle.fontSize; widthNode.style.fontFamily = inputStyle.fontFamily; + widthNode.style.fontWeight = inputStyle.fontWeight; + widthNode.style.fontStyle = inputStyle.fontStyle; widthNode.style.letterSpacing = inputStyle.letterSpacing; if (this.props.placeholder) { var placeholderNode = this.refs.placeholderSizer; placeholderNode.style.fontSize = inputStyle.fontSize; placeholderNode.style.fontFamily = inputStyle.fontFamily; + placeholderNode.style.fontWeight = inputStyle.fontWeight; + placeholderNode.style.fontStyle = inputStyle.fontStyle; placeholderNode.style.letterSpacing = inputStyle.letterSpacing; } }, @@ -18891,7 +18933,7 @@ var AutosizeInput = React.createClass({ if (!this.isMounted() || typeof this.refs.sizer.scrollWidth === 'undefined') { return; } - var newInputWidth; + var newInputWidth = undefined; if (this.props.placeholder) { newInputWidth = Math.max(this.refs.sizer.scrollWidth, this.refs.placeholderSizer.scrollWidth) + 2; } else { @@ -18912,15 +18954,18 @@ var AutosizeInput = React.createClass({ focus: function focus() { this.refs.input.focus(); }, + blur: function blur() { + this.refs.input.blur(); + }, select: function select() { this.refs.input.select(); }, render: function render() { - var escapedValue = (this.props.value || '').replace(/\&/g, '&').replace(/ /g, ' ').replace(/\/g, '>'); + var sizerValue = this.props.defaultValue || this.props.value || ''; var wrapperStyle = this.props.style || {}; if (!wrapperStyle.display) wrapperStyle.display = 'inline-block'; var inputStyle = _extends({}, this.props.inputStyle); - inputStyle.width = this.state.inputWidth; + inputStyle.width = this.state.inputWidth + 'px'; inputStyle.boxSizing = 'content-box'; var placeholder = this.props.placeholder ? React.createElement( 'div', @@ -18931,7 +18976,11 @@ var AutosizeInput = React.createClass({ 'div', { className: this.props.className, style: wrapperStyle }, React.createElement('input', _extends({}, this.props, { ref: 'input', className: this.props.inputClassName, style: inputStyle })), - React.createElement('div', { ref: 'sizer', style: sizerStyle, dangerouslySetInnerHTML: { __html: escapedValue } }), + React.createElement( + 'div', + { ref: 'sizer', style: sizerStyle }, + sizerValue + ), placeholder ); } diff --git a/package.json b/package.json index f73c643a22..7877d37351 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-select", - "version": "0.9.1", + "version": "0.9.1-react15", "description": "A Select control built with and for ReactJS", "main": "lib/Select.js", "style": "dist/default.css", @@ -36,8 +36,8 @@ "unexpected-sinon": "^8.0.0" }, "peerDependencies": { - "react": "^0.14.1", - "react-dom": "^0.14.1" + "react": "^15.3.1", + "react-dom": "^15.3.1" }, "browserify-shim": { "classnames": "global:classNames", diff --git a/src/Select.js b/src/Select.js index 61119edf9e..784f2ccc0c 100644 --- a/src/Select.js +++ b/src/Select.js @@ -602,9 +602,9 @@ var Select = React.createClass({ if (asyncOpts && typeof asyncOpts.then === 'function') { asyncOpts.then((data) => { - optionsResponseHandler(null, data) + optionsResponseHandler(null, data); }, (err) => { - optionsResponseHandler(err) + optionsResponseHandler(err); }); } }, diff --git a/test/Select-test.js b/test/Select-test.js index d88765b86b..679c7f47ae 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -1391,8 +1391,8 @@ describe('Select', () => { }); return new Promise((resolve, reject) => { - input === '_FAIL'? reject('nope') : resolve({options: options}); - }) + input === '_FAIL'? reject('nope') : resolve({ options: options }); + }); }); }); From df0ecf71bb961e3a1cbdad846d9db6f0c9f40f18 Mon Sep 17 00:00:00 2001 From: Vasyl Purchel Date: Thu, 12 Jan 2017 16:50:48 +0000 Subject: [PATCH 2/4] Updating bower.json to react15 version Change-Id: Ib230e3644995636d2f45a790aee3f16fde4c6c95 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index b9a7a9b4bf..140a27596e 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "dist/react-select.min.js", "dist/default.css" ], - "version": "0.9.1", + "version": "0.9.1-react15", "homepage": "https://github.com/JedWatson/react-select", "authors": [ "Jed Watson" From a7c0900ff1ed28ccc89c56e1bdbdfc8e4dbfe9e3 Mon Sep 17 00:00:00 2001 From: Vasyl Purchel Date: Thu, 12 Jan 2017 17:17:05 +0000 Subject: [PATCH 3/4] Reverting changes to dist files Change-Id: I01cf6e0a453f92e261283812afdb23fe7310baec --- dist/react-select.min.js | 2 +- examples/dist/app.js | 565 +++++++++++++++++---------------------- examples/dist/common.js | 127 +++------ 3 files changed, 280 insertions(+), 414 deletions(-) diff --git a/dist/react-select.min.js b/dist/react-select.min.js index 652d6d9a46..06436b124e 100644 --- a/dist/react-select.min.js +++ b/dist/react-select.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Select=e()}}(function(){return function e(t,s,o){function i(a,p){if(!s[a]){if(!t[a]){var r="function"==typeof require&&require;if(!p&&r)return r(a,!0);if(n)return n(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=s[a]={exports:{}};t[a][0].call(u.exports,function(e){var s=t[a][1][e];return i(s?s:e)},u,u.exports,e,t,s,o)}return s[a].exports}for(var n="function"==typeof require&&require,a=0;ai.bottom||o.top-1)return!1;if(this.props.filterOption)return this.props.filterOption.call(this,e,o);var t=String(e[this.props.valueKey]),s=String(e[this.props.labelKey]);return this.props.ignoreCase&&(t=t.toLowerCase(),s=s.toLowerCase(),o=o.toLowerCase()),o&&"start"!==this.props.matchPos?"label"!==this.props.matchProp&&t.indexOf(o)>=0||"value"!==this.props.matchProp&&s.indexOf(o)>=0:"label"!==this.props.matchProp&&t.substr(0,o.length)===o||"value"!==this.props.matchProp&&s.substr(0,o.length)===o};return(e||[]).filter(n,this)},selectFocusedOption:function(){return this.props.allowCreate&&!this.state.focusedOption?this.selectValue(this.state.inputValue):this.state.focusedOption?this.selectValue(this.state.focusedOption):void 0},focusOption:function(e){this.setState({focusedOption:e})},focusNextOption:function(){this.focusAdjacentOption("next")},focusPreviousOption:function(){this.focusAdjacentOption("previous")},focusAdjacentOption:function(e){this._focusedOptionReveal=!0;var t=this.state.filteredOptions.filter(function(e){return!e.disabled});if(!this.state.isOpen)return void this.setState({isOpen:!0,inputValue:"",focusedOption:this.state.focusedOption||t["next"===e?0:t.length-1]},this._bindCloseMenuIfClickedOutside);if(t.length){for(var s=-1,o=0;o-1&&s0?t[s-1]:t[t.length-1]),this.setState({focusedOption:i})}},unfocusOption:function(e){this.state.focusedOption===e&&this.setState({focusedOption:null})},renderOptionLabel:function(e){return e[this.props.labelKey]},buildMenu:function(){var e=this.state.focusedOption?this.state.focusedOption[this.props.valueKey]:null,t=this.props.optionRenderer||this.renderOptionLabel;this.state.filteredOptions.length>0&&(e=null==e?this.state.filteredOptions[0]:e);var s=this.state.filteredOptions;if(this.props.allowCreate&&this.state.inputValue.trim()){var o=this.state.inputValue;s=s.slice();var i=this.props.newOptionCreator?this.props.newOptionCreator(o):{value:o,label:o,create:!0};s.unshift(i)}var a=Object.keys(s).map(function(o){var i=s[o],a=this.state.value===i[this.props.valueKey],p=e===i[this.props.valueKey],l=r({"Select-option":!0,"is-selected":a,"is-focused":p,"is-disabled":i.disabled}),u=p?"focused":null,c=n.createElement(this.props.optionComponent,{key:"option-"+i[this.props.valueKey],className:l,renderFunc:t,mouseDown:this.selectValue,mouseEnter:this.focusOption,mouseLeave:this.unfocusOption,addLabelText:this.props.addLabelText,option:i,ref:u});return c},this);if(a.length)return a;var p,l;return this.isLoading()?(l="Select-searching",p=this.props.searchingText):this.state.inputValue||!this.props.asyncOptions?(l="Select-noresults",p=this.props.noResultsText):(l="Select-search-prompt",p=this.props.searchPromptText),n.createElement("div",{className:l},p)},handleOptionLabelClick:function(e,t){this.props.onOptionLabelClick&&this.props.onOptionLabelClick(e,t)},isLoading:function(){return this.props.isLoading||this.state.isLoading},render:function(){var e=r("Select",this.props.className,{"Select--multi":this.props.multi,"is-searchable":this.props.searchable,"is-open":this.state.isOpen,"is-focused":this.state.isFocused,"is-loading":this.isLoading(),"is-disabled":this.props.disabled,"has-value":this.state.value}),t=[];if(this.props.multi&&this.state.values.forEach(function(e){var s=this.props.valueRenderer||this.renderOptionLabel,o=this.handleOptionLabelClick.bind(this,e),i=this.removeValue.bind(this,e),a=n.createElement(this.props.valueComponent,{key:e[this.props.valueKey],option:e,renderer:s,optionLabelClick:!!this.props.onOptionLabelClick,onOptionLabelClick:o,onRemove:i,disabled:this.props.disabled});t.push(a)},this),!(this.state.inputValue||this.props.multi&&t.length)){var s=this.state.values[0]||null;if(this.props.valueRenderer&&this.state.values.length)t.push(n.createElement(l,{key:0,option:s,renderer:this.props.valueRenderer,disabled:this.props.disabled}));else{var o=n.createElement(this.props.singleValueComponent,{key:"placeholder",value:s,placeholder:this.state.placeholder});t.push(o)}}var a,u,c=this.isLoading()?n.createElement("span",{className:"Select-loading-zone","aria-hidden":"true"},n.createElement("span",{className:"Select-loading"})):null,h=this.props.clearable&&this.state.value&&!this.props.disabled&&!this.isLoading()?n.createElement("span",{className:"Select-clear-zone",title:this.props.multi?this.props.clearAllText:this.props.clearValueText,"aria-label":this.props.multi?this.props.clearAllText:this.props.clearValueText,onMouseDown:this.clearValue,onTouchEnd:this.clearValue,onClick:this.clearValue},n.createElement("span",{className:"Select-clear",dangerouslySetInnerHTML:{__html:"×"}})):null,d=n.createElement("span",{className:"Select-arrow-zone",onMouseDown:this.handleMouseDownOnArrow},n.createElement("span",{className:"Select-arrow",onMouseDown:this.handleMouseDownOnArrow}));this.state.isOpen&&(u={ref:"menu",className:"Select-menu",onMouseDown:this.handleMouseDownOnMenu},a=n.createElement("div",{ref:"selectMenuContainer",className:"Select-menu-outer"},n.createElement("div",u,this.buildMenu())));var f,v={ref:"input",className:"Select-input "+(this.props.inputProps.className||""),tabIndex:this.props.tabIndex||0,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur};for(var m in this.props.inputProps)this.props.inputProps.hasOwnProperty(m)&&"className"!==m&&(v[m]=this.props.inputProps[m]);return this.props.disabled?this.props.multi&&this.state.values.length||(f=n.createElement("div",{className:"Select-input"}," ")):f=this.props.searchable?n.createElement(p,i({value:this.state.inputValue,onChange:this.handleInputChange,minWidth:"5"},v)):n.createElement("div",v," "),n.createElement("div",{ref:"wrapper",className:e},n.createElement("input",{type:"hidden",ref:"value",name:this.props.name,value:this.state.value,disabled:this.props.disabled}),n.createElement("div",{className:"Select-control",ref:"control",onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onTouchEnd:this.handleMouseDown},t,f,c,h,d),a)}});t.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Option":1,"./SingleValue":3,"./Value":4,"react-dom":void 0}],3:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"SingleValue",propTypes:{placeholder:s.PropTypes.string,value:s.PropTypes.object},render:function(){var e=o("Select-placeholder",this.props.value&&this.props.value.className);return s.createElement("div",{className:e,style:this.props.value&&this.props.value.style,title:this.props.value&&this.props.value.title},this.props.placeholder)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"Value",propTypes:{disabled:s.PropTypes.bool,onOptionLabelClick:s.PropTypes.func,onRemove:s.PropTypes.func,option:s.PropTypes.object.isRequired,optionLabelClick:s.PropTypes.bool,renderer:s.PropTypes.func},blockEvent:function(e){e.stopPropagation()},handleOnRemove:function(e){this.props.disabled||this.props.onRemove(e)},render:function(){var e=this.props.option.label;return this.props.renderer&&(e=this.props.renderer(this.props.option)),this.props.onRemove||this.props.optionLabelClick?(this.props.optionLabelClick&&(e=s.createElement("a",{className:o("Select-item-label__a",this.props.option.className),onMouseDown:this.blockEvent,onTouchEnd:this.props.onOptionLabelClick,onClick:this.props.onOptionLabelClick,style:this.props.option.style,title:this.props.option.title},e)),s.createElement("div",{className:o("Select-item",this.props.option.className),style:this.props.option.style,title:this.props.option.title},s.createElement("span",{className:"Select-item-icon",onMouseDown:this.blockEvent,onClick:this.handleOnRemove,onTouchEnd:this.handleOnRemove},"×"),s.createElement("span",{className:"Select-item-label"},e))):s.createElement("div",{className:o("Select-value",this.props.option.className),style:this.props.option.style,title:this.props.option.title},e)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Select=e()}}(function(){return function e(t,s,o){function i(a,p){if(!s[a]){if(!t[a]){var r="function"==typeof require&&require;if(!p&&r)return r(a,!0);if(n)return n(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=s[a]={exports:{}};t[a][0].call(u.exports,function(e){var s=t[a][1][e];return i(s?s:e)},u,u.exports,e,t,s,o)}return s[a].exports}for(var n="function"==typeof require&&require,a=0;ai.bottom||o.top-1)return!1;if(this.props.filterOption)return this.props.filterOption.call(this,e,o);var t=String(e[this.props.valueKey]),s=String(e[this.props.labelKey]);return this.props.ignoreCase&&(t=t.toLowerCase(),s=s.toLowerCase(),o=o.toLowerCase()),o&&"start"!==this.props.matchPos?"label"!==this.props.matchProp&&t.indexOf(o)>=0||"value"!==this.props.matchProp&&s.indexOf(o)>=0:"label"!==this.props.matchProp&&t.substr(0,o.length)===o||"value"!==this.props.matchProp&&s.substr(0,o.length)===o};return(e||[]).filter(n,this)},selectFocusedOption:function(){return this.props.allowCreate&&!this.state.focusedOption?this.selectValue(this.state.inputValue):this.state.focusedOption?this.selectValue(this.state.focusedOption):void 0},focusOption:function(e){this.setState({focusedOption:e})},focusNextOption:function(){this.focusAdjacentOption("next")},focusPreviousOption:function(){this.focusAdjacentOption("previous")},focusAdjacentOption:function(e){this._focusedOptionReveal=!0;var t=this.state.filteredOptions.filter(function(e){return!e.disabled});if(!this.state.isOpen)return void this.setState({isOpen:!0,inputValue:"",focusedOption:this.state.focusedOption||t["next"===e?0:t.length-1]},this._bindCloseMenuIfClickedOutside);if(t.length){for(var s=-1,o=0;o-1&&s0?t[s-1]:t[t.length-1]),this.setState({focusedOption:i})}},unfocusOption:function(e){this.state.focusedOption===e&&this.setState({focusedOption:null})},renderOptionLabel:function(e){return e[this.props.labelKey]},buildMenu:function(){var e=this.state.focusedOption?this.state.focusedOption[this.props.valueKey]:null,t=this.props.optionRenderer||this.renderOptionLabel;this.state.filteredOptions.length>0&&(e=null==e?this.state.filteredOptions[0]:e);var s=this.state.filteredOptions;if(this.props.allowCreate&&this.state.inputValue.trim()){var o=this.state.inputValue;s=s.slice();var i=this.props.newOptionCreator?this.props.newOptionCreator(o):{value:o,label:o,create:!0};s.unshift(i)}var a=Object.keys(s).map(function(o){var i=s[o],a=this.state.value===i[this.props.valueKey],p=e===i[this.props.valueKey],l=r({"Select-option":!0,"is-selected":a,"is-focused":p,"is-disabled":i.disabled}),u=p?"focused":null,c=n.createElement(this.props.optionComponent,{key:"option-"+i[this.props.valueKey],className:l,renderFunc:t,mouseDown:this.selectValue,mouseEnter:this.focusOption,mouseLeave:this.unfocusOption,addLabelText:this.props.addLabelText,option:i,ref:u});return c},this);if(a.length)return a;var p,l;return this.isLoading()?(l="Select-searching",p=this.props.searchingText):this.state.inputValue||!this.props.asyncOptions?(l="Select-noresults",p=this.props.noResultsText):(l="Select-search-prompt",p=this.props.searchPromptText),n.createElement("div",{className:l},p)},handleOptionLabelClick:function(e,t){this.props.onOptionLabelClick&&this.props.onOptionLabelClick(e,t)},isLoading:function(){return this.props.isLoading||this.state.isLoading},render:function(){var e=r("Select",this.props.className,{"Select--multi":this.props.multi,"is-searchable":this.props.searchable,"is-open":this.state.isOpen,"is-focused":this.state.isFocused,"is-loading":this.isLoading(),"is-disabled":this.props.disabled,"has-value":this.state.value}),t=[];if(this.props.multi&&this.state.values.forEach(function(e){var s=this.props.valueRenderer||this.renderOptionLabel,o=this.handleOptionLabelClick.bind(this,e),i=this.removeValue.bind(this,e),a=n.createElement(this.props.valueComponent,{key:e[this.props.valueKey],option:e,renderer:s,optionLabelClick:!!this.props.onOptionLabelClick,onOptionLabelClick:o,onRemove:i,disabled:this.props.disabled});t.push(a)},this),!(this.state.inputValue||this.props.multi&&t.length)){var s=this.state.values[0]||null;if(this.props.valueRenderer&&this.state.values.length)t.push(n.createElement(l,{key:0,option:s,renderer:this.props.valueRenderer,disabled:this.props.disabled}));else{var o=n.createElement(this.props.singleValueComponent,{key:"placeholder",value:s,placeholder:this.state.placeholder});t.push(o)}}var a,u,c=this.isLoading()?n.createElement("span",{className:"Select-loading-zone","aria-hidden":"true"},n.createElement("span",{className:"Select-loading"})):null,h=this.props.clearable&&this.state.value&&!this.props.disabled&&!this.isLoading()?n.createElement("span",{className:"Select-clear-zone",title:this.props.multi?this.props.clearAllText:this.props.clearValueText,"aria-label":this.props.multi?this.props.clearAllText:this.props.clearValueText,onMouseDown:this.clearValue,onTouchEnd:this.clearValue,onClick:this.clearValue},n.createElement("span",{className:"Select-clear",dangerouslySetInnerHTML:{__html:"×"}})):null,d=n.createElement("span",{className:"Select-arrow-zone",onMouseDown:this.handleMouseDownOnArrow},n.createElement("span",{className:"Select-arrow",onMouseDown:this.handleMouseDownOnArrow}));this.state.isOpen&&(u={ref:"menu",className:"Select-menu",onMouseDown:this.handleMouseDownOnMenu},a=n.createElement("div",{ref:"selectMenuContainer",className:"Select-menu-outer"},n.createElement("div",u,this.buildMenu())));var f,v={ref:"input",className:"Select-input "+(this.props.inputProps.className||""),tabIndex:this.props.tabIndex||0,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur};for(var m in this.props.inputProps)this.props.inputProps.hasOwnProperty(m)&&"className"!==m&&(v[m]=this.props.inputProps[m]);return this.props.disabled?this.props.multi&&this.state.values.length||(f=n.createElement("div",{className:"Select-input"}," ")):f=this.props.searchable?n.createElement(p,i({value:this.state.inputValue,onChange:this.handleInputChange,minWidth:"5"},v)):n.createElement("div",v," "),n.createElement("div",{ref:"wrapper",className:e},n.createElement("input",{type:"hidden",ref:"value",name:this.props.name,value:this.state.value,disabled:this.props.disabled}),n.createElement("div",{className:"Select-control",ref:"control",onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onTouchEnd:this.handleMouseDown},t,f,c,h,d),a)}});t.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Option":1,"./SingleValue":3,"./Value":4,"react-dom":void 0}],3:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"SingleValue",propTypes:{placeholder:s.PropTypes.string,value:s.PropTypes.object},render:function(){var e=o("Select-placeholder",this.props.value&&this.props.value.className);return s.createElement("div",{className:e,style:this.props.value&&this.props.value.style,title:this.props.value&&this.props.value.title},this.props.placeholder)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,s){(function(e){"use strict";var s="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o="undefined"!=typeof window?window.classNames:"undefined"!=typeof e?e.classNames:null,i=s.createClass({displayName:"Value",propTypes:{disabled:s.PropTypes.bool,onOptionLabelClick:s.PropTypes.func,onRemove:s.PropTypes.func,option:s.PropTypes.object.isRequired,optionLabelClick:s.PropTypes.bool,renderer:s.PropTypes.func},blockEvent:function(e){e.stopPropagation()},handleOnRemove:function(e){this.props.disabled||this.props.onRemove(e)},render:function(){var e=this.props.option.label;return this.props.renderer&&(e=this.props.renderer(this.props.option)),this.props.onRemove||this.props.optionLabelClick?(this.props.optionLabelClick&&(e=s.createElement("a",{className:o("Select-item-label__a",this.props.option.className),onMouseDown:this.blockEvent,onTouchEnd:this.props.onOptionLabelClick,onClick:this.props.onOptionLabelClick,style:this.props.option.style,title:this.props.option.title},e)),s.createElement("div",{className:o("Select-item",this.props.option.className),style:this.props.option.style,title:this.props.option.title},s.createElement("span",{className:"Select-item-icon",onMouseDown:this.blockEvent,onClick:this.handleOnRemove,onTouchEnd:this.handleOnRemove},"×"),s.createElement("span",{className:"Select-item-label"},e))):s.createElement("div",{className:o("Select-value",this.props.option.className),style:this.props.option.style,title:this.props.option.title},e)}});t.exports=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)}); \ No newline at end of file diff --git a/examples/dist/app.js b/examples/dist/app.js index 52b092e8ac..0300796f8c 100644 --- a/examples/dist/app.js +++ b/examples/dist/app.js @@ -293,7 +293,7 @@ var Option = _react2['default'].createClass({ module.exports = Option; -},{"react":undefined,"react-gravatar":24}],5:[function(require,module,exports){ +},{"react":undefined,"react-gravatar":25}],5:[function(require,module,exports){ 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -428,7 +428,7 @@ var SingleValue = _react2['default'].createClass({ module.exports = SingleValue; -},{"react":undefined,"react-gravatar":24}],7:[function(require,module,exports){ +},{"react":undefined,"react-gravatar":25}],7:[function(require,module,exports){ 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -1176,29 +1176,6 @@ module.exports = charenc; })(); },{}],19:[function(require,module,exports){ -/*! - * Determine if an object is a Buffer - * - * @author Feross Aboukhadijeh - * @license MIT - */ - -// The _isBuffer check is for Safari 5-7 support, because it's missing -// Object.prototype.constructor. Remove this eventually -module.exports = function (obj) { - return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) -} - -function isBuffer (obj) { - return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) -} - -// For Node v0.10 support. Remove this eventually. -function isSlowBuffer (obj) { - return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) -} - -},{}],20:[function(require,module,exports){ module.exports = function() { var mediaQuery; if (typeof window !== "undefined" && window !== null) { @@ -1213,7 +1190,7 @@ module.exports = function() { return false; }; -},{}],21:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ (function(){ var crypt = require('crypt'), utf8 = require('charenc').utf8, @@ -1364,8 +1341,8 @@ module.exports = function() { md5._digestsize = 16; module.exports = function (message, options) { - if (message === undefined || message === null) - throw new Error('Illegal argument ' + message); + if(typeof message == 'undefined') + return; var digestbytes = crypt.wordsToBytes(md5(message, options)); return options && options.asBytes ? digestbytes : @@ -1375,344 +1352,282 @@ module.exports = function() { })(); -},{"charenc":17,"crypt":18,"is-buffer":19}],22:[function(require,module,exports){ -'use strict'; -/* eslint-disable no-unused-vars */ -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } +},{"charenc":17,"crypt":18,"is-buffer":21}],21:[function(require,module,exports){ +/** + * Determine if an object is Buffer + * + * Author: Feross Aboukhadijeh + * License: MIT + * + * `npm install is-buffer` + */ - return Object(val); +module.exports = function (obj) { + return !!( + obj != null && + obj.constructor && + typeof obj.constructor.isBuffer === 'function' && + obj.constructor.isBuffer(obj) + ) } -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. +},{}],22:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } +'use strict'; - return true; - } catch (e) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } +// If obj.hasOwnProperty has been overridden, then calling +// obj.hasOwnProperty(prop) will break. +// See: https://github.com/joyent/node/issues/1707 +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); } -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; +module.exports = function(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } + var regexp = /\+/g; + qs = qs.split(sep); - if (Object.getOwnPropertySymbols) { - symbols = Object.getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } - return to; -}; + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } -},{}],23:[function(require,module,exports){ -'use strict'; -var strictUriEncode = require('strict-uri-encode'); -var objectAssign = require('object-assign'); + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } -function encode(value, opts) { - if (opts.encode) { - return opts.strict ? strictUriEncode(value) : encodeURIComponent(value); - } + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); - return value; -} + if (!hasOwnProperty(obj, k)) { + obj[k] = v; + } else if (isArray(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } -exports.extract = function (str) { - return str.split('?')[1] || ''; + return obj; }; -exports.parse = function (str) { - // Create an object with no prototype - // https://github.com/sindresorhus/query-string/issues/47 - var ret = Object.create(null); - - if (typeof str !== 'string') { - return ret; - } - - str = str.trim().replace(/^(\?|#|&)/, ''); - - if (!str) { - return ret; - } - - str.split('&').forEach(function (param) { - var parts = param.replace(/\+/g, ' ').split('='); - // Firefox (pre 40) decodes `%3D` to `=` - // https://github.com/sindresorhus/query-string/pull/37 - var key = parts.shift(); - var val = parts.length > 0 ? parts.join('=') : undefined; - - key = decodeURIComponent(key); - - // missing `=` should be `null`: - // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters - val = val === undefined ? null : decodeURIComponent(val); - - if (ret[key] === undefined) { - ret[key] = val; - } else if (Array.isArray(ret[key])) { - ret[key].push(val); - } else { - ret[key] = [ret[key], val]; - } - }); - - return ret; +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; }; -exports.stringify = function (obj, opts) { - var defaults = { - encode: true, - strict: true - }; - - opts = objectAssign(defaults, opts); - - return obj ? Object.keys(obj).sort().map(function (key) { - var val = obj[key]; - - if (val === undefined) { - return ''; - } - - if (val === null) { - return encode(key, opts); - } - - if (Array.isArray(val)) { - var result = []; - - val.slice().forEach(function (val2) { - if (val2 === undefined) { - return; - } - - if (val2 === null) { - result.push(encode(key, opts)); - } else { - result.push(encode(key, opts) + '=' + encode(val2, opts)); - } - }); - - return result.join('&'); - } - - return encode(key, opts) + '=' + encode(val, opts); - }).filter(function (x) { - return x.length > 0; - }).join('&') : ''; -}; +},{}],23:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -},{"object-assign":22,"strict-uri-encode":25}],24:[function(require,module,exports){ 'use strict'; -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var stringifyPrimitive = function(v) { + switch (typeof v) { + case 'string': + return v; -var _react = require('react'); + case 'boolean': + return v ? 'true' : 'false'; -var _react2 = _interopRequireDefault(_react); + case 'number': + return isFinite(v) ? v : ''; -var _md = require('md5'); + default: + return ''; + } +}; -var _md2 = _interopRequireDefault(_md); +module.exports = function(obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } -var _queryString = require('query-string'); + if (typeof obj === 'object') { + return map(objectKeys(obj), function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (isArray(obj[k])) { + return map(obj[k], function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); -var _queryString2 = _interopRequireDefault(_queryString); + } -var _isRetina = require('is-retina'); + if (!name) return ''; + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); +}; -var _isRetina2 = _interopRequireDefault(_isRetina); +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function map (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f(xs[i], i)); + } + return res; +} -function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } +var objectKeys = Object.keys || function (obj) { + var res = []; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); + } + return res; +}; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +},{}],24:[function(require,module,exports){ +'use strict'; -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } +exports.decode = exports.parse = require('./decode'); +exports.encode = exports.stringify = require('./encode'); -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; } +},{"./decode":22,"./encode":23}],25:[function(require,module,exports){ +// Generated by CoffeeScript 1.10.0 +var React, isRetina, md5, querystring; -var Gravatar = function (_React$Component) { - _inherits(Gravatar, _React$Component); +React = require('react'); - function Gravatar() { - _classCallCheck(this, Gravatar); +md5 = require('md5'); - return _possibleConstructorReturn(this, Object.getPrototypeOf(Gravatar).apply(this, arguments)); - } +querystring = require('querystring'); - _createClass(Gravatar, [{ - key: 'render', - value: function render() { - var base = this.props.protocol + 'www.gravatar.com/avatar/'; +isRetina = require('is-retina'); - var query = _queryString2.default.stringify({ - s: this.props.size, - r: this.props.rating, - d: this.props.default +module.exports = React.createClass({ + displayName: 'Gravatar', + propTypes: { + email: React.PropTypes.string, + md5: React.PropTypes.string, + size: React.PropTypes.number, + rating: React.PropTypes.string, + https: React.PropTypes.bool, + "default": React.PropTypes.string, + className: React.PropTypes.string + }, + getDefaultProps: function() { + return { + size: 50, + rating: 'g', + https: false, + "default": "retro", + className: "" + }; + }, + render: function() { + var base, hash, modernBrowser, query, retinaQuery, retinaSrc, src; + base = this.props.https ? "https://secure.gravatar.com/avatar/" : 'http://www.gravatar.com/avatar/'; + query = querystring.stringify({ + s: this.props.size, + r: this.props.rating, + d: this.props["default"] + }); + retinaQuery = querystring.stringify({ + s: this.props.size * 2, + r: this.props.rating, + d: this.props["default"] + }); + if (this.props.md5) { + hash = this.props.md5; + } else if (this.props.email) { + hash = md5(this.props.email); + } else { + console.warn('Gravatar image can not be fetched. Either the "email" or "md5" prop must be specified.'); + return React.createElement("script", null); + } + src = base + hash + "?" + query; + retinaSrc = base + hash + "?" + retinaQuery; + modernBrowser = true; + if (typeof window !== "undefined" && window !== null) { + modernBrowser = 'srcset' in document.createElement('img'); + } + if (!modernBrowser && isRetina()) { + return React.createElement("img", { + "style": this.props.style, + "className": "react-gravatar " + this.props.className, + "src": retinaSrc, + "height": this.props.size, + "width": this.props.size }); - - var retinaQuery = _queryString2.default.stringify({ - s: this.props.size * 2, - r: this.props.rating, - d: this.props.default + } else { + return React.createElement("img", { + "style": this.props.style, + "className": "react-gravatar " + this.props.className, + "src": src, + "srcSet": retinaSrc + " 2x", + "height": this.props.size, + "width": this.props.size }); - - // Gravatar service currently trims and lowercases all registered emails - var formattedEmail = ('' + this.props.email).trim().toLowerCase(); - - var hash = void 0; - if (this.props.md5) { - hash = this.props.md5; - } else if (typeof this.props.email === 'string') { - hash = (0, _md2.default)(formattedEmail); - } else { - console.warn('Gravatar image can not be fetched. Either the "email" or "md5" prop must be specified.'); - return _react2.default.createElement('script', null); - } - - var src = '' + base + hash + '?' + query; - var retinaSrc = '' + base + hash + '?' + retinaQuery; - - var modernBrowser = true; // server-side, we render for modern browsers - - if (typeof window !== 'undefined') { - // this is not NodeJS - modernBrowser = 'srcset' in document.createElement('img'); - } - - var className = 'react-gravatar'; - if (this.props.className) { - className = className + ' ' + this.props.className; - } - - // Clone this.props and then delete Component specific props so we can - // spread the rest into the img. - - var rest = _objectWithoutProperties(this.props, []); - - delete rest.md5; - delete rest.email; - delete rest.protocol; - delete rest.rating; - delete rest.size; - delete rest.style; - delete rest.className; - delete rest.default; - if (!modernBrowser && (0, _isRetina2.default)()) { - return _react2.default.createElement('img', _extends({ - alt: 'Gravatar for ' + formattedEmail, - style: this.props.style, - src: retinaSrc, - height: this.props.size, - width: this.props.size - }, rest, { - className: className - })); - } - return _react2.default.createElement('img', _extends({ - alt: 'Gravatar for ' + formattedEmail, - style: this.props.style, - src: src, - srcSet: retinaSrc + ' 2x', - height: this.props.size, - width: this.props.size - }, rest, { - className: className - })); } - }]); - - return Gravatar; -}(_react2.default.Component); - -Gravatar.displayName = 'Gravatar'; -Gravatar.propTypes = { - email: _react2.default.PropTypes.string, - md5: _react2.default.PropTypes.string, - size: _react2.default.PropTypes.number, - rating: _react2.default.PropTypes.string, - default: _react2.default.PropTypes.string, - className: _react2.default.PropTypes.string, - protocol: _react2.default.PropTypes.string, - style: _react2.default.PropTypes.object -}; -Gravatar.defaultProps = { - size: 50, - rating: 'g', - default: 'retro', - protocol: '//' -}; - - -module.exports = Gravatar; -},{"is-retina":20,"md5":21,"query-string":23,"react":undefined}],25:[function(require,module,exports){ -'use strict'; -module.exports = function (str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { - return '%' + c.charCodeAt(0).toString(16).toUpperCase(); - }); -}; + } +}); -},{}]},{},[1]); +},{"is-retina":19,"md5":20,"querystring":24,"react":undefined}]},{},[1]); diff --git a/examples/dist/common.js b/examples/dist/common.js index 64dc13e3f9..c6ab2b1dc8 100644 --- a/examples/dist/common.js +++ b/examples/dist/common.js @@ -521,14 +521,11 @@ module.exports = focusNode; * @typechecks */ -/* eslint-disable fb-www/typeof-undefined */ - /** * Same as document.activeElement but wraps in a try-catch block. In IE it is * not safe to call document.activeElement if there is nothing focused. * - * The activeElement will be null only if the document or document body is not - * yet defined. + * The activeElement will be null only if the document or document body is not yet defined. */ 'use strict'; @@ -536,6 +533,7 @@ function getActiveElement() /*?DOMElement*/{ if (typeof document === 'undefined') { return null; } + try { return document.activeElement || document.body; } catch (e) { @@ -778,7 +776,7 @@ module.exports = hyphenateStyleName; * will remain to ensure logic does not differ in production. */ -function invariant(condition, format, a, b, c, d, e, f) { +var invariant = function (condition, format, a, b, c, d, e, f) { if ("production" !== 'production') { if (format === undefined) { throw new Error('invariant requires an error message argument'); @@ -792,16 +790,15 @@ function invariant(condition, format, a, b, c, d, e, f) { } else { var args = [a, b, c, d, e, f]; var argIndex = 0; - error = new Error(format.replace(/%s/g, function () { + error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () { return args[argIndex++]; })); - error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } -} +}; module.exports = invariant; },{}],17:[function(require,module,exports){ @@ -1063,24 +1060,19 @@ module.exports = performance || {}; 'use strict'; var performance = require('./performance'); - -var performanceNow; +var curPerformance = performance; /** * Detect if we can use `window.performance.now()` and gracefully fallback to * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now * because of Facebook's testing infrastructure. */ -if (performance.now) { - performanceNow = function () { - return performance.now(); - }; -} else { - performanceNow = function () { - return Date.now(); - }; +if (!curPerformance || !curPerformance.now) { + curPerformance = Date; } +var performanceNow = curPerformance.now.bind(curPerformance); + module.exports = performanceNow; },{"./performance":23}],25:[function(require,module,exports){ /** @@ -4464,7 +4456,6 @@ var HTMLDOMPropertyConfig = { icon: null, id: MUST_USE_PROPERTY, inputMode: MUST_USE_ATTRIBUTE, - integrity: null, is: MUST_USE_ATTRIBUTE, keyParams: MUST_USE_ATTRIBUTE, keyType: MUST_USE_ATTRIBUTE, @@ -4487,7 +4478,6 @@ var HTMLDOMPropertyConfig = { multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, name: null, - nonce: MUST_USE_ATTRIBUTE, noValidate: HAS_BOOLEAN_VALUE, open: HAS_BOOLEAN_VALUE, optimum: null, @@ -4499,7 +4489,6 @@ var HTMLDOMPropertyConfig = { readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, rel: null, required: HAS_BOOLEAN_VALUE, - reversed: HAS_BOOLEAN_VALUE, role: MUST_USE_ATTRIBUTE, rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE, rowSpan: null, @@ -4550,8 +4539,8 @@ var HTMLDOMPropertyConfig = { */ // autoCapitalize and autoCorrect are supported in Mobile Safari for // keyboard hints. - autoCapitalize: MUST_USE_ATTRIBUTE, - autoCorrect: MUST_USE_ATTRIBUTE, + autoCapitalize: null, + autoCorrect: null, // autoSave allows WebKit/Blink to persist values of input fields on page reloads autoSave: null, // color is for Safari mask-icon link @@ -4582,7 +4571,9 @@ var HTMLDOMPropertyConfig = { httpEquiv: 'http-equiv' }, DOMPropertyNames: { + autoCapitalize: 'autocapitalize', autoComplete: 'autocomplete', + autoCorrect: 'autocorrect', autoFocus: 'autofocus', autoPlay: 'autoplay', autoSave: 'autosave', @@ -4939,7 +4930,6 @@ assign(React, { }); React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM; -React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOMServer; module.exports = React; },{"./Object.assign":49,"./ReactDOM":62,"./ReactDOMServer":72,"./ReactIsomorphic":90,"./deprecated":133}],52:[function(require,module,exports){ @@ -7522,7 +7512,6 @@ var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules; // For quickly matching children type, to test if can be treated as content. var CONTENT_TYPES = { 'string': true, 'number': true }; -var CHILDREN = keyOf({ children: null }); var STYLE = keyOf({ style: null }); var HTML = keyOf({ __html: null }); @@ -8013,9 +8002,7 @@ ReactDOMComponent.Mixin = { } var markup = null; if (this._tag != null && isCustomComponent(this._tag, props)) { - if (propKey !== CHILDREN) { - markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); - } + markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); } else { markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue); } @@ -8275,9 +8262,6 @@ ReactDOMComponent.Mixin = { if (!node) { node = ReactMount.getNode(this._rootNodeID); } - if (propKey === CHILDREN) { - nextProp = null; - } DOMPropertyOperations.setValueForAttribute(node, propKey, nextProp); } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) { if (!node) { @@ -8958,10 +8942,7 @@ var ReactDOMOption = { } }); - if (content) { - nativeProps.children = content; - } - + nativeProps.children = content; return nativeProps; } @@ -8999,7 +8980,7 @@ function updateOptionsIfPendingUpdateAndMounted() { var value = LinkedValueUtils.getValue(props); if (value != null) { - updateOptions(this, Boolean(props.multiple), value); + updateOptions(this, props, value); } } } @@ -10071,9 +10052,7 @@ var DOM_OPERATION_TYPES = { 'setValueForProperty': 'update attribute', 'setValueForAttribute': 'update attribute', 'deleteValueForProperty': 'remove attribute', - 'setValueForStyles': 'update styles', - 'replaceNodeWithMarkup': 'replace', - 'updateTextContent': 'set textContent' + 'dangerouslyReplaceNodeWithMarkupByID': 'replace' }; function getTotalTime(measurements) { @@ -10803,10 +10782,6 @@ var ReactEmptyComponentInjection = { } }; -function registerNullComponentID() { - ReactEmptyComponentRegistry.registerNullComponentID(this._rootNodeID); -} - var ReactEmptyComponent = function (instantiate) { this._currentElement = null; this._rootNodeID = null; @@ -10815,7 +10790,7 @@ var ReactEmptyComponent = function (instantiate) { assign(ReactEmptyComponent.prototype, { construct: function (element) {}, mountComponent: function (rootID, transaction, context) { - transaction.getReactMountReady().enqueue(registerNullComponentID, this); + ReactEmptyComponentRegistry.registerNullComponentID(rootID); this._rootNodeID = rootID; return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context); }, @@ -10947,12 +10922,11 @@ if ("production" !== 'production') { var fakeNode = document.createElement('react'); ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) { var boundFunc = func.bind(null, a, b); - var evtType = 'react-' + name; - fakeNode.addEventListener(evtType, boundFunc, false); + fakeNode.addEventListener(name, boundFunc, false); var evt = document.createEvent('Event'); - evt.initEvent(evtType, false, false); + evt.initEvent(name, false, false); fakeNode.dispatchEvent(evt); - fakeNode.removeEventListener(evtType, boundFunc, false); + fakeNode.removeEventListener(name, boundFunc, false); }; } } @@ -15095,7 +15069,7 @@ module.exports = ReactUpdates; 'use strict'; -module.exports = '0.14.8'; +module.exports = '0.14.1'; },{}],112:[function(require,module,exports){ /** * Copyright 2013-2015, Facebook, Inc. @@ -16187,7 +16161,6 @@ var warning = require('fbjs/lib/warning'); */ var EventInterface = { type: null, - target: null, // currentTarget is set when dispatching; no use in copying it here currentTarget: emptyFunction.thatReturnsNull, eventPhase: null, @@ -16221,6 +16194,8 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent this.dispatchConfig = dispatchConfig; this.dispatchMarker = dispatchMarker; this.nativeEvent = nativeEvent; + this.target = nativeEventTarget; + this.currentTarget = nativeEventTarget; var Interface = this.constructor.Interface; for (var propName in Interface) { @@ -16231,11 +16206,7 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent if (normalize) { this[propName] = normalize(nativeEvent); } else { - if (propName === 'target') { - this.target = nativeEventTarget; - } else { - this[propName] = nativeEvent[propName]; - } + this[propName] = nativeEvent[propName]; } } @@ -17122,7 +17093,7 @@ module.exports = adler32; var canDefineProperty = false; if ("production" !== 'production') { try { - Object.defineProperty({}, 'x', { get: function () {} }); + Object.defineProperty({}, 'x', {}); canDefineProperty = true; } catch (x) { // IE will fail on defineProperty @@ -18807,7 +18778,7 @@ if ("production" !== 'production') { module.exports = validateDOMNesting; },{"./Object.assign":49,"fbjs/lib/emptyFunction":8,"fbjs/lib/warning":27}],"classnames":[function(require,module,exports){ /*! - Copyright (c) 2016 Jed Watson. + Copyright (c) 2015 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ @@ -18819,7 +18790,7 @@ module.exports = validateDOMNesting; var hasOwn = {}.hasOwnProperty; function classNames () { - var classes = []; + var classes = ''; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; @@ -18828,26 +18799,26 @@ module.exports = validateDOMNesting; var argType = typeof arg; if (argType === 'string' || argType === 'number') { - classes.push(arg); + classes += ' ' + arg; } else if (Array.isArray(arg)) { - classes.push(classNames.apply(null, arg)); + classes += ' ' + classNames.apply(null, arg); } else if (argType === 'object') { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); + classes += ' ' + key; } } } } - return classes.join(' '); + return classes.substr(1); } if (typeof module !== 'undefined' && module.exports) { module.exports = classNames; } else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) { // register as 'classnames', consistent with npm package name - define('classnames', [], function () { + define('classnames', function () { return classNames; }); } else { @@ -18867,13 +18838,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var React = require('react'); -var sizerStyle = { position: 'absolute', visibility: 'hidden', height: 0, width: 0, overflow: 'scroll', whiteSpace: 'pre' }; - -var nextFrame = typeof window !== 'undefined' ? (function () { - return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) { - window.setTimeout(callback, 1000 / 60); - }; -})().bind(window) : undefined; // If window is undefined, then we can't define a nextFrame function +var sizerStyle = { position: 'absolute', visibility: 'hidden', height: 0, width: 0, overflow: 'scroll', whiteSpace: 'nowrap' }; var AutosizeInput = React.createClass({ displayName: 'AutosizeInput', @@ -18911,21 +18876,14 @@ var AutosizeInput = React.createClass({ return; } var inputStyle = window.getComputedStyle(this.refs.input); - if (!inputStyle) { - return; - } var widthNode = this.refs.sizer; widthNode.style.fontSize = inputStyle.fontSize; widthNode.style.fontFamily = inputStyle.fontFamily; - widthNode.style.fontWeight = inputStyle.fontWeight; - widthNode.style.fontStyle = inputStyle.fontStyle; widthNode.style.letterSpacing = inputStyle.letterSpacing; if (this.props.placeholder) { var placeholderNode = this.refs.placeholderSizer; placeholderNode.style.fontSize = inputStyle.fontSize; placeholderNode.style.fontFamily = inputStyle.fontFamily; - placeholderNode.style.fontWeight = inputStyle.fontWeight; - placeholderNode.style.fontStyle = inputStyle.fontStyle; placeholderNode.style.letterSpacing = inputStyle.letterSpacing; } }, @@ -18933,7 +18891,7 @@ var AutosizeInput = React.createClass({ if (!this.isMounted() || typeof this.refs.sizer.scrollWidth === 'undefined') { return; } - var newInputWidth = undefined; + var newInputWidth; if (this.props.placeholder) { newInputWidth = Math.max(this.refs.sizer.scrollWidth, this.refs.placeholderSizer.scrollWidth) + 2; } else { @@ -18954,18 +18912,15 @@ var AutosizeInput = React.createClass({ focus: function focus() { this.refs.input.focus(); }, - blur: function blur() { - this.refs.input.blur(); - }, select: function select() { this.refs.input.select(); }, render: function render() { - var sizerValue = this.props.defaultValue || this.props.value || ''; + var escapedValue = (this.props.value || '').replace(/\&/g, '&').replace(/ /g, ' ').replace(/\/g, '>'); var wrapperStyle = this.props.style || {}; if (!wrapperStyle.display) wrapperStyle.display = 'inline-block'; var inputStyle = _extends({}, this.props.inputStyle); - inputStyle.width = this.state.inputWidth + 'px'; + inputStyle.width = this.state.inputWidth; inputStyle.boxSizing = 'content-box'; var placeholder = this.props.placeholder ? React.createElement( 'div', @@ -18976,11 +18931,7 @@ var AutosizeInput = React.createClass({ 'div', { className: this.props.className, style: wrapperStyle }, React.createElement('input', _extends({}, this.props, { ref: 'input', className: this.props.inputClassName, style: inputStyle })), - React.createElement( - 'div', - { ref: 'sizer', style: sizerStyle }, - sizerValue - ), + React.createElement('div', { ref: 'sizer', style: sizerStyle, dangerouslySetInnerHTML: { __html: escapedValue } }), placeholder ); } From bfaa1a4bccb70a0085aba3f1277f9161d9a576b7 Mon Sep 17 00:00:00 2001 From: Vasyl Purchel Date: Fri, 13 Jan 2017 10:08:56 +0000 Subject: [PATCH 4/4] Adding wday to version Change-Id: Icba4b2b31ff35b1e24ceccb9cc7812320e6d306a --- HISTORY.md | 4 ++++ bower.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 5dae12eac5..d2c37af04c 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # React-Select +## v0.9.1-wday-react15 + +* fixed; peer dependency when using react 15 + ## v0.9.1 / 2015-11-01 * added; new Contributors example w/ async options loading and custom value / label keys diff --git a/bower.json b/bower.json index 140a27596e..f63e40efa1 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "dist/react-select.min.js", "dist/default.css" ], - "version": "0.9.1-react15", + "version": "0.9.1-wday-react15", "homepage": "https://github.com/JedWatson/react-select", "authors": [ "Jed Watson" diff --git a/package.json b/package.json index 7877d37351..6ec5ddb99d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-select", - "version": "0.9.1-react15", + "version": "0.9.1-wday-react15", "description": "A Select control built with and for ReactJS", "main": "lib/Select.js", "style": "dist/default.css",