@blueprintjs/timezone
Advanced tools
Comparing version 2.0.0-rc.3 to 2.0.0-rc.4
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("classNames"),require("moment")):"function"==typeof define&&define.amd?define(["React","classNames","moment"],t):"object"==typeof exports?exports.Timezone=t(require("React"),require("classNames"),require("moment")):(e.Blueprint=e.Blueprint||{},e.Blueprint.Timezone=t(e.React,e.classNames,e.moment))}("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=4)}([function(t,n){t.exports=e},function(e,t){e.exports=Blueprint.Core},function(e,n){e.exports=t},function(e,t){e.exports=n},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,"TIMEZONE_PICKER",function(){return o}),n.d(r,"TIMEZONE_PICKER_POPOVER",function(){return i});var o="pt-timezone-picker",i=o+"-popover",s=r,a=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 p(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var l=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 u(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 c=n(2),v=n.n(c),m=n(0),d=n(1),f="pt-multi-select",h=f+"-popover",y="pt-omnibar",I=y+"-overlay",P="pt-select-popover",O=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.handleItemSelect=function(e,n){d.Utils.safeInvoke(t.props.onActiveItemChange,e),d.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleKeyDown=function(e){switch(e.keyCode){case d.Keys.ARROW_UP:e.preventDefault(),t.moveActiveIndex(-1);break;case d.Keys.ARROW_DOWN:e.preventDefault(),t.moveActiveIndex(1)}d.Utils.safeInvoke(t.props.onKeyDown,e)},t.handleKeyUp=function(e){var n=t.props,r=n.activeItem,o=n.onItemSelect,i=n.onKeyUp;e.keyCode===d.Keys.ENTER&&null!=r&&(e.preventDefault(),d.Utils.safeInvoke(o,r,e)),d.Utils.safeInvoke(i,e)},t.renderItem=function(e,n){var r=t.props,o=r.activeItem,i=r.itemListPredicate,s=r.itemPredicate,a=void 0===s?function(){return!0}:s,p=r.query,l=d.Utils.isFunction(i)?t.state.filteredItems.indexOf(e)>=0:a(p,e,n),u={active:o===e,disabled:!1,matchesPredicate:l};return t.props.itemRenderer(e,{handleClick:function(n){return t.handleItemSelect(e,n)},index:n,modifiers:u})},t}return p(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;return r({className:t,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,items:n,itemsParentRef:this.refHandlers.itemsParent,query:o,renderItem:this.renderItem})},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)&&d.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,a=this.getItemsParentPadding(),p=a.paddingTop,l=t+n+a.paddingBottom-o,u=t-p-o;l>=i+s?this.itemsParentRef.scrollTop=l+n-s:u<=i&&(this.itemsParentRef.scrollTop=u-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=d.Utils.clamp(this.getActiveIndex()+e,0,n);d.Utils.safeInvoke(this.props.onActiveItemChange,t[r])},t.displayName="Blueprint2.QueryList",t}(m.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,o=e.query;return d.Utils.isFunction(r)?r(o,t):d.Utils.isFunction(n)?t.filter(function(e,t){return n(o,e,t)}):t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={query:""},t.TypedQueryList=O.ofType(),t.refHandlers={queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,r=n.inputProps,o=void 0===r?{}:r,i=n.isOpen,s=n.overlayProps,a=void 0===s?{}:s,p=e.handleKeyDown,u=e.handleKeyUp,c=i&&!t.isQueryEmpty()?{onKeyDown:p,onKeyUp:u}:{};return m.createElement(d.Overlay,l({hasBackdrop:!0},a,{isOpen:i,className:v()(a.className,I),onClose:t.handleOverlayClose}),m.createElement("div",l({className:v()(e.className,y)},c),m.createElement(d.InputGroup,l({autoFocus:!0,className:d.Classes.LARGE,leftIcon:"search",placeholder:"Search...",value:e.query},o,{onChange:t.handleQueryChange})),t.maybeRenderMenu(e)))},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()||d.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}),d.Utils.safeInvoke(r.onChange,e)},t.handleOverlayClose=function(e){d.Utils.safeInvoke(t.props.onClose,e)},t}p(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.initialContent,e.isOpen,e.inputProps,e.noResults,e.overlayProps,u(e,["initialContent","isOpen","inputProps","noResults","overlayProps"]));return m.createElement(this.TypedQueryList,l({},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.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.prototype.renderItems=function(e){var t=e.items,n=e.renderItem,r=t.map(n).filter(function(e){return null!=e});return r.length>0?r:this.props.noResults},t.prototype.maybeRenderMenu=function(e){var t,n=this.props.initialContent;if(this.isQueryEmpty()?null!=n&&(t=n):t=this.renderItems(e),null!=t)return m.createElement(d.Menu,{ulRef:e.itemsParentRef},t)},t.displayName="Blueprint2.Omnibar"})(m.PureComponent),function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,query:""},t.TypedQueryList=O.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.tagInputProps,r=void 0===n?{}:n;d.Utils.safeInvoke(r.inputRef,e)},queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,r=n.tagInputProps,o=void 0===r?{}:r,i=n.popoverProps,s=void 0===i?{}:i,a=n.selectedItems,p=void 0===a?[]:a,u=e.handleKeyDown,c=e.handleKeyUp,y=e.query,I=l({placeholder:"Search..."},o.inputProps,{onChange:t.handleQueryChange,value:y});return m.createElement(d.Popover,l({autoFocus:!1,canEscapeKeyClose:!0,enforceFocus:!1,isOpen:t.state.isOpen,position:d.Position.BOTTOM_LEFT},s,{className:v()(e.className,s.className),onInteraction:t.handlePopoverInteraction,popoverClassName:v()(h,s.popoverClassName),popoverDidOpen:t.handlePopoverDidOpen,popoverWillOpen:t.handlePopoverWillOpen}),m.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(u),onKeyUp:t.state.isOpen?c:void 0},m.createElement(d.TagInput,l({},o,{inputProps:I,inputRef:t.refHandlers.input,className:v()(f,o.className),values:p.map(t.props.tagRenderer)}))),m.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(u),onKeyUp:c},m.createElement(d.Menu,{ulRef:e.itemsParentRef},t.renderItems(e))))},t.isQueryEmpty=function(){return 0===t.state.query.length},t.handleQueryChange=function(e){var n=t.props,r=n.tagInputProps,o=void 0===r?{}:r,i=n.openOnKeyDown,s=e.currentTarget.value;t.setState({query:s,isOpen:!t.isQueryEmpty()||!i}),null!=o.inputProps&&d.Utils.safeInvoke(o.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:""}),d.Utils.safeInvoke(t.props.onItemSelect,e,n))},t.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var n=t.props,r=n.popoverProps,o=void 0===r?{}:r,i=n.resetOnSelect;null!=t.input&&t.input!==document.activeElement?t.setState({activeItem:i?t.props.items[0]:t.state.activeItem,isOpen:!1,query:i?"":t.state.query}):t.props.openOnKeyDown||t.setState({isOpen:!0}),d.Utils.safeInvoke(o.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]}),d.Utils.safeInvoke(r.popoverWillOpen)},t.handlePopoverDidOpen=function(){var e=t.props.popoverProps,n=void 0===e?{}:e;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),d.Utils.safeInvoke(n.popoverDidOpen)},t.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,o=t.props.resetOnSelect;r===d.Keys.ESCAPE||r===d.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({activeItem:o?t.props.items[0]:t.state.activeItem,isOpen:!1,query:o?"":t.state.query})):r!==d.Keys.BACKSPACE&&r!==d.Keys.ARROW_LEFT&&r!==d.Keys.ARROW_RIGHT&&t.setState({isOpen:!0}),t.state.isOpen&&d.Utils.safeInvoke(e,n)}},t}p(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.initialContent,e.noResults,e.openOnKeyDown,e.popoverProps,e.resetOnSelect,e.tagInputProps,u(e,["initialContent","noResults","openOnKeyDown","popoverProps","resetOnSelect","tagInputProps"]));return m.createElement(this.TypedQueryList,l({},t,{activeItem:this.state.activeItem,onActiveItemChange:this.handleActiveItemChange,onItemSelect:this.handleItemSelect,query:this.state.query,ref:this.refHandlers.queryList,renderer:this.renderQueryList}))},t.prototype.renderItems=function(e){var t=e.items,n=e.renderItem,r=this.props,o=r.initialContent,i=r.noResults;if(null!=o&&this.isQueryEmpty())return o;var s=t.map(n).filter(function(e){return null!=e});return s.length>0?s:i},t.displayName="Blueprint2.MultiSelect"}(m.PureComponent);var T=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.TypedQueryList=O.ofType(),r.refHandlers={input:function(e){r.input=e;var t=r.props.inputProps,n=void 0===t?{}:t;d.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return r.list=e}},r.renderQueryList=function(e){var t=r.props,n=t.filterable,o=void 0===n||n,i=t.disabled,s=void 0!==i&&i,a=t.inputProps,p=void 0===a?{}:a,u=t.popoverProps,c=void 0===u?{}:u,f=m.createElement(d.InputGroup,l({autoFocus:!0,leftIcon:"search",placeholder:"Filter...",rightElement:r.maybeRenderInputClearButton(),value:e.query},p,{inputRef:r.refHandlers.input,onChange:r.handleQueryChange})),h=e.handleKeyDown,y=e.handleKeyUp;return m.createElement(d.Popover,l({autoFocus:!1,enforceFocus:!1,isOpen:r.state.isOpen,disabled:s,position:d.Position.BOTTOM_LEFT},c,{className:v()(e.className,c.className),onInteraction:r.handlePopoverInteraction,popoverClassName:v()(P,c.popoverClassName),popoverWillOpen:r.handlePopoverWillOpen,popoverDidOpen:r.handlePopoverDidOpen,popoverWillClose:r.handlePopoverWillClose}),m.createElement("div",{onKeyDown:r.state.isOpen?h:r.handleTargetKeyDown,onKeyUp:r.state.isOpen?y:void 0},r.props.children),m.createElement("div",{onKeyDown:h,onKeyUp:y},o?f:void 0,m.createElement(d.Menu,{ulRef:e.itemsParentRef},r.renderItems(e))))},r.isQueryEmpty=function(){return 0===r.state.query.length},r.handleActiveItemChange=function(e){return r.setState({activeItem:e})},r.handleTargetKeyDown=function(e){e.which!==d.Keys.ARROW_UP&&e.which!==d.Keys.ARROW_DOWN||r.setState({isOpen:!0})},r.handleItemSelect=function(e,t){r.setState({isOpen:!1}),r.props.resetOnSelect&&r.resetQuery(),d.Utils.safeInvoke(r.props.onItemSelect,e,t)},r.handlePopoverInteraction=function(e){r.setState({isOpen:e});var t=r.props.popoverProps,n=void 0===t?{}:t;d.Utils.safeInvoke(n.onInteraction,e)},r.handlePopoverWillOpen=function(){var e=r.props,t=e.popoverProps,n=void 0===t?{}:t,o=e.resetOnClose;r.previousFocusedElement=document.activeElement,o&&r.resetQuery(),d.Utils.safeInvoke(n.popoverWillOpen)},r.handlePopoverDidOpen=function(){null!=r.list&&r.list.scrollActiveItemIntoView(),requestAnimationFrame(function(){var e=r.props.inputProps;!1!==(void 0===e?{}:e).autoFocus&&null!=r.input&&r.input.focus()});var e=r.props.popoverProps,t=void 0===e?{}:e;d.Utils.safeInvoke(t.popoverDidOpen)},r.handlePopoverWillClose=function(){requestAnimationFrame(function(){void 0!==r.previousFocusedElement&&(r.previousFocusedElement.focus(),r.previousFocusedElement=void 0)});var e=r.props.popoverProps,t=void 0===e?{}:e;d.Utils.safeInvoke(t.popoverWillClose)},r.handleQueryChange=function(e){var t=r.props,n=t.inputProps,o=void 0===n?{}:n,i=t.onQueryChange,s=e.currentTarget.value;r.setState({query:s}),d.Utils.safeInvoke(o.onChange,e),d.Utils.safeInvoke(i,s)},r.resetQuery=function(){var e=r.props,t=e.items,n=e.onQueryChange;r.setState({activeItem:t[0],query:""}),d.Utils.safeInvoke(n,"")};var o=t.inputProps,i=void 0===o?{}:o,s=null==i.value?"":i.value.toString();return r.state={isOpen:!1,query:s},r}return p(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.filterable,e.initialContent,e.inputProps,e.noResults,e.popoverProps,u(e,["filterable","initialContent","inputProps","noResults","popoverProps"]));return m.createElement(this.TypedQueryList,l({},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.renderItems=function(e){var t=e.items,n=e.renderItem,r=this.props,o=r.initialContent,i=r.noResults;if(null!=o&&this.isQueryEmpty())return o;var s=t.map(n).filter(function(e){return null!=e});return s.length>0?s:i},t.prototype.maybeRenderInputClearButton=function(){return this.isQueryEmpty()?void 0:m.createElement(d.Button,{className:d.Classes.MINIMAL,icon:"cross",onClick:this.resetQuery})},t.displayName="Blueprint2.Select",t}(m.PureComponent),S=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,isTyping:!1,query:""},t.TypedQueryList=O.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.inputProps,r=void 0===n?{}:n;d.Utils.safeInvoke(r.inputRef,e)},queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,r=n.inputValueRenderer,o=n.inputProps,i=void 0===o?{}:o,s=n.popoverProps,a=void 0===s?{}:s,p=t.state,u=p.isTyping,c=p.selectedItem,f=p.query,h=e.handleKeyDown,y=e.handleKeyUp,I=u?f:c?r(c):"";return m.createElement(d.Popover,l({autoFocus:!1,enforceFocus:!1,isOpen:t.state.isOpen,position:d.Position.BOTTOM_LEFT},a,{className:v()(e.className,a.className),onInteraction:t.handlePopoverInteraction,popoverClassName:v()(P,a.popoverClassName),popoverDidOpen:t.handlePopoverDidOpen,popoverWillClose:t.handlePopoverWillClose}),m.createElement(d.InputGroup,l({placeholder:"Search...",value:I},i,{inputRef:t.refHandlers.input,onChange:t.handleQueryChange,onFocus:t.handleInputFocus,onKeyDown:t.getTargetKeyDownHandler(h),onKeyUp:t.getTargetKeyUpHandler(y)})),m.createElement("div",{onKeyDown:h,onKeyUp:y},m.createElement(d.Menu,{ulRef:e.itemsParentRef},t.renderItems(e))))},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,o=n.inputProps,i=void 0===o?{}:o;t.selectText(),r||t.setState({isOpen:!0}),d.Utils.safeInvoke(i.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}),d.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}),d.Utils.safeInvoke(r.onInteraction,e)})},t.handlePopoverDidOpen=function(){var e=t.props.popoverProps,n=void 0===e?{}:e;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),d.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:""}),d.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}),d.Utils.safeInvoke(r.onChange,e)},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,o=t.state,i=o.isTyping,s=o.selectedItem,a=t.props,p=a.inputProps,l=void 0===p?{}:p,u=a.openOnKeyDown;r===d.Keys.ESCAPE||r===d.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({isOpen:!1,selectedItem:i?void 0:s})):u&&r!==d.Keys.BACKSPACE&&r!==d.Keys.ARROW_LEFT&&r!==d.Keys.ARROW_RIGHT&&t.setState({isOpen:!0}),t.state.isOpen&&d.Utils.safeInvoke(e,n),d.Utils.safeInvoke(l.onKeyDown,n)}},t.getTargetKeyUpHandler=function(e){return function(n){var r=t.props.inputProps,o=void 0===r?{}:r;t.state.isOpen&&d.Utils.safeInvoke(e,n),d.Utils.safeInvoke(o.onKeyUp,n)}},t}p(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.inputProps,e.noResults,e.popoverProps,u(e,["inputProps","noResults","popoverProps"]));return m.createElement(this.TypedQueryList,l({},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.prototype.renderItems=function(e){var t=e.items,n=e.renderItem,r=t.map(n).filter(function(e){return null!=e});return r.length>0?r:this.props.noResults},t.displayName="Blueprint2.Suggest",t.defaultProps={closeOnSelect:!0,openOnKeyDown:!1}}(m.PureComponent),n(3)),E=/^[^-+]/;function R(e,t){var n=t.getTime(),r=S.tz.zone(e),o=S.tz(n,e),i=o.utcOffset(),s=o.format("Z"),a=r.abbr(n);return{abbreviation:E.test(a)?a:void 0,offset:i,offsetAsString:s,population:r.population,timezone:e}}var q={ABBREVIATION:"abbreviation",COMPOSITE:"composite",NAME:"name",OFFSET:"offset"};function A(e,t){var n,r,o,i,s=(n=e,r=S.tz.names().filter(function(e){return/\//.test(e)&&!/Etc\//.test(e)}),o=r.reduce(function(e,t){return e[t]=R(t,n),e},{}),i=r.reduce(function(e,t){var n=o[t],r=e[n.offsetAsString];return(null==r||n.population>o[r].population)&&(e[n.offsetAsString]=t),e},{}),Object.keys(i).map(function(e){return o[i[e]]}).sort(function(e,t){return e.offset-t.offset}).map(K)),a=function(e){var t=S.tz.guess();if(void 0!==t){var n=e.getTime(),r=S.tz(n,t),o=r.format("Z");return{iconName:"locate",key:t+"-local",label:o,text:"Current timezone",timezone:t}}return}(e);return t&&void 0!==a?[a].concat(s):s}function K(e){var t=e.abbreviation,n=e.offsetAsString,r=e.timezone;return{key:r,label:n,text:r+(t?" ("+t+")":""),timezone:r}}var U=T.ofType(),w=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.filterItems=function(e,t){var n=new RegExp(e.replace(/([[()+*?])/g,"\\$1").replace(" ","[ _/\\(\\)]+"),"i");return t.filter(function(e){return n.test(e.text+e.label)})},r.renderItem=function(e,t){var n=t.handleClick,r=t.modifiers;if(!r.matchesPredicate)return null;var o,i=v()(d.Classes.MENU_ITEM,d.Classes.intentClass(),((o={})[d.Classes.ACTIVE]=r.active,o[d.Classes.INTENT_PRIMARY]=r.active,o));return m.createElement(d.MenuItem,{key:e.key,className:i,icon:e.iconName,text:e.text,label:e.label,onClick:n,shouldDismissPopover:!1})},r.handleItemSelect=function(e){return d.Utils.safeInvoke(r.props.onChange,e.timezone)},r.handleQueryChange=function(e){return r.setState({query:e})};var o,i=t.date,s=void 0===i?new Date:i,a=t.showLocalTimezone,p=t.inputProps,l=void 0===p?{}:p;return r.state={query:l.value||""},r.timezoneItems=(o=s,S.tz.names().map(function(e){return R(e,o)}).sort(function(e,t){return e.offset-t.offset}).map(K)),r.initialTimezoneItems=A(s,a),r}return p(t,e),t.prototype.render=function(){var e=this.props,t=e.className,n=e.disabled,r=e.inputProps,s=e.popoverProps,a=this.state.query,p=l({placeholder:"Search for timezones..."},r),u=l({},s,{popoverClassName:v()(i,s.popoverClassName)});return m.createElement(U,{className:v()(o,t),items:a?this.timezoneItems:this.initialTimezoneItems,itemListPredicate:this.filterItems,itemRenderer:this.renderItem,noResults:m.createElement(d.MenuItem,{disabled:!0,text:"No matching timezones."}),onItemSelect:this.handleItemSelect,resetOnSelect:!0,resetOnClose:!0,popoverProps:u,inputProps:p,disabled:n,onQueryChange:this.handleQueryChange},this.renderButton())},t.prototype.componentWillReceiveProps=function(e){var t=e.date,n=void 0===t?new Date:t,r=e.inputProps,o=void 0===r?{}:r;this.props.showLocalTimezone!==e.showLocalTimezone&&(this.initialTimezoneItems=A(n,e.showLocalTimezone)),void 0!==o.value&&this.state.query!==o.value&&this.setState({query:o.value})},t.prototype.renderButton=function(){var e=this.props,t=e.buttonProps,n=void 0===t?{}:t,r=e.date,o=e.disabled,i=e.placeholder,s=e.value,a=e.valueDisplayFormat,p=s?function(e,t,n){if(e&&S.tz.zone(e)){var r=R(e,t),o=r.abbreviation,i=r.offsetAsString;switch(n){case q.ABBREVIATION:return void 0!==o?o:i;case q.NAME:return e;case q.OFFSET:return i;case q.COMPOSITE:return e+(o?" ("+o+")":"")+" "+i}}}(s,r,a):m.createElement("span",{className:d.Classes.TEXT_MUTED},i);return m.createElement(d.Button,l({rightIcon:"caret-down",disabled:o,text:p},n))},t.displayName="Blueprint2.TimezonePicker",t.defaultProps={date:new Date,disabled:!1,inputProps:{},placeholder:"Select timezone...",popoverProps:{},showLocalTimezone:!0,valueDisplayFormat:q.OFFSET},t}(d.AbstractPureComponent);n.d(t,"Classes",function(){return s}),n.d(t,"TimezoneDisplayFormat",function(){return q}),n.d(t,"TimezonePicker",function(){return w})}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("classNames"),require("moment")):"function"==typeof define&&define.amd?define(["React","classNames","moment"],t):"object"==typeof exports?exports.Timezone=t(require("React"),require("classNames"),require("moment")):(e.Blueprint=e.Blueprint||{},e.Blueprint.Timezone=t(e.React,e.classNames,e.moment))}("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=4)}([function(t,n){t.exports=e},function(e,t){e.exports=Blueprint.Core},function(e,n){e.exports=t},function(e,t){e.exports=n},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,"TIMEZONE_PICKER",function(){return i}),n.d(r,"TIMEZONE_PICKER_POPOVER",function(){return s});var o={};n.d(o,"MULTISELECT",function(){return h}),n.d(o,"MULTISELECT_POPOVER",function(){return y}),n.d(o,"OMNIBAR",function(){return I}),n.d(o,"OMNIBAR_OVERLAY",function(){return P}),n.d(o,"SELECT",function(){return O}),n.d(o,"SELECT_POPOVER",function(){return g});var i="pt-timezone-picker",s=i+"-popover",a=r,p=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 l(e,t){function n(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=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 c(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 v=n(2),d=n.n(v),m=n(0),f=n(1),h="pt-multi-select",y=h+"-popover",I="pt-omnibar",P=I+"-overlay",O="pt-select",g=O+"-popover";var C=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,o=function(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}(e,n.noResults,r);return m.createElement(f.Menu,{ulRef:e.itemsParentRef},o)},t.renderItem=function(e,n){var r=t.props,o=r.activeItem,i=r.query,s=t.state.filteredItems.indexOf(e)>=0,a={active:o===e,disabled:!1,matchesPredicate:s};return t.props.itemRenderer(e,{handleClick:function(n){return t.handleItemSelect(e,n)},index:n,modifiers:a,query:i})},t.handleItemSelect=function(e,n){f.Utils.safeInvoke(t.props.onActiveItemChange,e),f.Utils.safeInvoke(t.props.onItemSelect,e,n)},t.handleKeyDown=function(e){switch(e.keyCode){case f.Keys.ARROW_UP:e.preventDefault(),t.moveActiveIndex(-1);break;case f.Keys.ARROW_DOWN:e.preventDefault(),t.moveActiveIndex(1)}f.Utils.safeInvoke(t.props.onKeyDown,e)},t.handleKeyUp=function(e){var n=t.props,r=n.activeItem,o=n.onItemSelect,i=n.onKeyUp;e.keyCode===f.Keys.ENTER&&null!=r&&(e.preventDefault(),f.Utils.safeInvoke(o,r,e)),f.Utils.safeInvoke(i,e)},t}return l(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,a=this.state.filteredItems;return r({className:t,filteredItems:a,handleItemSelect:this.handleItemSelect,handleKeyDown:this.handleKeyDown,handleKeyUp:this.handleKeyUp,itemList:s({filteredItems:a,items:n,itemsParentRef:this.refHandlers.itemsParent,query:o,renderItem:this.renderItem}),query:o})},t.prototype.componentWillMount=function(){this.setState({filteredItems:E(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:E(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)&&f.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,a=this.getItemsParentPadding(),p=a.paddingTop,l=t+n+a.paddingBottom-o,u=t-p-o;l>=i+s?this.itemsParentRef.scrollTop=l+n-s:u<=i&&(this.itemsParentRef.scrollTop=u-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:T(e.paddingBottom),paddingTop:T(t)}},t.prototype.moveActiveIndex=function(e){this.shouldCheckActiveItemInViewport=!0;var t=this.state.filteredItems,n=Math.max(t.length-1,0),r=f.Utils.clamp(this.getActiveIndex()+e,0,n);f.Utils.safeInvoke(this.props.onActiveItemChange,t[r])},t.displayName="Blueprint2.QueryList",t}(m.Component);function T(e){return null==e?0:parseInt(e.slice(0,-2),10)}function E(e){var t=e.items,n=e.itemPredicate,r=e.itemListPredicate,o=e.query;return f.Utils.isFunction(r)?r(o,t):f.Utils.isFunction(n)?t.filter(function(e,t){return n(o,e,t)}):t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={query:""},t.TypedQueryList=C.ofType(),t.refHandlers={queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,r=n.inputProps,i=void 0===r?{}:r,s=n.isOpen,a=n.overlayProps,p=void 0===a?{}:a,l=e.handleKeyDown,c=e.handleKeyUp,v=s&&!t.isQueryEmpty()?{onKeyDown:l,onKeyUp:c}:{};return m.createElement(f.Overlay,u({hasBackdrop:!0},p,{isOpen:s,className:d()(p.className,o.OMNIBAR_OVERLAY),onClose:t.handleOverlayClose}),m.createElement("div",u({className:d()(e.className,o.OMNIBAR)},v),m.createElement(f.InputGroup,u({autoFocus:!0,className:f.Classes.LARGE,leftIcon:"search",placeholder:"Search...",value:e.query},i,{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()||f.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}),f.Utils.safeInvoke(r.onChange,e)},t.handleOverlayClose=function(e){f.Utils.safeInvoke(t.props.onClose,e)},t}l(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,c(e,["initialContent","isOpen","inputProps","overlayProps"]));return m.createElement(this.TypedQueryList,u({},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"})(m.PureComponent),function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,query:""},t.TypedQueryList=C.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.tagInputProps,r=void 0===n?{}:n;f.Utils.safeInvoke(r.inputRef,e)},queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,r=n.tagInputProps,i=void 0===r?{}:r,s=n.popoverProps,a=void 0===s?{}:s,p=n.selectedItems,l=void 0===p?[]:p,c=e.handleKeyDown,v=e.handleKeyUp,h=e.query,y=u({placeholder:"Search..."},i.inputProps,{onChange:t.handleQueryChange,value:h});return m.createElement(f.Popover,u({autoFocus:!1,canEscapeKeyClose:!0,enforceFocus:!1,isOpen:t.state.isOpen,position:f.Position.BOTTOM_LEFT},a,{className:d()(e.className,a.className),onInteraction:t.handlePopoverInteraction,popoverClassName:d()(o.MULTISELECT_POPOVER,a.popoverClassName),popoverDidOpen:t.handlePopoverDidOpen,popoverWillOpen:t.handlePopoverWillOpen}),m.createElement("div",{onKeyDown:t.getTargetKeyDownHandler(c),onKeyUp:t.state.isOpen?v:void 0},m.createElement(f.TagInput,u({},i,{inputProps:y,inputRef:t.refHandlers.input,className:d()(o.MULTISELECT,i.className),values:l.map(t.props.tagRenderer)}))),m.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,o=void 0===r?{}:r,i=n.openOnKeyDown,s=e.currentTarget.value;t.setState({query:s,isOpen:!t.isQueryEmpty()||!i}),null!=o.inputProps&&f.Utils.safeInvoke(o.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:""}),f.Utils.safeInvoke(t.props.onItemSelect,e,n))},t.handlePopoverInteraction=function(e){return requestAnimationFrame(function(){var n=t.props,r=n.popoverProps,o=void 0===r?{}:r,i=n.resetOnSelect;null!=t.input&&t.input!==document.activeElement?t.setState({activeItem:i?t.props.items[0]:t.state.activeItem,isOpen:!1,query:i?"":t.state.query}):t.props.openOnKeyDown||t.setState({isOpen:!0}),f.Utils.safeInvoke(o.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]}),f.Utils.safeInvoke(r.popoverWillOpen)},t.handlePopoverDidOpen=function(){var e=t.props.popoverProps,n=void 0===e?{}:e;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),f.Utils.safeInvoke(n.popoverDidOpen)},t.handleActiveItemChange=function(e){return t.setState({activeItem:e})},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,o=t.props.resetOnSelect;r===f.Keys.ESCAPE||r===f.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({activeItem:o?t.props.items[0]:t.state.activeItem,isOpen:!1,query:o?"":t.state.query})):r!==f.Keys.BACKSPACE&&r!==f.Keys.ARROW_LEFT&&r!==f.Keys.ARROW_RIGHT&&t.setState({isOpen:!0}),t.state.isOpen&&f.Utils.safeInvoke(e,n)}},t}l(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.openOnKeyDown,e.popoverProps,e.resetOnSelect,e.tagInputProps,c(e,["openOnKeyDown","popoverProps","resetOnSelect","tagInputProps"]));return m.createElement(this.TypedQueryList,u({},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"}(m.PureComponent);var S=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.TypedQueryList=C.ofType(),r.refHandlers={input:function(e){r.input=e;var t=r.props.inputProps,n=void 0===t?{}:t;f.Utils.safeInvoke(n.inputRef,e)},queryList:function(e){return r.list=e}},r.renderQueryList=function(e){var t=r.props,n=t.filterable,i=void 0===n||n,s=t.disabled,a=void 0!==s&&s,p=t.inputProps,l=void 0===p?{}:p,c=t.popoverProps,v=void 0===c?{}:c,h=m.createElement(f.InputGroup,u({autoFocus:!0,leftIcon:"search",placeholder:"Filter...",rightElement:r.maybeRenderInputClearButton(),value:e.query},l,{inputRef:r.refHandlers.input,onChange:r.handleQueryChange})),y=e.handleKeyDown,I=e.handleKeyUp;return m.createElement(f.Popover,u({autoFocus:!1,enforceFocus:!1,isOpen:r.state.isOpen,disabled:a,position:f.Position.BOTTOM_LEFT},v,{className:d()(e.className,v.className),onInteraction:r.handlePopoverInteraction,popoverClassName:d()(o.SELECT_POPOVER,v.popoverClassName),popoverWillOpen:r.handlePopoverWillOpen,popoverDidOpen:r.handlePopoverDidOpen,popoverWillClose:r.handlePopoverWillClose}),m.createElement("div",{onKeyDown:r.state.isOpen?y:r.handleTargetKeyDown,onKeyUp:r.state.isOpen?I:void 0},r.props.children),m.createElement("div",{onKeyDown:y,onKeyUp:I},i?h:void 0,e.itemList))},r.handleActiveItemChange=function(e){return r.setState({activeItem:e})},r.handleTargetKeyDown=function(e){e.which!==f.Keys.ARROW_UP&&e.which!==f.Keys.ARROW_DOWN||r.setState({isOpen:!0})},r.handleItemSelect=function(e,t){r.setState({isOpen:!1}),r.props.resetOnSelect&&r.resetQuery(),f.Utils.safeInvoke(r.props.onItemSelect,e,t)},r.handlePopoverInteraction=function(e){r.setState({isOpen:e});var t=r.props.popoverProps,n=void 0===t?{}:t;f.Utils.safeInvoke(n.onInteraction,e)},r.handlePopoverWillOpen=function(){var e=r.props,t=e.popoverProps,n=void 0===t?{}:t,o=e.resetOnClose;r.previousFocusedElement=document.activeElement,o&&r.resetQuery(),f.Utils.safeInvoke(n.popoverWillOpen)},r.handlePopoverDidOpen=function(){null!=r.list&&r.list.scrollActiveItemIntoView(),requestAnimationFrame(function(){var e=r.props.inputProps;!1!==(void 0===e?{}:e).autoFocus&&null!=r.input&&r.input.focus()});var e=r.props.popoverProps,t=void 0===e?{}:e;f.Utils.safeInvoke(t.popoverDidOpen)},r.handlePopoverWillClose=function(){requestAnimationFrame(function(){void 0!==r.previousFocusedElement&&(r.previousFocusedElement.focus(),r.previousFocusedElement=void 0)});var e=r.props.popoverProps,t=void 0===e?{}:e;f.Utils.safeInvoke(t.popoverWillClose)},r.handleQueryChange=function(e){var t=r.props,n=t.inputProps,o=void 0===n?{}:n,i=t.onQueryChange,s=e.currentTarget.value;r.setState({query:s}),f.Utils.safeInvoke(o.onChange,e),f.Utils.safeInvoke(i,s)},r.resetQuery=function(){var e=r.props,t=e.items,n=e.onQueryChange;r.setState({activeItem:t[0],query:""}),f.Utils.safeInvoke(n,"")};var i=t.inputProps,s=void 0===i?{}:i,a=null==s.value?"":s.value.toString();return r.state={isOpen:!1,query:a},r}return l(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.filterable,e.inputProps,e.popoverProps,c(e,["filterable","inputProps","popoverProps"]));return m.createElement(this.TypedQueryList,u({},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:m.createElement(f.Button,{className:f.Classes.MINIMAL,icon:"cross",onClick:this.resetQuery})},t.displayName="Blueprint2.Select",t}(m.PureComponent),A=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isOpen:!1,isTyping:!1,query:""},t.TypedQueryList=C.ofType(),t.refHandlers={input:function(e){t.input=e;var n=t.props.inputProps,r=void 0===n?{}:n;f.Utils.safeInvoke(r.inputRef,e)},queryList:function(e){return t.queryList=e}},t.renderQueryList=function(e){var n=t.props,r=n.inputValueRenderer,i=n.inputProps,s=void 0===i?{}:i,a=n.popoverProps,p=void 0===a?{}:a,l=t.state,c=l.isTyping,v=l.selectedItem,h=l.query,y=e.handleKeyDown,I=e.handleKeyUp,P=c?h:v?r(v):"";return m.createElement(f.Popover,u({autoFocus:!1,enforceFocus:!1,isOpen:t.state.isOpen,position:f.Position.BOTTOM_LEFT},p,{className:d()(e.className,p.className),onInteraction:t.handlePopoverInteraction,popoverClassName:d()(o.SELECT_POPOVER,p.popoverClassName),popoverDidOpen:t.handlePopoverDidOpen,popoverWillClose:t.handlePopoverWillClose}),m.createElement(f.InputGroup,u({placeholder:"Search...",value:P},s,{inputRef:t.refHandlers.input,onChange:t.handleQueryChange,onFocus:t.handleInputFocus,onKeyDown:t.getTargetKeyDownHandler(y),onKeyUp:t.getTargetKeyUpHandler(I)})),m.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,o=n.inputProps,i=void 0===o?{}:o;t.selectText(),r||t.setState({isOpen:!0}),f.Utils.safeInvoke(i.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}),f.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}),f.Utils.safeInvoke(r.onInteraction,e)})},t.handlePopoverDidOpen=function(){var e=t.props.popoverProps,n=void 0===e?{}:e;null!=t.queryList&&t.queryList.scrollActiveItemIntoView(),f.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:""}),f.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}),f.Utils.safeInvoke(r.onChange,e)},t.getTargetKeyDownHandler=function(e){return function(n){var r=n.which,o=t.state,i=o.isTyping,s=o.selectedItem,a=t.props,p=a.inputProps,l=void 0===p?{}:p,u=a.openOnKeyDown;r===f.Keys.ESCAPE||r===f.Keys.TAB?(null!=t.input&&t.input.blur(),t.setState({isOpen:!1,selectedItem:i?void 0:s})):u&&r!==f.Keys.BACKSPACE&&r!==f.Keys.ARROW_LEFT&&r!==f.Keys.ARROW_RIGHT&&t.setState({isOpen:!0}),t.state.isOpen&&f.Utils.safeInvoke(e,n),f.Utils.safeInvoke(l.onKeyDown,n)}},t.getTargetKeyUpHandler=function(e){return function(n){var r=t.props.inputProps,o=void 0===r?{}:r;t.state.isOpen&&f.Utils.safeInvoke(e,n),f.Utils.safeInvoke(o.onKeyUp,n)}},t}l(t,e),t.ofType=function(){return t},t.prototype.render=function(){var e=this.props,t=(e.inputProps,e.popoverProps,c(e,["inputProps","popoverProps"]));return m.createElement(this.TypedQueryList,u({},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}}(m.PureComponent),n(3)),q=/^[^-+]/;function R(e,t){var n=t.getTime(),r=A.tz.zone(e),o=A.tz(n,e),i=o.utcOffset(),s=o.format("Z"),a=r.abbr(n);return{abbreviation:q.test(a)?a:void 0,offset:i,offsetAsString:s,population:r.population,timezone:e}}var L={ABBREVIATION:"abbreviation",COMPOSITE:"composite",NAME:"name",OFFSET:"offset"};function U(e,t){var n,r,o,i,s=(n=e,r=A.tz.names().filter(function(e){return/\//.test(e)&&!/Etc\//.test(e)}),o=r.reduce(function(e,t){return e[t]=R(t,n),e},{}),i=r.reduce(function(e,t){var n=o[t],r=e[n.offsetAsString];return(null==r||n.population>o[r].population)&&(e[n.offsetAsString]=t),e},{}),Object.keys(i).map(function(e){return o[i[e]]}).sort(function(e,t){return e.offset-t.offset}).map(K)),a=function(e){var t=A.tz.guess();if(void 0!==t){var n=e.getTime(),r=A.tz(n,t),o=r.format("Z");return{iconName:"locate",key:t+"-local",label:o,text:"Current timezone",timezone:t}}return}(e);return t&&void 0!==a?[a].concat(s):s}function K(e){var t=e.abbreviation,n=e.offsetAsString,r=e.timezone;return{key:r,label:n,text:r+(t?" ("+t+")":""),timezone:r}}var w=S.ofType(),N=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.filterItems=function(e,t){var n=new RegExp(e.replace(/([[()+*?])/g,"\\$1").replace(" ","[ _/\\(\\)]+"),"i");return t.filter(function(e){return n.test(e.text+e.label)})},r.renderItem=function(e,t){var n=t.handleClick,r=t.modifiers;if(!r.matchesPredicate)return null;var o,i=d()(f.Classes.MENU_ITEM,f.Classes.intentClass(),((o={})[f.Classes.ACTIVE]=r.active,o[f.Classes.INTENT_PRIMARY]=r.active,o));return m.createElement(f.MenuItem,{key:e.key,className:i,icon:e.iconName,text:e.text,label:e.label,onClick:n,shouldDismissPopover:!1})},r.handleItemSelect=function(e){return f.Utils.safeInvoke(r.props.onChange,e.timezone)},r.handleQueryChange=function(e){return r.setState({query:e})};var o,i=t.date,s=void 0===i?new Date:i,a=t.showLocalTimezone,p=t.inputProps,l=void 0===p?{}:p;return r.state={query:l.value||""},r.timezoneItems=(o=s,A.tz.names().map(function(e){return R(e,o)}).sort(function(e,t){return e.offset-t.offset}).map(K)),r.initialTimezoneItems=U(s,a),r}return l(t,e),t.prototype.render=function(){var e=this.props,t=e.className,n=e.disabled,r=e.inputProps,o=e.popoverProps,a=this.state.query,p=u({placeholder:"Search for timezones..."},r),l=u({},o,{popoverClassName:d()(s,o.popoverClassName)});return m.createElement(w,{className:d()(i,t),items:a?this.timezoneItems:this.initialTimezoneItems,itemListPredicate:this.filterItems,itemRenderer:this.renderItem,noResults:m.createElement(f.MenuItem,{disabled:!0,text:"No matching timezones."}),onItemSelect:this.handleItemSelect,resetOnSelect:!0,resetOnClose:!0,popoverProps:l,inputProps:p,disabled:n,onQueryChange:this.handleQueryChange},this.renderButton())},t.prototype.componentWillReceiveProps=function(e){var t=e.date,n=void 0===t?new Date:t,r=e.inputProps,o=void 0===r?{}:r;this.props.showLocalTimezone!==e.showLocalTimezone&&(this.initialTimezoneItems=U(n,e.showLocalTimezone)),void 0!==o.value&&this.state.query!==o.value&&this.setState({query:o.value})},t.prototype.renderButton=function(){var e=this.props,t=e.buttonProps,n=void 0===t?{}:t,r=e.date,o=e.disabled,i=e.placeholder,s=e.value,a=e.valueDisplayFormat,p=s?function(e,t,n){if(e&&A.tz.zone(e)){var r=R(e,t),o=r.abbreviation,i=r.offsetAsString;switch(n){case L.ABBREVIATION:return void 0!==o?o:i;case L.NAME:return e;case L.OFFSET:return i;case L.COMPOSITE:return e+(o?" ("+o+")":"")+" "+i}}}(s,r,a):m.createElement("span",{className:f.Classes.TEXT_MUTED},i);return m.createElement(f.Button,u({rightIcon:"caret-down",disabled:o,text:p},n))},t.displayName="Blueprint2.TimezonePicker",t.defaultProps={date:new Date,disabled:!1,inputProps:{},placeholder:"Select timezone...",popoverProps:{},showLocalTimezone:!0,valueDisplayFormat:L.OFFSET},t}(f.AbstractPureComponent);n.d(t,"Classes",function(){return a}),n.d(t,"TimezoneDisplayFormat",function(){return L}),n.d(t,"TimezonePicker",function(){return N})}])}); |
{ | ||
"name": "@blueprintjs/timezone", | ||
"version": "2.0.0-rc.3", | ||
"version": "2.0.0-rc.4", | ||
"description": "Components related to timezone selection and UI", | ||
@@ -20,2 +20,3 @@ "main": "lib/cjs/index.js", | ||
"dist:bundle": "cross-env NODE_ENV=production webpack", | ||
"dist:css": "css-dist lib/css/*.css", | ||
"dist:verify": "assert-package-layout", | ||
@@ -34,4 +35,4 @@ "lint": "npm-run-all -p lint:stylelint lint:tslint", | ||
"dependencies": { | ||
"@blueprintjs/core": "^2.0.0-rc.3", | ||
"@blueprintjs/select": "^2.0.0-rc.3", | ||
"@blueprintjs/core": "^2.0.0-rc.4", | ||
"@blueprintjs/select": "^2.0.0-rc.4", | ||
"classnames": "^2.2", | ||
@@ -38,0 +39,0 @@ "moment": "^2.14.1", |
@@ -5,2 +5,5 @@ @# TimezonePicker | ||
[Moment Timezone](http://momentjs.com/timezone/) is used internally for the list of available timezones and | ||
timezone metadata. | ||
@reactExample TimezonePickerExample | ||
@@ -10,6 +13,5 @@ | ||
This component can be used in controlled or uncontrolled mode. | ||
This component only supports controlled usage. | ||
Control the selected timezone with the `value` prop. | ||
Use the `onChange` prop to listen for changes to the selected timezone. | ||
You can control the selected timezone by setting the `value` prop. | ||
Or, use the component in uncontrolled mode and specify an initial timezone by setting `defaultValue`. | ||
@@ -24,16 +26,12 @@ The `date` prop is used to determine the timezone offsets. | ||
using the most populous location for each offset. | ||
Moment Timezone uses a similar heuristic for | ||
[guessing](http://momentjs.com/timezone/docs/#/using-timezones/guessing-user-timezone/) the user's timezone. | ||
Moment Timezone uses a similar [heuristic for guessing](http://momentjs.com/timezone/docs/#/using-timezones/guessing-user-timezone/) | ||
the user's timezone. | ||
[Moment Timezone](http://momentjs.com/timezone/) is used internally for the list of available timezones and | ||
timezone metadata. | ||
<div class="pt-callout pt-intent-warning pt-icon-warning-sign"> | ||
<h4 class="pt-callout-title">Local timezone detection</h4> | ||
We detect the local timezone when the `showLocalTimezone` prop is used. | ||
We cannot guarantee that we'll get the correct local timezone in all browsers. | ||
We detect the local timezone when the `showLocalTimezone` prop is enabled and cannot guarantee correctness in all browsers. | ||
In supported browsers, the [i18n API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/resolvedOptions) is used. | ||
In other browsers, `Date` methods and a population heuristic are used. | ||
See [Moment Timezone's documentation](https://momentjs.com/timezone/docs/#/using-timezones/guessing-user-timezone/) | ||
for more information. | ||
for more information and browser compatibility. | ||
</div> | ||
@@ -40,0 +38,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
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
98191
1202