@transferwise/components 45.0.1 → 45.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE.md +4 -4
  2. package/README.md +3 -0
  3. package/build/es/no-polyfill/actionOption/ActionOption.story.js +1 -1
  4. package/build/es/no-polyfill/avatarWrapper/AvatarWrapper.js +1 -2
  5. package/build/es/no-polyfill/button/Button.js +1 -1
  6. package/build/es/no-polyfill/checkboxButton/CheckboxButton.story.js +1 -1
  7. package/build/es/no-polyfill/checkboxOption/CheckboxOption.story.js +1 -1
  8. package/build/es/no-polyfill/chips/Chips.story.js +1 -1
  9. package/build/es/no-polyfill/common/bottomSheet/BottomSheet.js +1 -21
  10. package/build/es/no-polyfill/common/hooks/useHasIntersected/useHasIntersected.js +1 -2
  11. package/build/es/no-polyfill/common/requirements.js +1 -19
  12. package/build/es/no-polyfill/dateInput/DateInput.js +3 -9
  13. package/build/es/no-polyfill/index.js +1 -1
  14. package/build/es/no-polyfill/inputs/Input.js +1 -0
  15. package/build/es/no-polyfill/inputs/TextArea.js +1 -0
  16. package/build/es/no-polyfill/inputs/_common.js +2 -0
  17. package/build/es/no-polyfill/modal/Modal.js +1 -2
  18. package/build/es/no-polyfill/moneyInput/MoneyInput.js +1 -1
  19. package/build/es/no-polyfill/phoneNumberInput/PhoneNumberInput.js +1 -1
  20. package/build/es/no-polyfill/progressBar/ProgressBar.story.js +1 -1
  21. package/build/es/no-polyfill/provider/Provider.spec.js +1 -2
  22. package/build/es/no-polyfill/select/searchBox/SearchBox.js +1 -1
  23. package/build/es/no-polyfill/slidingPanel/SlidingPanel.js +1 -1
  24. package/build/es/no-polyfill/tabs/Tabs.js +1 -6
  25. package/build/es/no-polyfill/typeahead/typeaheadInput/TypeaheadInput.js +1 -1
  26. package/build/es/no-polyfill/uploadInput/UploadInput.story.js +1 -1
  27. package/build/es/no-polyfill/utils.js +0 -0
  28. package/build/es/no-polyfill/withDisplayFormat/WithDisplayFormat.js +1 -2
  29. package/build/es/polyfill/actionOption/ActionOption.story.js +1 -1
  30. package/build/es/polyfill/avatarWrapper/AvatarWrapper.js +1 -2
  31. package/build/es/polyfill/button/Button.js +1 -1
  32. package/build/es/polyfill/checkboxButton/CheckboxButton.story.js +1 -1
  33. package/build/es/polyfill/checkboxOption/CheckboxOption.story.js +1 -1
  34. package/build/es/polyfill/chips/Chips.story.js +1 -1
  35. package/build/es/polyfill/common/bottomSheet/BottomSheet.js +1 -21
  36. package/build/es/polyfill/common/hooks/useHasIntersected/useHasIntersected.js +1 -2
  37. package/build/es/polyfill/common/requirements.js +1 -19
  38. package/build/es/polyfill/dateInput/DateInput.js +3 -9
  39. package/build/es/polyfill/index.js +1 -1
  40. package/build/es/polyfill/inputs/Input.js +1 -0
  41. package/build/es/polyfill/inputs/TextArea.js +1 -0
  42. package/build/es/polyfill/inputs/_common.js +2 -0
  43. package/build/es/polyfill/modal/Modal.js +1 -2
  44. package/build/es/polyfill/moneyInput/MoneyInput.js +1 -1
  45. package/build/es/polyfill/phoneNumberInput/PhoneNumberInput.js +1 -1
  46. package/build/es/polyfill/progressBar/ProgressBar.story.js +1 -1
  47. package/build/es/polyfill/provider/Provider.spec.js +1 -2
  48. package/build/es/polyfill/select/searchBox/SearchBox.js +1 -1
  49. package/build/es/polyfill/slidingPanel/SlidingPanel.js +1 -1
  50. package/build/es/polyfill/tabs/Tabs.js +1 -6
  51. package/build/es/polyfill/typeahead/typeaheadInput/TypeaheadInput.js +1 -1
  52. package/build/es/polyfill/uploadInput/UploadInput.story.js +1 -1
  53. package/build/es/polyfill/utils.js +0 -0
  54. package/build/es/polyfill/withDisplayFormat/WithDisplayFormat.js +1 -2
  55. package/build/main.css +1 -1
  56. package/build/styles/inputs/Input.css +1 -0
  57. package/build/styles/inputs/TextArea.css +1 -0
  58. package/build/styles/main.css +1 -1
  59. package/build/types/accordion/AccordionItem/AccordionItem.d.ts +8 -9
  60. package/build/types/actionButton/ActionButton.story.d.ts +7 -3
  61. package/build/types/actionOption/ActionOption.story.d.ts +4 -13
  62. package/build/types/alert/inlineMarkdown/InlineMarkdown.d.ts +2 -3
  63. package/build/types/alert/withArrow/withArrow.d.ts +1 -2
  64. package/build/types/checkboxButton/CheckboxButton.story.d.ts +4 -2
  65. package/build/types/checkboxOption/CheckboxOption.story.d.ts +4 -5
  66. package/build/types/chips/Chips.story.d.ts +9 -14
  67. package/build/types/common/RadioButton/RadioButton.d.ts +7 -8
  68. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +4 -5
  69. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +8 -9
  70. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +6 -7
  71. package/build/types/dateLookup/tableLink/TableLink.d.ts +8 -9
  72. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +7 -8
  73. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +6 -7
  74. package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts +2 -16
  75. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts +3 -4
  76. package/build/types/flowNavigation/backButton/BackButton.d.ts +3 -4
  77. package/build/types/index.d.ts +4 -0
  78. package/build/types/inputs/Input.d.ts +13 -0
  79. package/build/types/inputs/TextArea.d.ts +10 -0
  80. package/build/types/inputs/_common.d.ts +5 -0
  81. package/build/types/modal/Modal.story.d.ts +3 -2
  82. package/build/types/progressBar/ProgressBar.story.d.ts +3 -3
  83. package/build/types/provider/Provider.story.d.ts +2 -6
  84. package/build/types/select/searchBox/SearchBox.d.ts +1 -1
  85. package/build/types/tabs/TabList.d.ts +1 -2
  86. package/build/types/tabs/TabPanel.d.ts +4 -7
  87. package/build/types/test-utils/GlobalsDecorator.d.ts +4 -5
  88. package/build/types/test-utils/index.d.ts +1 -1
  89. package/build/types/tile/Tile.d.ts +9 -10
  90. package/build/types/tooltip/Tooltip.story.d.ts +2 -1
  91. package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +15 -16
  92. package/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts +4 -9
  93. package/build/types/upload/steps/completeStep/completeStep.d.ts +9 -10
  94. package/build/types/upload/steps/mediaUploadStep/mediaUploadStep.d.ts +8 -9
  95. package/build/types/upload/steps/processingStep/processingStep.d.ts +8 -9
  96. package/build/types/upload/steps/uploadImageStep/uploadImageStep.d.ts +8 -9
  97. package/build/types/uploadInput/UploadInput.story.d.ts +20 -37
  98. package/build/types/utils.d.ts +1 -0
  99. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +18 -19
  100. package/build/umd/no-polyfill/main.js +1 -1
  101. package/build/umd/polyfill/main.js +1 -1
  102. package/package.json +65 -33
  103. package/upgrades/2021-04-v35-36-typescript-support.js +1 -0
@@ -1,6 +1 @@
1
- import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.array.reduce.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.number.is-nan.js";import"core-js/modules/es.number.constructor.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import{Spring}from"@react-spring/web";import classNames from"classnames";import clamp from"lodash.clamp";import PropTypes from"prop-types";import{Component,createRef,Fragment}from"react";import{Size,Width,Direction}from"../common";import KeyCodes from"../common/keyCodes";import{DirectionContext}from"../provider/direction";import Tab from"./Tab";import TabList from"./TabList";import TabPanel from"./TabPanel";import{getElasticDragDifference,getSwipeDifference,swipedLeftToRight,swipedRightToLeft,swipeShouldChangeTab,getVelocity}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MIN_INDEX=0,enabledTabsFilter=function(a){return!a.disabled},SpacerWidth={default:0,xs:8,sm:16,md:24,lg:32},Tabs=/*#__PURE__*/function(a){/** @type {RefObject<HTMLDivElement>} */function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"containerReference",/*#__PURE__*/createRef()),_defineProperty(_assertThisInitialized(d),"container",null),_defineProperty(_assertThisInitialized(d),"containerWidth",0),_defineProperty(_assertThisInitialized(d),"tabRefs",[]),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setContainerWidth(d.container),d.setState(function(a){var b=a.selectedTabIndex;return{translateTo:-(d.containerWidth*b)}})}),_defineProperty(_assertThisInitialized(d),"setContainerRefAndWidth",function(a){d.container=a,d.setContainerWidth(a)}),_defineProperty(_assertThisInitialized(d),"setContainerWidth",function(a){if(a){var b=a.getBoundingClientRect(),c=b.width;d.containerWidth=c}}),_defineProperty(_assertThisInitialized(d),"isTabDisabled",function(a){var b=d.props.tabs;return b[a]&&b[a].disabled}),_defineProperty(_assertThisInitialized(d),"getAllTabsWidth",function(){return d.tabRefs.map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"getDistanceToSelectedTab",function(a){return d.tabRefs.filter(function(b,c){return c<a}).map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"setTabWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.headerWidth,e=b.selected,f=d.getAllTabsWidth();!a&&(c===Width.BLOCK||d.containerWidth<f)&&d.setState({fullWidthTabs:!0,translateLineX:"".concat(100*e,"%")}),a&&c===Width.AUTO&&d.containerWidth>=f&&d.setState({fullWidthTabs:!1,translateLineX:"".concat(d.getDistanceToSelectedTab(e),"px")})}),_defineProperty(_assertThisInitialized(d),"getTabLineWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.selected,e=b.tabs;if(a)return"".concat(100*(1/e.length),"%");var f=d.tabRefs[c]||d.tabRefs[d.tabRefs.length-1],g=f?f.getBoundingClientRect().width:0;return"".concat(g,"px")}),_defineProperty(_assertThisInitialized(d),"getTabToSelect",function(a,b,c){var e=a;if(swipedLeftToRight(b,c)){if(e-=1,e>MIN_INDEX&&d.isTabDisabled(e))return d.getTabToSelect(e,b,c);}else if(swipedRightToLeft(b,c)&&(e+=1,e<d.MAX_INDEX&&d.isTabDisabled(e)))return d.getTabToSelect(e,b,c);return e=clamp(e,Math.max(a-1,MIN_INDEX),Math.min(a+1,d.MAX_INDEX)),d.isTabDisabled(e)?a:e}),_defineProperty(_assertThisInitialized(d),"swipedOverHalfOfContainer",function(a){return .5<=a/d.containerWidth}),_defineProperty(_assertThisInitialized(d),"calculateApplicableDragDifference",function(a){var b=a.currentSelected,c=a.nextSelected,e=a.start,f=a.end,g=getSwipeDifference(e,f),h=getElasticDragDifference(g);return swipedLeftToRight(e,f)?b>MIN_INDEX&&b!==c?Math.min(g,d.containerWidth):h:!!swipedRightToLeft(e,f)&&(b<d.MAX_INDEX&&b!==c?-Math.min(g,d.containerWidth):-h)}),_defineProperty(_assertThisInitialized(d),"switchTab",function(a){var b=d.props.onTabSelect;b(a)}),_defineProperty(_assertThisInitialized(d),"animateToTab",function(a,b){d.animateLine(a),d.animatePanel(d.getTabIndexWithoutDisabledTabs(a),b)}),_defineProperty(_assertThisInitialized(d),"animateLine",function(a){d.setState(function(b){return{translateLineX:b.fullWidthTabs?"".concat(100*a,"%"):"".concat(d.getDistanceToSelectedTab(a),"px")}})}),_defineProperty(_assertThisInitialized(d),"animatePanel",function(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=d.state.translateTo,e=c,f=-(d.containerWidth*a);d.setState({selectedTabIndex:a,isAnimating:!b&&e!==f,translateFrom:e,translateTo:f})}),_defineProperty(_assertThisInitialized(d),"disableScroll",function(a){var b=d.state.isSwiping;b&&a.preventDefault()}),_defineProperty(_assertThisInitialized(d),"handleTabClick",function(a){return function(){d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"onKeyDown",function(a){return function(b){b&&b.keyCode===KeyCodes.ENTER&&d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){var b={x:a.nativeEvent.touches[0].clientX,y:a.nativeEvent.touches[0].clientY,time:Date.now()};d.setState({start:b,currentSwipe:[b]}),a.persist()}),_defineProperty(_assertThisInitialized(d),"handleTouchMove",function(a){var b=d.state.start,c=d.props.selected,e=d.getTabIndexWithoutDisabledTabs(c),f={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},g=getSwipeDifference(b,f),h=getSwipeDifference(b,f,"y"),i=d.state,j=i.isScrolling,k=i.isSwiping;if(a.persist(),j||k||(g>h?k=!0:j=!0),d.setState({isScrolling:j,isSwiping:k}),k){var l=d.getTabToSelect(c,b,f);d.animateLine(d.swipedOverHalfOfContainer(g)?l:c);var m=d.calculateApplicableDragDifference({currentSelected:c,nextSelected:l,start:b,end:f}),n=!!m&&-(d.containerWidth*e)+m;d.setState(function(a){return{currentSwipe:[].concat(_toConsumableArray(a.currentSwipe),[f]),translateFrom:n||a.translateFrom,translateTo:n||a.translateTo}})}}),_defineProperty(_assertThisInitialized(d),"handleTouchEnd",function(a){var b=d.state,c=b.start,e=b.isSwiping,f=d.props.selected,g={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},h=getSwipeDifference(c,g),i=getVelocity([].concat(_toConsumableArray(d.state.currentSwipe),[g]));d.setState({currentSwipe:[]});var j=f;a.persist(),e&&((swipeShouldChangeTab(c,g)||d.swipedOverHalfOfContainer(h))&&(j=d.getTabToSelect(j,c,g)),j===f?d.animateToTab(j):(d.switchTab(j),d.setState({lastSwipeVelocity:i}))),d.setState({isSwiping:!1,isScrolling:!1})}),d.state={start:null,translateX:0,translateFrom:0,translateTo:0,translateLineX:null,isAnimating:!1,isSwiping:!1,isScrolling:!1,lastSwipeVelocity:0,fullWidthTabs:a.headerWidth===Width.BLOCK},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"filteredTabsLength",get:function get(){return this.props.tabs.filter(enabledTabsFilter).length}},{key:"MAX_INDEX",get:function get(){return this.props.tabs.length-1}},{key:"componentDidMount",value:function componentDidMount(){var a=this.props.selected;this.setTabWidth(),this.switchTab(clamp(a,MIN_INDEX,this.MAX_INDEX)),this.animateToTab(clamp(a,MIN_INDEX,this.MAX_INDEX),!0),document.body.addEventListener("touchmove",this.disableScroll,{passive:!1}),document.body.addEventListener("touchforcechange",this.disableScroll,{passive:!1}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function componentDidUpdate(a,b){var c=this.props.selected,d=a.selected,e=this.props.tabs[c],f=e&&e.disabled,g=a.tabs[d],h=g&&g.disabled,i=this.props.tabs.length,j=a.tabs.length,k=this.props.tabs.filter(enabledTabsFilter).length,l=a.tabs.filter(enabledTabsFilter).length,m=this.props.headerWidth,n=a.headerWidth,o=this.props.animatePanelsOnClick,p=!o&&!b.isSwiping;(m!==n||i!==j)&&this.setTabWidth(),(c!==d||k!==l||f!==h)&&this.animateToTab(clamp(c,MIN_INDEX,this.MAX_INDEX),c===d||p)}},{key:"componentWillUnmount",value:function componentWillUnmount(){document.body.removeEventListener("touchmove",this.disableScroll),document.body.removeEventListener("touchforcechange",this.disableScroll),window.removeEventListener("resize",this.handleResize)}/*
2
- * Gets the next tab that should be selected based on the swipe direction
3
- * and the current selected tab (is called recursively to account for disabled tabs).
4
- */},{key:"getTabIndexWithoutDisabledTabs",value:function getTabIndexWithoutDisabledTabs(a){return a-this.props.tabs.slice(0,a).filter(function(a){return!enabledTabsFilter(a)}).length}// Pass `instant` to set the `translateX` to the new panel with no transition
5
- },{key:"render",value:function render(){var a=this,b=this.props,c=b.tabs,d=b.changeTabOnSwipe,e=b.name,f=b.selected,g=b.className,h=b.transitionSpacing,i=b.headerWidth,j=this.state,k=j.isSwiping,l=j.translateLineX,m=j.isAnimating,n=j.translateFrom,o=j.translateTo,p=j.lastSwipeVelocity,q=j.fullWidthTabs,r=SpacerWidth[h],s=this.filteredTabsLength,t=Math.abs(-n-this.containerWidth*f),u=k?1-t/this.containerWidth:1-Math.abs(t/this.containerWidth-1),v=(Number.isNaN(u)?0:u)*Math.min(10*Math.E,10*p*Math.E),w=m||k,x=s*this.containerWidth+2*r,y=function(a){var b=a.id;return 0<r&&/*#__PURE__*/_jsx("div",{style:{width:r,display:w?"block":"none"}},b)};// Uses `props.panelTransitionSpacing` to add a spacer in-between the `TabPanel` you're transitioning to/from
6
- return/*#__PURE__*/_jsx(DirectionContext.Consumer,{children:function children(b){var h=b===Direction.RTL;return/*#__PURE__*/_jsxs("div",{ref:a.containerReference,className:classNames("tabs",g,{"tabs--auto-width":i===Width.AUTO}),onTouchStart:d?a.handleTouchStart:void 0,onTouchEnd:d?a.handleTouchEnd:void 0,onTouchMove:d?a.handleTouchMove:void 0,children:[/*#__PURE__*/_jsxs(TabList,{children:[c.map(function(b,d){var g=b.title,h=b.disabled;return/*#__PURE__*/_jsx(Tab,_objectSpread(_objectSpread({ref:function ref(b){a.tabRefs[d]=b},id:"".concat(e,"-tab-").concat(d),panelId:"".concat(e,"-panel-").concat(d),selected:f===d,disabled:h,focusTab:function focusTab(){var b;null!==(b=a.containerReference.current)&&void 0!==b&&b.contains(document.activeElement)&&a.tabRefs[d].focus()},onClick:h?null:a.handleTabClick(d),onKeyDown:a.onKeyDown(d)},q?{style:{width:"".concat(100*(1/c.length),"%")}}:{}),{},{children:g}),g)}),l?/*#__PURE__*/_jsx("li",{className:classNames("tabs__line"),style:{width:a.getTabLineWidth(),transform:h?"translateX(-".concat(l,")"):"translateX(".concat(l,")")}}):null]}),/*#__PURE__*/_jsx("div",{ref:a.setContainerRefAndWidth,className:"tabs__panel-container",style:{overflow:w?"hidden":"visible"},children:/*#__PURE__*/_jsx(Spring,{from:{transform:"translateX(".concat(n-r,"px)")},to:{transform:"translateX(".concat(o-r,"px)")},config:{precision:k?1:.01,velocity:k?0:v,clamp:!0},onRest:function onRest(){m&&a.setState({isAnimating:!1,lastSwipeVelocity:0})},children:function children(b){return/*#__PURE__*/_jsx("div",{className:"tabs__slider",style:{width:w?"".concat(x,"px"):"100%",transform:w?b.transform:"translateX(0px)"},children:c.map(function(b,d){var g=b.content,h=b.disabled;return h?null:/*#__PURE__*/_jsxs(Fragment,{children:[d===f&&/*#__PURE__*/_jsx(y,{id:"left-spacer"}),/*#__PURE__*/_jsx(TabPanel,{tabId:"".concat(e,"-tab-").concat(d),id:"".concat(e,"-panel-").concat(d),style:{width:w?"".concat(a.containerWidth,"px"):"100%",display:w||d===f?"block":"none"},children:g},c[d].title),d===f&&/*#__PURE__*/_jsx(y,{id:"right-spacer"})]},"".concat(c[d].title,"-fragment"))})})}})})]})}})}}]),b}(Component),SpacerSizes=_objectSpread(_objectSpread({},Size),{},{NONE:"default"});Tabs.propTypes={tabs:PropTypes.arrayOf(PropTypes.shape({title:PropTypes.string.isRequired,content:PropTypes.node.isRequired,disabled:PropTypes.bool.isRequired})).isRequired,selected:PropTypes.number.isRequired,onTabSelect:PropTypes.func.isRequired,name:PropTypes.string.isRequired,animatePanelsOnClick:PropTypes.bool,changeTabOnSwipe:PropTypes.bool,className:PropTypes.string,transitionSpacing:PropTypes.oneOf(["default","xs","sm","md","lg"]),headerWidth:PropTypes.oneOf(["auto","block"]),id:PropTypes.string},Tabs.defaultProps={animatePanelsOnClick:!1,changeTabOnSwipe:!0,className:"",transitionSpacing:SpacerSizes.NONE,headerWidth:Width.BLOCK};export default Tabs;
1
+ import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.array.reduce.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.number.is-nan.js";import"core-js/modules/es.number.constructor.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import{Spring}from"@react-spring/web";import classNames from"classnames";import clamp from"lodash.clamp";import PropTypes from"prop-types";import{Component,createRef,Fragment}from"react";import{Size,Width,Direction}from"../common";import KeyCodes from"../common/keyCodes";import{DirectionContext}from"../provider/direction";import Tab from"./Tab";import TabList from"./TabList";import TabPanel from"./TabPanel";import{getElasticDragDifference,getSwipeDifference,swipedLeftToRight,swipedRightToLeft,swipeShouldChangeTab,getVelocity}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MIN_INDEX=0,enabledTabsFilter=function(a){return!a.disabled},SpacerWidth={default:0,xs:8,sm:16,md:24,lg:32},Tabs=/*#__PURE__*/function(a){/** @type {RefObject<HTMLDivElement>} */function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"containerReference",/*#__PURE__*/createRef()),_defineProperty(_assertThisInitialized(d),"container",null),_defineProperty(_assertThisInitialized(d),"containerWidth",0),_defineProperty(_assertThisInitialized(d),"tabRefs",[]),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setContainerWidth(d.container),d.setState(function(a){var b=a.selectedTabIndex;return{translateTo:-(d.containerWidth*b)}})}),_defineProperty(_assertThisInitialized(d),"setContainerRefAndWidth",function(a){d.container=a,d.setContainerWidth(a)}),_defineProperty(_assertThisInitialized(d),"setContainerWidth",function(a){if(a){var b=a.getBoundingClientRect(),c=b.width;d.containerWidth=c}}),_defineProperty(_assertThisInitialized(d),"isTabDisabled",function(a){var b=d.props.tabs;return b[a]&&b[a].disabled}),_defineProperty(_assertThisInitialized(d),"getAllTabsWidth",function(){return d.tabRefs.map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"getDistanceToSelectedTab",function(a){return d.tabRefs.filter(function(b,c){return c<a}).map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"setTabWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.headerWidth,e=b.selected,f=d.getAllTabsWidth();!a&&(c===Width.BLOCK||d.containerWidth<f)&&d.setState({fullWidthTabs:!0,translateLineX:"".concat(100*e,"%")}),a&&c===Width.AUTO&&d.containerWidth>=f&&d.setState({fullWidthTabs:!1,translateLineX:"".concat(d.getDistanceToSelectedTab(e),"px")})}),_defineProperty(_assertThisInitialized(d),"getTabLineWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.selected,e=b.tabs;if(a)return"".concat(100*(1/e.length),"%");var f=d.tabRefs[c]||d.tabRefs[d.tabRefs.length-1],g=f?f.getBoundingClientRect().width:0;return"".concat(g,"px")}),_defineProperty(_assertThisInitialized(d),"getTabToSelect",function(a,b,c){var e=a;if(swipedLeftToRight(b,c)){if(e-=1,e>MIN_INDEX&&d.isTabDisabled(e))return d.getTabToSelect(e,b,c);}else if(swipedRightToLeft(b,c)&&(e+=1,e<d.MAX_INDEX&&d.isTabDisabled(e)))return d.getTabToSelect(e,b,c);return e=clamp(e,Math.max(a-1,MIN_INDEX),Math.min(a+1,d.MAX_INDEX)),d.isTabDisabled(e)?a:e}),_defineProperty(_assertThisInitialized(d),"swipedOverHalfOfContainer",function(a){return .5<=a/d.containerWidth}),_defineProperty(_assertThisInitialized(d),"calculateApplicableDragDifference",function(a){var b=a.currentSelected,c=a.nextSelected,e=a.start,f=a.end,g=getSwipeDifference(e,f),h=getElasticDragDifference(g);return swipedLeftToRight(e,f)?b>MIN_INDEX&&b!==c?Math.min(g,d.containerWidth):h:!!swipedRightToLeft(e,f)&&(b<d.MAX_INDEX&&b!==c?-Math.min(g,d.containerWidth):-h)}),_defineProperty(_assertThisInitialized(d),"switchTab",function(a){var b=d.props.onTabSelect;b(a)}),_defineProperty(_assertThisInitialized(d),"animateToTab",function(a,b){d.animateLine(a),d.animatePanel(d.getTabIndexWithoutDisabledTabs(a),b)}),_defineProperty(_assertThisInitialized(d),"animateLine",function(a){d.setState(function(b){return{translateLineX:b.fullWidthTabs?"".concat(100*a,"%"):"".concat(d.getDistanceToSelectedTab(a),"px")}})}),_defineProperty(_assertThisInitialized(d),"animatePanel",function(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=d.state.translateTo,e=c,f=-(d.containerWidth*a);d.setState({selectedTabIndex:a,isAnimating:!b&&e!==f,translateFrom:e,translateTo:f})}),_defineProperty(_assertThisInitialized(d),"disableScroll",function(a){var b=d.state.isSwiping;b&&a.preventDefault()}),_defineProperty(_assertThisInitialized(d),"handleTabClick",function(a){return function(){d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"onKeyDown",function(a){return function(b){b&&b.keyCode===KeyCodes.ENTER&&d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){var b={x:a.nativeEvent.touches[0].clientX,y:a.nativeEvent.touches[0].clientY,time:Date.now()};d.setState({start:b,currentSwipe:[b]}),a.persist()}),_defineProperty(_assertThisInitialized(d),"handleTouchMove",function(a){var b=d.state.start,c=d.props.selected,e=d.getTabIndexWithoutDisabledTabs(c),f={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},g=getSwipeDifference(b,f),h=getSwipeDifference(b,f,"y"),i=d.state,j=i.isScrolling,k=i.isSwiping;if(a.persist(),j||k||(g>h?k=!0:j=!0),d.setState({isScrolling:j,isSwiping:k}),k){var l=d.getTabToSelect(c,b,f);d.animateLine(d.swipedOverHalfOfContainer(g)?l:c);var m=d.calculateApplicableDragDifference({currentSelected:c,nextSelected:l,start:b,end:f}),n=!!m&&-(d.containerWidth*e)+m;d.setState(function(a){return{currentSwipe:[].concat(_toConsumableArray(a.currentSwipe),[f]),translateFrom:n||a.translateFrom,translateTo:n||a.translateTo}})}}),_defineProperty(_assertThisInitialized(d),"handleTouchEnd",function(a){var b=d.state,c=b.start,e=b.isSwiping,f=d.props.selected,g={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},h=getSwipeDifference(c,g),i=getVelocity([].concat(_toConsumableArray(d.state.currentSwipe),[g]));d.setState({currentSwipe:[]});var j=f;a.persist(),e&&((swipeShouldChangeTab(c,g)||d.swipedOverHalfOfContainer(h))&&(j=d.getTabToSelect(j,c,g)),j===f?d.animateToTab(j):(d.switchTab(j),d.setState({lastSwipeVelocity:i}))),d.setState({isSwiping:!1,isScrolling:!1})}),d.state={start:null,translateX:0,translateFrom:0,translateTo:0,translateLineX:null,isAnimating:!1,isSwiping:!1,isScrolling:!1,lastSwipeVelocity:0,fullWidthTabs:a.headerWidth===Width.BLOCK},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"filteredTabsLength",get:function get(){return this.props.tabs.filter(enabledTabsFilter).length}},{key:"MAX_INDEX",get:function get(){return this.props.tabs.length-1}},{key:"componentDidMount",value:function componentDidMount(){var a=this.props.selected;this.setTabWidth(),this.switchTab(clamp(a,MIN_INDEX,this.MAX_INDEX)),this.animateToTab(clamp(a,MIN_INDEX,this.MAX_INDEX),!0),document.body.addEventListener("touchmove",this.disableScroll,{passive:!1}),document.body.addEventListener("touchforcechange",this.disableScroll,{passive:!1}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function componentDidUpdate(a,b){var c=this.props.selected,d=a.selected,e=this.props.tabs[c],f=e&&e.disabled,g=a.tabs[d],h=g&&g.disabled,i=this.props.tabs.length,j=a.tabs.length,k=this.props.tabs.filter(enabledTabsFilter).length,l=a.tabs.filter(enabledTabsFilter).length,m=this.props.headerWidth,n=a.headerWidth,o=this.props.animatePanelsOnClick,p=!o&&!b.isSwiping;(m!==n||i!==j)&&this.setTabWidth(),(c!==d||k!==l||f!==h)&&this.animateToTab(clamp(c,MIN_INDEX,this.MAX_INDEX),c===d||p)}},{key:"componentWillUnmount",value:function componentWillUnmount(){document.body.removeEventListener("touchmove",this.disableScroll),document.body.removeEventListener("touchforcechange",this.disableScroll),window.removeEventListener("resize",this.handleResize)}},{key:"getTabIndexWithoutDisabledTabs",value:function getTabIndexWithoutDisabledTabs(a){return a-this.props.tabs.slice(0,a).filter(function(a){return!enabledTabsFilter(a)}).length}},{key:"render",value:function render(){var a=this,b=this.props,c=b.tabs,d=b.changeTabOnSwipe,e=b.name,f=b.selected,g=b.className,h=b.transitionSpacing,i=b.headerWidth,j=this.state,k=j.isSwiping,l=j.translateLineX,m=j.isAnimating,n=j.translateFrom,o=j.translateTo,p=j.lastSwipeVelocity,q=j.fullWidthTabs,r=SpacerWidth[h],s=this.filteredTabsLength,t=Math.abs(-n-this.containerWidth*f),u=k?1-t/this.containerWidth:1-Math.abs(t/this.containerWidth-1),v=(Number.isNaN(u)?0:u)*Math.min(10*Math.E,10*p*Math.E),w=m||k,x=s*this.containerWidth+2*r,y=function(a){var b=a.id;return 0<r&&/*#__PURE__*/_jsx("div",{style:{width:r,display:w?"block":"none"}},b)};return/*#__PURE__*/_jsx(DirectionContext.Consumer,{children:function children(b){var h=b===Direction.RTL;return/*#__PURE__*/_jsxs("div",{ref:a.containerReference,className:classNames("tabs",g,{"tabs--auto-width":i===Width.AUTO}),onTouchStart:d?a.handleTouchStart:void 0,onTouchEnd:d?a.handleTouchEnd:void 0,onTouchMove:d?a.handleTouchMove:void 0,children:[/*#__PURE__*/_jsxs(TabList,{children:[c.map(function(b,d){var g=b.title,h=b.disabled;return/*#__PURE__*/_jsx(Tab,_objectSpread(_objectSpread({ref:function ref(b){a.tabRefs[d]=b},id:"".concat(e,"-tab-").concat(d),panelId:"".concat(e,"-panel-").concat(d),selected:f===d,disabled:h,focusTab:function focusTab(){var b;null!==(b=a.containerReference.current)&&void 0!==b&&b.contains(document.activeElement)&&a.tabRefs[d].focus()},onClick:h?null:a.handleTabClick(d),onKeyDown:a.onKeyDown(d)},q?{style:{width:"".concat(100*(1/c.length),"%")}}:{}),{},{children:g}),g)}),l?/*#__PURE__*/_jsx("li",{className:classNames("tabs__line"),style:{width:a.getTabLineWidth(),transform:h?"translateX(-".concat(l,")"):"translateX(".concat(l,")")}}):null]}),/*#__PURE__*/_jsx("div",{ref:a.setContainerRefAndWidth,className:"tabs__panel-container",style:{overflow:w?"hidden":"visible"},children:/*#__PURE__*/_jsx(Spring,{from:{transform:"translateX(".concat(n-r,"px)")},to:{transform:"translateX(".concat(o-r,"px)")},config:{precision:k?1:.01,velocity:k?0:v,clamp:!0},onRest:function onRest(){m&&a.setState({isAnimating:!1,lastSwipeVelocity:0})},children:function children(b){return/*#__PURE__*/_jsx("div",{className:"tabs__slider",style:{width:w?"".concat(x,"px"):"100%",transform:w?b.transform:"translateX(0px)"},children:c.map(function(b,d){var g=b.content,h=b.disabled;return h?null:/*#__PURE__*/_jsxs(Fragment,{children:[d===f&&/*#__PURE__*/_jsx(y,{id:"left-spacer"}),/*#__PURE__*/_jsx(TabPanel,{tabId:"".concat(e,"-tab-").concat(d),id:"".concat(e,"-panel-").concat(d),style:{width:w?"".concat(a.containerWidth,"px"):"100%",display:w||d===f?"block":"none"},children:g},c[d].title),d===f&&/*#__PURE__*/_jsx(y,{id:"right-spacer"})]},"".concat(c[d].title,"-fragment"))})})}})})]})}})}}]),b}(Component),SpacerSizes=_objectSpread(_objectSpread({},Size),{},{NONE:"default"});Tabs.propTypes={tabs:PropTypes.arrayOf(PropTypes.shape({title:PropTypes.string.isRequired,content:PropTypes.node.isRequired,disabled:PropTypes.bool.isRequired})).isRequired,selected:PropTypes.number.isRequired,onTabSelect:PropTypes.func.isRequired,name:PropTypes.string.isRequired,animatePanelsOnClick:PropTypes.bool,changeTabOnSwipe:PropTypes.bool,className:PropTypes.string,transitionSpacing:PropTypes.oneOf(["default","xs","sm","md","lg"]),headerWidth:PropTypes.oneOf(["auto","block"]),id:PropTypes.string},Tabs.defaultProps={animatePanelsOnClick:!1,changeTabOnSwipe:!0,className:"",transitionSpacing:SpacerSizes.NONE,headerWidth:Width.BLOCK};export default Tabs;
@@ -1 +1 @@
1
- import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.map.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}/* eslint-disable jsx-a11y/no-autofocus */ /* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */import classnames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var DEFAULT_INPUT_MIN_WIDTH=10,TypeaheadInput=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"recalculateWidth",function(){requestAnimationFrame(function(){a.setState({inputWidth:Math.max(DEFAULT_INPUT_MIN_WIDTH,a.sizerRef.scrollWidth+10)})})}),_defineProperty(_assertThisInitialized(a),"renderInput",function(){var b=a.props,c=b.typeaheadId,d=b.autoFocus,e=b.multiple,f=b.name,g=b.optionsShown,h=b.placeholder,i=b.selected,j=b.value,k=b.onChange,l=b.onKeyDown,m=b.onFocus,n=b.onPaste,o=b.autoComplete,p=a.state.inputWidth,q=!e||0===i.length;return/*#__PURE__*/_jsx("input",{ref:function ref(b){a.inputRef=b},className:classnames({"typeahead__input form-control":e,"form-control":!e}),type:"text",name:f,id:"input-".concat(c),autoFocus:d,placeholder:q?h:"","aria-autocomplete":"list","aria-expanded":g,"aria-haspopup":"listbox","aria-controls":"menu-".concat(c),autoComplete:o,role:"combobox",value:j,style:e&&0<i.length?{width:p}:{},onChange:k,onKeyDown:l,onClick:m,onFocus:m,onPaste:n})}),a.state={inputWidth:DEFAULT_INPUT_MIN_WIDTH},a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentDidMount",value:function componentDidMount(){var a=this.props.autoFocus;a&&this.inputRef.focus()}},{key:"componentDidUpdate",value:function componentDidUpdate(a){a.value!==this.props.value&&this.props.multiple&&this.recalculateWidth()}},{key:"render",value:function render(){var a=this,b=this.props,c=b.multiple,d=b.selected,e=b.value,f=b.maxHeight,g=b.renderChip;return c?/*#__PURE__*/_jsxs("div",{className:"form-control typeahead__input-container",style:f&&{maxHeight:f},onClick:function onClick(){a.inputRef.focus()},children:[/*#__PURE__*/_jsxs("div",{className:"typeahead__input-wrapper",children:[d&&d.map(function(a,b){return g(a,b)}),this.renderInput(),/*#__PURE__*/_jsx("div",{className:"typeahead__input-aligner"})]}),/*#__PURE__*/_jsx("div",{ref:function ref(b){a.sizerRef=b},className:"sizer form-control typeahead__input",children:e})]}):this.renderInput()}}]),b}(Component);export{TypeaheadInput as default};TypeaheadInput.propTypes={typeaheadId:PropTypes.string.isRequired,name:PropTypes.string.isRequired,autoFocus:PropTypes.bool,multiple:PropTypes.bool.isRequired,value:PropTypes.string.isRequired,selected:PropTypes.arrayOf(PropTypes.object),placeholder:PropTypes.string,optionsShown:PropTypes.bool,maxHeight:PropTypes.number,autoComplete:PropTypes.string.isRequired,onChange:PropTypes.func.isRequired,renderChip:PropTypes.func.isRequired,onKeyDown:PropTypes.func.isRequired,onFocus:PropTypes.func.isRequired,onPaste:PropTypes.func.isRequired},TypeaheadInput.defaultProps={autoFocus:!1,maxHeight:null,placeholder:"",optionsShown:!1,selected:[]};
1
+ import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.map.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}/* eslint-disable jsx-a11y/no-autofocus */ /* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */import classnames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import{Input}from"../../inputs/Input";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var DEFAULT_INPUT_MIN_WIDTH=10,TypeaheadInput=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"recalculateWidth",function(){requestAnimationFrame(function(){a.setState({inputWidth:Math.max(DEFAULT_INPUT_MIN_WIDTH,a.sizerRef.scrollWidth+10)})})}),_defineProperty(_assertThisInitialized(a),"renderInput",function(){var b=a.props,c=b.typeaheadId,d=b.autoFocus,e=b.multiple,f=b.name,g=b.optionsShown,h=b.placeholder,i=b.selected,j=b.value,k=b.onChange,l=b.onKeyDown,m=b.onFocus,n=b.onPaste,o=b.autoComplete,p=a.state.inputWidth,q=!e||0===i.length;return/*#__PURE__*/_jsx(Input,{ref:function ref(b){a.inputRef=b},className:classnames(e&&"typeahead__input"),name:f,id:"input-".concat(c),autoFocus:d,placeholder:q?h:"","aria-autocomplete":"list","aria-expanded":g,"aria-haspopup":"listbox","aria-controls":"menu-".concat(c),autoComplete:o,role:"combobox",value:j,style:e&&0<i.length?{width:p}:{},onChange:k,onKeyDown:l,onClick:m,onFocus:m,onPaste:n})}),a.state={inputWidth:DEFAULT_INPUT_MIN_WIDTH},a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentDidMount",value:function componentDidMount(){var a=this.props.autoFocus;a&&this.inputRef.focus()}},{key:"componentDidUpdate",value:function componentDidUpdate(a){a.value!==this.props.value&&this.props.multiple&&this.recalculateWidth()}},{key:"render",value:function render(){var a=this,b=this.props,c=b.multiple,d=b.selected,e=b.value,f=b.maxHeight,g=b.renderChip;return c?/*#__PURE__*/_jsxs("div",{className:"form-control typeahead__input-container",style:f&&{maxHeight:f},onClick:function onClick(){a.inputRef.focus()},children:[/*#__PURE__*/_jsxs("div",{className:"typeahead__input-wrapper",children:[d&&d.map(function(a,b){return g(a,b)}),this.renderInput(),/*#__PURE__*/_jsx("div",{className:"typeahead__input-aligner"})]}),/*#__PURE__*/_jsx("div",{ref:function ref(b){a.sizerRef=b},className:"sizer form-control typeahead__input",children:e})]}):this.renderInput()}}]),b}(Component);export{TypeaheadInput as default};TypeaheadInput.propTypes={typeaheadId:PropTypes.string.isRequired,name:PropTypes.string.isRequired,autoFocus:PropTypes.bool,multiple:PropTypes.bool.isRequired,value:PropTypes.string.isRequired,selected:PropTypes.arrayOf(PropTypes.object),placeholder:PropTypes.string,optionsShown:PropTypes.bool,maxHeight:PropTypes.number,autoComplete:PropTypes.string.isRequired,onChange:PropTypes.func.isRequired,renderChip:PropTypes.func.isRequired,onKeyDown:PropTypes.func.isRequired,onFocus:PropTypes.func.isRequired,onPaste:PropTypes.func.isRequired},TypeaheadInput.defaultProps={autoFocus:!1,maxHeight:null,placeholder:"",optionsShown:!1,selected:[]};
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.slice.js";import{action}from"@storybook/addon-actions";import{Status}from"../common";import UploadInput from"./UploadInput";import{jsx as _jsx}from"react/jsx-runtime";export default{title:"Forms/UploadInput",component:UploadInput,tags:["autodocs"]};var files=[{id:1,filename:"purchase-receipt.pdf",url:"https://wise.com/public-resources/assets/logos/wise/brand_logo_inverse.svg"},{id:2,filename:"receipt failed.png",status:Status.FAILED},{id:3,filename:"receipt failed with error string.png",status:Status.SUCCEEDED},{id:4,filename:"receipt failed with error object.png",status:Status.SUCCEEDED}],createDelayedPromise=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=a.successful,c=a.delaySeconds,d=void 0===c?3:c,e=a.response,f=void 0===e?{id:Math.round(1e4*Math.random()),url:"#"}:e;return new Promise(function(a,c){setTimeout(function(){return!(void 0!==b)||b?a(f):c(new Error("Unexpected error"))},1e3*d)})},props={onUploadFile:function onUploadFile(){return createDelayedPromise()},onDeleteFile:function onDeleteFile(){return createDelayedPromise()}},Template=function(a){return/*#__PURE__*/_jsx(UploadInput,_objectSpread({},a))};export var SingleFile=Template.bind({});SingleFile.args=_objectSpread({},props);export var MultipleFiles=Template.bind({});MultipleFiles.args=_objectSpread(_objectSpread({},props),{},{multiple:!0});export var UploadInputWithDescriptionFromProps=Template.bind({});UploadInputWithDescriptionFromProps.args=_objectSpread(_objectSpread({},props),{},{multiple:!0,description:"Custom file description from prop"});export var Disabled=Template.bind({});Disabled.args=_objectSpread(_objectSpread({},props),{},{disabled:!0});export var WithAnyFileType=Template.bind({});WithAnyFileType.args=_objectSpread(_objectSpread({},props),{},{fileTypes:"*"});export var WithSingleFileType=Template.bind({});WithSingleFileType.args=_objectSpread(_objectSpread({},props),{},{fileTypes:".zip,application/zip"});export var WithMultipleExistingFiles=Template.bind({});WithMultipleExistingFiles.args=_objectSpread(_objectSpread({},props),{},{files:files,multiple:!0});export var WithoutDelete=Template.bind({});WithoutDelete.args=_objectSpread(_objectSpread({},props),{},{files:files,onDeleteFile:void 0,multiple:!0});export var WithUploadFailed=Template.bind({});WithUploadFailed.args=_objectSpread(_objectSpread({},props),{},{files:files.slice(0),onUploadFile:function onUploadFile(){return createDelayedPromise({successful:!1})},multiple:!0});export var WithDeleteFailed=Template.bind({});WithDeleteFailed.args=_objectSpread(_objectSpread({},props),{},{files:files.slice(0),onDeleteFile:function onDeleteFile(){return createDelayedPromise({successful:!1})},multiple:!0});export var CustomConfirmMessage=Template.bind({});CustomConfirmMessage.args=_objectSpread(_objectSpread({},props),{},{files:files.slice(0),deleteConfirm:{title:"Sure you want to remove this invoice?",body:/*#__PURE__*/_jsx("img",{alt:"brand logo",src:"https://wise.com/public-resources/assets/logos/wise/brand_logo.svg"})}});export var withManualDownloadHandler=Template.bind({});withManualDownloadHandler.args=_objectSpread(_objectSpread({},props),{},{files:files,onDownload:action("Manual download handler")});export var withFilesChangeHandler=Template.bind({});withFilesChangeHandler.args=_objectSpread(_objectSpread({},props),{},{files:files,onFilesChange:action("Files change handler")});export var withMaxFilesToUploadLimit=Template.bind({});withMaxFilesToUploadLimit.args=_objectSpread(_objectSpread({},props),{},{multiple:!0,maxFiles:5,maxFilesErrorMessage:"Can't upload as maximum number of files allowed are already uploaded"});export var withFileSizeErrorMessage=Template.bind({});withFileSizeErrorMessage.args=_objectSpread(_objectSpread({},props),{},{sizeLimit:1,sizeLimitErrorMessage:"The file is oversized"});export var withCustomUploadButtonTitle=Template.bind({});withCustomUploadButtonTitle.args=_objectSpread(_objectSpread({},props),{},{uploadButtonTitle:"Upload the VAT receipts for FY 2022-23"});
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.slice.js";import{action}from"@storybook/addon-actions";import{Status}from"../common";import UploadInput from"./UploadInput";import{jsx as _jsx}from"react/jsx-runtime";var meta={title:"Forms/UploadInput",component:UploadInput,tags:["autodocs"]};export default meta;var files=[{id:1,filename:"purchase-receipt.pdf",url:"https://wise.com/public-resources/assets/logos/wise/brand_logo_inverse.svg"},{id:2,filename:"receipt failed.png",status:Status.FAILED},{id:3,filename:"receipt failed with error string.png",status:Status.SUCCEEDED},{id:4,filename:"receipt failed with error object.png",status:Status.SUCCEEDED}],createDelayedPromise=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},b=a.successful,c=a.delaySeconds,d=void 0===c?3:c,e=a.response,f=void 0===e?{id:Math.round(1e4*Math.random()),url:"#"}:e;return new Promise(function(a,c){setTimeout(function(){return!(void 0!==b)||b?a(f):c(new Error("Unexpected error"))},1e3*d)})},props={onUploadFile:function onUploadFile(){return createDelayedPromise()},onDeleteFile:function onDeleteFile(){return createDelayedPromise()}},Template=function(a){return/*#__PURE__*/_jsx(UploadInput,_objectSpread({},a))};export var SingleFile=Template.bind({});SingleFile.args=_objectSpread({},props);export var MultipleFiles=Template.bind({});MultipleFiles.args=_objectSpread(_objectSpread({},props),{},{multiple:!0});export var UploadInputWithDescriptionFromProps=Template.bind({});UploadInputWithDescriptionFromProps.args=_objectSpread(_objectSpread({},props),{},{multiple:!0,description:"Custom file description from prop"});export var Disabled=Template.bind({});Disabled.args=_objectSpread(_objectSpread({},props),{},{disabled:!0});export var WithAnyFileType=Template.bind({});WithAnyFileType.args=_objectSpread(_objectSpread({},props),{},{fileTypes:"*"});export var WithSingleFileType=Template.bind({});WithSingleFileType.args=_objectSpread(_objectSpread({},props),{},{fileTypes:".zip,application/zip"});export var WithMultipleExistingFiles=Template.bind({});WithMultipleExistingFiles.args=_objectSpread(_objectSpread({},props),{},{files:files,multiple:!0});export var WithoutDelete=Template.bind({});WithoutDelete.args=_objectSpread(_objectSpread({},props),{},{files:files,onDeleteFile:void 0,multiple:!0});export var WithUploadFailed=Template.bind({});WithUploadFailed.args=_objectSpread(_objectSpread({},props),{},{files:files.slice(0),onUploadFile:function onUploadFile(){return createDelayedPromise({successful:!1})},multiple:!0});export var WithDeleteFailed=Template.bind({});WithDeleteFailed.args=_objectSpread(_objectSpread({},props),{},{files:files.slice(0),onDeleteFile:function onDeleteFile(){return createDelayedPromise({successful:!1})},multiple:!0});export var CustomConfirmMessage=Template.bind({});CustomConfirmMessage.args=_objectSpread(_objectSpread({},props),{},{files:files.slice(0),deleteConfirm:{title:"Sure you want to remove this invoice?",body:/*#__PURE__*/_jsx("img",{alt:"brand logo",src:"https://wise.com/public-resources/assets/logos/wise/brand_logo.svg"})}});export var withManualDownloadHandler=Template.bind({});withManualDownloadHandler.args=_objectSpread(_objectSpread({},props),{},{files:files,onDownload:action("Manual download handler")});export var withFilesChangeHandler=Template.bind({});withFilesChangeHandler.args=_objectSpread(_objectSpread({},props),{},{files:files,onFilesChange:action("Files change handler")});export var withMaxFilesToUploadLimit=Template.bind({});withMaxFilesToUploadLimit.args=_objectSpread(_objectSpread({},props),{},{multiple:!0,maxFiles:5,maxFilesErrorMessage:"Can't upload as maximum number of files allowed are already uploaded"});export var withFileSizeErrorMessage=Template.bind({});withFileSizeErrorMessage.args=_objectSpread(_objectSpread({},props),{},{sizeLimit:1,sizeLimitErrorMessage:"The file is oversized"});export var withCustomUploadButtonTitle=Template.bind({});withCustomUploadButtonTitle.args=_objectSpread(_objectSpread({},props),{},{uploadButtonTitle:"Upload the VAT receipts for FY 2022-23"});
File without changes
@@ -1,7 +1,6 @@
1
1
  import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import"core-js/modules/es.array.splice.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.function.name.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import PropTypes from"prop-types";import{Component}from"react";import{HistoryNavigator}from"../common";import{formatWithPattern,getCountOfSymbolsInSelection,getCursorPositionAfterKeystroke,unformatWithPattern,getDistanceToPreviousSymbol,getDistanceToNextSymbol}from"../common/textFormat";var WithDisplayFormat=/*#__PURE__*/function(a){function b(a){var d;_classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"getUserAction",function(a){var b=d.state,c=b.triggerEvent,e=b.triggerType,f=b.value,g=d.props.displayPattern,h=String.fromCharCode(c.which).toLowerCase();return"Paste"===e||"Cut"===e?e:(c.ctrlKey||c.metaKey)&&"z"===h?c.shiftKey?"Redo":"Undo":c.ctrlKey&&"d"===h?"Delete":"undefined"==typeof c.key&&a.length<=unformatWithPattern(f,g).length?"Backspace":c.key;// Detect mouse event redo
2
2
  // Android Fix.
3
- }),_defineProperty(_assertThisInitialized(d),"resetEvent",function(){d.setState({triggerType:null,triggerEvent:null,pastedLength:0})}),_defineProperty(_assertThisInitialized(d),"detectUndoRedo",function(a){var b=String.fromCharCode(a.which).toLowerCase();return(a.ctrlKey||a.metaKey)&&"z"===b?a.shiftKey?"Redo":"Undo":null}),_defineProperty(_assertThisInitialized(d),"handleOnKeyDown",function(a){a.persist();var b=a.target,c=b.selectionStart,e=b.selectionEnd,f=d.state.historyNavigator,g=d.props.displayPattern,h="";// Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.
4
- "Undo"===d.detectUndoRedo(a)?(h=formatWithPattern(f.undo(),g),d.setState({value:h,triggerType:"Undo"})):"Redo"===d.detectUndoRedo(a)?(h=formatWithPattern(f.redo(),g),d.setState({value:h,triggerType:"Redo"})):d.setState({triggerEvent:a,triggerType:"KeyDown",selectionStart:c,selectionEnd:e})}),_defineProperty(_assertThisInitialized(d),"handleOnPaste",function(a){var b=d.props.displayPattern,c=unformatWithPattern(a.clipboardData.getData("Text"),b).length;d.setState({triggerType:"Paste",pastedLength:c})}),_defineProperty(_assertThisInitialized(d),"handleOnCut",function(){d.setState({triggerType:"Cut"})}),_defineProperty(_assertThisInitialized(d),"isKeyAllowed",function(a){var b=d.props.displayPattern,c=b.split("").filter(function(a){return"*"!==a});return!c.includes(a)}),_defineProperty(_assertThisInitialized(d),"handleOnChange",function(a){var b=d.state,c=b.historyNavigator,e=b.triggerEvent,f=b.triggerType,g=d.props,h=g.displayPattern,i=g.onChange,j=a.target.value,k=unformatWithPattern(j,h),l=null===e?// triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
3
+ }),_defineProperty(_assertThisInitialized(d),"resetEvent",function(){d.setState({triggerType:null,triggerEvent:null,pastedLength:0})}),_defineProperty(_assertThisInitialized(d),"detectUndoRedo",function(a){var b=String.fromCharCode(a.which).toLowerCase();return(a.ctrlKey||a.metaKey)&&"z"===b?a.shiftKey?"Redo":"Undo":null}),_defineProperty(_assertThisInitialized(d),"handleOnKeyDown",function(a){a.persist();var b=a.target,c=b.selectionStart,e=b.selectionEnd,f=d.state.historyNavigator,g=d.props.displayPattern,h="";"Undo"===d.detectUndoRedo(a)?(h=formatWithPattern(f.undo(),g),d.setState({value:h,triggerType:"Undo"})):"Redo"===d.detectUndoRedo(a)?(h=formatWithPattern(f.redo(),g),d.setState({value:h,triggerType:"Redo"})):d.setState({triggerEvent:a,triggerType:"KeyDown",selectionStart:c,selectionEnd:e})}),_defineProperty(_assertThisInitialized(d),"handleOnPaste",function(a){var b=d.props.displayPattern,c=unformatWithPattern(a.clipboardData.getData("Text"),b).length;d.setState({triggerType:"Paste",pastedLength:c})}),_defineProperty(_assertThisInitialized(d),"handleOnCut",function(){d.setState({triggerType:"Cut"})}),_defineProperty(_assertThisInitialized(d),"isKeyAllowed",function(a){var b=d.props.displayPattern,c=b.split("").filter(function(a){return"*"!==a});return!c.includes(a)}),_defineProperty(_assertThisInitialized(d),"handleOnChange",function(a){var b=d.state,c=b.historyNavigator,e=b.triggerEvent,f=b.triggerType,g=d.props,h=g.displayPattern,i=g.onChange,j=a.target.value,k=unformatWithPattern(j,h),l=null===e?// triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
5
4
  "Paste":d.getUserAction(k);if(d.isKeyAllowed(l)&&"Undo"!==f&&"Redo"!==f){("Backspace"===l||"Delete"===l)&&(k=d.handleDelete(k,l));var m=formatWithPattern(k,h);c.add(k),d.handleCursorPositioning(l);var n=unformatWithPattern(m,h);d.setState({value:m},d.resetEvent(),i(n))}}),_defineProperty(_assertThisInitialized(d),"handleOnBlur",function(a){var b=d.props,c=b.displayPattern,e=b.onBlur;e&&e(unformatWithPattern(a.target.value,c))}),_defineProperty(_assertThisInitialized(d),"handleOnFocus",function(a){var b=d.props,c=b.displayPattern,e=b.onFocus;e&&(d.handleOnChange(a),e(unformatWithPattern(a.target.value,c)))}),_defineProperty(_assertThisInitialized(d),"handleDelete",function(a,b){var c=d.props.displayPattern,e=d.state,f=e.selectionStart,g=e.selectionEnd,h=_toConsumableArray(a);if(f===g){var i=f-getCountOfSymbolsInSelection(0,f,c),j=0,k=getDistanceToNextSymbol(f,c);"Backspace"===b&&(i-=1,k=getDistanceToPreviousSymbol(f,c)),0<=i&&k&&(j=1),h.splice(i,j)}return h.join("")}),_defineProperty(_assertThisInitialized(d),"handleCursorPositioning",function(a){var b=d.props.displayPattern,c=d.state,e=c.triggerEvent,f=c.selectionStart,g=c.selectionEnd,h=c.pastedLength,i=getCursorPositionAfterKeystroke(a,f,g,b,h);setTimeout(function(){e&&e.target.setSelectionRange(i,i),d.setState({selectionStart:i,selectionEnd:i})},0)});var e=a.value,f=a.displayPattern,g=unformatWithPattern(e,f);return d.state={value:formatWithPattern(g,f),historyNavigator:new HistoryNavigator,prevDisplayPattern:a.displayPattern,triggerType:null,triggerEvent:null},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"render",value:function render(){var a=this.props,b=a.type,c=a.inputMode,d=a.className,e=a.id,f=a.name,g=a.placeholder,h=a.readOnly,i=a.required,j=a.minLength,k=a.maxLength,l=a.disabled,m=a.autoComplete,n=this.state.value,o={type:b,inputMode:c,className:d,id:e,name:f,placeholder:g,readOnly:h,required:i,minLength:j,maxLength:k,disabled:l,autoComplete:m,value:n,onFocus:this.handleOnFocus,onBlur:this.handleOnBlur,onPaste:this.handleOnPaste,onKeyDown:this.handleOnKeyDown,onChange:this.handleOnChange,onCut:this.handleOnCut};return this.props.render(o)}}],[{key:"getDerivedStateFromProps",value:function getDerivedStateFromProps(a,b){var c=a.displayPattern,d=b.prevDisplayPattern;if(b.prevDisplayPattern!==c){var e=b.value,f=b.historyNavigator,g=unformatWithPattern(e,d);return f.reset(),{prevDisplayPattern:c,value:formatWithPattern(g,c),triggerType:null,triggerEvent:null,pastedLength:0}}return null}}]),b}(Component);WithDisplayFormat.propTypes={/**
6
5
  * autocomplete hides our form help so we need to disable it when help text
7
6
  * is present. Chrome ignores autocomplete=off, the only way to disable it is