react-autowhatever
Advanced tools
Comparing version 6.0.0 to 7.0.0
@@ -45,2 +45,5 @@ 'use strict'; | ||
var emptyObject = {}; | ||
var defaultRenderInputComponent = function defaultRenderInputComponent(props) { | ||
return _react2.default.createElement('input', props); | ||
}; | ||
var defaultRenderItemsContainer = function defaultRenderItemsContainer(props) { | ||
@@ -207,3 +210,4 @@ return _react2.default.createElement('div', props); | ||
theme: theme, | ||
sectionKeyPrefix: sectionKeyPrefix }), | ||
sectionKeyPrefix: sectionKeyPrefix | ||
}), | ||
_react2.default.createElement(_ItemsList2.default, { | ||
@@ -220,3 +224,4 @@ items: _this2.sectionsItems[sectionIndex], | ||
keyPrefix: keyPrefix, | ||
ref: _this2.storeItemsListReference }) | ||
ref: _this2.storeItemsListReference | ||
}) | ||
); | ||
@@ -255,3 +260,4 @@ /* eslint-enable react/jsx-key */ | ||
theme: theme, | ||
keyPrefix: 'react-autowhatever-' + id + '-' }); | ||
keyPrefix: 'react-autowhatever-' + id + '-' | ||
}); | ||
} | ||
@@ -324,2 +330,3 @@ }, { | ||
var multiSection = _props4.multiSection; | ||
var renderInputComponent = _props4.renderInputComponent; | ||
var renderItemsContainer = _props4.renderItemsContainer; | ||
@@ -334,3 +341,3 @@ var focusedSectionIndex = _props4.focusedSectionIndex; | ||
var itemsContainerId = 'react-autowhatever-' + id; | ||
var inputProps = _extends({ | ||
var inputComponent = renderInputComponent(_extends({ | ||
type: 'text', | ||
@@ -348,10 +355,7 @@ value: '', | ||
ref: this.storeInputReference | ||
}); | ||
var itemsContainerProps = _extends({ | ||
})); | ||
var itemsContainer = renderItemsContainer(_extends({ | ||
id: itemsContainerId | ||
}, theme('react-autowhatever-' + id + '-items-container', 'itemsContainer'), { | ||
ref: this.storeItemsContainerReference | ||
}); | ||
var InputComponent = this.props.inputComponent || 'input'; | ||
var itemsContainer = renderItemsContainer(_extends({}, itemsContainerProps, { | ||
ref: this.storeItemsContainerReference, | ||
children: renderedItems | ||
@@ -363,3 +367,3 @@ })); | ||
containerProps, | ||
_react2.default.createElement(InputComponent, inputProps), | ||
inputComponent, | ||
itemsContainer | ||
@@ -376,2 +380,3 @@ ); | ||
multiSection: _react.PropTypes.bool, // Indicates whether a multi section layout should be rendered. | ||
renderInputComponent: _react.PropTypes.func, // Renders the input component. | ||
items: _react.PropTypes.array.isRequired, // Array of items or sections to render. | ||
@@ -396,2 +401,3 @@ renderItemsContainer: _react.PropTypes.func, // Renders the items container. | ||
multiSection: false, | ||
renderInputComponent: defaultRenderInputComponent, | ||
renderItemsContainer: defaultRenderItemsContainer, | ||
@@ -398,0 +404,0 @@ shouldRenderSection: alwaysTrue, |
@@ -94,3 +94,4 @@ 'use strict'; | ||
renderItem: renderItem, | ||
renderItemData: renderItemData })); | ||
renderItemData: renderItemData | ||
})); | ||
/* eslint-enable react/jsx-key */ | ||
@@ -97,0 +98,0 @@ }) |
@@ -109,2 +109,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var emptyObject = {}; | ||
var defaultRenderInputComponent = function defaultRenderInputComponent(props) { | ||
return _react2.default.createElement('input', props); | ||
}; | ||
var defaultRenderItemsContainer = function defaultRenderItemsContainer(props) { | ||
@@ -271,3 +274,4 @@ return _react2.default.createElement('div', props); | ||
theme: theme, | ||
sectionKeyPrefix: sectionKeyPrefix }), | ||
sectionKeyPrefix: sectionKeyPrefix | ||
}), | ||
_react2.default.createElement(_ItemsList2.default, { | ||
@@ -284,3 +288,4 @@ items: _this2.sectionsItems[sectionIndex], | ||
keyPrefix: keyPrefix, | ||
ref: _this2.storeItemsListReference }) | ||
ref: _this2.storeItemsListReference | ||
}) | ||
); | ||
@@ -319,3 +324,4 @@ /* eslint-enable react/jsx-key */ | ||
theme: theme, | ||
keyPrefix: 'react-autowhatever-' + id + '-' }); | ||
keyPrefix: 'react-autowhatever-' + id + '-' | ||
}); | ||
} | ||
@@ -388,2 +394,3 @@ }, { | ||
var multiSection = _props4.multiSection; | ||
var renderInputComponent = _props4.renderInputComponent; | ||
var renderItemsContainer = _props4.renderItemsContainer; | ||
@@ -398,3 +405,3 @@ var focusedSectionIndex = _props4.focusedSectionIndex; | ||
var itemsContainerId = 'react-autowhatever-' + id; | ||
var inputProps = _extends({ | ||
var inputComponent = renderInputComponent(_extends({ | ||
type: 'text', | ||
@@ -412,10 +419,7 @@ value: '', | ||
ref: this.storeInputReference | ||
}); | ||
var itemsContainerProps = _extends({ | ||
})); | ||
var itemsContainer = renderItemsContainer(_extends({ | ||
id: itemsContainerId | ||
}, theme('react-autowhatever-' + id + '-items-container', 'itemsContainer'), { | ||
ref: this.storeItemsContainerReference | ||
}); | ||
var InputComponent = this.props.inputComponent || 'input'; | ||
var itemsContainer = renderItemsContainer(_extends({}, itemsContainerProps, { | ||
ref: this.storeItemsContainerReference, | ||
children: renderedItems | ||
@@ -427,3 +431,3 @@ })); | ||
containerProps, | ||
_react2.default.createElement(InputComponent, inputProps), | ||
inputComponent, | ||
itemsContainer | ||
@@ -440,2 +444,3 @@ ); | ||
multiSection: _react.PropTypes.bool, // Indicates whether a multi section layout should be rendered. | ||
renderInputComponent: _react.PropTypes.func, // Renders the input component. | ||
items: _react.PropTypes.array.isRequired, // Array of items or sections to render. | ||
@@ -460,2 +465,3 @@ renderItemsContainer: _react.PropTypes.func, // Renders the items container. | ||
multiSection: false, | ||
renderInputComponent: defaultRenderInputComponent, | ||
renderItemsContainer: defaultRenderItemsContainer, | ||
@@ -935,3 +941,4 @@ shouldRenderSection: alwaysTrue, | ||
renderItem: renderItem, | ||
renderItemData: renderItemData })); | ||
renderItemData: renderItemData | ||
})); | ||
/* eslint-enable react/jsx-key */ | ||
@@ -938,0 +945,0 @@ }) |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.Autowhatever=t(require("React")):e.Autowhatever=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(1)["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(r=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(c){o=!0,i=c}finally{try{!r&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),f=r(l),p=n(3),d=r(p),m=n(4),y=r(m),h=n(6),v=r(h),I=n(8),b=r(I),w=function(){return!0},P={},g=function(e){return f["default"].createElement("div",e)},x={container:"react-autowhatever__container",containerOpen:"react-autowhatever__container--open",input:"react-autowhatever__input",itemsContainer:"react-autowhatever__items-container",itemsList:"react-autowhatever__items-list",item:"react-autowhatever__item",itemFocused:"react-autowhatever__item--focused",sectionContainer:"react-autowhatever__section-container",sectionTitle:"react-autowhatever__section-title"},T=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.focusedItem=null,n.setSectionsItems(e),n.setSectionIterator(e),n.setTheme(e),n.onKeyDown=n.onKeyDown.bind(n),n.storeInputReference=n.storeInputReference.bind(n),n.storeItemsContainerReference=n.storeItemsContainerReference.bind(n),n.onFocusedItemChange=n.onFocusedItemChange.bind(n),n.getItemId=n.getItemId.bind(n),n}return u(t,e),a(t,[{key:"componentDidMount",value:function(){this.ensureFocusedItemIsVisible()}},{key:"componentWillReceiveProps",value:function(e){e.items!==this.props.items&&this.setSectionsItems(e),e.items===this.props.items&&e.multiSection===this.props.multiSection||this.setSectionIterator(e),e.theme!==this.props.theme&&this.setTheme(e)}},{key:"componentDidUpdate",value:function(){this.ensureFocusedItemIsVisible()}},{key:"setSectionsItems",value:function(e){e.multiSection&&(this.sectionsItems=e.items.map(function(t){return e.getSectionItems(t)}),this.sectionsLengths=this.sectionsItems.map(function(e){return e.length}),this.allSectionsAreEmpty=this.sectionsLengths.every(function(e){return 0===e}))}},{key:"setSectionIterator",value:function(e){this.sectionIterator=(0,d["default"])({multiSection:e.multiSection,data:e.multiSection?this.sectionsLengths:e.items.length})}},{key:"setTheme",value:function(e){this.theme=(0,y["default"])(e.theme)}},{key:"storeInputReference",value:function(e){null!==e&&(this.input=e)}},{key:"storeItemsContainerReference",value:function(e){null!==e&&(this.itemsContainer=e)}},{key:"onFocusedItemChange",value:function(e){this.focusedItem=e}},{key:"getItemId",value:function(e,t){if(null===t)return null;var n=this.props.id,r=null===e?"":"section-"+e;return"react-autowhatever-"+n+"-"+r+"-item-"+t}},{key:"renderSections",value:function(){var e=this;if(this.allSectionsAreEmpty)return null;var t=this.theme,n=this.props,r=n.id,o=n.items,i=n.renderItem,u=n.renderItemData,s=n.shouldRenderSection,c=n.renderSectionTitle,a=n.focusedSectionIndex,l=n.focusedItemIndex,p=n.itemProps;return o.map(function(n,o){if(!s(n))return null;var d="react-autowhatever-"+r+"-",m=d+"section-"+o+"-";return f["default"].createElement("div",t(m+"container","sectionContainer"),f["default"].createElement(v["default"],{section:n,renderSectionTitle:c,theme:t,sectionKeyPrefix:m}),f["default"].createElement(b["default"],{items:e.sectionsItems[o],itemProps:p,renderItem:i,renderItemData:u,sectionIndex:o,focusedItemIndex:a===o?l:null,onFocusedItemChange:e.onFocusedItemChange,getItemId:e.getItemId,theme:t,keyPrefix:d,ref:e.storeItemsListReference}))})}},{key:"renderItems",value:function(){var e=this.props.items;if(0===e.length)return null;var t=this.theme,n=this.props,r=n.id,o=n.renderItem,i=n.renderItemData,u=n.focusedSectionIndex,s=n.focusedItemIndex,c=n.itemProps;return f["default"].createElement(b["default"],{items:e,itemProps:c,renderItem:o,renderItemData:i,focusedItemIndex:null===u?s:null,onFocusedItemChange:this.onFocusedItemChange,getItemId:this.getItemId,theme:t,keyPrefix:"react-autowhatever-"+r+"-"})}},{key:"onKeyDown",value:function(e){var t=this.props,n=t.inputProps,r=t.focusedSectionIndex,o=t.focusedItemIndex;switch(e.key){case"ArrowDown":case"ArrowUp":var i="ArrowDown"===e.key?"next":"prev",u=this.sectionIterator[i]([r,o]),s=c(u,2),a=s[0],l=s[1];n.onKeyDown(e,{newFocusedSectionIndex:a,newFocusedItemIndex:l});break;default:n.onKeyDown(e,{focusedSectionIndex:r,focusedItemIndex:o})}}},{key:"ensureFocusedItemIsVisible",value:function(){var e=this.focusedItem;if(e){var t=this.itemsContainer,n=e.offsetParent===t?e.offsetTop:e.offsetTop-t.offsetTop,r=t.scrollTop;n<r?r=n:n+e.offsetHeight>r+t.offsetHeight&&(r=n+e.offsetHeight-t.offsetHeight),r!==t.scrollTop&&(t.scrollTop=r)}}},{key:"render",value:function(){var e=this.theme,t=this.props,n=t.id,r=t.multiSection,o=t.renderItemsContainer,i=t.focusedSectionIndex,u=t.focusedItemIndex,c=r?this.renderSections():this.renderItems(),a=null!==c,l=this.getItemId(i,u),p=e("react-autowhatever-"+n+"-container","container",a&&"containerOpen"),d="react-autowhatever-"+n,m=s({type:"text",value:"",autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-owns":d,"aria-expanded":a,"aria-haspopup":a,"aria-activedescendant":l},e("react-autowhatever-"+n+"-input","input"),this.props.inputProps,{onKeyDown:this.props.inputProps.onKeyDown&&this.onKeyDown,ref:this.storeInputReference}),y=s({id:d},e("react-autowhatever-"+n+"-items-container","itemsContainer"),{ref:this.storeItemsContainerReference}),h=this.props.inputComponent||"input",v=o(s({},y,{children:c}));return f["default"].createElement("div",p,f["default"].createElement(h,m),v)}}]),t}(l.Component);T.propTypes={id:l.PropTypes.string,multiSection:l.PropTypes.bool,items:l.PropTypes.array.isRequired,renderItemsContainer:l.PropTypes.func,renderItem:l.PropTypes.func,renderItemData:l.PropTypes.object,shouldRenderSection:l.PropTypes.func,renderSectionTitle:l.PropTypes.func,getSectionItems:l.PropTypes.func,inputComponent:l.PropTypes.func,inputProps:l.PropTypes.object,itemProps:l.PropTypes.oneOfType([l.PropTypes.object,l.PropTypes.func]),focusedSectionIndex:l.PropTypes.number,focusedItemIndex:l.PropTypes.number,theme:l.PropTypes.oneOfType([l.PropTypes.object,l.PropTypes.array])},T.defaultProps={id:"1",multiSection:!1,renderItemsContainer:g,shouldRenderSection:w,renderItem:function(){throw new Error("`renderItem` must be provided")},renderItemData:P,renderSectionTitle:function(){throw new Error("`renderSectionTitle` must be provided")},getSectionItems:function(){throw new Error("`getSectionItems` must be provided")},inputProps:P,itemProps:P,focusedSectionIndex:null,focusedItemIndex:null,theme:x},t["default"]=T},function(t,n){t.exports=e},function(e,t){"use strict";var n=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(r=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(c){o=!0,i=c}finally{try{!r&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.exports=function(e){function t(e){for(null===e?e=0:e++;e<s.length&&0===s[e];)e++;return e===s.length?null:e}function r(e){for(null===e?e=s.length-1:e--;e>=0&&0===s[e];)e--;return e===-1?null:e}function o(e){var r=n(e,2),o=r[0],i=r[1];return c?null===i||i===s[o]-1?(o=t(o),null===o?[null,null]:[o,0]):[o,i+1]:0===s||i===s-1?[null,null]:null===i?[null,0]:[null,i+1]}function i(e){var t=n(e,2),o=t[0],i=t[1];return c?null===i||0===i?(o=r(o),null===o?[null,null]:[o,s[o]-1]):[o,i-1]:0===s||0===i?[null,null]:null===i?[null,s-1]:[null,i-1]}function u(e){return null===o(e)[1]}var s=e.data,c=e.multiSection;return{next:o,prev:i,isLast:u}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(r=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(c){o=!0,i=c}finally{try{!r&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(5),s=r(u),c=function(e){return e};t["default"]=function(e){var t=Array.isArray(e)&&2===e.length?e:[e,null],n=i(t,2),r=n[0],u=n[1];return function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];var a=n.map(function(e){return r[e]}).filter(c);return"string"==typeof a[0]||"function"==typeof u?{key:e,className:u?u.apply(void 0,o(a)):a.join(" ")}:{key:e,style:s["default"].apply(void 0,[{}].concat(o(a)))}}},e.exports=t["default"]},function(e,t){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(e){var t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e))),t.filter(function(t){return o.call(e,t)})}var o=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(e,t){for(var o,i,u=n(e),s=1;s<arguments.length;s++){o=arguments[s],i=r(Object(o));for(var c=0;c<i.length;c++)u[i[c]]=o[i[c]]}return u}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(2),a=r(c),l=n(7),f=r(l),p=function(e){function t(){return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,e),s(t,[{key:"shouldComponentUpdate",value:function(e){return(0,f["default"])(e,this.props)}},{key:"render",value:function(){var e=this.props,t=e.section,n=e.renderSectionTitle,r=e.theme,o=e.sectionKeyPrefix,i=n(t);return i?a["default"].createElement("div",r(o+"title","sectionTitle"),i):null}}]),t}(c.Component);p.propTypes={section:c.PropTypes.any.isRequired,renderSectionTitle:c.PropTypes.func.isRequired,theme:c.PropTypes.func.isRequired,sectionKeyPrefix:c.PropTypes.string.isRequired},t["default"]=p},function(e,t){"use strict";function n(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e===t)return!1;var o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!0;var u={},s=void 0,c=void 0;for(s=0,c=n.length;s<c;s++)u[n[s]]=!0;for(s=0,c=o.length;s<c;s++){var a=o[s],l=e[a],f=t[a];if(l!==f){if(!u[a]||null===l||null===f||"object"!==("undefined"==typeof l?"undefined":r(l))||"object"!==("undefined"==typeof f?"undefined":r(f)))return!0;var p=Object.keys(l),d=Object.keys(f);if(p.length!==d.length)return!0;for(var m=0,y=p.length;m<y;m++){var h=p[m];if(l[h]!==f[h])return!0}}}return!1}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t["default"]=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(2),l=r(a),f=n(9),p=r(f),d=n(7),m=r(d),y=function(e){function t(){o(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.storeFocusedItemReference=e.storeFocusedItemReference.bind(e),e}return u(t,e),c(t,[{key:"shouldComponentUpdate",value:function(e){return(0,m["default"])(e,this.props,["itemProps"])}},{key:"storeFocusedItemReference",value:function(e){this.props.onFocusedItemChange(null===e?null:e.item)}},{key:"render",value:function(){var e=this,t=this.props,n=t.items,r=t.itemProps,o=t.renderItem,i=t.renderItemData,u=t.sectionIndex,c=t.focusedItemIndex,a=t.getItemId,f=t.theme,d=t.keyPrefix,m=null===u?d:d+"section-"+u+"-",y="function"==typeof r;return l["default"].createElement("ul",s({role:"listbox"},f(m+"items-list","itemsList")),n.map(function(t,n){var d=n===c,h=m+"item-"+n,v=y?r({sectionIndex:u,itemIndex:n}):r,I=s({id:a(u,n)},f(h,"item",d&&"itemFocused"),v);return d&&(I.ref=e.storeFocusedItemReference),l["default"].createElement(p["default"],s({},I,{sectionIndex:u,itemIndex:n,item:t,renderItem:o,renderItemData:i}))}))}}]),t}(a.Component);y.propTypes={items:a.PropTypes.array.isRequired,itemProps:a.PropTypes.oneOfType([a.PropTypes.object,a.PropTypes.func]),renderItem:a.PropTypes.func.isRequired,renderItemData:a.PropTypes.object.isRequired,sectionIndex:a.PropTypes.number,focusedItemIndex:a.PropTypes.number,onFocusedItemChange:a.PropTypes.func.isRequired,getItemId:a.PropTypes.func.isRequired,theme:a.PropTypes.func.isRequired,keyPrefix:a.PropTypes.string.isRequired},y.defaultProps={sectionIndex:null},t["default"]=y},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),f=r(l),p=n(7),d=r(p),m=function(e){function t(){i(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.storeItemReference=e.storeItemReference.bind(e),e.onMouseEnter=e.onMouseEnter.bind(e),e.onMouseLeave=e.onMouseLeave.bind(e),e.onMouseDown=e.onMouseDown.bind(e),e.onClick=e.onClick.bind(e),e}return s(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e){return(0,d["default"])(e,this.props,["renderItemData"])}},{key:"storeItemReference",value:function(e){null!==e&&(this.item=e)}},{key:"onMouseEnter",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onMouseEnter(e,{sectionIndex:n,itemIndex:r})}},{key:"onMouseLeave",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onMouseLeave(e,{sectionIndex:n,itemIndex:r})}},{key:"onMouseDown",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onMouseDown(e,{sectionIndex:n,itemIndex:r})}},{key:"onClick",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onClick(e,{sectionIndex:n,itemIndex:r})}},{key:"render",value:function(){var e=this.props,t=e.item,n=e.renderItem,r=e.renderItemData,i=o(e,["item","renderItem","renderItemData"]);return delete i.sectionIndex,delete i.itemIndex,"function"==typeof i.onMouseEnter&&(i.onMouseEnter=this.onMouseEnter),"function"==typeof i.onMouseLeave&&(i.onMouseLeave=this.onMouseLeave),"function"==typeof i.onMouseDown&&(i.onMouseDown=this.onMouseDown),"function"==typeof i.onClick&&(i.onClick=this.onClick),f["default"].createElement("li",c({role:"option"},i,{ref:this.storeItemReference}),n(t,r))}}]),t}(l.Component);m.propTypes={sectionIndex:l.PropTypes.number,itemIndex:l.PropTypes.number.isRequired,item:l.PropTypes.any.isRequired,renderItem:l.PropTypes.func.isRequired,renderItemData:l.PropTypes.object.isRequired,onMouseEnter:l.PropTypes.func,onMouseLeave:l.PropTypes.func,onMouseDown:l.PropTypes.func,onClick:l.PropTypes.func},t["default"]=m}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.Autowhatever=t(require("React")):e.Autowhatever=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(1)["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(r=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(c){o=!0,i=c}finally{try{!r&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),f=r(l),p=n(3),d=r(p),m=n(4),y=r(m),h=n(6),v=r(h),I=n(8),b=r(I),w=function(){return!0},P={},g=function(e){return f["default"].createElement("input",e)},x=function(e){return f["default"].createElement("div",e)},T={container:"react-autowhatever__container",containerOpen:"react-autowhatever__container--open",input:"react-autowhatever__input",itemsContainer:"react-autowhatever__items-container",itemsList:"react-autowhatever__items-list",item:"react-autowhatever__item",itemFocused:"react-autowhatever__item--focused",sectionContainer:"react-autowhatever__section-container",sectionTitle:"react-autowhatever__section-title"},O=function(e){function t(e){o(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.focusedItem=null,n.setSectionsItems(e),n.setSectionIterator(e),n.setTheme(e),n.onKeyDown=n.onKeyDown.bind(n),n.storeInputReference=n.storeInputReference.bind(n),n.storeItemsContainerReference=n.storeItemsContainerReference.bind(n),n.onFocusedItemChange=n.onFocusedItemChange.bind(n),n.getItemId=n.getItemId.bind(n),n}return u(t,e),a(t,[{key:"componentDidMount",value:function(){this.ensureFocusedItemIsVisible()}},{key:"componentWillReceiveProps",value:function(e){e.items!==this.props.items&&this.setSectionsItems(e),e.items===this.props.items&&e.multiSection===this.props.multiSection||this.setSectionIterator(e),e.theme!==this.props.theme&&this.setTheme(e)}},{key:"componentDidUpdate",value:function(){this.ensureFocusedItemIsVisible()}},{key:"setSectionsItems",value:function(e){e.multiSection&&(this.sectionsItems=e.items.map(function(t){return e.getSectionItems(t)}),this.sectionsLengths=this.sectionsItems.map(function(e){return e.length}),this.allSectionsAreEmpty=this.sectionsLengths.every(function(e){return 0===e}))}},{key:"setSectionIterator",value:function(e){this.sectionIterator=(0,d["default"])({multiSection:e.multiSection,data:e.multiSection?this.sectionsLengths:e.items.length})}},{key:"setTheme",value:function(e){this.theme=(0,y["default"])(e.theme)}},{key:"storeInputReference",value:function(e){null!==e&&(this.input=e)}},{key:"storeItemsContainerReference",value:function(e){null!==e&&(this.itemsContainer=e)}},{key:"onFocusedItemChange",value:function(e){this.focusedItem=e}},{key:"getItemId",value:function(e,t){if(null===t)return null;var n=this.props.id,r=null===e?"":"section-"+e;return"react-autowhatever-"+n+"-"+r+"-item-"+t}},{key:"renderSections",value:function(){var e=this;if(this.allSectionsAreEmpty)return null;var t=this.theme,n=this.props,r=n.id,o=n.items,i=n.renderItem,u=n.renderItemData,s=n.shouldRenderSection,c=n.renderSectionTitle,a=n.focusedSectionIndex,l=n.focusedItemIndex,p=n.itemProps;return o.map(function(n,o){if(!s(n))return null;var d="react-autowhatever-"+r+"-",m=d+"section-"+o+"-";return f["default"].createElement("div",t(m+"container","sectionContainer"),f["default"].createElement(v["default"],{section:n,renderSectionTitle:c,theme:t,sectionKeyPrefix:m}),f["default"].createElement(b["default"],{items:e.sectionsItems[o],itemProps:p,renderItem:i,renderItemData:u,sectionIndex:o,focusedItemIndex:a===o?l:null,onFocusedItemChange:e.onFocusedItemChange,getItemId:e.getItemId,theme:t,keyPrefix:d,ref:e.storeItemsListReference}))})}},{key:"renderItems",value:function(){var e=this.props.items;if(0===e.length)return null;var t=this.theme,n=this.props,r=n.id,o=n.renderItem,i=n.renderItemData,u=n.focusedSectionIndex,s=n.focusedItemIndex,c=n.itemProps;return f["default"].createElement(b["default"],{items:e,itemProps:c,renderItem:o,renderItemData:i,focusedItemIndex:null===u?s:null,onFocusedItemChange:this.onFocusedItemChange,getItemId:this.getItemId,theme:t,keyPrefix:"react-autowhatever-"+r+"-"})}},{key:"onKeyDown",value:function(e){var t=this.props,n=t.inputProps,r=t.focusedSectionIndex,o=t.focusedItemIndex;switch(e.key){case"ArrowDown":case"ArrowUp":var i="ArrowDown"===e.key?"next":"prev",u=this.sectionIterator[i]([r,o]),s=c(u,2),a=s[0],l=s[1];n.onKeyDown(e,{newFocusedSectionIndex:a,newFocusedItemIndex:l});break;default:n.onKeyDown(e,{focusedSectionIndex:r,focusedItemIndex:o})}}},{key:"ensureFocusedItemIsVisible",value:function(){var e=this.focusedItem;if(e){var t=this.itemsContainer,n=e.offsetParent===t?e.offsetTop:e.offsetTop-t.offsetTop,r=t.scrollTop;n<r?r=n:n+e.offsetHeight>r+t.offsetHeight&&(r=n+e.offsetHeight-t.offsetHeight),r!==t.scrollTop&&(t.scrollTop=r)}}},{key:"render",value:function(){var e=this.theme,t=this.props,n=t.id,r=t.multiSection,o=t.renderInputComponent,i=t.renderItemsContainer,u=t.focusedSectionIndex,c=t.focusedItemIndex,a=r?this.renderSections():this.renderItems(),l=null!==a,p=this.getItemId(u,c),d=e("react-autowhatever-"+n+"-container","container",l&&"containerOpen"),m="react-autowhatever-"+n,y=o(s({type:"text",value:"",autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-owns":m,"aria-expanded":l,"aria-haspopup":l,"aria-activedescendant":p},e("react-autowhatever-"+n+"-input","input"),this.props.inputProps,{onKeyDown:this.props.inputProps.onKeyDown&&this.onKeyDown,ref:this.storeInputReference})),h=i(s({id:m},e("react-autowhatever-"+n+"-items-container","itemsContainer"),{ref:this.storeItemsContainerReference,children:a}));return f["default"].createElement("div",d,y,h)}}]),t}(l.Component);O.propTypes={id:l.PropTypes.string,multiSection:l.PropTypes.bool,renderInputComponent:l.PropTypes.func,items:l.PropTypes.array.isRequired,renderItemsContainer:l.PropTypes.func,renderItem:l.PropTypes.func,renderItemData:l.PropTypes.object,shouldRenderSection:l.PropTypes.func,renderSectionTitle:l.PropTypes.func,getSectionItems:l.PropTypes.func,inputComponent:l.PropTypes.func,inputProps:l.PropTypes.object,itemProps:l.PropTypes.oneOfType([l.PropTypes.object,l.PropTypes.func]),focusedSectionIndex:l.PropTypes.number,focusedItemIndex:l.PropTypes.number,theme:l.PropTypes.oneOfType([l.PropTypes.object,l.PropTypes.array])},O.defaultProps={id:"1",multiSection:!1,renderInputComponent:g,renderItemsContainer:x,shouldRenderSection:w,renderItem:function(){throw new Error("`renderItem` must be provided")},renderItemData:P,renderSectionTitle:function(){throw new Error("`renderSectionTitle` must be provided")},getSectionItems:function(){throw new Error("`getSectionItems` must be provided")},inputProps:P,itemProps:P,focusedSectionIndex:null,focusedItemIndex:null,theme:T},t["default"]=O},function(t,n){t.exports=e},function(e,t){"use strict";var n=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(r=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(c){o=!0,i=c}finally{try{!r&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.exports=function(e){function t(e){for(null===e?e=0:e++;e<s.length&&0===s[e];)e++;return e===s.length?null:e}function r(e){for(null===e?e=s.length-1:e--;e>=0&&0===s[e];)e--;return e===-1?null:e}function o(e){var r=n(e,2),o=r[0],i=r[1];return c?null===i||i===s[o]-1?(o=t(o),null===o?[null,null]:[o,0]):[o,i+1]:0===s||i===s-1?[null,null]:null===i?[null,0]:[null,i+1]}function i(e){var t=n(e,2),o=t[0],i=t[1];return c?null===i||0===i?(o=r(o),null===o?[null,null]:[o,s[o]-1]):[o,i-1]:0===s||0===i?[null,null]:null===i?[null,s-1]:[null,i-1]}function u(e){return null===o(e)[1]}var s=e.data,c=e.multiSection;return{next:o,prev:i,isLast:u}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,s=e[Symbol.iterator]();!(r=(u=s.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(c){o=!0,i=c}finally{try{!r&&s["return"]&&s["return"]()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=n(5),s=r(u),c=function(e){return e};t["default"]=function(e){var t=Array.isArray(e)&&2===e.length?e:[e,null],n=i(t,2),r=n[0],u=n[1];return function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];var a=n.map(function(e){return r[e]}).filter(c);return"string"==typeof a[0]||"function"==typeof u?{key:e,className:u?u.apply(void 0,o(a)):a.join(" ")}:{key:e,style:s["default"].apply(void 0,[{}].concat(o(a)))}}},e.exports=t["default"]},function(e,t){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(e){var t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e))),t.filter(function(t){return o.call(e,t)})}var o=Object.prototype.propertyIsEnumerable;e.exports=Object.assign||function(e,t){for(var o,i,u=n(e),s=1;s<arguments.length;s++){o=arguments[s],i=r(Object(o));for(var c=0;c<i.length;c++)u[i[c]]=o[i[c]]}return u}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(2),a=r(c),l=n(7),f=r(l),p=function(e){function t(){return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,e),s(t,[{key:"shouldComponentUpdate",value:function(e){return(0,f["default"])(e,this.props)}},{key:"render",value:function(){var e=this.props,t=e.section,n=e.renderSectionTitle,r=e.theme,o=e.sectionKeyPrefix,i=n(t);return i?a["default"].createElement("div",r(o+"title","sectionTitle"),i):null}}]),t}(c.Component);p.propTypes={section:c.PropTypes.any.isRequired,renderSectionTitle:c.PropTypes.func.isRequired,theme:c.PropTypes.func.isRequired,sectionKeyPrefix:c.PropTypes.string.isRequired},t["default"]=p},function(e,t){"use strict";function n(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e===t)return!1;var o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!0;var u={},s=void 0,c=void 0;for(s=0,c=n.length;s<c;s++)u[n[s]]=!0;for(s=0,c=o.length;s<c;s++){var a=o[s],l=e[a],f=t[a];if(l!==f){if(!u[a]||null===l||null===f||"object"!==("undefined"==typeof l?"undefined":r(l))||"object"!==("undefined"==typeof f?"undefined":r(f)))return!0;var p=Object.keys(l),d=Object.keys(f);if(p.length!==d.length)return!0;for(var m=0,y=p.length;m<y;m++){var h=p[m];if(l[h]!==f[h])return!0}}}return!1}Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t["default"]=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(2),l=r(a),f=n(9),p=r(f),d=n(7),m=r(d),y=function(e){function t(){o(this,t);var e=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.storeFocusedItemReference=e.storeFocusedItemReference.bind(e),e}return u(t,e),c(t,[{key:"shouldComponentUpdate",value:function(e){return(0,m["default"])(e,this.props,["itemProps"])}},{key:"storeFocusedItemReference",value:function(e){this.props.onFocusedItemChange(null===e?null:e.item)}},{key:"render",value:function(){var e=this,t=this.props,n=t.items,r=t.itemProps,o=t.renderItem,i=t.renderItemData,u=t.sectionIndex,c=t.focusedItemIndex,a=t.getItemId,f=t.theme,d=t.keyPrefix,m=null===u?d:d+"section-"+u+"-",y="function"==typeof r;return l["default"].createElement("ul",s({role:"listbox"},f(m+"items-list","itemsList")),n.map(function(t,n){var d=n===c,h=m+"item-"+n,v=y?r({sectionIndex:u,itemIndex:n}):r,I=s({id:a(u,n)},f(h,"item",d&&"itemFocused"),v);return d&&(I.ref=e.storeFocusedItemReference),l["default"].createElement(p["default"],s({},I,{sectionIndex:u,itemIndex:n,item:t,renderItem:o,renderItemData:i}))}))}}]),t}(a.Component);y.propTypes={items:a.PropTypes.array.isRequired,itemProps:a.PropTypes.oneOfType([a.PropTypes.object,a.PropTypes.func]),renderItem:a.PropTypes.func.isRequired,renderItemData:a.PropTypes.object.isRequired,sectionIndex:a.PropTypes.number,focusedItemIndex:a.PropTypes.number,onFocusedItemChange:a.PropTypes.func.isRequired,getItemId:a.PropTypes.func.isRequired,theme:a.PropTypes.func.isRequired,keyPrefix:a.PropTypes.string.isRequired},y.defaultProps={sectionIndex:null},t["default"]=y},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(2),f=r(l),p=n(7),d=r(p),m=function(e){function t(){i(this,t);var e=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.storeItemReference=e.storeItemReference.bind(e),e.onMouseEnter=e.onMouseEnter.bind(e),e.onMouseLeave=e.onMouseLeave.bind(e),e.onMouseDown=e.onMouseDown.bind(e),e.onClick=e.onClick.bind(e),e}return s(t,e),a(t,[{key:"shouldComponentUpdate",value:function(e){return(0,d["default"])(e,this.props,["renderItemData"])}},{key:"storeItemReference",value:function(e){null!==e&&(this.item=e)}},{key:"onMouseEnter",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onMouseEnter(e,{sectionIndex:n,itemIndex:r})}},{key:"onMouseLeave",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onMouseLeave(e,{sectionIndex:n,itemIndex:r})}},{key:"onMouseDown",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onMouseDown(e,{sectionIndex:n,itemIndex:r})}},{key:"onClick",value:function(e){var t=this.props,n=t.sectionIndex,r=t.itemIndex;this.props.onClick(e,{sectionIndex:n,itemIndex:r})}},{key:"render",value:function(){var e=this.props,t=e.item,n=e.renderItem,r=e.renderItemData,i=o(e,["item","renderItem","renderItemData"]);return delete i.sectionIndex,delete i.itemIndex,"function"==typeof i.onMouseEnter&&(i.onMouseEnter=this.onMouseEnter),"function"==typeof i.onMouseLeave&&(i.onMouseLeave=this.onMouseLeave),"function"==typeof i.onMouseDown&&(i.onMouseDown=this.onMouseDown),"function"==typeof i.onClick&&(i.onClick=this.onClick),f["default"].createElement("li",c({role:"option"},i,{ref:this.storeItemReference}),n(t,r))}}]),t}(l.Component);m.propTypes={sectionIndex:l.PropTypes.number,itemIndex:l.PropTypes.number.isRequired,item:l.PropTypes.any.isRequired,renderItem:l.PropTypes.func.isRequired,renderItemData:l.PropTypes.object.isRequired,onMouseEnter:l.PropTypes.func,onMouseLeave:l.PropTypes.func,onMouseDown:l.PropTypes.func,onClick:l.PropTypes.func},t["default"]=m}])}); |
{ | ||
"name": "react-autowhatever", | ||
"version": "6.0.0", | ||
"version": "7.0.0", | ||
"description": "Accessible rendering layer for Autosuggest and Autocomplete components", | ||
@@ -47,6 +47,6 @@ "main": "dist/index.js", | ||
"css-loader": "^0.25.0", | ||
"eslint": "^3.7.1", | ||
"eslint": "^3.8.1", | ||
"eslint-plugin-react": "^6.4.1", | ||
"extract-text-webpack-plugin": "^1.0.1", | ||
"jsdom": "^9.6.0", | ||
"jsdom": "^9.8.0", | ||
"less": "^2.7.1", | ||
@@ -56,3 +56,3 @@ "less-loader": "^2.2.3", | ||
"openurl": "^1.1.1", | ||
"postcss-loader": "^0.13.0", | ||
"postcss-loader": "^1.0.0", | ||
"react": "^15.3.2", | ||
@@ -59,0 +59,0 @@ "react-addons-test-utils": "^15.3.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99781
1550