@blueprintjs/select
Advanced tools
Comparing version 4.1.2 to 4.1.3
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@blueprintjs/core"),require("classnames"),require("react"),require("tslib")):"function"==typeof define&&define.amd?define(["@blueprintjs/core","classnames","react","tslib"],t):"object"==typeof exports?exports.Blueprint=t(require("@blueprintjs/core"),require("classnames"),require("react"),require("tslib")):(e.Blueprint=e.Blueprint||{},e.Blueprint.Select=t(e.Blueprint.Core,e.classNames,e.React,e.window))}(self,(function(e,t,n,r){return function(){"use strict";var i={762:function(t){t.exports=e},905:function(e){e.exports=t},359:function(e){e.exports=n},532:function(e){e.exports=r}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return function(){s.r(l),s.d(l,{Classes:function(){return e},MultiSelect:function(){return S},Omnibar:function(){return w},QueryList:function(){return C},Select:function(){return K},Suggest:function(){return L},executeItemsEqual:function(){return m},getActiveItem:function(){return y},getCreateNewItem:function(){return h},getFirstEnabledItem:function(){return T},isCreateNewItem:function(){return f},renderFilteredItems:function(){return v}});var e={};s.r(e),s.d(e,{MULTISELECT:function(){return r},MULTISELECT_POPOVER:function(){return i},MULTISELECT_TAG_INPUT_INPUT:function(){return o},OMNIBAR:function(){return p},OMNIBAR_OVERLAY:function(){return u},SELECT:function(){return a},SELECT_MATCH_TARGET_WIDTH:function(){return d},SELECT_POPOVER:function(){return c}});var t=s(762),n=t.Classes.getClassNamespace(),r="".concat(n,"-multi-select"),i="".concat(r,"-popover"),o="".concat(r,"-tag-input-input"),p="".concat(n,"-omnibar"),u="".concat(p,"-overlay"),a="".concat(n,"-select"),c="".concat(a,"-popover"),d="".concat(a,"-match-target-width");function v(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}function m(e,n,r){return void 0===e||null==n||null==r?n===r:t.Utils.isFunction(e)?e(n,r):n[e]===r[e]}function h(){return{__blueprintCreateNewItemBrand:"blueprint-create-new-item"}}function f(e){if(null==e)return!1;var t=Object.keys(e);return 1===t.length&&"__blueprintCreateNewItemBrand"===t[0]&&"blueprint-create-new-item"===e.__blueprintCreateNewItemBrand}function y(e){return null==e||f(e)?null:e}var I=s(532),P=s(905),g=s.n(P),O=s(359),C=function(e){function n(n,r){var i,o,s=this;(s=e.call(this,n,r)||this).refHandlers={itemsParent:function(e){return s.itemsParentRef=e}},s.shouldCheckActiveItemInViewport=!1,s.expectedNextActiveItem=null,s.isEnterKeyPressed=!1,s.renderItemList=function(e){var n=s.props,r=n.initialContent,i=n.noResults,o=e.renderCreateItem(),l=v(e,null!=o?null:i,r);if(null==l&&null==o)return null;var p=s.isCreateItemFirst();return O.createElement(t.Menu,{ulRef:e.itemsParentRef},p&&o,l,!p&&o)},s.renderItem=function(e,t){if(!0!==s.props.disabled){var n=s.state,r=n.activeItem,i=n.query,o=s.state.filteredItems.indexOf(e)>=0,l={active:m(s.props.itemsEqual,y(r),e),disabled:A(e,t,s.props.itemDisabled),matchesPredicate:o};return s.props.itemRenderer(e,{handleClick:function(t){return s.handleItemSelect(e,t)},index:t,modifiers:l,query:i})}return null},s.renderCreateItemMenuItem=function(){if(s.isCreateItemRendered()){var e=s.state,t=e.activeItem,n=e.query.trim(),r=f(t);return s.props.createNewItemRenderer(n,r,(function(e){s.handleItemCreate(n,e)}))}return null},s.handleItemCreate=function(e,t){var n,r,i,o,l=null===(r=(n=s.props).createNewItemFromQuery)||void 0===r?void 0:r.call(n,e);null!=l&&(null===(o=(i=s.props).onItemSelect)||void 0===o||o.call(i,l,t),s.maybeResetQuery())},s.handleItemSelect=function(e,t){var n,r;s.setActiveItem(e),null===(r=(n=s.props).onItemSelect)||void 0===r||r.call(n,e,t),s.maybeResetQuery()},s.handlePaste=function(e){for(var t,n=s.props,r=n.createNewItemFromQuery,i=n.onItemsPaste,o=[],l=[],p=0,u=e;p<u.length;p++){var a=u[p],c=E(a,s.props);if(void 0!==c)t=c,l.push(c);else if(s.canCreateItems()){var d=null==r?void 0:r(a);void 0!==d&&l.push(d)}else o.push(a)}s.setQuery(o.join(", "),!1),void 0!==t&&s.setActiveItem(t),null==i||i(l)},s.handleKeyDown=function(e){var n,r,i=e.keyCode;if(i===t.Keys.ARROW_UP||i===t.Keys.ARROW_DOWN){e.preventDefault();var o=s.getNextActiveItem(i===t.Keys.ARROW_UP?-1:1);null!=o&&s.setActiveItem(o)}else i===t.Keys.ENTER&&(s.isEnterKeyPressed=!0);null===(r=(n=s.props).onKeyDown)||void 0===r||r.call(n,e)},s.handleKeyUp=function(e){var n=s.props.onKeyUp,r=s.state.activeItem;e.keyCode===t.Keys.ENTER&&s.isEnterKeyPressed&&(e.preventDefault(),null==r||f(r)?s.handleItemCreate(s.state.query,e):s.handleItemSelect(r,e),s.isEnterKeyPressed=!1),null==n||n(e)},s.handleInputQueryChange=function(e){var t,n,r=null==e?"":e.target.value;s.setQuery(r),null===(n=(t=s.props).onQueryChange)||void 0===n||n.call(t,r,e)};var l=n.query,p=void 0===l?"":l,u=null===(i=n.createNewItemFromQuery)||void 0===i?void 0:i.call(n,p),a=_(p,n);return s.state={activeItem:void 0!==n.activeItem?n.activeItem:null!==(o=n.initialActiveItem)&&void 0!==o?o:T(a,n.itemDisabled),createNewItem:u,filteredItems:a,query:p},s}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e=this.props,t=e.className,n=e.items,r=e.renderer,i=e.itemListRenderer,o=void 0===i?this.renderItemList:i,s=this.state,l=(s.createNewItem,(0,I.__rest)(s,["createNewItem"]));return r((0,I.__assign)((0,I.__assign)({},l),{className:t,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,handlePaste:this.handlePaste,handleQueryChange:this.handleInputQueryChange,itemList:o((0,I.__assign)((0,I.__assign)({},l),{items:n,itemsParentRef:this.refHandlers.itemsParent,renderCreateItem:this.renderCreateItemMenuItem,renderItem:this.renderItem}))}))},n.prototype.componentDidUpdate=function(e){var n=this;void 0!==this.props.activeItem&&this.props.activeItem!==this.state.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:this.props.activeItem})),null!=this.props.query&&this.props.query!==e.query?this.setQuery(this.props.query,this.props.resetOnQuery,this.props):t.Utils.shallowCompareKeys(this.props,e,{include:["items","itemListPredicate","itemPredicate"]})||this.setQuery(this.state.query),this.shouldCheckActiveItemInViewport&&(this.requestAnimationFrame((function(){return n.scrollActiveItemIntoView()})),this.shouldCheckActiveItemInViewport=!1)},n.prototype.scrollActiveItemIntoView=function(){var e=!1!==this.props.scrollToActiveItem,t=!m(this.props.itemsEqual,y(this.expectedNextActiveItem),y(this.props.activeItem));if(this.expectedNextActiveItem=null,e||!t){var n=this.getActiveElement();if(null!=this.itemsParentRef&&null!=n){var r=n.offsetTop,i=n.offsetHeight,o=this.itemsParentRef,s=o.offsetTop,l=o.scrollTop,p=o.clientHeight,u=this.getItemsParentPadding(),a=u.paddingTop,c=r+i+u.paddingBottom-s,d=r-a-s;c>=l+p?this.itemsParentRef.scrollTop=c+i-p:d<=l&&(this.itemsParentRef.scrollTop=d-i)}}},n.prototype.setQuery=function(e,t,n){var r;void 0===t&&(t=this.props.resetOnQuery),void 0===n&&(n=this.props);var i=n.createNewItemFromQuery;this.shouldCheckActiveItemInViewport=!0,e!==this.state.query&&(null===(r=n.onQueryChange)||void 0===r||r.call(n,e));var o=e.trim(),s=_(o,n),l=null!=i&&""!==o?i(o):void 0;this.setState({createNewItem:l,filteredItems:s,query:e});var p=this.getActiveIndex(s);(t||p<0||A(y(this.state.activeItem),p,n.itemDisabled))&&(this.isCreateItemRendered()&&this.isCreateItemFirst()?this.setActiveItem({__blueprintCreateNewItemBrand:"blueprint-create-new-item"}):this.setActiveItem(T(s,n.itemDisabled)))},n.prototype.setActiveItem=function(e){var t,n,r,i;this.expectedNextActiveItem=e,void 0===this.props.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:e})),f(e)?null===(n=(t=this.props).onActiveItemChange)||void 0===n||n.call(t,null,!0):null===(i=(r=this.props).onActiveItemChange)||void 0===i||i.call(r,e,!1)},n.prototype.getActiveElement=function(){var e=this.state.activeItem;if(null!=this.itemsParentRef){if(f(e)){var t=this.isCreateItemFirst()?0:this.state.filteredItems.length;return this.itemsParentRef.children.item(t)}var n=this.getActiveIndex();return this.itemsParentRef.children.item(n)}},n.prototype.getActiveIndex=function(e){void 0===e&&(e=this.state.filteredItems);var t=this.state.activeItem;if(null==t||f(t))return-1;for(var n=0;n<e.length;++n)if(m(this.props.itemsEqual,e[n],t))return n;return-1},n.prototype.getItemsParentPadding=function(){var e=getComputedStyle(this.itemsParentRef),t=e.paddingTop;return{paddingBottom:R(e.paddingBottom),paddingTop:R(t)}},n.prototype.getNextActiveItem=function(e,t){return void 0===t&&(t=this.getActiveIndex()),this.isCreateItemRendered()&&(0===t&&-1===e||t===this.state.filteredItems.length-1&&1===e)?{__blueprintCreateNewItemBrand:"blueprint-create-new-item"}:T(this.state.filteredItems,this.props.itemDisabled,e,t)},n.prototype.isCreateItemRendered=function(){return this.canCreateItems()&&""!==this.state.query&&!this.wouldCreatedItemMatchSomeExistingItem()},n.prototype.isCreateItemFirst=function(){return"first"===this.props.createNewItemPosition},n.prototype.canCreateItems=function(){return null!=this.props.createNewItemFromQuery&&null!=this.props.createNewItemRenderer},n.prototype.wouldCreatedItemMatchSomeExistingItem=function(){var e=this;return this.state.filteredItems.some((function(t){return m(e.props.itemsEqual,t,e.state.createNewItem)}))},n.prototype.maybeResetQuery=function(){this.props.resetOnSelect&&this.setQuery("",!0)},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".QueryList"),n.defaultProps={disabled:!1,resetOnQuery:!0},n}(t.AbstractComponent2);function R(e){return null==e?0:parseInt(e.slice(0,-2),10)}function E(e,n){var r=n.items,i=n.itemPredicate;if(t.Utils.isFunction(i))for(var o=0;o<r.length;o++){var s=r[o];if(i(e,s,o,!0))return s}}function _(e,n){var r=n.items,i=n.itemPredicate,o=n.itemListPredicate;return t.Utils.isFunction(o)?o(e,r):t.Utils.isFunction(i)?r.filter((function(t,n){return i(e,t,n)})):r}function A(e,n,r){return null!=r&&null!=e&&(t.Utils.isFunction(r)?r(e,n):!!e[r])}function T(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r=e.length-1),0===e.length)return null;var i,o,s=r,l=e.length-1;do{if(o=l,!A(e[s=(i=s+n)<0?o:i>o?0:i],s,t))return e[s]}while(s!==r&&-1!==r);return null}var w=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.TypedQueryList=C.ofType(),n.renderQueryList=function(e){var r=n.props,i=r.inputProps,o=void 0===i?{}:i,s=r.isOpen,l=r.overlayProps,a=void 0===l?{}:l,c=e.handleKeyDown,d=e.handleKeyUp,v=s?{onKeyDown:c,onKeyUp:d}:{};return O.createElement(t.Overlay,(0,I.__assign)({hasBackdrop:!0},a,{isOpen:s,className:g()(u,a.className),onClose:n.handleOverlayClose}),O.createElement("div",(0,I.__assign)({className:g()(p,e.className)},v),O.createElement(t.InputGroup,(0,I.__assign)({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search..."},o,{onChange:e.handleQueryChange,value:e.query})),e.itemList))},n.handleOverlayClose=function(e){var t,r,i,o;null===(r=null===(t=n.props.overlayProps)||void 0===t?void 0:t.onClose)||void 0===r||r.call(t,e),null===(o=(i=n.props).onClose)||void 0===o||o.call(i,e)},n}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e=this.props,t=(e.isOpen,e.inputProps,e.overlayProps,(0,I.__rest)(e,["isOpen","inputProps","overlayProps"])),n="initialContent"in this.props?this.props.initialContent:null;return O.createElement(this.TypedQueryList,(0,I.__assign)({},t,{initialContent:n,renderer:this.renderQueryList}))},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".Omnibar"),n}(O.PureComponent),S=function(e){function n(){var n,s=this;return(s=e.apply(this,arguments)||this).state={isOpen:s.props.popoverProps&&s.props.popoverProps.isOpen||!1},s.TypedQueryList=C.ofType(),s.input=null,s.queryList=null,s.refHandlers={input:(0,t.refHandler)(s,"input",null===(n=s.props.tagInputProps)||void 0===n?void 0:n.inputRef),queryList:function(e){return s.queryList=e}},s.renderQueryList=function(e){var n,l=s.props,p=l.fill,u=l.tagInputProps,a=void 0===u?{}:u,c=l.popoverProps,d=void 0===c?{}:c,v=l.selectedItems,m=void 0===v?[]:v,h=l.placeholder,f=e.handlePaste,y=e.handleKeyDown,P=e.handleKeyUp;p&&(d.fill=!0,a.fill=!0);var C=(0,I.__assign)((0,I.__assign)({},a.inputProps),{className:g()(null===(n=a.inputProps)||void 0===n?void 0:n.className,o)});return O.createElement(t.Popover,(0,I.__assign)({autoFocus:!1,canEscapeKeyClose:!0,enforceFocus:!1,isOpen:s.state.isOpen,position:t.Position.BOTTOM_LEFT},d,{className:g()(e.className,d.className),interactionKind:t.PopoverInteractionKind.CLICK,onInteraction:s.handlePopoverInteraction,popoverClassName:g()(i,d.popoverClassName),onOpened:s.handlePopoverOpened}),O.createElement("div",{onKeyDown:s.getTagInputKeyDownHandler(y),onKeyUp:s.getTagInputKeyUpHandler(P)},O.createElement(t.TagInput,(0,I.__assign)({placeholder:h},a,{className:g()(r,a.className),inputRef:s.refHandlers.input,inputProps:C,inputValue:e.query,onAdd:function(e,t){"paste"===t&&f(e)},onInputChange:e.handleQueryChange,onRemove:s.handleTagRemove,values:m.map(s.props.tagRenderer)}))),O.createElement("div",{onKeyDown:y,onKeyUp:P},e.itemList))},s.handleItemSelect=function(e,t){var n,r;null!=s.input&&s.input.focus(),null===(r=(n=s.props).onItemSelect)||void 0===r||r.call(n,e,t)},s.handleQueryChange=function(e,t){var n,r;s.setState({isOpen:e.length>0||!s.props.openOnKeyDown}),null===(r=(n=s.props).onQueryChange)||void 0===r||r.call(n,e,t)},s.handlePopoverInteraction=function(e,t){return s.requestAnimationFrame((function(){var n,r,i=s.input===document.activeElement;null==s.input||i?s.props.openOnKeyDown||s.setState({isOpen:!0}):s.setState({isOpen:!1}),null===(r=null===(n=s.props.popoverProps)||void 0===n?void 0:n.onInteraction)||void 0===r||r.call(n,e,t)}))},s.handlePopoverOpened=function(e){var t,n;null!=s.queryList&&s.queryList.scrollActiveItemIntoView(),null===(n=null===(t=s.props.popoverProps)||void 0===t?void 0:t.onOpened)||void 0===n||n.call(t,e)},s.handleTagRemove=function(e,t){var n,r=s.props,i=r.selectedItems,o=void 0===i?[]:i,l=r.onRemove,p=r.tagInputProps;null==l||l(o[t],t),null===(n=null==p?void 0:p.onRemove)||void 0===n||n.call(p,e,t)},s.getTagInputKeyDownHandler=function(e){return function(n){var r=n.which;r===t.Keys.ESCAPE||r===t.Keys.TAB?(null!=s.input&&s.input.blur(),s.setState({isOpen:!1})):r!==t.Keys.BACKSPACE&&r!==t.Keys.ARROW_LEFT&&r!==t.Keys.ARROW_RIGHT&&s.setState({isOpen:!0});var i=null!=n.target.closest(".".concat(t.Classes.TAG_REMOVE));s.state.isOpen&&!i&&(null==e||e(n))}},s.getTagInputKeyUpHandler=function(e){return function(t){var n=t.target.classList.contains(o);s.state.isOpen&&n&&(null==e||e(t))}},s}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.componentDidUpdate=function(e){var n,r,i,o,s;(null===(n=e.tagInputProps)||void 0===n?void 0:n.inputRef)!==(null===(r=this.props.tagInputProps)||void 0===r?void 0:r.inputRef)&&((0,t.setRef)(null===(i=e.tagInputProps)||void 0===i?void 0:i.inputRef,null),this.refHandlers.input=(0,t.refHandler)(this,"input",null===(o=this.props.tagInputProps)||void 0===o?void 0:o.inputRef),(0,t.setRef)(null===(s=this.props.tagInputProps)||void 0===s?void 0:s.inputRef,this.input))},n.prototype.render=function(){var e=this.props,t=(e.openOnKeyDown,e.popoverProps,e.tagInputProps,(0,I.__rest)(e,["openOnKeyDown","popoverProps","tagInputProps"]));return O.createElement(this.TypedQueryList,(0,I.__assign)({},t,{onItemSelect:this.handleItemSelect,onQueryChange:this.handleQueryChange,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".MultiSelect"),n.defaultProps={fill:!1,placeholder:"Search..."},n}(t.AbstractPureComponent2),K=function(e){function n(){var n,r=this;return(r=e.apply(this,arguments)||this).state={isOpen:!1},r.TypedQueryList=C.ofType(),r.inputElement=null,r.queryList=null,r.handleInputRef=(0,t.refHandler)(r,"inputElement",null===(n=r.props.inputProps)||void 0===n?void 0:n.inputRef),r.handleQueryListRef=function(e){return r.queryList=e},r.renderQueryList=function(e){var n,i=r.props,o=i.fill,s=i.filterable,l=void 0===s||s,p=i.disabled,u=void 0!==p&&p,a=i.inputProps,v=void 0===a?{}:a,m=i.popoverProps,h=void 0===m?{}:m,f=i.matchTargetWidth;o&&(h.fill=!0),f&&(null==h.modifiers&&(h.modifiers={}),h.modifiers.minWidth={enabled:!0,fn:function(e){return e.styles.width="".concat(e.offsets.reference.width,"px"),e},order:800},h.usePortal=!1,h.wrapperTagName="div");var y=O.createElement(t.InputGroup,(0,I.__assign)({leftIcon:"search",placeholder:"Filter...",rightElement:r.maybeRenderClearButton(e.query)},v,{inputRef:r.handleInputRef,onChange:e.handleQueryChange,value:e.query})),P=e.handleKeyDown,C=e.handleKeyUp;return O.createElement(t.Popover,(0,I.__assign)({autoFocus:!1,enforceFocus:!1,isOpen:r.state.isOpen,disabled:u,position:t.Position.BOTTOM_LEFT},h,{className:g()(e.className,h.className),onInteraction:r.handlePopoverInteraction,popoverClassName:g()(c,h.popoverClassName,(n={},n[d]=f,n)),onOpening:r.handlePopoverOpening,onOpened:r.handlePopoverOpened,onClosing:r.handlePopoverClosing}),O.createElement("div",{onKeyDown:r.state.isOpen?P:r.handleTargetKeyDown,onKeyUp:r.state.isOpen?C:void 0},r.props.children),O.createElement("div",{onKeyDown:P,onKeyUp:C},l?y:void 0,e.itemList))},r.handleTargetKeyDown=function(e){e.which!==t.Keys.ARROW_UP&&e.which!==t.Keys.ARROW_DOWN||(e.preventDefault(),r.setState({isOpen:!0}))},r.handleItemSelect=function(e,t){var n,i;r.setState({isOpen:!1}),null===(i=(n=r.props).onItemSelect)||void 0===i||i.call(n,e,t)},r.handlePopoverInteraction=function(e,t){var n,i;r.setState({isOpen:e}),null===(i=null===(n=r.props.popoverProps)||void 0===n?void 0:n.onInteraction)||void 0===i||i.call(n,e,t)},r.handlePopoverOpening=function(e){var t,n;r.previousFocusedElement=document.activeElement,r.props.resetOnClose&&r.resetQuery(),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpening)||void 0===n||n.call(t,e)},r.handlePopoverOpened=function(e){var t,n;null!=r.queryList&&r.queryList.scrollActiveItemIntoView(),r.requestAnimationFrame((function(){var e,t=r.props.inputProps;!1!==(void 0===t?{}:t).autoFocus&&(null===(e=r.inputElement)||void 0===e||e.focus())})),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpened)||void 0===n||n.call(t,e)},r.handlePopoverClosing=function(e){var t,n;r.requestAnimationFrame((function(){void 0!==r.previousFocusedElement&&(r.previousFocusedElement.focus(),r.previousFocusedElement=void 0)})),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onClosing)||void 0===n||n.call(t,e)},r.resetQuery=function(){return r.queryList&&r.queryList.setQuery("",!0)},r}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e=this.props,t=(e.filterable,e.inputProps,e.popoverProps,(0,I.__rest)(e,["filterable","inputProps","popoverProps"]));return O.createElement(this.TypedQueryList,(0,I.__assign)({},t,{onItemSelect:this.handleItemSelect,ref:this.handleQueryListRef,renderer:this.renderQueryList}))},n.prototype.componentDidUpdate=function(e,n){var r,i,o,s,l;(null===(r=e.inputProps)||void 0===r?void 0:r.inputRef)!==(null===(i=this.props.inputProps)||void 0===i?void 0:i.inputRef)&&((0,t.setRef)(null===(o=e.inputProps)||void 0===o?void 0:o.inputRef,null),this.handleInputRef=(0,t.refHandler)(this,"inputElement",null===(s=this.props.inputProps)||void 0===s?void 0:s.inputRef),(0,t.setRef)(null===(l=this.props.inputProps)||void 0===l?void 0:l.inputRef,this.inputElement)),this.state.isOpen&&!n.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},n.prototype.maybeRenderClearButton=function(e){return e.length>0?O.createElement(t.Button,{icon:"cross",minimal:!0,onClick:this.resetQuery}):void 0},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".Select"),n}(t.AbstractPureComponent2),L=function(e){function n(){var n,r=this;return(r=e.apply(this,arguments)||this).state={isOpen:null!=r.props.popoverProps&&r.props.popoverProps.isOpen||!1,selectedItem:r.getInitialSelectedItem()},r.TypedQueryList=C.ofType(),r.inputElement=null,r.queryList=null,r.handleInputRef=(0,t.refHandler)(r,"inputElement",null===(n=r.props.inputProps)||void 0===n?void 0:n.inputRef),r.handleQueryListRef=function(e){return r.queryList=e},r.renderQueryList=function(e){var n=r.props,i=n.fill,o=n.inputProps,s=void 0===o?{}:o,l=n.popoverProps,p=void 0===l?{}:l,u=r.state,a=u.isOpen,d=u.selectedItem,v=e.handleKeyDown,m=e.handleKeyUp,h=s.autoComplete,f=void 0===h?"off":h,y=s.placeholder,P=void 0===y?"Search...":y,C=d?r.props.inputValueRenderer(d):"",R=a&&C?C:P,E=a?e.query:C||(r.props.resetOnClose?"":e.query);return i&&(p.fill=!0,s.fill=!0),O.createElement(t.Popover,(0,I.__assign)({autoFocus:!1,enforceFocus:!1,isOpen:a,position:t.Position.BOTTOM_LEFT},p,{className:g()(e.className,p.className),interactionKind:t.PopoverInteractionKind.CLICK,onInteraction:r.handlePopoverInteraction,popoverClassName:g()(c,p.popoverClassName),onOpening:r.handlePopoverOpening,onOpened:r.handlePopoverOpened}),O.createElement(t.InputGroup,(0,I.__assign)({autoComplete:f,disabled:r.props.disabled},s,{inputRef:r.handleInputRef,onChange:e.handleQueryChange,onFocus:r.handleInputFocus,onKeyDown:r.getTargetKeyDownHandler(v),onKeyUp:r.getTargetKeyUpHandler(m),placeholder:R,value:E})),O.createElement("div",{onKeyDown:v,onKeyUp:m},e.itemList))},r.selectText=function(){r.requestAnimationFrame((function(){var e;null===(e=r.inputElement)||void 0===e||e.setSelectionRange(0,r.inputElement.value.length)}))},r.handleInputFocus=function(e){var t,n;r.selectText(),r.props.openOnKeyDown||r.setState({isOpen:!0}),null===(n=null===(t=r.props.inputProps)||void 0===t?void 0:t.onFocus)||void 0===n||n.call(t,e)},r.handleItemSelect=function(e,t){var n,i,o,s,l;r.props.closeOnSelect?(null===(i=r.inputElement)||void 0===i||i.blur(),l=!1):(null===(n=r.inputElement)||void 0===n||n.focus(),r.selectText(),l=!0),void 0===r.props.selectedItem?r.setState({isOpen:l,selectedItem:e}):r.setState({isOpen:l}),null===(s=(o=r.props).onItemSelect)||void 0===s||s.call(o,e,t)},r.handlePopoverInteraction=function(e,t){return r.requestAnimationFrame((function(){var n,i,o=r.inputElement===document.activeElement;null==r.inputElement||o||r.setState({isOpen:!1}),null===(i=null===(n=r.props.popoverProps)||void 0===n?void 0:n.onInteraction)||void 0===i||i.call(n,e,t)}))},r.handlePopoverOpening=function(e){var t,n;r.props.resetOnClose&&r.queryList&&r.queryList.setQuery("",!0),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpening)||void 0===n||n.call(t,e)},r.handlePopoverOpened=function(e){var t,n;null!=r.queryList&&r.queryList.scrollActiveItemIntoView(),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpened)||void 0===n||n.call(t,e)},r.getTargetKeyDownHandler=function(e){return function(n){var i,o,s,l=n.which;l===t.Keys.ESCAPE||l===t.Keys.TAB?(null===(i=r.inputElement)||void 0===i||i.blur(),r.setState({isOpen:!1})):r.props.openOnKeyDown&&l!==t.Keys.BACKSPACE&&l!==t.Keys.ARROW_LEFT&&l!==t.Keys.ARROW_RIGHT&&r.setState({isOpen:!0}),r.state.isOpen&&(null==e||e(n)),null===(s=null===(o=r.props.inputProps)||void 0===o?void 0:o.onKeyDown)||void 0===s||s.call(o,n)}},r.getTargetKeyUpHandler=function(e){return function(t){var n,i;r.state.isOpen&&(null==e||e(t)),null===(i=null===(n=r.props.inputProps)||void 0===n?void 0:n.onKeyUp)||void 0===i||i.call(n,t)}},r}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e,t=this.props,n=(t.disabled,t.inputProps,t.popoverProps,(0,I.__rest)(t,["disabled","inputProps","popoverProps"]));return O.createElement(this.TypedQueryList,(0,I.__assign)({},n,{initialActiveItem:null!==(e=this.props.selectedItem)&&void 0!==e?e:void 0,onItemSelect:this.handleItemSelect,ref:this.handleQueryListRef,renderer:this.renderQueryList}))},n.prototype.componentDidUpdate=function(e,n){var r,i,o,s,l,p,u,a=this;if((null===(r=e.inputProps)||void 0===r?void 0:r.inputRef)!==(null===(i=this.props.inputProps)||void 0===i?void 0:i.inputRef)&&((0,t.setRef)(null===(o=e.inputProps)||void 0===o?void 0:o.inputRef,null),this.handleInputRef=(0,t.refHandler)(this,"inputElement",null===(s=this.props.inputProps)||void 0===s?void 0:s.inputRef),(0,t.setRef)(null===(l=this.props.inputProps)||void 0===l?void 0:l.inputRef,this.inputElement)),void 0!==this.props.selectedItem&&this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem}),!1===this.state.isOpen&&!0===n.isOpen){var c=null!==(u=null===(p=this.props.popoverProps)||void 0===p?void 0:p.transitionDuration)&&void 0!==u?u:t.Popover.defaultProps.transitionDuration;setTimeout((function(){return a.maybeResetActiveItemToSelectedItem()}),c)}this.state.isOpen&&!n.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},n.prototype.getInitialSelectedItem=function(){return void 0!==this.props.selectedItem?this.props.selectedItem:void 0!==this.props.defaultSelectedItem?this.props.defaultSelectedItem:null},n.prototype.maybeResetActiveItemToSelectedItem=function(){var e,t=void 0===this.props.activeItem&&null!==this.state.selectedItem&&!this.props.resetOnSelect;null!==this.queryList&&t&&this.queryList.setActiveItem(null!==(e=this.props.selectedItem)&&void 0!==e?e:this.state.selectedItem)},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".Suggest"),n.defaultProps={closeOnSelect:!0,fill:!1,openOnKeyDown:!1,resetOnClose:!1},n}(t.AbstractPureComponent2)}(),l}()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@blueprintjs/core"),require("classnames"),require("react"),require("tslib")):"function"==typeof define&&define.amd?define(["@blueprintjs/core","classnames","react","tslib"],t):"object"==typeof exports?exports.Blueprint=t(require("@blueprintjs/core"),require("classnames"),require("react"),require("tslib")):(e.Blueprint=e.Blueprint||{},e.Blueprint.Select=t(e.Blueprint.Core,e.classNames,e.React,e.window))}(self,(function(e,t,n,r){return function(){"use strict";var i={762:function(t){t.exports=e},905:function(e){e.exports=t},359:function(e){e.exports=n},532:function(e){e.exports=r}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return function(){s.r(l),s.d(l,{Classes:function(){return e},MultiSelect:function(){return S},Omnibar:function(){return w},QueryList:function(){return C},Select:function(){return K},Suggest:function(){return L},executeItemsEqual:function(){return m},getActiveItem:function(){return y},getCreateNewItem:function(){return h},getFirstEnabledItem:function(){return T},isCreateNewItem:function(){return f},renderFilteredItems:function(){return v}});var e={};s.r(e),s.d(e,{MULTISELECT:function(){return r},MULTISELECT_POPOVER:function(){return i},MULTISELECT_TAG_INPUT_INPUT:function(){return o},OMNIBAR:function(){return p},OMNIBAR_OVERLAY:function(){return u},SELECT:function(){return a},SELECT_MATCH_TARGET_WIDTH:function(){return d},SELECT_POPOVER:function(){return c}});var t=s(762),n=t.Classes.getClassNamespace(),r="".concat(n,"-multi-select"),i="".concat(r,"-popover"),o="".concat(r,"-tag-input-input"),p="".concat(n,"-omnibar"),u="".concat(p,"-overlay"),a="".concat(n,"-select"),c="".concat(a,"-popover"),d="".concat(a,"-match-target-width");function v(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}function m(e,n,r){return void 0===e||null==n||null==r?n===r:t.Utils.isFunction(e)?e(n,r):n[e]===r[e]}function h(){return{__blueprintCreateNewItemBrand:"blueprint-create-new-item"}}function f(e){if(null==e)return!1;var t=Object.keys(e);return 1===t.length&&"__blueprintCreateNewItemBrand"===t[0]&&"blueprint-create-new-item"===e.__blueprintCreateNewItemBrand}function y(e){return null==e||f(e)?null:e}var I=s(532),P=s(905),g=s.n(P),O=s(359),C=function(e){function n(n,r){var i,o,s=this;(s=e.call(this,n,r)||this).refHandlers={itemsParent:function(e){return s.itemsParentRef=e}},s.shouldCheckActiveItemInViewport=!1,s.expectedNextActiveItem=null,s.isEnterKeyPressed=!1,s.renderItemList=function(e){var n=s.props,r=n.initialContent,i=n.noResults,o=e.renderCreateItem(),l=v(e,null!=o?null:i,r);if(null==l&&null==o)return null;var p=s.isCreateItemFirst();return O.createElement(t.Menu,{ulRef:e.itemsParentRef},p&&o,l,!p&&o)},s.renderItem=function(e,t){if(!0!==s.props.disabled){var n=s.state,r=n.activeItem,i=n.query,o=s.state.filteredItems.indexOf(e)>=0,l={active:m(s.props.itemsEqual,y(r),e),disabled:A(e,t,s.props.itemDisabled),matchesPredicate:o};return s.props.itemRenderer(e,{handleClick:function(t){return s.handleItemSelect(e,t)},handleFocus:function(){return s.setActiveItem(e)},index:t,modifiers:l,query:i})}return null},s.renderCreateItemMenuItem=function(){if(s.isCreateItemRendered()){var e=s.state,t=e.activeItem,n=e.query.trim(),r=f(t);return s.props.createNewItemRenderer(n,r,(function(e){s.handleItemCreate(n,e)}))}return null},s.handleItemCreate=function(e,t){var n,r,i,o,l=null===(r=(n=s.props).createNewItemFromQuery)||void 0===r?void 0:r.call(n,e);null!=l&&(null===(o=(i=s.props).onItemSelect)||void 0===o||o.call(i,l,t),s.maybeResetQuery())},s.handleItemSelect=function(e,t){var n,r;s.setActiveItem(e),null===(r=(n=s.props).onItemSelect)||void 0===r||r.call(n,e,t),s.maybeResetQuery()},s.handlePaste=function(e){for(var t,n=s.props,r=n.createNewItemFromQuery,i=n.onItemsPaste,o=[],l=[],p=0,u=e;p<u.length;p++){var a=u[p],c=E(a,s.props);if(void 0!==c)t=c,l.push(c);else if(s.canCreateItems()){var d=null==r?void 0:r(a);void 0!==d&&l.push(d)}else o.push(a)}s.setQuery(o.join(", "),!1),void 0!==t&&s.setActiveItem(t),null==i||i(l)},s.handleKeyDown=function(e){var n,r,i=e.keyCode;if(i===t.Keys.ARROW_UP||i===t.Keys.ARROW_DOWN){e.preventDefault();var o=s.getNextActiveItem(i===t.Keys.ARROW_UP?-1:1);null!=o&&s.setActiveItem(o)}else i===t.Keys.ENTER&&(s.isEnterKeyPressed=!0);null===(r=(n=s.props).onKeyDown)||void 0===r||r.call(n,e)},s.handleKeyUp=function(e){var n=s.props.onKeyUp,r=s.state.activeItem;e.keyCode===t.Keys.ENTER&&s.isEnterKeyPressed&&(e.preventDefault(),null==r||f(r)?s.handleItemCreate(s.state.query,e):s.handleItemSelect(r,e),s.isEnterKeyPressed=!1),null==n||n(e)},s.handleInputQueryChange=function(e){var t,n,r=null==e?"":e.target.value;s.setQuery(r),null===(n=(t=s.props).onQueryChange)||void 0===n||n.call(t,r,e)};var l=n.query,p=void 0===l?"":l,u=null===(i=n.createNewItemFromQuery)||void 0===i?void 0:i.call(n,p),a=_(p,n);return s.state={activeItem:void 0!==n.activeItem?n.activeItem:null!==(o=n.initialActiveItem)&&void 0!==o?o:T(a,n.itemDisabled),createNewItem:u,filteredItems:a,query:p},s}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e=this.props,t=e.className,n=e.items,r=e.renderer,i=e.itemListRenderer,o=void 0===i?this.renderItemList:i,s=this.state,l=(s.createNewItem,(0,I.__rest)(s,["createNewItem"]));return r((0,I.__assign)((0,I.__assign)({},l),{className:t,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,handlePaste:this.handlePaste,handleQueryChange:this.handleInputQueryChange,itemList:o((0,I.__assign)((0,I.__assign)({},l),{items:n,itemsParentRef:this.refHandlers.itemsParent,renderCreateItem:this.renderCreateItemMenuItem,renderItem:this.renderItem}))}))},n.prototype.componentDidUpdate=function(e){var n=this;void 0!==this.props.activeItem&&this.props.activeItem!==this.state.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:this.props.activeItem})),null!=this.props.query&&this.props.query!==e.query?this.setQuery(this.props.query,this.props.resetOnQuery,this.props):t.Utils.shallowCompareKeys(this.props,e,{include:["items","itemListPredicate","itemPredicate"]})||this.setQuery(this.state.query),this.shouldCheckActiveItemInViewport&&(this.requestAnimationFrame((function(){return n.scrollActiveItemIntoView()})),this.shouldCheckActiveItemInViewport=!1)},n.prototype.scrollActiveItemIntoView=function(){var e=!1!==this.props.scrollToActiveItem,t=!m(this.props.itemsEqual,y(this.expectedNextActiveItem),y(this.props.activeItem));if(this.expectedNextActiveItem=null,e||!t){var n=this.getActiveElement();if(null!=this.itemsParentRef&&null!=n){var r=n.offsetTop,i=n.offsetHeight,o=this.itemsParentRef,s=o.offsetTop,l=o.scrollTop,p=o.clientHeight,u=this.getItemsParentPadding(),a=u.paddingTop,c=r+i+u.paddingBottom-s,d=r-a-s;c>=l+p?this.itemsParentRef.scrollTop=c+i-p:d<=l&&(this.itemsParentRef.scrollTop=d-i)}}},n.prototype.setQuery=function(e,t,n){var r;void 0===t&&(t=this.props.resetOnQuery),void 0===n&&(n=this.props);var i=n.createNewItemFromQuery;this.shouldCheckActiveItemInViewport=!0,e!==this.state.query&&(null===(r=n.onQueryChange)||void 0===r||r.call(n,e));var o=e.trim(),s=_(o,n),l=null!=i&&""!==o?i(o):void 0;this.setState({createNewItem:l,filteredItems:s,query:e});var p=this.getActiveIndex(s);(t||p<0||A(y(this.state.activeItem),p,n.itemDisabled))&&(this.isCreateItemRendered()&&this.isCreateItemFirst()?this.setActiveItem({__blueprintCreateNewItemBrand:"blueprint-create-new-item"}):this.setActiveItem(T(s,n.itemDisabled)))},n.prototype.setActiveItem=function(e){var t,n,r,i;this.expectedNextActiveItem=e,void 0===this.props.activeItem&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:e})),f(e)?null===(n=(t=this.props).onActiveItemChange)||void 0===n||n.call(t,null,!0):null===(i=(r=this.props).onActiveItemChange)||void 0===i||i.call(r,e,!1)},n.prototype.getActiveElement=function(){var e=this.state.activeItem;if(null!=this.itemsParentRef){if(f(e)){var t=this.isCreateItemFirst()?0:this.state.filteredItems.length;return this.itemsParentRef.children.item(t)}var n=this.getActiveIndex();return this.itemsParentRef.children.item(n)}},n.prototype.getActiveIndex=function(e){void 0===e&&(e=this.state.filteredItems);var t=this.state.activeItem;if(null==t||f(t))return-1;for(var n=0;n<e.length;++n)if(m(this.props.itemsEqual,e[n],t))return n;return-1},n.prototype.getItemsParentPadding=function(){var e=getComputedStyle(this.itemsParentRef),t=e.paddingTop;return{paddingBottom:R(e.paddingBottom),paddingTop:R(t)}},n.prototype.getNextActiveItem=function(e,t){return void 0===t&&(t=this.getActiveIndex()),this.isCreateItemRendered()&&(0===t&&-1===e||t===this.state.filteredItems.length-1&&1===e)?{__blueprintCreateNewItemBrand:"blueprint-create-new-item"}:T(this.state.filteredItems,this.props.itemDisabled,e,t)},n.prototype.isCreateItemRendered=function(){return this.canCreateItems()&&""!==this.state.query&&!this.wouldCreatedItemMatchSomeExistingItem()},n.prototype.isCreateItemFirst=function(){return"first"===this.props.createNewItemPosition},n.prototype.canCreateItems=function(){return null!=this.props.createNewItemFromQuery&&null!=this.props.createNewItemRenderer},n.prototype.wouldCreatedItemMatchSomeExistingItem=function(){var e=this;return this.state.filteredItems.some((function(t){return m(e.props.itemsEqual,t,e.state.createNewItem)}))},n.prototype.maybeResetQuery=function(){this.props.resetOnSelect&&this.setQuery("",!0)},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".QueryList"),n.defaultProps={disabled:!1,resetOnQuery:!0},n}(t.AbstractComponent2);function R(e){return null==e?0:parseInt(e.slice(0,-2),10)}function E(e,n){var r=n.items,i=n.itemPredicate;if(t.Utils.isFunction(i))for(var o=0;o<r.length;o++){var s=r[o];if(i(e,s,o,!0))return s}}function _(e,n){var r=n.items,i=n.itemPredicate,o=n.itemListPredicate;return t.Utils.isFunction(o)?o(e,r):t.Utils.isFunction(i)?r.filter((function(t,n){return i(e,t,n)})):r}function A(e,n,r){return null!=r&&null!=e&&(t.Utils.isFunction(r)?r(e,n):!!e[r])}function T(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r=e.length-1),0===e.length)return null;var i,o,s=r,l=e.length-1;do{if(o=l,!A(e[s=(i=s+n)<0?o:i>o?0:i],s,t))return e[s]}while(s!==r&&-1!==r);return null}var w=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.TypedQueryList=C.ofType(),n.renderQueryList=function(e){var r=n.props,i=r.inputProps,o=void 0===i?{}:i,s=r.isOpen,l=r.overlayProps,a=void 0===l?{}:l,c=e.handleKeyDown,d=e.handleKeyUp,v=s?{onKeyDown:c,onKeyUp:d}:{};return O.createElement(t.Overlay,(0,I.__assign)({hasBackdrop:!0},a,{isOpen:s,className:g()(u,a.className),onClose:n.handleOverlayClose}),O.createElement("div",(0,I.__assign)({className:g()(p,e.className)},v),O.createElement(t.InputGroup,(0,I.__assign)({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search..."},o,{onChange:e.handleQueryChange,value:e.query})),e.itemList))},n.handleOverlayClose=function(e){var t,r,i,o;null===(r=null===(t=n.props.overlayProps)||void 0===t?void 0:t.onClose)||void 0===r||r.call(t,e),null===(o=(i=n.props).onClose)||void 0===o||o.call(i,e)},n}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e=this.props,t=(e.isOpen,e.inputProps,e.overlayProps,(0,I.__rest)(e,["isOpen","inputProps","overlayProps"])),n="initialContent"in this.props?this.props.initialContent:null;return O.createElement(this.TypedQueryList,(0,I.__assign)({},t,{initialContent:n,renderer:this.renderQueryList}))},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".Omnibar"),n}(O.PureComponent),S=function(e){function n(){var n,s=this;return(s=e.apply(this,arguments)||this).state={isOpen:s.props.popoverProps&&s.props.popoverProps.isOpen||!1},s.TypedQueryList=C.ofType(),s.input=null,s.queryList=null,s.refHandlers={input:(0,t.refHandler)(s,"input",null===(n=s.props.tagInputProps)||void 0===n?void 0:n.inputRef),queryList:function(e){return s.queryList=e}},s.renderQueryList=function(e){var n,l=s.props,p=l.fill,u=l.tagInputProps,a=void 0===u?{}:u,c=l.popoverProps,d=void 0===c?{}:c,v=l.selectedItems,m=void 0===v?[]:v,h=l.placeholder,f=e.handlePaste,y=e.handleKeyDown,P=e.handleKeyUp;p&&(d.fill=!0,a.fill=!0);var C=(0,I.__assign)((0,I.__assign)({},a.inputProps),{className:g()(null===(n=a.inputProps)||void 0===n?void 0:n.className,o)});return O.createElement(t.Popover,(0,I.__assign)({autoFocus:!1,canEscapeKeyClose:!0,enforceFocus:!1,isOpen:s.state.isOpen,position:t.Position.BOTTOM_LEFT},d,{className:g()(e.className,d.className),interactionKind:t.PopoverInteractionKind.CLICK,onInteraction:s.handlePopoverInteraction,popoverClassName:g()(i,d.popoverClassName),onOpened:s.handlePopoverOpened}),O.createElement("div",{onKeyDown:s.getTagInputKeyDownHandler(y),onKeyUp:s.getTagInputKeyUpHandler(P)},O.createElement(t.TagInput,(0,I.__assign)({placeholder:h},a,{className:g()(r,a.className),inputRef:s.refHandlers.input,inputProps:C,inputValue:e.query,onAdd:function(e,t){"paste"===t&&f(e)},onInputChange:e.handleQueryChange,onRemove:s.handleTagRemove,values:m.map(s.props.tagRenderer)}))),O.createElement("div",{onKeyDown:y,onKeyUp:P},e.itemList))},s.handleItemSelect=function(e,t){var n,r;null!=s.input&&s.input.focus(),null===(r=(n=s.props).onItemSelect)||void 0===r||r.call(n,e,t)},s.handleQueryChange=function(e,t){var n,r;s.setState({isOpen:e.length>0||!s.props.openOnKeyDown}),null===(r=(n=s.props).onQueryChange)||void 0===r||r.call(n,e,t)},s.handlePopoverInteraction=function(e,t){return s.requestAnimationFrame((function(){var n,r,i=s.input===document.activeElement;null==s.input||i?s.props.openOnKeyDown||s.setState({isOpen:!0}):s.setState({isOpen:!1}),null===(r=null===(n=s.props.popoverProps)||void 0===n?void 0:n.onInteraction)||void 0===r||r.call(n,e,t)}))},s.handlePopoverOpened=function(e){var t,n;null!=s.queryList&&s.queryList.scrollActiveItemIntoView(),null===(n=null===(t=s.props.popoverProps)||void 0===t?void 0:t.onOpened)||void 0===n||n.call(t,e)},s.handleTagRemove=function(e,t){var n,r=s.props,i=r.selectedItems,o=void 0===i?[]:i,l=r.onRemove,p=r.tagInputProps;null==l||l(o[t],t),null===(n=null==p?void 0:p.onRemove)||void 0===n||n.call(p,e,t)},s.getTagInputKeyDownHandler=function(e){return function(n){var r=n.which;r===t.Keys.ESCAPE||r===t.Keys.TAB?(null!=s.input&&s.input.blur(),s.setState({isOpen:!1})):r!==t.Keys.BACKSPACE&&r!==t.Keys.ARROW_LEFT&&r!==t.Keys.ARROW_RIGHT&&s.setState({isOpen:!0});var i=null!=n.target.closest(".".concat(t.Classes.TAG_REMOVE));s.state.isOpen&&!i&&(null==e||e(n))}},s.getTagInputKeyUpHandler=function(e){return function(t){var n=t.target.classList.contains(o);s.state.isOpen&&n&&(null==e||e(t))}},s}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.componentDidUpdate=function(e){var n,r,i,o,s;(null===(n=e.tagInputProps)||void 0===n?void 0:n.inputRef)!==(null===(r=this.props.tagInputProps)||void 0===r?void 0:r.inputRef)&&((0,t.setRef)(null===(i=e.tagInputProps)||void 0===i?void 0:i.inputRef,null),this.refHandlers.input=(0,t.refHandler)(this,"input",null===(o=this.props.tagInputProps)||void 0===o?void 0:o.inputRef),(0,t.setRef)(null===(s=this.props.tagInputProps)||void 0===s?void 0:s.inputRef,this.input))},n.prototype.render=function(){var e=this.props,t=(e.openOnKeyDown,e.popoverProps,e.tagInputProps,(0,I.__rest)(e,["openOnKeyDown","popoverProps","tagInputProps"]));return O.createElement(this.TypedQueryList,(0,I.__assign)({},t,{onItemSelect:this.handleItemSelect,onQueryChange:this.handleQueryChange,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".MultiSelect"),n.defaultProps={fill:!1,placeholder:"Search..."},n}(t.AbstractPureComponent2),K=function(e){function n(){var n,r=this;return(r=e.apply(this,arguments)||this).state={isOpen:!1},r.TypedQueryList=C.ofType(),r.inputElement=null,r.queryList=null,r.handleInputRef=(0,t.refHandler)(r,"inputElement",null===(n=r.props.inputProps)||void 0===n?void 0:n.inputRef),r.handleQueryListRef=function(e){return r.queryList=e},r.renderQueryList=function(e){var n,i=r.props,o=i.fill,s=i.filterable,l=void 0===s||s,p=i.disabled,u=void 0!==p&&p,a=i.inputProps,v=void 0===a?{}:a,m=i.popoverProps,h=void 0===m?{}:m,f=i.matchTargetWidth;o&&(h.fill=!0),f&&(null==h.modifiers&&(h.modifiers={}),h.modifiers.minWidth={enabled:!0,fn:function(e){return e.styles.width="".concat(e.offsets.reference.width,"px"),e},order:800},h.usePortal=!1,h.wrapperTagName="div");var y=O.createElement(t.InputGroup,(0,I.__assign)({leftIcon:"search",placeholder:"Filter...",rightElement:r.maybeRenderClearButton(e.query)},v,{inputRef:r.handleInputRef,onChange:e.handleQueryChange,value:e.query})),P=e.handleKeyDown,C=e.handleKeyUp;return O.createElement(t.Popover,(0,I.__assign)({autoFocus:!1,enforceFocus:!1,isOpen:r.state.isOpen,disabled:u,position:t.Position.BOTTOM_LEFT},h,{className:g()(e.className,h.className),onInteraction:r.handlePopoverInteraction,popoverClassName:g()(c,h.popoverClassName,(n={},n[d]=f,n)),onOpening:r.handlePopoverOpening,onOpened:r.handlePopoverOpened,onClosing:r.handlePopoverClosing}),O.createElement("div",{onKeyDown:r.state.isOpen?P:r.handleTargetKeyDown,onKeyUp:r.state.isOpen?C:void 0},r.props.children),O.createElement("div",{onKeyDown:P,onKeyUp:C},l?y:void 0,e.itemList))},r.handleTargetKeyDown=function(e){e.which!==t.Keys.ARROW_UP&&e.which!==t.Keys.ARROW_DOWN||(e.preventDefault(),r.setState({isOpen:!0}))},r.handleItemSelect=function(e,t){var n,i;r.setState({isOpen:!1}),null===(i=(n=r.props).onItemSelect)||void 0===i||i.call(n,e,t)},r.handlePopoverInteraction=function(e,t){var n,i;r.setState({isOpen:e}),null===(i=null===(n=r.props.popoverProps)||void 0===n?void 0:n.onInteraction)||void 0===i||i.call(n,e,t)},r.handlePopoverOpening=function(e){var t,n;r.previousFocusedElement=document.activeElement,r.props.resetOnClose&&r.resetQuery(),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpening)||void 0===n||n.call(t,e)},r.handlePopoverOpened=function(e){var t,n;null!=r.queryList&&r.queryList.scrollActiveItemIntoView(),r.requestAnimationFrame((function(){var e,t=r.props.inputProps;!1!==(void 0===t?{}:t).autoFocus&&(null===(e=r.inputElement)||void 0===e||e.focus())})),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpened)||void 0===n||n.call(t,e)},r.handlePopoverClosing=function(e){var t,n;r.requestAnimationFrame((function(){void 0!==r.previousFocusedElement&&(r.previousFocusedElement.focus(),r.previousFocusedElement=void 0)})),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onClosing)||void 0===n||n.call(t,e)},r.resetQuery=function(){return r.queryList&&r.queryList.setQuery("",!0)},r}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e=this.props,t=(e.filterable,e.inputProps,e.popoverProps,(0,I.__rest)(e,["filterable","inputProps","popoverProps"]));return O.createElement(this.TypedQueryList,(0,I.__assign)({},t,{onItemSelect:this.handleItemSelect,ref:this.handleQueryListRef,renderer:this.renderQueryList}))},n.prototype.componentDidUpdate=function(e,n){var r,i,o,s,l;(null===(r=e.inputProps)||void 0===r?void 0:r.inputRef)!==(null===(i=this.props.inputProps)||void 0===i?void 0:i.inputRef)&&((0,t.setRef)(null===(o=e.inputProps)||void 0===o?void 0:o.inputRef,null),this.handleInputRef=(0,t.refHandler)(this,"inputElement",null===(s=this.props.inputProps)||void 0===s?void 0:s.inputRef),(0,t.setRef)(null===(l=this.props.inputProps)||void 0===l?void 0:l.inputRef,this.inputElement)),this.state.isOpen&&!n.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},n.prototype.maybeRenderClearButton=function(e){return e.length>0?O.createElement(t.Button,{icon:"cross",minimal:!0,onClick:this.resetQuery}):void 0},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".Select"),n}(t.AbstractPureComponent2),L=function(e){function n(){var n,r=this;return(r=e.apply(this,arguments)||this).state={isOpen:null!=r.props.popoverProps&&r.props.popoverProps.isOpen||!1,selectedItem:r.getInitialSelectedItem()},r.TypedQueryList=C.ofType(),r.inputElement=null,r.queryList=null,r.handleInputRef=(0,t.refHandler)(r,"inputElement",null===(n=r.props.inputProps)||void 0===n?void 0:n.inputRef),r.handleQueryListRef=function(e){return r.queryList=e},r.renderQueryList=function(e){var n=r.props,i=n.fill,o=n.inputProps,s=void 0===o?{}:o,l=n.popoverProps,p=void 0===l?{}:l,u=r.state,a=u.isOpen,d=u.selectedItem,v=e.handleKeyDown,m=e.handleKeyUp,h=s.autoComplete,f=void 0===h?"off":h,y=s.placeholder,P=void 0===y?"Search...":y,C=d?r.props.inputValueRenderer(d):"",R=a&&C?C:P,E=a?e.query:C||(r.props.resetOnClose?"":e.query);return i&&(p.fill=!0,s.fill=!0),O.createElement(t.Popover,(0,I.__assign)({autoFocus:!1,enforceFocus:!1,isOpen:a,position:t.Position.BOTTOM_LEFT},p,{className:g()(e.className,p.className),interactionKind:t.PopoverInteractionKind.CLICK,onInteraction:r.handlePopoverInteraction,popoverClassName:g()(c,p.popoverClassName),onOpening:r.handlePopoverOpening,onOpened:r.handlePopoverOpened}),O.createElement(t.InputGroup,(0,I.__assign)({autoComplete:f,disabled:r.props.disabled},s,{inputRef:r.handleInputRef,onChange:e.handleQueryChange,onFocus:r.handleInputFocus,onKeyDown:r.getTargetKeyDownHandler(v),onKeyUp:r.getTargetKeyUpHandler(m),placeholder:R,value:E})),O.createElement("div",{onKeyDown:v,onKeyUp:m},e.itemList))},r.selectText=function(){r.requestAnimationFrame((function(){var e;null===(e=r.inputElement)||void 0===e||e.setSelectionRange(0,r.inputElement.value.length)}))},r.handleInputFocus=function(e){var t,n;r.selectText(),r.props.openOnKeyDown||r.setState({isOpen:!0}),null===(n=null===(t=r.props.inputProps)||void 0===t?void 0:t.onFocus)||void 0===n||n.call(t,e)},r.handleItemSelect=function(e,t){var n,i,o,s,l;r.props.closeOnSelect?(null===(i=r.inputElement)||void 0===i||i.blur(),l=!1):(null===(n=r.inputElement)||void 0===n||n.focus(),r.selectText(),l=!0),void 0===r.props.selectedItem?r.setState({isOpen:l,selectedItem:e}):r.setState({isOpen:l}),null===(s=(o=r.props).onItemSelect)||void 0===s||s.call(o,e,t)},r.handlePopoverInteraction=function(e,t){return r.requestAnimationFrame((function(){var n,i,o=r.inputElement===document.activeElement;null==r.inputElement||o||r.setState({isOpen:!1}),null===(i=null===(n=r.props.popoverProps)||void 0===n?void 0:n.onInteraction)||void 0===i||i.call(n,e,t)}))},r.handlePopoverOpening=function(e){var t,n;r.props.resetOnClose&&r.queryList&&r.queryList.setQuery("",!0),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpening)||void 0===n||n.call(t,e)},r.handlePopoverOpened=function(e){var t,n;null!=r.queryList&&r.queryList.scrollActiveItemIntoView(),null===(n=null===(t=r.props.popoverProps)||void 0===t?void 0:t.onOpened)||void 0===n||n.call(t,e)},r.getTargetKeyDownHandler=function(e){return function(n){var i,o,s,l=n.which;l===t.Keys.ESCAPE||l===t.Keys.TAB?(null===(i=r.inputElement)||void 0===i||i.blur(),r.setState({isOpen:!1})):r.props.openOnKeyDown&&l!==t.Keys.BACKSPACE&&l!==t.Keys.ARROW_LEFT&&l!==t.Keys.ARROW_RIGHT&&r.setState({isOpen:!0}),r.state.isOpen&&(null==e||e(n)),null===(s=null===(o=r.props.inputProps)||void 0===o?void 0:o.onKeyDown)||void 0===s||s.call(o,n)}},r.getTargetKeyUpHandler=function(e){return function(t){var n,i;r.state.isOpen&&(null==e||e(t)),null===(i=null===(n=r.props.inputProps)||void 0===n?void 0:n.onKeyUp)||void 0===i||i.call(n,t)}},r}return(0,I.__extends)(n,e),n.ofType=function(){return n},n.prototype.render=function(){var e,t=this.props,n=(t.disabled,t.inputProps,t.popoverProps,(0,I.__rest)(t,["disabled","inputProps","popoverProps"]));return O.createElement(this.TypedQueryList,(0,I.__assign)({},n,{initialActiveItem:null!==(e=this.props.selectedItem)&&void 0!==e?e:void 0,onItemSelect:this.handleItemSelect,ref:this.handleQueryListRef,renderer:this.renderQueryList}))},n.prototype.componentDidUpdate=function(e,n){var r,i,o,s,l,p,u,a=this;if((null===(r=e.inputProps)||void 0===r?void 0:r.inputRef)!==(null===(i=this.props.inputProps)||void 0===i?void 0:i.inputRef)&&((0,t.setRef)(null===(o=e.inputProps)||void 0===o?void 0:o.inputRef,null),this.handleInputRef=(0,t.refHandler)(this,"inputElement",null===(s=this.props.inputProps)||void 0===s?void 0:s.inputRef),(0,t.setRef)(null===(l=this.props.inputProps)||void 0===l?void 0:l.inputRef,this.inputElement)),void 0!==this.props.selectedItem&&this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem}),!1===this.state.isOpen&&!0===n.isOpen){var c=null!==(u=null===(p=this.props.popoverProps)||void 0===p?void 0:p.transitionDuration)&&void 0!==u?u:t.Popover.defaultProps.transitionDuration;setTimeout((function(){return a.maybeResetActiveItemToSelectedItem()}),c)}this.state.isOpen&&!n.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},n.prototype.getInitialSelectedItem=function(){return void 0!==this.props.selectedItem?this.props.selectedItem:void 0!==this.props.defaultSelectedItem?this.props.defaultSelectedItem:null},n.prototype.maybeResetActiveItemToSelectedItem=function(){var e,t=void 0===this.props.activeItem&&null!==this.state.selectedItem&&!this.props.resetOnSelect;null!==this.queryList&&t&&this.queryList.setActiveItem(null!==(e=this.props.selectedItem)&&void 0!==e?e:this.state.selectedItem)},n.displayName="".concat(t.DISPLAYNAME_PREFIX,".Suggest"),n.defaultProps={closeOnSelect:!0,fill:!1,openOnKeyDown:!1,resetOnClose:!1},n}(t.AbstractPureComponent2)}(),l}()})); |
@@ -17,2 +17,4 @@ import { MouseEventHandler } from "react"; | ||
handleClick: MouseEventHandler<HTMLElement>; | ||
/** Focus event handler to set this as the "active" item */ | ||
handleFocus: () => void; | ||
index?: number; | ||
@@ -19,0 +21,0 @@ /** Modifiers that describe how to render this item, such as `active` or `disabled`. */ |
@@ -86,2 +86,3 @@ "use strict"; | ||
handleClick: function (e) { return _this.handleItemSelect(item, e); }, | ||
handleFocus: function () { return _this.setActiveItem(item); }, | ||
index: index, | ||
@@ -88,0 +89,0 @@ modifiers: modifiers, |
@@ -17,2 +17,4 @@ import { MouseEventHandler } from "react"; | ||
handleClick: MouseEventHandler<HTMLElement>; | ||
/** Focus event handler to set this as the "active" item */ | ||
handleFocus: () => void; | ||
index?: number; | ||
@@ -19,0 +21,0 @@ /** Modifiers that describe how to render this item, such as `active` or `disabled`. */ |
@@ -83,2 +83,3 @@ /* | ||
handleClick: function (e) { return _this.handleItemSelect(item, e); }, | ||
handleFocus: function () { return _this.setActiveItem(item); }, | ||
index: index, | ||
@@ -85,0 +86,0 @@ modifiers: modifiers, |
@@ -17,2 +17,4 @@ import { MouseEventHandler } from "react"; | ||
handleClick: MouseEventHandler<HTMLElement>; | ||
/** Focus event handler to set this as the "active" item */ | ||
handleFocus: () => void; | ||
index?: number; | ||
@@ -19,0 +21,0 @@ /** Modifiers that describe how to render this item, such as `active` or `disabled`. */ |
@@ -213,2 +213,3 @@ /* | ||
handleClick: e => this.handleItemSelect(item, e), | ||
handleFocus: () => this.setActiveItem(item), | ||
index, | ||
@@ -215,0 +216,0 @@ modifiers, |
{ | ||
"name": "@blueprintjs/select", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "Components related to selecting items from a list", | ||
@@ -38,3 +38,3 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@blueprintjs/core": "^4.1.2", | ||
"@blueprintjs/core": "^4.2.0", | ||
"classnames": "^2.2", | ||
@@ -41,0 +41,0 @@ "tslib": "~2.3.1" |
@@ -38,2 +38,5 @@ /* | ||
/** Focus event handler to set this as the "active" item */ | ||
handleFocus: () => void; | ||
index?: number; | ||
@@ -40,0 +43,0 @@ |
@@ -226,3 +226,3 @@ @# Select | ||
const renderFilm: ItemRenderer<Film> = (film, { handleClick, modifiers }) => { | ||
const renderFilm: ItemRenderer<Film> = (film, { handleClick, handleFocus, modifiers }) => { | ||
if (!modifiers.matchesPredicate) { | ||
@@ -237,2 +237,3 @@ return null; | ||
onClick={handleClick} | ||
onFocus={handleFocus} | ||
text={film.title} | ||
@@ -239,0 +240,0 @@ /> |
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
Sorry, the diff of this file is not supported yet
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
572107
8357
Updated@blueprintjs/core@^4.2.0