@blueprintjs/select
Advanced tools
Comparing version 3.0.0-beta.0 to 3.0.0-rc.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@blueprintjs/core"),require("react"),require("classnames")):"function"==typeof define&&define.amd?define(["@blueprintjs/core","react","classnames"],t):"object"==typeof exports?exports.Select=t(require("@blueprintjs/core"),require("react"),require("classnames")):(e.Blueprint=e.Blueprint||{},e.Blueprint.Select=t(e.Blueprint.Core,e.React,e.classNames))}("undefined"!=typeof self?self:this,function(e,t,n){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=3)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t,n){e.exports=n(4)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={};n.d(r,"MULTISELECT",function(){return s}),n.d(r,"MULTISELECT_POPOVER",function(){return p}),n.d(r,"OMNIBAR",function(){return a}),n.d(r,"OMNIBAR_OVERLAY",function(){return u}),n.d(r,"SELECT",function(){return l}),n.d(r,"SELECT_POPOVER",function(){return c});var o=n(0),i=o.Classes.getClassNamespace(),s=i+"-multi-select",p=s+"-popover",a=i+"-omnibar",u=a+"-overlay",l=i+"-select",c=l+"-popover";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}var d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function f(e,t){function n(){this.constructor=e}d(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var m=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e};function y(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&(n[r[o]]=e[r[o]])}return n}var h=n(2),I=n.n(h),O=n(1),P=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.refHandlers={itemsParent:function(e){return t.itemsParentRef=e}},t.shouldCheckActiveItemInViewport=!1,t.renderItemList=function(e){var n=t.props,r=n.initialContent,i=v(e,n.noResults,r);return O.createElement(o.Menu,{ulRef:e.itemsParentRef},i)},t.renderItem=function(e,n){var r=t.props,o=r.activeItem,i=r.query,s=t.state.filteredItems.indexOf(e)>=0,p={active:o===e,disabled:!1,matchesPredicate:s};return t.props.itemRenderer(e,{handleClick:function(n){return t.handleItemSelect(e,n)},index:n,modifiers:p,query:i})},t.handleItemSelect=function(e,n){o.Utils.safeInvoke(t.props.onActiveItemChange,e),o.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleKeyDown=function(e){switch(e.keyCode){case o.Keys.ARROW_UP:e.preventDefault(),t.moveActiveIndex(-1);break;case o.Keys.ARROW_DOWN:e.preventDefault(),t.moveActiveIndex(1)}o.Utils.safeInvoke(t.props.onKeyDown,e)},t.handleKeyUp=function(e){var n=t.props,r=n.activeItem,i=n.onItemSelect,s=n.onKeyUp;e.keyCode===o.Keys.ENTER&&null!=r&&(e.preventDefault(),o.Utils.safeInvoke(i,r,e)),o.Utils.safeInvoke(s,e)},t}return f(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.query,i=e.itemListRenderer,s=void 0===i?this.renderItemList:i,p=this.state.filteredItems;return r({className:t,filteredItems:p,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,itemList:s({filteredItems:p,items:n,itemsParentRef:this.refHandlers.itemsParent,query:o,renderItem:this.renderItem}),query:o})},t.prototype.componentWillMount=function(){this.setState({filteredItems:C(this.props)})},t.prototype.componentWillReceiveProps=function(e){e.items===this.props.items&&e.itemListPredicate===this.props.itemListPredicate&&e.itemPredicate===this.props.itemPredicate&&e.query===this.props.query||(this.shouldCheckActiveItemInViewport=!0,this.setState({filteredItems:C(e)}))},t.prototype.componentDidUpdate=function(){var e=this;this.shouldCheckActiveItemInViewport&&(requestAnimationFrame(function(){return e.scrollActiveItemIntoView()}),this.shouldCheckActiveItemInViewport=!1),this.getActiveIndex()<0&&(0!==this.state.filteredItems.length||void 0!==this.props.activeItem)&&o.Utils.safeInvoke(this.props.onActiveItemChange,this.state.filteredItems[0])},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,i=r.scrollTop,s=r.clientHeight,p=this.getItemsParentPadding(),a=p.paddingTop,u=t+n+p.paddingBottom-o,l=t-a-o;u>=i+s?this.itemsParentRef.scrollTop=u+n-s:l<=i&&(this.itemsParentRef.scrollTop=l-n)}},t.prototype.getActiveElement=function(){if(null!=this.itemsParentRef)return this.itemsParentRef.children.item(this.getActiveIndex())},t.prototype.getActiveIndex=function(){var e=this.props.activeItem;return null==e?-1:this.state.filteredItems.indexOf(e)},t.prototype.getItemsParentPadding=function(){var e=getComputedStyle(this.itemsParentRef),t=e.paddingTop;return{paddingBottom:g(e.paddingBottom),paddingTop:g(t)}},t.prototype.moveActiveIndex=function(e){this.shouldCheckActiveItemInViewport=!0;var t=this.state.filteredItems,n=Math.max(t.length-1,0),r=o.Utils.clamp(this.getActiveIndex()+e,0,n);o.Utils.safeInvoke(this.props.onActiveItemChange,t[r])},t.displayName="Blueprint2.QueryList",t}(O.Component);function g(e){return null==e?0:parseInt(e.slice(0,-2),10)}function C(e){var t=e.items,n=e.itemPredicate,r=e.itemListPredicate,i=e.query;return o.Utils.isFunction(r)?r(i,t):o.Utils.isFunction(n)?t.filter(function(e,t){return n(i,e,t)}):t}var S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={query:""},t.TypedQueryList=P.ofType(),t.refHandlers={queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,i=n.inputProps,s=void 0===i?{}:i,p=n.isOpen,a=n.overlayProps,u=void 0===a?{}:a,l=e.handleKeyDown,c=e.handleKeyUp,v=p&&!t.isQueryEmpty()?{onKeyDown:l,onKeyUp:c}:{};return O.createElement(o.Overlay,m({hasBackdrop:!0},u,{isOpen:p,className:I()(u.className,r.OMNIBAR_OVERLAY),onClose:t.handleOverlayClose}),O.createElement("div",m({className:I()(e.className,r.OMNIBAR)},v),O.createElement(o.InputGroup,m({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search...",value:e.query},s,{onChange:t.handleQueryChange})),e.itemList))},t.isQueryEmpty=function(){return 0===t.state.query.length},t.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.handleItemSelect=function(e,n){t.isQueryEmpty()||o.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleQueryChange=function(e){var n=t.props.inputProps,r=void 0===n?{}:n;t.setState({query:e.currentTarget.value}),o.Utils.safeInvoke(r.onChange,e)},t.handleOverlayClose=function(e){o.Utils.safeInvoke(t.props.onClose,e)},t}return f(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,y(e,["initialContent","isOpen","inputProps","overlayProps"]));return O.createElement(this.TypedQueryList,m({},r,{activeItem:this.state.activeItem,initialContent:n,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentWillReceiveProps=function(e){var t=e.isOpen,n=!this.props.isOpen&&t&&this.props.resetOnSelect;this.setState({activeItem:n?this.props.items[0]:this.state.activeItem,query:n?"":this.state.query})},t.displayName="Blueprint2.Omnibar",t}(O.PureComponent),T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,query:""},t.TypedQueryList=P.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,i=n.tagInputProps,s=void 0===i?{}:i,p=n.popoverProps,a=void 0===p?{}:p,u=n.selectedItems,l=void 0===u?[]:u,c=e.handleKeyDown,v=e.handleKeyUp,d=e.query,f=m({placeholder:"Search..."},s.inputProps,{onChange:t.handleQueryChange,value:d});return O.createElement(o.Popover,m({autoFocus:!1,canEscapeKeyClose:!0,enforceFocus:!1,isOpen:t.state.isOpen,position:o.Position.BOTTOM_LEFT},a,{className:I()(e.className,a.className),onInteraction:t.handlePopoverInteraction,popoverClassName:I()(r.MULTISELECT_POPOVER,a.popoverClassName),popoverDidOpen:t.handlePopoverDidOpen,popoverWillOpen:t.handlePopoverWillOpen}),O.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(c),onKeyUp:t.state.isOpen?v:void 0},O.createElement(o.TagInput,m({},s,{inputProps:f,inputRef:t.refHandlers.input,className:I()(r.MULTISELECT,s.className),values:l.map(t.props.tagRenderer)}))),O.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(c),onKeyUp:v},e.itemList))},t.isQueryEmpty=function(){return 0===t.state.query.length},t.handleQueryChange=function(e){var n=t.props,r=n.tagInputProps,i=void 0===r?{}:r,s=n.openOnKeyDown,p=e.currentTarget.value;t.setState({query:p,isOpen:!t.isQueryEmpty()||!s}),null!=i.inputProps&&o.Utils.safeInvoke(i.inputProps.onChange,e)},t.handleItemSelect=function(e,n){null!=t.input&&t.input.focus(),null!=t.state.activeItem&&(t.props.resetOnSelect&&!t.isQueryEmpty()&&t.setState({activeItem:t.props.items[0],query:""}),o.Utils.safeInvoke(t.props.onItemSelect,e,n))},t.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var n=t.props,r=n.popoverProps,i=void 0===r?{}:r,s=n.resetOnSelect;null!=t.input&&t.input!==document.activeElement?t.setState({activeItem:s?t.props.items[0]:t.state.activeItem,isOpen:!1,query:s?"":t.state.query}):t.props.openOnKeyDown||t.setState({isOpen:!0}),o.Utils.safeInvoke(i.onInteraction,e)})},t.handlePopoverWillOpen=function(){var e=t.props,n=e.popoverProps,r=void 0===n?{}:n;e.resetOnSelect&&t.setState({activeItem:t.props.items[0]}),o.Utils.safeInvoke(r.popoverWillOpen)},t.handlePopoverDidOpen=function(){var e=t.props.popoverProps,n=void 0===e?{}:e;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),o.Utils.safeInvoke(n.popoverDidOpen)},t.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,i=t.props.resetOnSelect;r===o.Keys.ESCAPE||r===o.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({activeItem:i?t.props.items[0]:t.state.activeItem,isOpen:!1,query:i?"":t.state.query})):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 f(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.openOnKeyDown,e.popoverProps,e.resetOnSelect,e.tagInputProps,y(e,["openOnKeyDown","popoverProps","resetOnSelect","tagInputProps"]));return O.createElement(this.TypedQueryList,m({},t,{activeItem:this.state.activeItem,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.displayName="Blueprint2.MultiSelect",t}(O.PureComponent),q=function(e){function t(t,n){var i=e.call(this,t,n)||this;i.TypedQueryList=P.ofType(),i.refHandlers={input:function(e){i.input=e;var t=i.props.inputProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return i.list=e}},i.renderQueryList=function(e){var t=i.props,n=t.filterable,s=void 0===n||n,p=t.disabled,a=void 0!==p&&p,u=t.inputProps,l=void 0===u?{}:u,c=t.popoverProps,v=void 0===c?{}:c,d=O.createElement(o.InputGroup,m({autoFocus:!0,leftIcon:"search",placeholder:"Filter...",rightElement:i.maybeRenderInputClearButton(),value:e.query},l,{inputRef:i.refHandlers.input,onChange:i.handleQueryChange})),f=e.handleKeyDown,y=e.handleKeyUp;return O.createElement(o.Popover,m({autoFocus:!1,enforceFocus:!1,isOpen:i.state.isOpen,disabled:a,position:o.Position.BOTTOM_LEFT},v,{className:I()(e.className,v.className),onInteraction:i.handlePopoverInteraction,popoverClassName:I()(r.SELECT_POPOVER,v.popoverClassName),popoverWillOpen:i.handlePopoverWillOpen,popoverDidOpen:i.handlePopoverDidOpen,popoverWillClose:i.handlePopoverWillClose}),O.createElement("div",{onKeyDown:i.state.isOpen?f:i.handleTargetKeyDown,onKeyUp:i.state.isOpen?y:void 0},i.props.children),O.createElement("div",{onKeyDown:f,onKeyUp:y},s?d:void 0,e.itemList))},i.handleActiveItemChange=function(e){return i.setState({activeItem:e})},i.handleTargetKeyDown=function(e){e.which!==o.Keys.ARROW_UP&&e.which!==o.Keys.ARROW_DOWN||i.setState({isOpen:!0})},i.handleItemSelect=function(e,t){i.setState({isOpen:!1}),i.props.resetOnSelect&&i.resetQuery(),o.Utils.safeInvoke(i.props.onItemSelect,e,t)},i.handlePopoverInteraction=function(e){i.setState({isOpen:e});var t=i.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onInteraction,e)},i.handlePopoverWillOpen=function(){var e=i.props,t=e.popoverProps,n=void 0===t?{}:t,r=e.resetOnClose;i.previousFocusedElement=document.activeElement,r&&i.resetQuery(),o.Utils.safeInvoke(n.popoverWillOpen)},i.handlePopoverDidOpen=function(){null!=i.list&&i.list.scrollActiveItemIntoView(),requestAnimationFrame(function(){var e=i.props.inputProps;!1!==(void 0===e?{}:e).autoFocus&&null!=i.input&&i.input.focus()});var e=i.props.popoverProps,t=void 0===e?{}:e;o.Utils.safeInvoke(t.popoverDidOpen)},i.handlePopoverWillClose=function(){requestAnimationFrame(function(){void 0!==i.previousFocusedElement&&(i.previousFocusedElement.focus(),i.previousFocusedElement=void 0)});var e=i.props.popoverProps,t=void 0===e?{}:e;o.Utils.safeInvoke(t.popoverWillClose)},i.handleQueryChange=function(e){var t=i.props,n=t.inputProps,r=void 0===n?{}:n,s=t.onQueryChange,p=e.currentTarget.value;i.setState({query:p}),o.Utils.safeInvoke(r.onChange,e),o.Utils.safeInvoke(s,p)},i.resetQuery=function(){var e=i.props,t=e.items,n=e.onQueryChange;i.setState({activeItem:t[0],query:""}),o.Utils.safeInvoke(n,"")};var s=t.inputProps,p=void 0===s?{}:s,a=null==p.value?"":p.value.toString();return i.state={isOpen:!1,query:a},i}return f(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.filterable,e.inputProps,e.popoverProps,y(e,["filterable","inputProps","popoverProps"]));return O.createElement(this.TypedQueryList,m({},t,{activeItem:this.state.activeItem,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentWillReceiveProps=function(e){var t=e.inputProps,n=void 0===t?{}:t;void 0!==n.value&&this.state.query!==n.value&&this.setState({query:n.value.toString()})},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.list&&this.list.scrollActiveItemIntoView()},t.prototype.maybeRenderInputClearButton=function(){return 0===this.state.query.length?void 0:O.createElement(o.Button,{icon:"cross",minimal:!0,onClick:this.resetQuery})},t.displayName="Blueprint2.Select",t}(O.PureComponent),E=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,isTyping:!1,query:""},t.TypedQueryList=P.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.inputProps,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,i=n.inputValueRenderer,s=n.inputProps,p=void 0===s?{}:s,a=n.popoverProps,u=void 0===a?{}:a,l=t.state,c=l.isTyping,v=l.selectedItem,d=l.query,f=e.handleKeyDown,y=e.handleKeyUp,h=c?d:v?i(v):"";return O.createElement(o.Popover,m({autoFocus:!1,enforceFocus:!1,isOpen:t.state.isOpen,position:o.Position.BOTTOM_LEFT},u,{className:I()(e.className,u.className),onInteraction:t.handlePopoverInteraction,popoverClassName:I()(r.SELECT_POPOVER,u.popoverClassName),popoverDidOpen:t.handlePopoverDidOpen,popoverWillClose:t.handlePopoverWillClose}),O.createElement(o.InputGroup,m({placeholder:"Search...",value:h},p,{inputRef:t.refHandlers.input,onChange:t.handleQueryChange,onFocus:t.handleInputFocus,onKeyDown:t.getTargetKeyDownHandler(f),onKeyUp:t.getTargetKeyUpHandler(y)})),O.createElement("div",{onKeyDown:f,onKeyUp:y},e.itemList))},t.selectText=function(){requestAnimationFrame(function(){null!=t.input&&t.input.setSelectionRange(0,t.input.value.length)})},t.handleInputFocus=function(e){var n=t.props,r=n.openOnKeyDown,i=n.inputProps,s=void 0===i?{}:i;t.selectText(),r||t.setState({isOpen:!0}),o.Utils.safeInvoke(s.onFocus,e)},t.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.handleItemSelect=function(e,n){var r;t.props.closeOnSelect?(null!=t.input&&t.input.blur(),r=!1):(null!=t.input&&t.input.focus(),t.selectText(),r=!0),t.setState({isOpen:r,isTyping:!1,query:"",selectedItem:e}),o.Utils.safeInvoke(t.props.onItemSelect,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}),o.Utils.safeInvoke(r.onInteraction,e)})},t.handlePopoverDidOpen=function(){var e=t.props.popoverProps,n=void 0===e?{}:e;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),o.Utils.safeInvoke(n.popoverDidOpen)},t.handlePopoverWillClose=function(){var e=t.props.popoverProps,n=void 0===e?{}:e,r=t.state.selectedItem;t.setState({activeItem:r||t.props.items[0],query:""}),o.Utils.safeInvoke(n.popoverDidOpen)},t.handleQueryChange=function(e){var n=t.props.inputProps,r=void 0===n?{}:n;t.setState({isTyping:!0,query:e.currentTarget.value}),o.Utils.safeInvoke(r.onChange,e)},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,i=t.state,s=i.isTyping,p=i.selectedItem,a=t.props,u=a.inputProps,l=void 0===u?{}:u,c=a.openOnKeyDown;r===o.Keys.ESCAPE||r===o.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({isOpen:!1,selectedItem:s?void 0:p})):c&&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),o.Utils.safeInvoke(l.onKeyDown,n)}},t.getTargetKeyUpHandler=function(e){return function(n){var r=t.props.inputProps,i=void 0===r?{}:r;t.state.isOpen&&o.Utils.safeInvoke(e,n),o.Utils.safeInvoke(i.onKeyUp,n)}},t}return f(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.inputProps,e.popoverProps,y(e,["inputProps","popoverProps"]));return O.createElement(this.TypedQueryList,m({},t,{activeItem:this.state.activeItem,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},t.displayName="Blueprint2.Suggest",t.defaultProps={closeOnSelect:!0,openOnKeyDown:!1},t}(O.PureComponent);n.d(t,"Classes",function(){return r}),n.d(t,"renderFilteredItems",function(){return v}),n.d(t,"Omnibar",function(){return S}),n.d(t,"QueryList",function(){return P}),n.d(t,"MultiSelect",function(){return T}),n.d(t,"Select",function(){return q}),n.d(t,"Suggest",function(){return E})}])}); | ||
!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 s}),n.d(r,"MULTISELECT_POPOVER",function(){return p}),n.d(r,"OMNIBAR",function(){return a}),n.d(r,"OMNIBAR_OVERLAY",function(){return u}),n.d(r,"SELECT",function(){return l}),n.d(r,"SELECT_POPOVER",function(){return c});var o=n(0),i=o.Classes.getClassNamespace(),s=i+"-multi-select",p=s+"-popover",a=i+"-omnibar",u=a+"-overlay",l=i+"-select",c=l+"-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(){var t=null!==e&&e.apply(this,arguments)||this;return t.refHandlers={itemsParent:function(e){return t.itemsParentRef=e}},t.shouldCheckActiveItemInViewport=!1,t.renderItemList=function(e){var n=t.props,r=n.initialContent,i=d(e,n.noResults,r);return h.createElement(o.Menu,{ulRef:e.itemsParentRef},i)},t.renderItem=function(e,n){var r=t.props,o=r.activeItem,i=r.query,s=t.state.filteredItems.indexOf(e)>=0,p={active:o===e,disabled:t.isItemDisabled(e,n),matchesPredicate:s};return t.props.itemRenderer(e,{handleClick:function(n){return t.handleItemSelect(e,n)},index:n,modifiers:p,query:i})},t.handleItemSelect=function(e,n){o.Utils.safeInvoke(t.props.onActiveItemChange,e),o.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleKeyDown=function(e){var n=e.keyCode;if(n===o.Keys.ARROW_UP||n===o.Keys.ARROW_DOWN){e.preventDefault();var r=t.getNextActiveItem(n===o.Keys.ARROW_UP?-1:1);null!=r&&(t.shouldCheckActiveItemInViewport=!0,o.Utils.safeInvoke(t.props.onActiveItemChange,r))}o.Utils.safeInvoke(t.props.onKeyDown,e)},t.handleKeyUp=function(e){var n=t.props,r=n.activeItem,i=n.onItemSelect,s=n.onKeyUp;e.keyCode===o.Keys.ENTER&&null!=r&&(e.preventDefault(),o.Utils.safeInvoke(i,r,e)),o.Utils.safeInvoke(s,e)},t}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.query,i=e.itemListRenderer,s=void 0===i?this.renderItemList:i,p=this.state.filteredItems;return r({className:t,filteredItems:p,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,itemList:s({filteredItems:p,items:n,itemsParentRef:this.refHandlers.itemsParent,query:o,renderItem:this.renderItem}),query:o})},t.prototype.componentWillMount=function(){this.setState({filteredItems:g(this.props)})},t.prototype.componentWillReceiveProps=function(e){e.items===this.props.items&&e.itemListPredicate===this.props.itemListPredicate&&e.itemPredicate===this.props.itemPredicate&&e.query===this.props.query||(this.shouldCheckActiveItemInViewport=!0,this.setState({filteredItems:g(e)}))},t.prototype.componentDidUpdate=function(){var e=this;this.shouldCheckActiveItemInViewport&&(requestAnimationFrame(function(){return e.scrollActiveItemIntoView()}),this.shouldCheckActiveItemInViewport=!1),this.getActiveIndex()<0&&(0!==this.state.filteredItems.length||void 0!==this.props.activeItem)&&o.Utils.safeInvoke(this.props.onActiveItemChange,this.state.filteredItems[0])},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,i=r.scrollTop,s=r.clientHeight,p=this.getItemsParentPadding(),a=p.paddingTop,u=t+n+p.paddingBottom-o,l=t-a-o;u>=i+s?this.itemsParentRef.scrollTop=u+n-s:l<=i&&(this.itemsParentRef.scrollTop=l-n)}},t.prototype.getActiveElement=function(){if(null!=this.itemsParentRef)return this.itemsParentRef.children.item(this.getActiveIndex())},t.prototype.getActiveIndex=function(){var e=this.props.activeItem;return null==e?-1:this.state.filteredItems.indexOf(e)},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){var t=this.state.filteredItems,n=this.getActiveIndex(),r=n,o=t.length-1;do{if(n=P(n+e,0,o),!this.isItemDisabled(t[n],n))return t[n]}while(n!==r)},t.prototype.isItemDisabled=function(e,t){var n=this.props.itemDisabled;return null!=n&&(o.Utils.isFunction(n)?n(e,t):!!e[n])},t.displayName="Blueprint2.QueryList",t}(h.Component);function I(e){return null==e?0:parseInt(e.slice(0,-2),10)}function g(e){var t=e.items,n=e.itemPredicate,r=e.itemListPredicate,i=e.query;return o.Utils.isFunction(r)?r(i,t):o.Utils.isFunction(n)?t.filter(function(e,t){return n(i,e,t)}):t}function P(e,t,n){return e<t?n:e>n?t:e}var O=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={query:""},t.TypedQueryList=y.ofType(),t.refHandlers={queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,i=n.inputProps,s=void 0===i?{}:i,p=n.isOpen,a=n.overlayProps,u=void 0===a?{}:a,l=e.handleKeyDown,c=e.handleKeyUp,d=p&&!t.isQueryEmpty()?{onKeyDown:l,onKeyUp:c}:{};return h.createElement(o.Overlay,v.__assign({hasBackdrop:!0},u,{isOpen:p,className:m()(u.className,r.OMNIBAR_OVERLAY),onClose:t.handleOverlayClose}),h.createElement("div",v.__assign({className:m()(e.className,r.OMNIBAR)},d),h.createElement(o.InputGroup,v.__assign({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search...",value:e.query},s,{onChange:t.handleQueryChange})),e.itemList))},t.isQueryEmpty=function(){return 0===t.state.query.length},t.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.handleItemSelect=function(e,n){t.isQueryEmpty()||o.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleQueryChange=function(e){var n=t.props.inputProps,r=void 0===n?{}:n;t.setState({query:e.currentTarget.value}),o.Utils.safeInvoke(r.onChange,e)},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,{activeItem:this.state.activeItem,initialContent:n,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentWillReceiveProps=function(e){var t=e.isOpen,n=!this.props.isOpen&&t&&this.props.resetOnSelect;this.setState({activeItem:n?this.props.items[0]:this.state.activeItem,query:n?"":this.state.query})},t.displayName="Blueprint2.Omnibar",t}(h.PureComponent),C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,query:""},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,i=n.tagInputProps,s=void 0===i?{}:i,p=n.popoverProps,a=void 0===p?{}:p,u=n.selectedItems,l=void 0===u?[]:u,c=e.handleKeyDown,d=e.handleKeyUp,f=e.query,y=v.__assign({placeholder:"Search..."},s.inputProps,{onChange:t.handleQueryChange,value:f});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,onOpening:t.handlePopoverOpening}),h.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(c),onKeyUp:t.state.isOpen?d:void 0},h.createElement(o.TagInput,v.__assign({},s,{inputProps:y,inputRef:t.refHandlers.input,className:m()(r.MULTISELECT,s.className),values:l.map(t.props.tagRenderer)}))),h.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(c),onKeyUp:d},e.itemList))},t.isQueryEmpty=function(){return 0===t.state.query.length},t.handleQueryChange=function(e){var n=t.props,r=n.tagInputProps,i=void 0===r?{}:r,s=n.openOnKeyDown,p=e.currentTarget.value;t.setState({query:p,isOpen:!t.isQueryEmpty()||!s}),null!=i.inputProps&&o.Utils.safeInvoke(i.inputProps.onChange,e)},t.handleItemSelect=function(e,n){null!=t.input&&t.input.focus(),null!=t.state.activeItem&&(t.props.resetOnSelect&&!t.isQueryEmpty()&&t.setState({activeItem:t.props.items[0],query:""}),o.Utils.safeInvoke(t.props.onItemSelect,e,n))},t.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var n=t.props,r=n.popoverProps,i=void 0===r?{}:r,s=n.resetOnSelect;null!=t.input&&t.input!==document.activeElement?t.setState({activeItem:s?t.props.items[0]:t.state.activeItem,isOpen:!1,query:s?"":t.state.query}):t.props.openOnKeyDown||t.setState({isOpen:!0}),o.Utils.safeInvoke(i.onInteraction,e)})},t.handlePopoverOpening=function(e){var n=t.props,r=n.popoverProps,i=void 0===r?{}:r;n.resetOnSelect&&t.setState({activeItem:t.props.items[0]}),o.Utils.safeInvoke(i.onOpening,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.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,i=t.props.resetOnSelect;r===o.Keys.ESCAPE||r===o.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({activeItem:i?t.props.items[0]:t.state.activeItem,isOpen:!1,query:i?"":t.state.query})):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.resetOnSelect,e.tagInputProps,v.__rest(e,["openOnKeyDown","popoverProps","resetOnSelect","tagInputProps"]));return h.createElement(this.TypedQueryList,v.__assign({},t,{activeItem:this.state.activeItem,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.displayName="Blueprint2.MultiSelect",t}(h.PureComponent),S=function(e){function t(t,n){var i=e.call(this,t,n)||this;i.TypedQueryList=y.ofType(),i.refHandlers={input:function(e){i.input=e;var t=i.props.inputProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return i.list=e}},i.renderQueryList=function(e){var t=i.props,n=t.filterable,s=void 0===n||n,p=t.disabled,a=void 0!==p&&p,u=t.inputProps,l=void 0===u?{}:u,c=t.popoverProps,d=void 0===c?{}:c,f=h.createElement(o.InputGroup,v.__assign({leftIcon:"search",placeholder:"Filter...",rightElement:i.maybeRenderInputClearButton(),value:e.query},l,{inputRef:i.refHandlers.input,onChange:i.handleQueryChange})),y=e.handleKeyDown,I=e.handleKeyUp;return h.createElement(o.Popover,v.__assign({autoFocus:!1,enforceFocus:!1,isOpen:i.state.isOpen,disabled:a,position:o.Position.BOTTOM_LEFT},d,{className:m()(e.className,d.className),onInteraction:i.handlePopoverInteraction,popoverClassName:m()(r.SELECT_POPOVER,d.popoverClassName),onOpening:i.handlePopoverOpening,onOpened:i.handlePopoverOpened,onClosing:i.handlePopoverClosing}),h.createElement("div",{onKeyDown:i.state.isOpen?y:i.handleTargetKeyDown,onKeyUp:i.state.isOpen?I:void 0},i.props.children),h.createElement("div",{onKeyDown:y,onKeyUp:I},s?f:void 0,e.itemList))},i.handleActiveItemChange=function(e){return i.setState({activeItem:e})},i.handleTargetKeyDown=function(e){e.which!==o.Keys.ARROW_UP&&e.which!==o.Keys.ARROW_DOWN||i.setState({isOpen:!0})},i.handleItemSelect=function(e,t){i.setState({isOpen:!1}),i.props.resetOnSelect&&i.resetQuery(),o.Utils.safeInvoke(i.props.onItemSelect,e,t)},i.handlePopoverInteraction=function(e){i.setState({isOpen:e});var t=i.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onInteraction,e)},i.handlePopoverOpening=function(e){var t=i.props,n=t.popoverProps,r=void 0===n?{}:n,s=t.resetOnClose;i.previousFocusedElement=document.activeElement,s&&i.resetQuery(),o.Utils.safeInvoke(r.onOpening,e)},i.handlePopoverOpened=function(e){null!=i.list&&i.list.scrollActiveItemIntoView(),requestAnimationFrame(function(){var e=i.props.inputProps;!1!==(void 0===e?{}:e).autoFocus&&null!=i.input&&i.input.focus()});var t=i.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onOpened,e)},i.handlePopoverClosing=function(e){requestAnimationFrame(function(){void 0!==i.previousFocusedElement&&(i.previousFocusedElement.focus(),i.previousFocusedElement=void 0)});var t=i.props.popoverProps,n=void 0===t?{}:t;o.Utils.safeInvoke(n.onClosing,e)},i.handleQueryChange=function(e){var t=i.props,n=t.inputProps,r=void 0===n?{}:n,s=t.onQueryChange,p=e.currentTarget.value;i.setState({query:p}),o.Utils.safeInvoke(r.onChange,e),o.Utils.safeInvoke(s,p)},i.resetQuery=function(){var e=i.props,t=e.items,n=e.onQueryChange;i.setState({activeItem:t[0],query:""}),o.Utils.safeInvoke(n,"")};var s=t.inputProps,p=void 0===s?{}:s,a=null==p.value?"":p.value.toString();return i.state={isOpen:!1,query:a},i}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,{activeItem:this.state.activeItem,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentWillReceiveProps=function(e){var t=e.inputProps,n=void 0===t?{}:t;void 0!==n.value&&this.state.query!==n.value&&this.setState({query:n.value.toString()})},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.list&&this.list.scrollActiveItemIntoView()},t.prototype.maybeRenderInputClearButton=function(){return 0===this.state.query.length?void 0:h.createElement(o.Button,{icon:"cross",minimal:!0,onClick:this.resetQuery})},t.displayName="Blueprint2.Select",t}(h.PureComponent),q=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,isTyping:!1,query:""},t.TypedQueryList=y.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.inputProps,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,i=n.inputValueRenderer,s=n.inputProps,p=void 0===s?{}:s,a=n.popoverProps,u=void 0===a?{}:a,l=t.state,c=l.isTyping,d=l.selectedItem,f=l.query,y=e.handleKeyDown,I=e.handleKeyUp,g=c?f:d?i(d):"";return h.createElement(o.Popover,v.__assign({autoFocus:!1,enforceFocus:!1,isOpen:t.state.isOpen,position:o.Position.BOTTOM_LEFT},u,{className:m()(e.className,u.className),onInteraction:t.handlePopoverInteraction,popoverClassName:m()(r.SELECT_POPOVER,u.popoverClassName),onOpened:t.handlePopoverOpened,onClosing:t.handlePopoverClosing}),h.createElement(o.InputGroup,v.__assign({placeholder:"Search...",value:g},p,{inputRef:t.refHandlers.input,onChange:t.handleQueryChange,onFocus:t.handleInputFocus,onKeyDown:t.getTargetKeyDownHandler(y),onKeyUp:t.getTargetKeyUpHandler(I)})),h.createElement("div",{onKeyDown:y,onKeyUp:I},e.itemList))},t.selectText=function(){requestAnimationFrame(function(){null!=t.input&&t.input.setSelectionRange(0,t.input.value.length)})},t.handleInputFocus=function(e){var n=t.props,r=n.openOnKeyDown,i=n.inputProps,s=void 0===i?{}:i;t.selectText(),r||t.setState({isOpen:!0}),o.Utils.safeInvoke(s.onFocus,e)},t.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.handleItemSelect=function(e,n){var r;t.props.closeOnSelect?(null!=t.input&&t.input.blur(),r=!1):(null!=t.input&&t.input.focus(),t.selectText(),r=!0),t.setState({isOpen:r,isTyping:!1,query:"",selectedItem:e}),o.Utils.safeInvoke(t.props.onItemSelect,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}),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.handlePopoverClosing=function(e){var n=t.props.popoverProps,r=void 0===n?{}:n,i=t.state.selectedItem;t.setState({activeItem:i||t.props.items[0],query:""}),o.Utils.safeInvoke(r.onClosing,e)},t.handleQueryChange=function(e){var n=t.props.inputProps,r=void 0===n?{}:n;t.setState({isTyping:!0,query:e.currentTarget.value}),o.Utils.safeInvoke(r.onChange,e)},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,i=t.state,s=i.isTyping,p=i.selectedItem,a=t.props,u=a.inputProps,l=void 0===u?{}:u,c=a.openOnKeyDown;r===o.Keys.ESCAPE||r===o.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({isOpen:!1,selectedItem:s?void 0:p})):c&&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),o.Utils.safeInvoke(l.onKeyDown,n)}},t.getTargetKeyUpHandler=function(e){return function(n){var r=t.props.inputProps,i=void 0===r?{}:r;t.state.isOpen&&o.Utils.safeInvoke(e,n),o.Utils.safeInvoke(i.onKeyUp,n)}},t}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,{activeItem:this.state.activeItem,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.componentDidUpdate=function(e,t){this.state.isOpen&&!t.isOpen&&null!=this.queryList&&this.queryList.scrollActiveItemIntoView()},t.displayName="Blueprint2.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 O}),n.d(t,"QueryList",function(){return y}),n.d(t,"MultiSelect",function(){return C}),n.d(t,"Select",function(){return S}),n.d(t,"Suggest",function(){return q})}])}); |
@@ -16,1 +16,2 @@ "use strict"; | ||
exports.SELECT_POPOVER = exports.SELECT + "-popover"; | ||
//# sourceMappingURL=classes.js.map |
@@ -12,1 +12,2 @@ "use strict"; | ||
tslib_1.__exportStar(require("./itemListRenderer"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -35,3 +35,3 @@ /// <reference types="react" /> | ||
*/ | ||
renderItem: (item: T, index?: number) => JSX.Element | null; | ||
renderItem: (item: T, index: number) => JSX.Element | null; | ||
} | ||
@@ -38,0 +38,0 @@ /** Type alias for a function that renders the list of items. */ |
@@ -21,1 +21,2 @@ "use strict"; | ||
exports.renderFilteredItems = renderFilteredItems; | ||
//# sourceMappingURL=itemListRenderer.js.map |
@@ -8,1 +8,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=itemRenderer.js.map |
@@ -11,2 +11,8 @@ /// <reference types="react" /> | ||
/** | ||
* Determine if the given item is disabled. Provide a callback function, or | ||
* simply provide the name of a boolean property on the item that exposes | ||
* its disabled state. | ||
*/ | ||
itemDisabled?: keyof T | ((item: T, index: number) => boolean); | ||
/** | ||
* Customize querying of entire `items` array. Return new list of items. | ||
@@ -13,0 +19,0 @@ * This method can reorder, add, or remove items at will. |
@@ -8,1 +8,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=listItemsProps.js.map |
@@ -8,1 +8,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=predicate.js.map |
@@ -14,1 +14,2 @@ "use strict"; | ||
tslib_1.__exportStar(require("./select/suggest"), exports); | ||
//# sourceMappingURL=index.js.map |
/// <reference types="react" /> | ||
import * as React from "react"; | ||
import { HTMLInputProps, IBackdropProps, IInputGroupProps, IOverlayableProps, IOverlayProps } from "@blueprintjs/core"; | ||
import { HTMLInputProps, IInputGroupProps, IOverlayProps } from "@blueprintjs/core"; | ||
import { IListItemsProps } from "../../common"; | ||
@@ -18,11 +18,14 @@ export interface IOmnibarProps<T> extends IListItemsProps<T> { | ||
/** | ||
* A callback that is invoked when user interaction causes the overlay to close, such as | ||
* clicking on the overlay or pressing the `esc` key (if enabled). | ||
* Receives the event from the user's interaction, if there was an event (generally either a | ||
* mouse or key event). Note that, since this component is controlled by the `isOpen` prop, it | ||
* will not actually close itself until that prop becomes `false`. | ||
* A callback that is invoked when user interaction causes the omnibar to | ||
* close, such as clicking on the overlay or pressing the `esc` key (if | ||
* enabled). Receives the event from the user's interaction, if there was an | ||
* event (generally either a mouse or key event). | ||
* | ||
* Note that due to controlled usage, this component will not actually close | ||
* itself until the `isOpen` prop becomes `false`. | ||
* . | ||
*/ | ||
onClose?: (event?: React.SyntheticEvent<HTMLElement>) => void; | ||
/** Props to spread to `Overlay`. Note that `content` cannot be changed. */ | ||
overlayProps?: Partial<IOverlayProps> & object; | ||
/** Props to spread to `Overlay`. */ | ||
overlayProps?: Partial<IOverlayProps>; | ||
/** | ||
@@ -36,3 +39,3 @@ * Whether the filtering state should be reset to initial when an item is selected | ||
} | ||
export interface IOmnibarState<T> extends IOverlayableProps, IBackdropProps { | ||
export interface IOmnibarState<T> { | ||
activeItem?: T; | ||
@@ -39,0 +42,0 @@ query: string; |
@@ -47,2 +47,4 @@ "use strict"; | ||
_this.handleOverlayClose = function (event) { | ||
var _a = _this.props.overlayProps, overlayProps = _a === void 0 ? {} : _a; | ||
core_1.Utils.safeInvoke(overlayProps.onClose, event); | ||
core_1.Utils.safeInvoke(_this.props.onClose, event); | ||
@@ -72,1 +74,2 @@ }; | ||
exports.Omnibar = Omnibar; | ||
//# sourceMappingURL=omnibar.js.map |
@@ -98,3 +98,9 @@ /// <reference types="react" /> | ||
private handleKeyUp; | ||
private moveActiveIndex(direction); | ||
/** | ||
* Get the next enabled item, moving in the given direction from the current | ||
* index. An `undefined` return value means no suitable item was found. | ||
* @param direction amount to move in each iteration, typically +/-1 | ||
*/ | ||
private getNextActiveItem(direction); | ||
private isItemDisabled(item, index); | ||
} |
@@ -36,3 +36,3 @@ "use strict"; | ||
active: activeItem === item, | ||
disabled: false, | ||
disabled: _this.isItemDisabled(item, index), | ||
matchesPredicate: matchesPredicate, | ||
@@ -52,13 +52,11 @@ }; | ||
_this.handleKeyDown = function (event) { | ||
switch (event.keyCode) { | ||
case core_1.Keys.ARROW_UP: | ||
event.preventDefault(); | ||
_this.moveActiveIndex(-1); | ||
break; | ||
case core_1.Keys.ARROW_DOWN: | ||
event.preventDefault(); | ||
_this.moveActiveIndex(1); | ||
break; | ||
default: | ||
break; | ||
var keyCode = event.keyCode; | ||
if (keyCode === core_1.Keys.ARROW_UP || keyCode === core_1.Keys.ARROW_DOWN) { | ||
event.preventDefault(); | ||
var nextActiveItem = _this.getNextActiveItem(keyCode === core_1.Keys.ARROW_UP ? -1 : 1); | ||
if (nextActiveItem != null) { | ||
// indicate that the active item may need to be scrolled into view after update. | ||
_this.shouldCheckActiveItemInViewport = true; | ||
core_1.Utils.safeInvoke(_this.props.onActiveItemChange, nextActiveItem); | ||
} | ||
} | ||
@@ -169,11 +167,34 @@ core_1.Utils.safeInvoke(_this.props.onKeyDown, event); | ||
}; | ||
QueryList.prototype.moveActiveIndex = function (direction) { | ||
// indicate that the active item may need to be scrolled into view after update. | ||
// this is not possible with mouse hover cuz you can't hover on something off screen. | ||
this.shouldCheckActiveItemInViewport = true; | ||
/** | ||
* Get the next enabled item, moving in the given direction from the current | ||
* index. An `undefined` return value means no suitable item was found. | ||
* @param direction amount to move in each iteration, typically +/-1 | ||
*/ | ||
QueryList.prototype.getNextActiveItem = function (direction) { | ||
var filteredItems = this.state.filteredItems; | ||
var maxIndex = Math.max(filteredItems.length - 1, 0); | ||
var nextActiveIndex = core_1.Utils.clamp(this.getActiveIndex() + direction, 0, maxIndex); | ||
core_1.Utils.safeInvoke(this.props.onActiveItemChange, filteredItems[nextActiveIndex]); | ||
var index = this.getActiveIndex(); | ||
// remember where we started to prevent an infinite loop | ||
var startIndex = index; | ||
var maxIndex = filteredItems.length - 1; | ||
do { | ||
// find first non-disabled item | ||
index = wrapNumber(index + direction, 0, maxIndex); | ||
if (!this.isItemDisabled(filteredItems[index], index)) { | ||
return filteredItems[index]; | ||
} | ||
} while (index !== startIndex); | ||
return undefined; | ||
}; | ||
QueryList.prototype.isItemDisabled = function (item, index) { | ||
var itemDisabled = this.props.itemDisabled; | ||
if (itemDisabled == null) { | ||
return false; | ||
} | ||
else if (core_1.Utils.isFunction(itemDisabled)) { | ||
return itemDisabled(item, index); | ||
} | ||
else { | ||
return !!item[itemDisabled]; | ||
} | ||
}; | ||
QueryList.displayName = "Blueprint2.QueryList"; | ||
@@ -197,1 +218,12 @@ return QueryList; | ||
} | ||
/** Wrap number around min/max values: if it exceeds one bound, return the other. */ | ||
function wrapNumber(value, min, max) { | ||
if (value < min) { | ||
return max; | ||
} | ||
else if (value > max) { | ||
return min; | ||
} | ||
return value; | ||
} | ||
//# sourceMappingURL=queryList.js.map |
@@ -46,6 +46,6 @@ /// <reference types="react" /> | ||
private handlePopoverInteraction; | ||
private handlePopoverWillOpen; | ||
private handlePopoverDidOpen; | ||
private handlePopoverOpening; | ||
private handlePopoverOpened; | ||
private handleActiveItemChange; | ||
private getTargetKeyDownHandler; | ||
} |
@@ -34,3 +34,3 @@ "use strict"; | ||
var defaultInputProps = tslib_1.__assign({ placeholder: "Search..." }, tagInputProps.inputProps, { onChange: _this.handleQueryChange, value: query }); | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ autoFocus: false, canEscapeKeyClose: true, enforceFocus: false, isOpen: _this.state.isOpen, position: core_1.Position.BOTTOM_LEFT }, popoverProps, { className: classnames_1.default(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classnames_1.default(common_1.Classes.MULTISELECT_POPOVER, popoverProps.popoverClassName), popoverDidOpen: _this.handlePopoverDidOpen, popoverWillOpen: _this.handlePopoverWillOpen }), | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ autoFocus: false, canEscapeKeyClose: true, enforceFocus: false, isOpen: _this.state.isOpen, position: core_1.Position.BOTTOM_LEFT }, popoverProps, { className: classnames_1.default(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classnames_1.default(common_1.Classes.MULTISELECT_POPOVER, popoverProps.popoverClassName), onOpened: _this.handlePopoverOpened, onOpening: _this.handlePopoverOpening }), | ||
React.createElement("div", { onKeyDown: _this.getTargetKeyDownHandler(handleKeyDown), onKeyUp: _this.state.isOpen ? handleKeyUp : undefined }, | ||
@@ -83,3 +83,3 @@ React.createElement(core_1.TagInput, tslib_1.__assign({}, tagInputProps, { inputProps: defaultInputProps, inputRef: _this.refHandlers.input, className: classnames_1.default(common_1.Classes.MULTISELECT, tagInputProps.className), values: selectedItems.map(_this.props.tagRenderer) }))), | ||
}; | ||
_this.handlePopoverWillOpen = function () { | ||
_this.handlePopoverOpening = function (node) { | ||
var _a = _this.props, _b = _a.popoverProps, popoverProps = _b === void 0 ? {} : _b, resetOnSelect = _a.resetOnSelect; | ||
@@ -89,5 +89,5 @@ if (resetOnSelect) { | ||
} | ||
core_1.Utils.safeInvoke(popoverProps.popoverWillOpen); | ||
core_1.Utils.safeInvoke(popoverProps.onOpening, node); | ||
}; | ||
_this.handlePopoverDidOpen = function () { | ||
_this.handlePopoverOpened = function (node) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
@@ -98,3 +98,3 @@ if (_this.queryList != null) { | ||
} | ||
core_1.Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
core_1.Utils.safeInvoke(popoverProps.onOpened, node); | ||
}; | ||
@@ -140,1 +140,2 @@ _this.handleActiveItemChange = function (activeItem) { return _this.setState({ activeItem: activeItem }); }; | ||
exports.MultiSelect = MultiSelect; | ||
//# sourceMappingURL=multiSelect.js.map |
@@ -68,7 +68,7 @@ /// <reference types="react" /> | ||
private handlePopoverInteraction; | ||
private handlePopoverWillOpen; | ||
private handlePopoverDidOpen; | ||
private handlePopoverWillClose; | ||
private handlePopoverOpening; | ||
private handlePopoverOpened; | ||
private handlePopoverClosing; | ||
private handleQueryChange; | ||
private resetQuery; | ||
} |
@@ -30,5 +30,5 @@ "use strict"; | ||
var _a = _this.props, _b = _a.filterable, filterable = _b === void 0 ? true : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.inputProps, inputProps = _d === void 0 ? {} : _d, _e = _a.popoverProps, popoverProps = _e === void 0 ? {} : _e; | ||
var input = (React.createElement(core_1.InputGroup, tslib_1.__assign({ autoFocus: true, leftIcon: "search", placeholder: "Filter...", rightElement: _this.maybeRenderInputClearButton(), value: listProps.query }, inputProps, { inputRef: _this.refHandlers.input, onChange: _this.handleQueryChange }))); | ||
var input = (React.createElement(core_1.InputGroup, tslib_1.__assign({ leftIcon: "search", placeholder: "Filter...", rightElement: _this.maybeRenderInputClearButton(), value: listProps.query }, inputProps, { inputRef: _this.refHandlers.input, onChange: _this.handleQueryChange }))); | ||
var handleKeyDown = listProps.handleKeyDown, handleKeyUp = listProps.handleKeyUp; | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, disabled: disabled, position: core_1.Position.BOTTOM_LEFT }, popoverProps, { className: classnames_1.default(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classnames_1.default(common_1.Classes.SELECT_POPOVER, popoverProps.popoverClassName), popoverWillOpen: _this.handlePopoverWillOpen, popoverDidOpen: _this.handlePopoverDidOpen, popoverWillClose: _this.handlePopoverWillClose }), | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, disabled: disabled, position: core_1.Position.BOTTOM_LEFT }, popoverProps, { className: classnames_1.default(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classnames_1.default(common_1.Classes.SELECT_POPOVER, popoverProps.popoverClassName), onOpening: _this.handlePopoverOpening, onOpened: _this.handlePopoverOpened, onClosing: _this.handlePopoverClosing }), | ||
React.createElement("div", { onKeyDown: _this.state.isOpen ? handleKeyDown : _this.handleTargetKeyDown, onKeyUp: _this.state.isOpen ? handleKeyUp : undefined }, _this.props.children), | ||
@@ -58,3 +58,3 @@ React.createElement("div", { onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }, | ||
}; | ||
_this.handlePopoverWillOpen = function () { | ||
_this.handlePopoverOpening = function (node) { | ||
var _a = _this.props, _b = _a.popoverProps, popoverProps = _b === void 0 ? {} : _b, resetOnClose = _a.resetOnClose; | ||
@@ -66,5 +66,5 @@ // save currently focused element before popover steals focus, so we can restore it when closing. | ||
} | ||
core_1.Utils.safeInvoke(popoverProps.popoverWillOpen); | ||
core_1.Utils.safeInvoke(popoverProps.onOpening, node); | ||
}; | ||
_this.handlePopoverDidOpen = function () { | ||
_this.handlePopoverOpened = function (node) { | ||
// scroll active item into view after popover transition completes and all dimensions are stable. | ||
@@ -82,5 +82,5 @@ if (_this.list != null) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
core_1.Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
core_1.Utils.safeInvoke(popoverProps.onOpened, node); | ||
}; | ||
_this.handlePopoverWillClose = function () { | ||
_this.handlePopoverClosing = function (node) { | ||
// restore focus to saved element. | ||
@@ -95,3 +95,3 @@ // timeout allows popover to begin closing and remove focus handlers beforehand. | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
core_1.Utils.safeInvoke(popoverProps.popoverWillClose); | ||
core_1.Utils.safeInvoke(popoverProps.onClosing, node); | ||
}; | ||
@@ -142,1 +142,2 @@ _this.handleQueryChange = function (event) { | ||
exports.Select = Select; | ||
//# sourceMappingURL=select.js.map |
@@ -54,4 +54,4 @@ /// <reference types="react" /> | ||
private handlePopoverInteraction; | ||
private handlePopoverDidOpen; | ||
private handlePopoverWillClose; | ||
private handlePopoverOpened; | ||
private handlePopoverClosing; | ||
private handleQueryChange; | ||
@@ -58,0 +58,0 @@ private getTargetKeyDownHandler; |
@@ -37,3 +37,3 @@ "use strict"; | ||
var inputValue = isTyping ? query : selectedItem ? inputValueRenderer(selectedItem) : ""; | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, position: core_1.Position.BOTTOM_LEFT }, popoverProps, { className: classnames_1.default(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classnames_1.default(common_1.Classes.SELECT_POPOVER, popoverProps.popoverClassName), popoverDidOpen: _this.handlePopoverDidOpen, popoverWillClose: _this.handlePopoverWillClose }), | ||
return (React.createElement(core_1.Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, position: core_1.Position.BOTTOM_LEFT }, popoverProps, { className: classnames_1.default(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classnames_1.default(common_1.Classes.SELECT_POPOVER, popoverProps.popoverClassName), onOpened: _this.handlePopoverOpened, onClosing: _this.handlePopoverClosing }), | ||
React.createElement(core_1.InputGroup, tslib_1.__assign({ placeholder: "Search...", value: inputValue }, inputProps, { inputRef: _this.refHandlers.input, onChange: _this.handleQueryChange, onFocus: _this.handleInputFocus, onKeyDown: _this.getTargetKeyDownHandler(handleKeyDown), onKeyUp: _this.getTargetKeyUpHandler(handleKeyUp) })), | ||
@@ -92,3 +92,3 @@ React.createElement("div", { onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }, listProps.itemList))); | ||
}; | ||
_this.handlePopoverDidOpen = function () { | ||
_this.handlePopoverOpened = function (node) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
@@ -99,5 +99,5 @@ // scroll active item into view after popover transition completes and all dimensions are stable. | ||
} | ||
core_1.Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
core_1.Utils.safeInvoke(popoverProps.onOpened, node); | ||
}; | ||
_this.handlePopoverWillClose = function () { | ||
_this.handlePopoverClosing = function (node) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
@@ -111,3 +111,3 @@ var selectedItem = _this.state.selectedItem; | ||
}); | ||
core_1.Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
core_1.Utils.safeInvoke(popoverProps.onClosing, node); | ||
}; | ||
@@ -181,1 +181,2 @@ _this.handleQueryChange = function (event) { | ||
exports.Suggest = Suggest; | ||
//# sourceMappingURL=suggest.js.map |
@@ -11,1 +11,2 @@ "use strict"; | ||
tslib_1.__exportStar(require("./components"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -14,1 +14,2 @@ /* | ||
export var SELECT_POPOVER = SELECT + "-popover"; | ||
//# sourceMappingURL=classes.js.map |
@@ -9,1 +9,2 @@ /* | ||
export * from "./itemListRenderer"; | ||
//# sourceMappingURL=index.js.map |
@@ -35,3 +35,3 @@ /// <reference types="react" /> | ||
*/ | ||
renderItem: (item: T, index?: number) => JSX.Element | null; | ||
renderItem: (item: T, index: number) => JSX.Element | null; | ||
} | ||
@@ -38,0 +38,0 @@ /** Type alias for a function that renders the list of items. */ |
@@ -18,1 +18,2 @@ /* | ||
} | ||
//# sourceMappingURL=itemListRenderer.js.map |
@@ -6,1 +6,2 @@ /* | ||
*/ | ||
//# sourceMappingURL=itemRenderer.js.map |
@@ -11,2 +11,8 @@ /// <reference types="react" /> | ||
/** | ||
* Determine if the given item is disabled. Provide a callback function, or | ||
* simply provide the name of a boolean property on the item that exposes | ||
* its disabled state. | ||
*/ | ||
itemDisabled?: keyof T | ((item: T, index: number) => boolean); | ||
/** | ||
* Customize querying of entire `items` array. Return new list of items. | ||
@@ -13,0 +19,0 @@ * This method can reorder, add, or remove items at will. |
@@ -6,1 +6,2 @@ /* | ||
*/ | ||
//# sourceMappingURL=listItemsProps.js.map |
@@ -6,1 +6,2 @@ /* | ||
*/ | ||
//# sourceMappingURL=predicate.js.map |
@@ -11,1 +11,2 @@ /* | ||
export * from "./select/suggest"; | ||
//# sourceMappingURL=index.js.map |
/// <reference types="react" /> | ||
import * as React from "react"; | ||
import { HTMLInputProps, IBackdropProps, IInputGroupProps, IOverlayableProps, IOverlayProps } from "@blueprintjs/core"; | ||
import { HTMLInputProps, IInputGroupProps, IOverlayProps } from "@blueprintjs/core"; | ||
import { IListItemsProps } from "../../common"; | ||
@@ -18,11 +18,14 @@ export interface IOmnibarProps<T> extends IListItemsProps<T> { | ||
/** | ||
* A callback that is invoked when user interaction causes the overlay to close, such as | ||
* clicking on the overlay or pressing the `esc` key (if enabled). | ||
* Receives the event from the user's interaction, if there was an event (generally either a | ||
* mouse or key event). Note that, since this component is controlled by the `isOpen` prop, it | ||
* will not actually close itself until that prop becomes `false`. | ||
* A callback that is invoked when user interaction causes the omnibar to | ||
* close, such as clicking on the overlay or pressing the `esc` key (if | ||
* enabled). Receives the event from the user's interaction, if there was an | ||
* event (generally either a mouse or key event). | ||
* | ||
* Note that due to controlled usage, this component will not actually close | ||
* itself until the `isOpen` prop becomes `false`. | ||
* . | ||
*/ | ||
onClose?: (event?: React.SyntheticEvent<HTMLElement>) => void; | ||
/** Props to spread to `Overlay`. Note that `content` cannot be changed. */ | ||
overlayProps?: Partial<IOverlayProps> & object; | ||
/** Props to spread to `Overlay`. */ | ||
overlayProps?: Partial<IOverlayProps>; | ||
/** | ||
@@ -36,3 +39,3 @@ * Whether the filtering state should be reset to initial when an item is selected | ||
} | ||
export interface IOmnibarState<T> extends IOverlayableProps, IBackdropProps { | ||
export interface IOmnibarState<T> { | ||
activeItem?: T; | ||
@@ -39,0 +42,0 @@ query: string; |
@@ -9,3 +9,3 @@ /* | ||
import * as React from "react"; | ||
import { InputGroup, Overlay, Utils, } from "@blueprintjs/core"; | ||
import { InputGroup, Overlay, Utils } from "@blueprintjs/core"; | ||
import { Classes } from "../../common"; | ||
@@ -46,2 +46,4 @@ import { QueryList } from "../query-list/queryList"; | ||
_this.handleOverlayClose = function (event) { | ||
var _a = _this.props.overlayProps, overlayProps = _a === void 0 ? {} : _a; | ||
Utils.safeInvoke(overlayProps.onClose, event); | ||
Utils.safeInvoke(_this.props.onClose, event); | ||
@@ -71,1 +73,2 @@ }; | ||
export { Omnibar }; | ||
//# sourceMappingURL=omnibar.js.map |
@@ -98,3 +98,9 @@ /// <reference types="react" /> | ||
private handleKeyUp; | ||
private moveActiveIndex(direction); | ||
/** | ||
* Get the next enabled item, moving in the given direction from the current | ||
* index. An `undefined` return value means no suitable item was found. | ||
* @param direction amount to move in each iteration, typically +/-1 | ||
*/ | ||
private getNextActiveItem(direction); | ||
private isItemDisabled(item, index); | ||
} |
@@ -34,3 +34,3 @@ /* | ||
active: activeItem === item, | ||
disabled: false, | ||
disabled: _this.isItemDisabled(item, index), | ||
matchesPredicate: matchesPredicate, | ||
@@ -50,13 +50,11 @@ }; | ||
_this.handleKeyDown = function (event) { | ||
switch (event.keyCode) { | ||
case Keys.ARROW_UP: | ||
event.preventDefault(); | ||
_this.moveActiveIndex(-1); | ||
break; | ||
case Keys.ARROW_DOWN: | ||
event.preventDefault(); | ||
_this.moveActiveIndex(1); | ||
break; | ||
default: | ||
break; | ||
var keyCode = event.keyCode; | ||
if (keyCode === Keys.ARROW_UP || keyCode === Keys.ARROW_DOWN) { | ||
event.preventDefault(); | ||
var nextActiveItem = _this.getNextActiveItem(keyCode === Keys.ARROW_UP ? -1 : 1); | ||
if (nextActiveItem != null) { | ||
// indicate that the active item may need to be scrolled into view after update. | ||
_this.shouldCheckActiveItemInViewport = true; | ||
Utils.safeInvoke(_this.props.onActiveItemChange, nextActiveItem); | ||
} | ||
} | ||
@@ -167,11 +165,34 @@ Utils.safeInvoke(_this.props.onKeyDown, event); | ||
}; | ||
QueryList.prototype.moveActiveIndex = function (direction) { | ||
// indicate that the active item may need to be scrolled into view after update. | ||
// this is not possible with mouse hover cuz you can't hover on something off screen. | ||
this.shouldCheckActiveItemInViewport = true; | ||
/** | ||
* Get the next enabled item, moving in the given direction from the current | ||
* index. An `undefined` return value means no suitable item was found. | ||
* @param direction amount to move in each iteration, typically +/-1 | ||
*/ | ||
QueryList.prototype.getNextActiveItem = function (direction) { | ||
var filteredItems = this.state.filteredItems; | ||
var maxIndex = Math.max(filteredItems.length - 1, 0); | ||
var nextActiveIndex = Utils.clamp(this.getActiveIndex() + direction, 0, maxIndex); | ||
Utils.safeInvoke(this.props.onActiveItemChange, filteredItems[nextActiveIndex]); | ||
var index = this.getActiveIndex(); | ||
// remember where we started to prevent an infinite loop | ||
var startIndex = index; | ||
var maxIndex = filteredItems.length - 1; | ||
do { | ||
// find first non-disabled item | ||
index = wrapNumber(index + direction, 0, maxIndex); | ||
if (!this.isItemDisabled(filteredItems[index], index)) { | ||
return filteredItems[index]; | ||
} | ||
} while (index !== startIndex); | ||
return undefined; | ||
}; | ||
QueryList.prototype.isItemDisabled = function (item, index) { | ||
var itemDisabled = this.props.itemDisabled; | ||
if (itemDisabled == null) { | ||
return false; | ||
} | ||
else if (Utils.isFunction(itemDisabled)) { | ||
return itemDisabled(item, index); | ||
} | ||
else { | ||
return !!item[itemDisabled]; | ||
} | ||
}; | ||
QueryList.displayName = "Blueprint2.QueryList"; | ||
@@ -195,1 +216,12 @@ return QueryList; | ||
} | ||
/** Wrap number around min/max values: if it exceeds one bound, return the other. */ | ||
function wrapNumber(value, min, max) { | ||
if (value < min) { | ||
return max; | ||
} | ||
else if (value > max) { | ||
return min; | ||
} | ||
return value; | ||
} | ||
//# sourceMappingURL=queryList.js.map |
@@ -46,6 +46,6 @@ /// <reference types="react" /> | ||
private handlePopoverInteraction; | ||
private handlePopoverWillOpen; | ||
private handlePopoverDidOpen; | ||
private handlePopoverOpening; | ||
private handlePopoverOpened; | ||
private handleActiveItemChange; | ||
private getTargetKeyDownHandler; | ||
} |
@@ -32,3 +32,3 @@ /* | ||
var defaultInputProps = tslib_1.__assign({ placeholder: "Search..." }, tagInputProps.inputProps, { onChange: _this.handleQueryChange, value: query }); | ||
return (React.createElement(Popover, tslib_1.__assign({ autoFocus: false, canEscapeKeyClose: true, enforceFocus: false, isOpen: _this.state.isOpen, position: Position.BOTTOM_LEFT }, popoverProps, { className: classNames(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classNames(Classes.MULTISELECT_POPOVER, popoverProps.popoverClassName), popoverDidOpen: _this.handlePopoverDidOpen, popoverWillOpen: _this.handlePopoverWillOpen }), | ||
return (React.createElement(Popover, tslib_1.__assign({ autoFocus: false, canEscapeKeyClose: true, enforceFocus: false, isOpen: _this.state.isOpen, position: Position.BOTTOM_LEFT }, popoverProps, { className: classNames(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classNames(Classes.MULTISELECT_POPOVER, popoverProps.popoverClassName), onOpened: _this.handlePopoverOpened, onOpening: _this.handlePopoverOpening }), | ||
React.createElement("div", { onKeyDown: _this.getTargetKeyDownHandler(handleKeyDown), onKeyUp: _this.state.isOpen ? handleKeyUp : undefined }, | ||
@@ -81,3 +81,3 @@ React.createElement(TagInput, tslib_1.__assign({}, tagInputProps, { inputProps: defaultInputProps, inputRef: _this.refHandlers.input, className: classNames(Classes.MULTISELECT, tagInputProps.className), values: selectedItems.map(_this.props.tagRenderer) }))), | ||
}; | ||
_this.handlePopoverWillOpen = function () { | ||
_this.handlePopoverOpening = function (node) { | ||
var _a = _this.props, _b = _a.popoverProps, popoverProps = _b === void 0 ? {} : _b, resetOnSelect = _a.resetOnSelect; | ||
@@ -87,5 +87,5 @@ if (resetOnSelect) { | ||
} | ||
Utils.safeInvoke(popoverProps.popoverWillOpen); | ||
Utils.safeInvoke(popoverProps.onOpening, node); | ||
}; | ||
_this.handlePopoverDidOpen = function () { | ||
_this.handlePopoverOpened = function (node) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
@@ -96,3 +96,3 @@ if (_this.queryList != null) { | ||
} | ||
Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
Utils.safeInvoke(popoverProps.onOpened, node); | ||
}; | ||
@@ -138,1 +138,2 @@ _this.handleActiveItemChange = function (activeItem) { return _this.setState({ activeItem: activeItem }); }; | ||
export { MultiSelect }; | ||
//# sourceMappingURL=multiSelect.js.map |
@@ -68,7 +68,7 @@ /// <reference types="react" /> | ||
private handlePopoverInteraction; | ||
private handlePopoverWillOpen; | ||
private handlePopoverDidOpen; | ||
private handlePopoverWillClose; | ||
private handlePopoverOpening; | ||
private handlePopoverOpened; | ||
private handlePopoverClosing; | ||
private handleQueryChange; | ||
private resetQuery; | ||
} |
@@ -28,5 +28,5 @@ /* | ||
var _a = _this.props, _b = _a.filterable, filterable = _b === void 0 ? true : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.inputProps, inputProps = _d === void 0 ? {} : _d, _e = _a.popoverProps, popoverProps = _e === void 0 ? {} : _e; | ||
var input = (React.createElement(InputGroup, tslib_1.__assign({ autoFocus: true, leftIcon: "search", placeholder: "Filter...", rightElement: _this.maybeRenderInputClearButton(), value: listProps.query }, inputProps, { inputRef: _this.refHandlers.input, onChange: _this.handleQueryChange }))); | ||
var input = (React.createElement(InputGroup, tslib_1.__assign({ leftIcon: "search", placeholder: "Filter...", rightElement: _this.maybeRenderInputClearButton(), value: listProps.query }, inputProps, { inputRef: _this.refHandlers.input, onChange: _this.handleQueryChange }))); | ||
var handleKeyDown = listProps.handleKeyDown, handleKeyUp = listProps.handleKeyUp; | ||
return (React.createElement(Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, disabled: disabled, position: Position.BOTTOM_LEFT }, popoverProps, { className: classNames(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classNames(Classes.SELECT_POPOVER, popoverProps.popoverClassName), popoverWillOpen: _this.handlePopoverWillOpen, popoverDidOpen: _this.handlePopoverDidOpen, popoverWillClose: _this.handlePopoverWillClose }), | ||
return (React.createElement(Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, disabled: disabled, position: Position.BOTTOM_LEFT }, popoverProps, { className: classNames(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classNames(Classes.SELECT_POPOVER, popoverProps.popoverClassName), onOpening: _this.handlePopoverOpening, onOpened: _this.handlePopoverOpened, onClosing: _this.handlePopoverClosing }), | ||
React.createElement("div", { onKeyDown: _this.state.isOpen ? handleKeyDown : _this.handleTargetKeyDown, onKeyUp: _this.state.isOpen ? handleKeyUp : undefined }, _this.props.children), | ||
@@ -56,3 +56,3 @@ React.createElement("div", { onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }, | ||
}; | ||
_this.handlePopoverWillOpen = function () { | ||
_this.handlePopoverOpening = function (node) { | ||
var _a = _this.props, _b = _a.popoverProps, popoverProps = _b === void 0 ? {} : _b, resetOnClose = _a.resetOnClose; | ||
@@ -64,5 +64,5 @@ // save currently focused element before popover steals focus, so we can restore it when closing. | ||
} | ||
Utils.safeInvoke(popoverProps.popoverWillOpen); | ||
Utils.safeInvoke(popoverProps.onOpening, node); | ||
}; | ||
_this.handlePopoverDidOpen = function () { | ||
_this.handlePopoverOpened = function (node) { | ||
// scroll active item into view after popover transition completes and all dimensions are stable. | ||
@@ -80,5 +80,5 @@ if (_this.list != null) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
Utils.safeInvoke(popoverProps.onOpened, node); | ||
}; | ||
_this.handlePopoverWillClose = function () { | ||
_this.handlePopoverClosing = function (node) { | ||
// restore focus to saved element. | ||
@@ -93,3 +93,3 @@ // timeout allows popover to begin closing and remove focus handlers beforehand. | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
Utils.safeInvoke(popoverProps.popoverWillClose); | ||
Utils.safeInvoke(popoverProps.onClosing, node); | ||
}; | ||
@@ -140,1 +140,2 @@ _this.handleQueryChange = function (event) { | ||
export { Select }; | ||
//# sourceMappingURL=select.js.map |
@@ -54,4 +54,4 @@ /// <reference types="react" /> | ||
private handlePopoverInteraction; | ||
private handlePopoverDidOpen; | ||
private handlePopoverWillClose; | ||
private handlePopoverOpened; | ||
private handlePopoverClosing; | ||
private handleQueryChange; | ||
@@ -58,0 +58,0 @@ private getTargetKeyDownHandler; |
@@ -35,3 +35,3 @@ /* | ||
var inputValue = isTyping ? query : selectedItem ? inputValueRenderer(selectedItem) : ""; | ||
return (React.createElement(Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, position: Position.BOTTOM_LEFT }, popoverProps, { className: classNames(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classNames(Classes.SELECT_POPOVER, popoverProps.popoverClassName), popoverDidOpen: _this.handlePopoverDidOpen, popoverWillClose: _this.handlePopoverWillClose }), | ||
return (React.createElement(Popover, tslib_1.__assign({ autoFocus: false, enforceFocus: false, isOpen: _this.state.isOpen, position: Position.BOTTOM_LEFT }, popoverProps, { className: classNames(listProps.className, popoverProps.className), onInteraction: _this.handlePopoverInteraction, popoverClassName: classNames(Classes.SELECT_POPOVER, popoverProps.popoverClassName), onOpened: _this.handlePopoverOpened, onClosing: _this.handlePopoverClosing }), | ||
React.createElement(InputGroup, tslib_1.__assign({ placeholder: "Search...", value: inputValue }, inputProps, { inputRef: _this.refHandlers.input, onChange: _this.handleQueryChange, onFocus: _this.handleInputFocus, onKeyDown: _this.getTargetKeyDownHandler(handleKeyDown), onKeyUp: _this.getTargetKeyUpHandler(handleKeyUp) })), | ||
@@ -90,3 +90,3 @@ React.createElement("div", { onKeyDown: handleKeyDown, onKeyUp: handleKeyUp }, listProps.itemList))); | ||
}; | ||
_this.handlePopoverDidOpen = function () { | ||
_this.handlePopoverOpened = function (node) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
@@ -97,5 +97,5 @@ // scroll active item into view after popover transition completes and all dimensions are stable. | ||
} | ||
Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
Utils.safeInvoke(popoverProps.onOpened, node); | ||
}; | ||
_this.handlePopoverWillClose = function () { | ||
_this.handlePopoverClosing = function (node) { | ||
var _a = _this.props.popoverProps, popoverProps = _a === void 0 ? {} : _a; | ||
@@ -109,3 +109,3 @@ var selectedItem = _this.state.selectedItem; | ||
}); | ||
Utils.safeInvoke(popoverProps.popoverDidOpen); | ||
Utils.safeInvoke(popoverProps.onClosing, node); | ||
}; | ||
@@ -179,1 +179,2 @@ _this.handleQueryChange = function (event) { | ||
export { Suggest }; | ||
//# sourceMappingURL=suggest.js.map |
@@ -8,1 +8,2 @@ /* | ||
export * from "./components"; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@blueprintjs/select", | ||
"version": "3.0.0-beta.0", | ||
"version": "3.0.0-rc.0", | ||
"description": "Components related to selecting items from a list", | ||
@@ -36,3 +36,3 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@blueprintjs/core": "^3.0.0-beta.0", | ||
"@blueprintjs/core": "^3.0.0-rc.0", | ||
"classnames": "^2.2", | ||
@@ -42,4 +42,4 @@ "tslib": "^1.9.0" | ||
"devDependencies": { | ||
"@blueprintjs/karma-build-scripts": "^0.6.1", | ||
"@blueprintjs/node-build-scripts": "^0.6.1", | ||
"@blueprintjs/karma-build-scripts": "^0.7.0", | ||
"@blueprintjs/node-build-scripts": "^0.6.2", | ||
"enzyme": "^3.3.0", | ||
@@ -52,3 +52,2 @@ "karma": "^1.7.1", | ||
"react-test-renderer": "^16.2.0", | ||
"react-transition-group": "^2.2.1", | ||
"typescript": "~2.7.2", | ||
@@ -55,0 +54,0 @@ "webpack": "^3.10.0" |
@@ -44,3 +44,3 @@ /* | ||
*/ | ||
renderItem: (item: T, index?: number) => JSX.Element | null; | ||
renderItem: (item: T, index: number) => JSX.Element | null; | ||
} | ||
@@ -47,0 +47,0 @@ |
@@ -18,2 +18,9 @@ /* | ||
/** | ||
* Determine if the given item is disabled. Provide a callback function, or | ||
* simply provide the name of a boolean property on the item that exposes | ||
* its disabled state. | ||
*/ | ||
itemDisabled?: keyof T | ((item: T, index: number) => boolean); | ||
/** | ||
* Customize querying of entire `items` array. Return new list of items. | ||
@@ -20,0 +27,0 @@ * This method can reorder, add, or remove items at will. |
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
309145
11
110
4109