Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blueprintjs/select

Package Overview
Dependencies
Maintainers
1
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blueprintjs/select - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

2

dist/select.bundle.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@blueprintjs/core"),require("tslib"),require("react"),require("classnames")):"function"==typeof define&&define.amd?define(["@blueprintjs/core","tslib","react","classnames"],t):"object"==typeof exports?exports.Select=t(require("@blueprintjs/core"),require("tslib"),require("react"),require("classnames")):(e.Blueprint=e.Blueprint||{},e.Blueprint.Select=t(e.Blueprint.Core,e.tslib,e.React,e.classNames))}("undefined"!=typeof self?self:this,function(e,t,n,r){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,n){e.exports=n(5)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={};n.d(r,"MULTISELECT",function(){return i}),n.d(r,"MULTISELECT_POPOVER",function(){return p}),n.d(r,"OMNIBAR",function(){return a}),n.d(r,"OMNIBAR_OVERLAY",function(){return l}),n.d(r,"SELECT",function(){return u}),n.d(r,"SELECT_POPOVER",function(){return c});var o=n(0),s=o.Classes.getClassNamespace(),i=s+"-multi-select",p=i+"-popover",a=s+"-omnibar",l=a+"-overlay",u=s+"-select",c=u+"-popover";function d(e,t,n){if(0===e.query.length&&void 0!==n)return n;var r=e.filteredItems.map(e.renderItem).filter(function(e){return null!=e});return r.length>0?r:t}var v=n(1),f=n(3),m=n.n(f),h=n(2),y=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.refHandlers={itemsParent:function(e){return r.itemsParentRef=e}},r.shouldCheckActiveItemInViewport=!1,r.renderItemList=function(e){var t=r.props,n=t.initialContent,s=d(e,t.noResults,n);return h.createElement(o.Menu,{ulRef:e.itemsParentRef},s)},r.renderItem=function(e,t){var n=r.state,o=n.activeItem,s=n.query,i=r.state.filteredItems.indexOf(e)>=0,p={active:o===e,disabled:O(e,t,r.props.itemDisabled),matchesPredicate:i};return r.props.itemRenderer(e,{handleClick:function(t){return r.handleItemSelect(e,t)},index:t,modifiers:p,query:s})},r.handleItemSelect=function(e,t){r.setActiveItem(e),o.Utils.safeInvoke(r.props.onItemSelect,e,t),r.props.resetOnSelect&&r.setQuery("",!0)},r.handleKeyDown=function(e){var t=e.keyCode;if(t===o.Keys.ARROW_UP||t===o.Keys.ARROW_DOWN){e.preventDefault();var n=r.getNextActiveItem(t===o.Keys.ARROW_UP?-1:1);null!=n&&r.setActiveItem(n)}o.Utils.safeInvoke(r.props.onKeyDown,e)},r.handleKeyUp=function(e){var t=r.props.onKeyUp,n=r.state.activeItem;e.keyCode===o.Keys.ENTER&&null!=n&&(e.preventDefault(),r.handleItemSelect(n,e)),o.Utils.safeInvoke(t,e)},r.handleQueryChange=function(e){var t=null==e?"":e.target.value;r.setQuery(t),o.Utils.safeInvoke(r.props.onQueryChange,t,e)};var s=r.props.query,i=void 0===s?"":s,p=P(i,r.props);return r.state={activeItem:g(p,r.props.itemDisabled),filteredItems:p,query:i},r}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=e.className,n=e.items,r=e.renderer,o=e.itemListRenderer,s=void 0===o?this.renderItemList:o;return r(v.__assign({},this.state,{className:t,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,handleQueryChange:this.handleQueryChange,itemList:s(v.__assign({},this.state,{items:n,itemsParentRef:this.refHandlers.itemsParent,renderItem:this.renderItem}))}))},t.prototype.componentWillReceiveProps=function(e){void 0!==e.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:e.activeItem})),null!=e.query&&this.setQuery(e.query)},t.prototype.componentDidUpdate=function(e){var t=this;o.Utils.shallowCompareKeys(this.props,e,{include:["items","itemListPredicate","itemPredicate"]})||this.setQuery(this.state.query),this.shouldCheckActiveItemInViewport&&(requestAnimationFrame(function(){return t.scrollActiveItemIntoView()}),this.shouldCheckActiveItemInViewport=!1)},t.prototype.scrollActiveItemIntoView=function(){var e=this.getActiveElement();if(null!=this.itemsParentRef&&null!=e){var t=e.offsetTop,n=e.offsetHeight,r=this.itemsParentRef,o=r.offsetTop,s=r.scrollTop,i=r.clientHeight,p=this.getItemsParentPadding(),a=p.paddingTop,l=t+n+p.paddingBottom-o,u=t-a-o;l>=s+i?this.itemsParentRef.scrollTop=l+n-i:u<=s&&(this.itemsParentRef.scrollTop=u-n)}},t.prototype.setQuery=function(e,t){void 0===t&&(t=this.props.resetOnQuery),this.shouldCheckActiveItemInViewport=!0,e!==this.state.query&&o.Utils.safeInvoke(this.props.onQueryChange,e);var n=P(e,this.props);this.setState({filteredItems:n,query:e});var r=this.getActiveIndex(n);(t||r<0||O(this.state.activeItem,r,this.props.itemDisabled))&&this.setActiveItem(g(n,this.props.itemDisabled))},t.prototype.getActiveElement=function(){if(null!=this.itemsParentRef)return this.itemsParentRef.children.item(this.getActiveIndex())},t.prototype.getActiveIndex=function(e){void 0===e&&(e=this.state.filteredItems);var t=this.state.activeItem;return null==t?-1:e.indexOf(t)},t.prototype.getItemsParentPadding=function(){var e=getComputedStyle(this.itemsParentRef),t=e.paddingTop;return{paddingBottom:I(e.paddingBottom),paddingTop:I(t)}},t.prototype.getNextActiveItem=function(e,t){return void 0===t&&(t=this.getActiveIndex()),g(this.state.filteredItems,this.props.itemDisabled,e,t)},t.prototype.setActiveItem=function(e){void 0===this.props.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:e})),o.Utils.safeInvoke(this.props.onActiveItemChange,e)},t.displayName=o.DISPLAYNAME_PREFIX+".QueryList",t.defaultProps={resetOnQuery:!0},t}(h.Component);function I(e){return null==e?0:parseInt(e.slice(0,-2),10)}function P(e,t){var n=t.items,r=t.itemPredicate,s=t.itemListPredicate;return o.Utils.isFunction(s)?s(e,n):o.Utils.isFunction(r)?n.filter(function(t,n){return r(e,t,n)}):n}function O(e,t,n){return null!=n&&null!=e&&(o.Utils.isFunction(n)?n(e,t):!!e[n])}function g(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r=e.length-1),0===e.length)return null;var o,s,i,p=r,a=e.length-1;do{if(i=a,!O(e[p=(o=p+n)<(s=0)?i:o>i?s:o],p,t))return e[p]}while(p!==r);return null}var E=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.TypedQueryList=y.ofType(),t.refHandlers={queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,s=n.inputProps,i=void 0===s?{}:s,p=n.isOpen,a=n.overlayProps,l=void 0===a?{}:a,u=e.handleKeyDown,c=e.handleKeyUp,d=p&&e.query.length>0?{onKeyDown:u,onKeyUp:c}:{};return h.createElement(o.Overlay,v.__assign({hasBackdrop:!0},l,{isOpen:p,className:m()(r.OMNIBAR_OVERLAY,l.className),onClose:t.handleOverlayClose}),h.createElement("div",v.__assign({className:m()(r.OMNIBAR,e.className)},d),h.createElement(o.InputGroup,v.__assign({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search..."},i,{onChange:e.handleQueryChange,value:e.query})),e.itemList))},t.handleOverlayClose=function(e){var n=t.props.overlayProps,r=void 0===n?{}:n;o.Utils.safeInvoke(r.onClose,e),o.Utils.safeInvoke(t.props.onClose,e)},t}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=e.initialContent,n=void 0===t?null:t,r=(e.isOpen,e.inputProps,e.overlayProps,v.__rest(e,["initialContent","isOpen","inputProps","overlayProps"]));return h.createElement(this.TypedQueryList,v.__assign({},r,{initialContent:n,onItemSelect:this.props.onItemSelect,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.displayName=o.DISPLAYNAME_PREFIX+".Omnibar",t}(h.PureComponent),C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:t.props.popoverProps&&t.props.popoverProps.isOpen||!1},t.TypedQueryList=y.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.tagInputProps,r=void 0===n?{}:n;o.Utils.safeInvoke(r.inputRef,e)},queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,s=n.tagInputProps,i=void 0===s?{}:s,p=n.popoverProps,a=void 0===p?{}:p,l=n.selectedItems,u=void 0===l?[]:l,c=n.placeholder,d=e.handleKeyDown,f=e.handleKeyUp;return h.createElement(o.Popover,v.__assign({autoFocus:!1,canEscapeKeyClose:!0,enforceFocus:!1,isOpen:t.state.isOpen,position:o.Position.BOTTOM_LEFT},a,{className:m()(e.className,a.className),onInteraction:t.handlePopoverInteraction,popoverClassName:m()(r.MULTISELECT_POPOVER,a.popoverClassName),onOpened:t.handlePopoverOpened}),h.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(d),onKeyUp:t.state.isOpen?f:void 0},h.createElement(o.TagInput,v.__assign({placeholder:c},i,{className:m()(r.MULTISELECT,i.className),inputRef:t.refHandlers.input,inputValue:e.query,onInputChange:e.handleQueryChange,values:u.map(t.props.tagRenderer)}))),h.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(d),onKeyUp:f},e.itemList))},t.handleItemSelect=function(e,n){null!=t.input&&t.input.focus(),o.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleQueryChange=function(e,n){t.setState({isOpen:e.length>0||!t.props.openOnKeyDown}),o.Utils.safeInvoke(t.props.onQueryChange,e,n)},t.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var n=t.props.popoverProps,r=void 0===n?{}:n;null!=t.input&&t.input!==document.activeElement?t.setState({isOpen:!1}):t.props.openOnKeyDown||t.setState({isOpen:!0}),o.Utils.safeInvoke(r.onInteraction,e)})},t.handlePopoverOpened=function(e){var n=t.props.popoverProps,r=void 0===n?{}:n;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),o.Utils.safeInvoke(r.onOpened,e)},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which;r===o.Keys.ESCAPE||r===o.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({isOpen:!1})):r!==o.Keys.BACKSPACE&&r!==o.Keys.ARROW_LEFT&&r!==o.Keys.ARROW_RIGHT&&t.setState({isOpen:!0}),t.state.isOpen&&o.Utils.safeInvoke(e,n)}},t}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.openOnKeyDown,e.popoverProps,e.tagInputProps,v.__rest(e,["openOnKeyDown","popoverProps","tagInputProps"]));return h.createElement(this.TypedQueryList,v.__assign({},t,{onItemSelect:this.handleItemSelect,onQueryChange:this.handleQueryChange,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.displayName=o.DISPLAYNAME_PREFIX+".MultiSelect",t.defaultProps={placeholder:"Search..."},t}(h.PureComponent),_=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.TypedQueryList=y.ofType(),s.refHandlers={input:function(e){s.input=e;var t=s.props.inputProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return s.list=e}},s.renderQueryList=function(e){var t=s.props,n=t.filterable,i=void 0===n||n,p=t.disabled,a=void 0!==p&&p,l=t.inputProps,u=void 0===l?{}:l,c=t.popoverProps,d=void 0===c?{}:c,f=h.createElement(o.InputGroup,v.__assign({leftIcon:"search",placeholder:"Filter...",rightElement:s.maybeRenderClearButton(e.query)},u,{inputRef:s.refHandlers.input,onChange:e.handleQueryChange,value:e.query})),y=e.handleKeyDown,I=e.handleKeyUp;return h.createElement(o.Popover,v.__assign({autoFocus:!1,enforceFocus:!1,isOpen:s.state.isOpen,disabled:a,position:o.Position.BOTTOM_LEFT},d,{className:m()(e.className,d.className),onInteraction:s.handlePopoverInteraction,popoverClassName:m()(r.SELECT_POPOVER,d.popoverClassName),onOpening:s.handlePopoverOpening,onOpened:s.handlePopoverOpened,onClosing:s.handlePopoverClosing}),h.createElement("div",{onKeyDown:s.state.isOpen?y:s.handleTargetKeyDown,onKeyUp:s.state.isOpen?I:void 0},s.props.children),h.createElement("div",{onKeyDown:y,onKeyUp:I},i?f:void 0,e.itemList))},s.handleTargetKeyDown=function(e){e.which!==o.Keys.ARROW_UP&&e.which!==o.Keys.ARROW_DOWN||(e.preventDefault(),s.setState({isOpen:!0}))},s.handleItemSelect=function(e,t){s.setState({isOpen:!1}),o.Utils.safeInvoke(s.props.onItemSelect,e,t)},s.handlePopoverInteraction=function(e){s.setState({isOpen:e});var t=s.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onInteraction,e)},s.handlePopoverOpening=function(e){var t=s.props,n=t.popoverProps,r=void 0===n?{}:n,i=t.resetOnClose;s.previousFocusedElement=document.activeElement,i&&s.resetQuery(),o.Utils.safeInvoke(r.onOpening,e)},s.handlePopoverOpened=function(e){null!=s.list&&s.list.scrollActiveItemIntoView(),requestAnimationFrame(function(){var e=s.props.inputProps;!1!==(void 0===e?{}:e).autoFocus&&null!=s.input&&s.input.focus()});var t=s.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onOpened,e)},s.handlePopoverClosing=function(e){requestAnimationFrame(function(){void 0!==s.previousFocusedElement&&(s.previousFocusedElement.focus(),s.previousFocusedElement=void 0)});var t=s.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onClosing,e)},s.resetQuery=function(){return s.list&&s.list.setQuery("",!0)},s.state={isOpen:!1},s}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.filterable,e.inputProps,e.popoverProps,v.__rest(e,["filterable","inputProps","popoverProps"]));return h.createElement(this.TypedQueryList,v.__assign({},t,{onItemSelect:this.handleItemSelect,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.list&&this.list.scrollActiveItemIntoView()},t.prototype.maybeRenderClearButton=function(e){return e.length>0?h.createElement(o.Button,{icon:"cross",minimal:!0,onClick:this.resetQuery}):void 0},t.displayName=o.DISPLAYNAME_PREFIX+".Select",t}(h.PureComponent),S=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.TypedQueryList=y.ofType(),s.refHandlers={input:function(e){s.input=e;var t=s.props.inputProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return s.queryList=e}},s.renderQueryList=function(e){var t=s.props,n=t.inputProps,i=void 0===n?{}:n,p=t.popoverProps,a=void 0===p?{}:p,l=s.state,u=l.isOpen,c=l.selectedItem,d=e.handleKeyDown,f=e.handleKeyUp,y=i.placeholder,I=void 0===y?"Search...":y,P=c?s.props.inputValueRenderer(c):"";return h.createElement(o.Popover,v.__assign({autoFocus:!1,enforceFocus:!1,isOpen:u,position:o.Position.BOTTOM_LEFT},a,{className:m()(e.className,a.className),onInteraction:s.handlePopoverInteraction,popoverClassName:m()(r.SELECT_POPOVER,a.popoverClassName),onOpened:s.handlePopoverOpened}),h.createElement(o.InputGroup,v.__assign({},i,{placeholder:u&&P?P:I,inputRef:s.refHandlers.input,onChange:e.handleQueryChange,onFocus:s.handleInputFocus,onKeyDown:s.getTargetKeyDownHandler(d),onKeyUp:s.getTargetKeyUpHandler(f),value:u?e.query:P})),h.createElement("div",{onKeyDown:d,onKeyUp:f},e.itemList))},s.selectText=function(){requestAnimationFrame(function(){null!=s.input&&s.input.setSelectionRange(0,s.input.value.length)})},s.handleInputFocus=function(e){var t=s.props,n=t.openOnKeyDown,r=t.inputProps,i=void 0===r?{}:r;s.selectText(),n||s.setState({isOpen:!0}),o.Utils.safeInvoke(i.onFocus,e)},s.handleItemSelect=function(e,t){var n;s.props.closeOnSelect?(null!=s.input&&s.input.blur(),n=!1):(null!=s.input&&s.input.focus(),s.selectText(),n=!0),void 0===s.props.selectedItem?s.setState({isOpen:n,selectedItem:e}):s.setState({isOpen:n}),o.Utils.safeInvoke(s.props.onItemSelect,e,t)},s.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var t=s.props.popoverProps,n=void 0===t?{}:t;null!=s.input&&s.input!==document.activeElement&&s.setState({isOpen:!1}),o.Utils.safeInvoke(n.onInteraction,e)})},s.handlePopoverOpened=function(e){var t=s.props.popoverProps,n=void 0===t?{}:t;null!=s.queryList&&s.queryList.scrollActiveItemIntoView(),o.Utils.safeInvoke(n.onOpened,e)},s.getTargetKeyDownHandler=function(e){return function(t){var n=t.which,r=s.props,i=r.inputProps,p=void 0===i?{}:i,a=r.openOnKeyDown;n===o.Keys.ESCAPE||n===o.Keys.TAB?(null!=s.input&&s.input.blur(),s.setState({isOpen:!1})):a&&n!==o.Keys.BACKSPACE&&n!==o.Keys.ARROW_LEFT&&n!==o.Keys.ARROW_RIGHT&&s.setState({isOpen:!0}),s.state.isOpen&&o.Utils.safeInvoke(e,t),o.Utils.safeInvoke(p.onKeyDown,t)}},s.getTargetKeyUpHandler=function(e){return function(t){var n=s.props.inputProps,r=void 0===n?{}:n;s.state.isOpen&&o.Utils.safeInvoke(e,t),o.Utils.safeInvoke(r.onKeyUp,t)}},s.state={isOpen:t.popoverProps&&t.popoverProps.isOpen||!1,selectedItem:s.getInitialSelectedItem()},s}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.inputProps,e.popoverProps,v.__rest(e,["inputProps","popoverProps"]));return h.createElement(this.TypedQueryList,v.__assign({},t,{onItemSelect:this.handleItemSelect,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentWillReceiveProps=function(e){void 0!==e.selectedItem&&e.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:e.selectedItem})},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},t.prototype.getInitialSelectedItem=function(){return void 0!==this.props.selectedItem?this.props.selectedItem:void 0!==this.props.defaultSelectedItem?this.props.defaultSelectedItem:null},t.displayName=o.DISPLAYNAME_PREFIX+".Suggest",t.defaultProps={closeOnSelect:!0,openOnKeyDown:!1},t}(h.PureComponent);n.d(t,"Classes",function(){return r}),n.d(t,"renderFilteredItems",function(){return d}),n.d(t,"Omnibar",function(){return E}),n.d(t,"QueryList",function(){return y}),n.d(t,"getFirstEnabledItem",function(){return g}),n.d(t,"MultiSelect",function(){return C}),n.d(t,"Select",function(){return _}),n.d(t,"Suggest",function(){return S})}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@blueprintjs/core"),require("tslib"),require("react"),require("classnames")):"function"==typeof define&&define.amd?define(["@blueprintjs/core","tslib","react","classnames"],t):"object"==typeof exports?exports.Select=t(require("@blueprintjs/core"),require("tslib"),require("react"),require("classnames")):(e.Blueprint=e.Blueprint||{},e.Blueprint.Select=t(e.Blueprint.Core,e.tslib,e.React,e.classNames))}("undefined"!=typeof self?self:this,function(e,t,n,r){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,n){e.exports=n(5)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={};n.d(r,"MULTISELECT",function(){return i}),n.d(r,"MULTISELECT_POPOVER",function(){return p}),n.d(r,"OMNIBAR",function(){return a}),n.d(r,"OMNIBAR_OVERLAY",function(){return l}),n.d(r,"SELECT",function(){return u}),n.d(r,"SELECT_POPOVER",function(){return c});var o=n(0),s=o.Classes.getClassNamespace(),i=s+"-multi-select",p=i+"-popover",a=s+"-omnibar",l=a+"-overlay",u=s+"-select",c=u+"-popover";function d(e,t,n){if(0===e.query.length&&void 0!==n)return n;var r=e.filteredItems.map(e.renderItem).filter(function(e){return null!=e});return r.length>0?r:t}var v=n(1),f=n(3),m=n.n(f),h=n(2),y=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.refHandlers={itemsParent:function(e){return r.itemsParentRef=e}},r.shouldCheckActiveItemInViewport=!1,r.renderItemList=function(e){var t=r.props,n=t.initialContent,s=d(e,t.noResults,n);return h.createElement(o.Menu,{ulRef:e.itemsParentRef},s)},r.renderItem=function(e,t){var n=r.state,o=n.activeItem,s=n.query,i=r.state.filteredItems.indexOf(e)>=0,p={active:o===e,disabled:O(e,t,r.props.itemDisabled),matchesPredicate:i};return r.props.itemRenderer(e,{handleClick:function(t){return r.handleItemSelect(e,t)},index:t,modifiers:p,query:s})},r.handleItemSelect=function(e,t){r.setActiveItem(e),o.Utils.safeInvoke(r.props.onItemSelect,e,t),r.props.resetOnSelect&&r.setQuery("",!0)},r.handleKeyDown=function(e){var t=e.keyCode;if(t===o.Keys.ARROW_UP||t===o.Keys.ARROW_DOWN){e.preventDefault();var n=r.getNextActiveItem(t===o.Keys.ARROW_UP?-1:1);null!=n&&r.setActiveItem(n)}o.Utils.safeInvoke(r.props.onKeyDown,e)},r.handleKeyUp=function(e){var t=r.props.onKeyUp,n=r.state.activeItem;e.keyCode===o.Keys.ENTER&&null!=n&&(e.preventDefault(),r.handleItemSelect(n,e)),o.Utils.safeInvoke(t,e)},r.handleQueryChange=function(e){var t=null==e?"":e.target.value;r.setQuery(t),o.Utils.safeInvoke(r.props.onQueryChange,t,e)};var s=r.props.query,i=void 0===s?"":s,p=P(i,r.props);return r.state={activeItem:g(p,r.props.itemDisabled),filteredItems:p,query:i},r}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=e.className,n=e.items,r=e.renderer,o=e.itemListRenderer,s=void 0===o?this.renderItemList:o;return r(v.__assign({},this.state,{className:t,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,handleQueryChange:this.handleQueryChange,itemList:s(v.__assign({},this.state,{items:n,itemsParentRef:this.refHandlers.itemsParent,renderItem:this.renderItem}))}))},t.prototype.componentWillReceiveProps=function(e){void 0!==e.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:e.activeItem})),null!=e.query&&this.setQuery(e.query)},t.prototype.componentDidUpdate=function(e){var t=this;o.Utils.shallowCompareKeys(this.props,e,{include:["items","itemListPredicate","itemPredicate"]})||this.setQuery(this.state.query),this.shouldCheckActiveItemInViewport&&(requestAnimationFrame(function(){return t.scrollActiveItemIntoView()}),this.shouldCheckActiveItemInViewport=!1)},t.prototype.scrollActiveItemIntoView=function(){var e=this.getActiveElement();if(null!=this.itemsParentRef&&null!=e){var t=e.offsetTop,n=e.offsetHeight,r=this.itemsParentRef,o=r.offsetTop,s=r.scrollTop,i=r.clientHeight,p=this.getItemsParentPadding(),a=p.paddingTop,l=t+n+p.paddingBottom-o,u=t-a-o;l>=s+i?this.itemsParentRef.scrollTop=l+n-i:u<=s&&(this.itemsParentRef.scrollTop=u-n)}},t.prototype.setQuery=function(e,t){void 0===t&&(t=this.props.resetOnQuery),this.shouldCheckActiveItemInViewport=!0;var n=e!==this.state.query;n&&o.Utils.safeInvoke(this.props.onQueryChange,e);var r=P(e,this.props);this.setState({filteredItems:r,query:e});var s=this.getActiveIndex(r),i=t||s<0||O(this.state.activeItem,s,this.props.itemDisabled);n&&i&&this.setActiveItem(g(r,this.props.itemDisabled))},t.prototype.getActiveElement=function(){if(null!=this.itemsParentRef)return this.itemsParentRef.children.item(this.getActiveIndex())},t.prototype.getActiveIndex=function(e){void 0===e&&(e=this.state.filteredItems);var t=this.state.activeItem;return null==t?-1:e.indexOf(t)},t.prototype.getItemsParentPadding=function(){var e=getComputedStyle(this.itemsParentRef),t=e.paddingTop;return{paddingBottom:I(e.paddingBottom),paddingTop:I(t)}},t.prototype.getNextActiveItem=function(e,t){return void 0===t&&(t=this.getActiveIndex()),g(this.state.filteredItems,this.props.itemDisabled,e,t)},t.prototype.setActiveItem=function(e){void 0===this.props.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:e})),o.Utils.safeInvoke(this.props.onActiveItemChange,e)},t.displayName=o.DISPLAYNAME_PREFIX+".QueryList",t.defaultProps={resetOnQuery:!0},t}(h.Component);function I(e){return null==e?0:parseInt(e.slice(0,-2),10)}function P(e,t){var n=t.items,r=t.itemPredicate,s=t.itemListPredicate;return o.Utils.isFunction(s)?s(e,n):o.Utils.isFunction(r)?n.filter(function(t,n){return r(e,t,n)}):n}function O(e,t,n){return null!=n&&null!=e&&(o.Utils.isFunction(n)?n(e,t):!!e[n])}function g(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r=e.length-1),0===e.length)return null;var o,s,i,p=r,a=e.length-1;do{if(i=a,!O(e[p=(o=p+n)<(s=0)?i:o>i?s:o],p,t))return e[p]}while(p!==r);return null}var E=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.TypedQueryList=y.ofType(),t.refHandlers={queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,s=n.inputProps,i=void 0===s?{}:s,p=n.isOpen,a=n.overlayProps,l=void 0===a?{}:a,u=e.handleKeyDown,c=e.handleKeyUp,d=p&&e.query.length>0?{onKeyDown:u,onKeyUp:c}:{};return h.createElement(o.Overlay,v.__assign({hasBackdrop:!0},l,{isOpen:p,className:m()(r.OMNIBAR_OVERLAY,l.className),onClose:t.handleOverlayClose}),h.createElement("div",v.__assign({className:m()(r.OMNIBAR,e.className)},d),h.createElement(o.InputGroup,v.__assign({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search..."},i,{onChange:e.handleQueryChange,value:e.query})),e.itemList))},t.handleOverlayClose=function(e){var n=t.props.overlayProps,r=void 0===n?{}:n;o.Utils.safeInvoke(r.onClose,e),o.Utils.safeInvoke(t.props.onClose,e)},t}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=e.initialContent,n=void 0===t?null:t,r=(e.isOpen,e.inputProps,e.overlayProps,v.__rest(e,["initialContent","isOpen","inputProps","overlayProps"]));return h.createElement(this.TypedQueryList,v.__assign({},r,{initialContent:n,onItemSelect:this.props.onItemSelect,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.displayName=o.DISPLAYNAME_PREFIX+".Omnibar",t}(h.PureComponent),C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:t.props.popoverProps&&t.props.popoverProps.isOpen||!1},t.TypedQueryList=y.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.tagInputProps,r=void 0===n?{}:n;o.Utils.safeInvoke(r.inputRef,e)},queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,s=n.tagInputProps,i=void 0===s?{}:s,p=n.popoverProps,a=void 0===p?{}:p,l=n.selectedItems,u=void 0===l?[]:l,c=n.placeholder,d=e.handleKeyDown,f=e.handleKeyUp;return h.createElement(o.Popover,v.__assign({autoFocus:!1,canEscapeKeyClose:!0,enforceFocus:!1,isOpen:t.state.isOpen,position:o.Position.BOTTOM_LEFT},a,{className:m()(e.className,a.className),onInteraction:t.handlePopoverInteraction,popoverClassName:m()(r.MULTISELECT_POPOVER,a.popoverClassName),onOpened:t.handlePopoverOpened}),h.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(d),onKeyUp:t.state.isOpen?f:void 0},h.createElement(o.TagInput,v.__assign({placeholder:c},i,{className:m()(r.MULTISELECT,i.className),inputRef:t.refHandlers.input,inputValue:e.query,onInputChange:e.handleQueryChange,values:u.map(t.props.tagRenderer)}))),h.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(d),onKeyUp:f},e.itemList))},t.handleItemSelect=function(e,n){null!=t.input&&t.input.focus(),o.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleQueryChange=function(e,n){t.setState({isOpen:e.length>0||!t.props.openOnKeyDown}),o.Utils.safeInvoke(t.props.onQueryChange,e,n)},t.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var n=t.props.popoverProps,r=void 0===n?{}:n;null!=t.input&&t.input!==document.activeElement?t.setState({isOpen:!1}):t.props.openOnKeyDown||t.setState({isOpen:!0}),o.Utils.safeInvoke(r.onInteraction,e)})},t.handlePopoverOpened=function(e){var n=t.props.popoverProps,r=void 0===n?{}:n;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),o.Utils.safeInvoke(r.onOpened,e)},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which;r===o.Keys.ESCAPE||r===o.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({isOpen:!1})):r!==o.Keys.BACKSPACE&&r!==o.Keys.ARROW_LEFT&&r!==o.Keys.ARROW_RIGHT&&t.setState({isOpen:!0}),t.state.isOpen&&o.Utils.safeInvoke(e,n)}},t}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.openOnKeyDown,e.popoverProps,e.tagInputProps,v.__rest(e,["openOnKeyDown","popoverProps","tagInputProps"]));return h.createElement(this.TypedQueryList,v.__assign({},t,{onItemSelect:this.handleItemSelect,onQueryChange:this.handleQueryChange,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.displayName=o.DISPLAYNAME_PREFIX+".MultiSelect",t.defaultProps={placeholder:"Search..."},t}(h.PureComponent),_=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.TypedQueryList=y.ofType(),s.refHandlers={input:function(e){s.input=e;var t=s.props.inputProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return s.list=e}},s.renderQueryList=function(e){var t=s.props,n=t.filterable,i=void 0===n||n,p=t.disabled,a=void 0!==p&&p,l=t.inputProps,u=void 0===l?{}:l,c=t.popoverProps,d=void 0===c?{}:c,f=h.createElement(o.InputGroup,v.__assign({leftIcon:"search",placeholder:"Filter...",rightElement:s.maybeRenderClearButton(e.query)},u,{inputRef:s.refHandlers.input,onChange:e.handleQueryChange,value:e.query})),y=e.handleKeyDown,I=e.handleKeyUp;return h.createElement(o.Popover,v.__assign({autoFocus:!1,enforceFocus:!1,isOpen:s.state.isOpen,disabled:a,position:o.Position.BOTTOM_LEFT},d,{className:m()(e.className,d.className),onInteraction:s.handlePopoverInteraction,popoverClassName:m()(r.SELECT_POPOVER,d.popoverClassName),onOpening:s.handlePopoverOpening,onOpened:s.handlePopoverOpened,onClosing:s.handlePopoverClosing}),h.createElement("div",{onKeyDown:s.state.isOpen?y:s.handleTargetKeyDown,onKeyUp:s.state.isOpen?I:void 0},s.props.children),h.createElement("div",{onKeyDown:y,onKeyUp:I},i?f:void 0,e.itemList))},s.handleTargetKeyDown=function(e){e.which!==o.Keys.ARROW_UP&&e.which!==o.Keys.ARROW_DOWN||(e.preventDefault(),s.setState({isOpen:!0}))},s.handleItemSelect=function(e,t){s.setState({isOpen:!1}),o.Utils.safeInvoke(s.props.onItemSelect,e,t)},s.handlePopoverInteraction=function(e){s.setState({isOpen:e});var t=s.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onInteraction,e)},s.handlePopoverOpening=function(e){var t=s.props,n=t.popoverProps,r=void 0===n?{}:n,i=t.resetOnClose;s.previousFocusedElement=document.activeElement,i&&s.resetQuery(),o.Utils.safeInvoke(r.onOpening,e)},s.handlePopoverOpened=function(e){null!=s.list&&s.list.scrollActiveItemIntoView(),requestAnimationFrame(function(){var e=s.props.inputProps;!1!==(void 0===e?{}:e).autoFocus&&null!=s.input&&s.input.focus()});var t=s.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onOpened,e)},s.handlePopoverClosing=function(e){requestAnimationFrame(function(){void 0!==s.previousFocusedElement&&(s.previousFocusedElement.focus(),s.previousFocusedElement=void 0)});var t=s.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onClosing,e)},s.resetQuery=function(){return s.list&&s.list.setQuery("",!0)},s.state={isOpen:!1},s}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.filterable,e.inputProps,e.popoverProps,v.__rest(e,["filterable","inputProps","popoverProps"]));return h.createElement(this.TypedQueryList,v.__assign({},t,{onItemSelect:this.handleItemSelect,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.list&&this.list.scrollActiveItemIntoView()},t.prototype.maybeRenderClearButton=function(e){return e.length>0?h.createElement(o.Button,{icon:"cross",minimal:!0,onClick:this.resetQuery}):void 0},t.displayName=o.DISPLAYNAME_PREFIX+".Select",t}(h.PureComponent),S=function(e){function t(t,n){var s=e.call(this,t,n)||this;return s.TypedQueryList=y.ofType(),s.refHandlers={input:function(e){s.input=e;var t=s.props.inputProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return s.queryList=e}},s.renderQueryList=function(e){var t=s.props,n=t.inputProps,i=void 0===n?{}:n,p=t.popoverProps,a=void 0===p?{}:p,l=s.state,u=l.isOpen,c=l.selectedItem,d=e.handleKeyDown,f=e.handleKeyUp,y=i.placeholder,I=void 0===y?"Search...":y,P=c?s.props.inputValueRenderer(c):"";return h.createElement(o.Popover,v.__assign({autoFocus:!1,enforceFocus:!1,isOpen:u,position:o.Position.BOTTOM_LEFT},a,{className:m()(e.className,a.className),onInteraction:s.handlePopoverInteraction,popoverClassName:m()(r.SELECT_POPOVER,a.popoverClassName),onOpened:s.handlePopoverOpened}),h.createElement(o.InputGroup,v.__assign({},i,{placeholder:u&&P?P:I,inputRef:s.refHandlers.input,onChange:e.handleQueryChange,onFocus:s.handleInputFocus,onKeyDown:s.getTargetKeyDownHandler(d),onKeyUp:s.getTargetKeyUpHandler(f),value:u?e.query:P})),h.createElement("div",{onKeyDown:d,onKeyUp:f},e.itemList))},s.selectText=function(){requestAnimationFrame(function(){null!=s.input&&s.input.setSelectionRange(0,s.input.value.length)})},s.handleInputFocus=function(e){var t=s.props,n=t.openOnKeyDown,r=t.inputProps,i=void 0===r?{}:r;s.selectText(),n||s.setState({isOpen:!0}),o.Utils.safeInvoke(i.onFocus,e)},s.handleItemSelect=function(e,t){var n;s.props.closeOnSelect?(null!=s.input&&s.input.blur(),n=!1):(null!=s.input&&s.input.focus(),s.selectText(),n=!0),void 0===s.props.selectedItem?s.setState({isOpen:n,selectedItem:e}):s.setState({isOpen:n}),o.Utils.safeInvoke(s.props.onItemSelect,e,t)},s.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var t=s.props.popoverProps,n=void 0===t?{}:t;null!=s.input&&s.input!==document.activeElement&&s.setState({isOpen:!1}),o.Utils.safeInvoke(n.onInteraction,e)})},s.handlePopoverOpened=function(e){var t=s.props.popoverProps,n=void 0===t?{}:t;null!=s.queryList&&s.queryList.scrollActiveItemIntoView(),o.Utils.safeInvoke(n.onOpened,e)},s.getTargetKeyDownHandler=function(e){return function(t){var n=t.which,r=s.props,i=r.inputProps,p=void 0===i?{}:i,a=r.openOnKeyDown;n===o.Keys.ESCAPE||n===o.Keys.TAB?(null!=s.input&&s.input.blur(),s.setState({isOpen:!1})):a&&n!==o.Keys.BACKSPACE&&n!==o.Keys.ARROW_LEFT&&n!==o.Keys.ARROW_RIGHT&&s.setState({isOpen:!0}),s.state.isOpen&&o.Utils.safeInvoke(e,t),o.Utils.safeInvoke(p.onKeyDown,t)}},s.getTargetKeyUpHandler=function(e){return function(t){var n=s.props.inputProps,r=void 0===n?{}:n;s.state.isOpen&&o.Utils.safeInvoke(e,t),o.Utils.safeInvoke(r.onKeyUp,t)}},s.state={isOpen:t.popoverProps&&t.popoverProps.isOpen||!1,selectedItem:s.getInitialSelectedItem()},s}return v.__extends(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.inputProps,e.popoverProps,v.__rest(e,["inputProps","popoverProps"]));return h.createElement(this.TypedQueryList,v.__assign({},t,{onItemSelect:this.handleItemSelect,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentWillReceiveProps=function(e){void 0!==e.selectedItem&&e.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:e.selectedItem})},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},t.prototype.getInitialSelectedItem=function(){return void 0!==this.props.selectedItem?this.props.selectedItem:void 0!==this.props.defaultSelectedItem?this.props.defaultSelectedItem:null},t.displayName=o.DISPLAYNAME_PREFIX+".Suggest",t.defaultProps={closeOnSelect:!0,openOnKeyDown:!1},t}(h.PureComponent);n.d(t,"Classes",function(){return r}),n.d(t,"renderFilteredItems",function(){return d}),n.d(t,"Omnibar",function(){return E}),n.d(t,"QueryList",function(){return y}),n.d(t,"getFirstEnabledItem",function(){return g}),n.d(t,"MultiSelect",function(){return C}),n.d(t,"Select",function(){return _}),n.d(t,"Suggest",function(){return S})}])});

@@ -141,3 +141,4 @@ "use strict";

this.shouldCheckActiveItemInViewport = true;
if (query !== this.state.query) {
var hasQueryChanged = query !== this.state.query;
if (hasQueryChanged) {
core_1.Utils.safeInvoke(this.props.onQueryChange, query);

@@ -149,5 +150,6 @@ }

var activeIndex = this.getActiveIndex(filteredItems);
if (resetActiveItem ||
var shouldUpdateActiveItem = resetActiveItem ||
activeIndex < 0 ||
isItemDisabled(this.state.activeItem, activeIndex, this.props.itemDisabled)) {
isItemDisabled(this.state.activeItem, activeIndex, this.props.itemDisabled);
if (hasQueryChanged && shouldUpdateActiveItem) {
this.setActiveItem(getFirstEnabledItem(filteredItems, this.props.itemDisabled));

@@ -154,0 +156,0 @@ }

@@ -139,3 +139,4 @@ /*

this.shouldCheckActiveItemInViewport = true;
if (query !== this.state.query) {
var hasQueryChanged = query !== this.state.query;
if (hasQueryChanged) {
Utils.safeInvoke(this.props.onQueryChange, query);

@@ -147,5 +148,6 @@ }

var activeIndex = this.getActiveIndex(filteredItems);
if (resetActiveItem ||
var shouldUpdateActiveItem = resetActiveItem ||
activeIndex < 0 ||
isItemDisabled(this.state.activeItem, activeIndex, this.props.itemDisabled)) {
isItemDisabled(this.state.activeItem, activeIndex, this.props.itemDisabled);
if (hasQueryChanged && shouldUpdateActiveItem) {
this.setActiveItem(getFirstEnabledItem(filteredItems, this.props.itemDisabled));

@@ -152,0 +154,0 @@ }

{
"name": "@blueprintjs/select",
"version": "3.2.0",
"version": "3.2.1",
"description": "Components related to selecting items from a list",

@@ -5,0 +5,0 @@ "main": "lib/cjs/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc