@transferwise/components 43.13.49 → 44.0.1

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 (100) hide show
  1. package/README.md +1 -1
  2. package/build/es/no-polyfill/alert/Alert.js +1 -1
  3. package/build/es/no-polyfill/alert/withArrow/alertArrowPositions.js +1 -1
  4. package/build/es/no-polyfill/avatar/avatarTypes.js +1 -1
  5. package/build/es/no-polyfill/common/direction.js +1 -1
  6. package/build/es/no-polyfill/common/fileType.js +1 -1
  7. package/build/es/no-polyfill/common/focusBoundary/utils/getFocusableElements.js +1 -1
  8. package/build/es/no-polyfill/common/propsValues/breakpoint.js +1 -1
  9. package/build/es/no-polyfill/common/propsValues/control.js +1 -1
  10. package/build/es/no-polyfill/common/propsValues/dateMode.js +1 -1
  11. package/build/es/no-polyfill/common/propsValues/layouts.js +1 -1
  12. package/build/es/no-polyfill/common/propsValues/markdownNodeType.js +1 -1
  13. package/build/es/no-polyfill/common/propsValues/monthFormat.js +1 -1
  14. package/build/es/no-polyfill/common/propsValues/position.js +1 -1
  15. package/build/es/no-polyfill/common/propsValues/profileType.js +1 -1
  16. package/build/es/no-polyfill/common/propsValues/scroll.js +1 -1
  17. package/build/es/no-polyfill/common/propsValues/sentiment.js +1 -1
  18. package/build/es/no-polyfill/common/propsValues/size.js +1 -1
  19. package/build/es/no-polyfill/common/propsValues/status.js +1 -1
  20. package/build/es/no-polyfill/common/propsValues/type.js +1 -1
  21. package/build/es/no-polyfill/common/propsValues/typography.js +1 -1
  22. package/build/es/no-polyfill/common/propsValues/variant.js +1 -1
  23. package/build/es/no-polyfill/common/propsValues/width.js +1 -1
  24. package/build/es/no-polyfill/common/theme.js +1 -1
  25. package/build/es/no-polyfill/decision/decisionEnums.js +2 -2
  26. package/build/es/no-polyfill/info/infoPresentations.js +1 -1
  27. package/build/es/no-polyfill/lab/pagination/Pagination.js +1 -1
  28. package/build/es/no-polyfill/loader/Loader.js +3 -3
  29. package/build/es/no-polyfill/logo/logoTypes.js +1 -1
  30. package/build/es/no-polyfill/select/Select.js +1 -1
  31. package/build/es/no-polyfill/select/option/Option.js +1 -1
  32. package/build/es/no-polyfill/tabs/Tabs.js +1 -1
  33. package/build/es/no-polyfill/title/Title.js +1 -1
  34. package/build/es/no-polyfill/typeahead/Typeahead.js +1 -1
  35. package/build/es/no-polyfill/upload/uploadSteps.js +1 -1
  36. package/build/es/no-polyfill/uploadInput/UploadInput.js +5 -5
  37. package/build/es/no-polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
  38. package/build/es/no-polyfill/uploadInput/uploadItem/UploadItem.js +1 -1
  39. package/build/es/polyfill/alert/Alert.js +1 -1
  40. package/build/es/polyfill/alert/withArrow/alertArrowPositions.js +1 -1
  41. package/build/es/polyfill/avatar/avatarTypes.js +1 -1
  42. package/build/es/polyfill/avatarWrapper/AvatarWrapper.js +1 -1
  43. package/build/es/polyfill/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.js +1 -1
  44. package/build/es/polyfill/common/direction.js +1 -1
  45. package/build/es/polyfill/common/fileType.js +1 -1
  46. package/build/es/polyfill/common/focusBoundary/utils/getFocusableElements.js +1 -1
  47. package/build/es/polyfill/common/propsValues/breakpoint.js +1 -1
  48. package/build/es/polyfill/common/propsValues/control.js +1 -1
  49. package/build/es/polyfill/common/propsValues/dateMode.js +1 -1
  50. package/build/es/polyfill/common/propsValues/layouts.js +1 -1
  51. package/build/es/polyfill/common/propsValues/markdownNodeType.js +1 -1
  52. package/build/es/polyfill/common/propsValues/monthFormat.js +1 -1
  53. package/build/es/polyfill/common/propsValues/position.js +1 -1
  54. package/build/es/polyfill/common/propsValues/profileType.js +1 -1
  55. package/build/es/polyfill/common/propsValues/scroll.js +1 -1
  56. package/build/es/polyfill/common/propsValues/sentiment.js +1 -1
  57. package/build/es/polyfill/common/propsValues/size.js +1 -1
  58. package/build/es/polyfill/common/propsValues/status.js +1 -1
  59. package/build/es/polyfill/common/propsValues/type.js +1 -1
  60. package/build/es/polyfill/common/propsValues/typography.js +1 -1
  61. package/build/es/polyfill/common/propsValues/variant.js +1 -1
  62. package/build/es/polyfill/common/propsValues/width.js +1 -1
  63. package/build/es/polyfill/common/requirements.js +1 -1
  64. package/build/es/polyfill/common/textFormat/formatWithPattern/formatWithPattern.js +1 -1
  65. package/build/es/polyfill/common/textFormat/getSymbolsInPatternWithPosition/getSymbolsInPatternWithPosition.js +1 -1
  66. package/build/es/polyfill/common/textFormat/unformatWithPattern/unformatWithPattern.js +1 -1
  67. package/build/es/polyfill/common/theme.js +1 -1
  68. package/build/es/polyfill/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.js +1 -1
  69. package/build/es/polyfill/decision/decisionEnums.js +2 -2
  70. package/build/es/polyfill/info/infoPresentations.js +1 -1
  71. package/build/es/polyfill/lab/pagination/Pagination.js +1 -1
  72. package/build/es/polyfill/loader/Loader.js +3 -3
  73. package/build/es/polyfill/logo/logoTypes.js +1 -1
  74. package/build/es/polyfill/modal/Modal.js +1 -1
  75. package/build/es/polyfill/select/Select.js +1 -1
  76. package/build/es/polyfill/select/option/Option.js +1 -1
  77. package/build/es/polyfill/tabs/Tabs.js +1 -1
  78. package/build/es/polyfill/title/Title.js +1 -1
  79. package/build/es/polyfill/typeahead/Typeahead.js +1 -1
  80. package/build/es/polyfill/upload/uploadSteps.js +1 -1
  81. package/build/es/polyfill/upload/utils/getSupportedSpotMimeTypes/getSupportedSpotMimeTypes.js +1 -1
  82. package/build/es/polyfill/upload/utils/isTypeValid/isTypeValid.js +1 -1
  83. package/build/es/polyfill/uploadInput/UploadInput.js +5 -5
  84. package/build/es/polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
  85. package/build/es/polyfill/uploadInput/uploadButton/getAllowedFileTypes.js +1 -1
  86. package/build/es/polyfill/uploadInput/uploadItem/UploadItem.js +1 -1
  87. package/build/es/polyfill/withDisplayFormat/WithDisplayFormat.js +1 -1
  88. package/build/main.css +1 -1
  89. package/build/styles/dimmer/Dimmer.css +1 -1
  90. package/build/styles/drawer/Drawer.css +1 -1
  91. package/build/styles/loader/Loader.css +1 -1
  92. package/build/styles/main.css +1 -1
  93. package/build/styles/moneyInput/MoneyInput.css +1 -1
  94. package/build/styles/select/Select.css +1 -1
  95. package/build/styles/snackbar/Snackbar.css +1 -1
  96. package/build/types/loader/Loader.d.ts +5 -3
  97. package/build/types/tabs/Tabs.d.ts +1 -0
  98. package/build/umd/no-polyfill/main.js +1 -1
  99. package/build/umd/polyfill/main.js +1 -1
  100. package/package.json +7 -16
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![ci-cd](https://github.com/transferwise/neptune-web/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/transferwise/neptune-web/actions) [![NPM](https://badge.fury.io/js/%40transferwise%2Fcomponents.svg)](https://www.npmjs.com/package/@transferwise/components)
2
2
 
3
- # Neptune Web React Components
3
+ # Neptune Web React Components Temp
4
4
 
5
5
  Neptune is the Design System built by and used at TransferWise. Neptune Web is the Neptune framework for Web. Neptune Web provides a way to build high quality, consistent user experiences on the web with ease.
6
6
 
@@ -1 +1 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _deprecatedTypeMap,_deprecatedTypeMapMes;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{InfoCircle,Warning as AlertTriangle,CrossCircle,CheckCircle,Clock}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement,useState,useRef}from"react";import requiredIf from"react-required-if";import Body from"../body/Body";import{Sentiment,Size,Typography,Variant}from"../common";import{CloseButton}from"../common/closeButton";import Link from"../link";import StatusIcon from"../statusIcon";import{logActionRequiredIf,deprecated}from"../utilities";import InlineMarkdown from"./inlineMarkdown";import withArrow from"./withArrow";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var deprecatedTypeMap=(_deprecatedTypeMap={},_defineProperty(_deprecatedTypeMap,Sentiment.SUCCESS,Sentiment.POSITIVE),_defineProperty(_deprecatedTypeMap,Sentiment.INFO,Sentiment.NEUTRAL),_defineProperty(_deprecatedTypeMap,Sentiment.ERROR,Sentiment.NEGATIVE),_deprecatedTypeMap),Alert=function(a){var b,c=useTheme(),d=c.isModern,e=(b={},_defineProperty(b,Sentiment.POSITIVE,CheckCircle),_defineProperty(b,Sentiment.NEUTRAL,InfoCircle),_defineProperty(b,Sentiment.WARNING,AlertTriangle),_defineProperty(b,Sentiment.NEGATIVE,CrossCircle),_defineProperty(b,Sentiment.PENDING,Clock),b),f=useState(!1),g=_slicedToArray(f,2),h=g[0],i=g[1],j=a.arrow,k=a.action,l=a.children,m=a.className,n=a.icon,o=a.onDismiss,p=a.message,q=a.type,r=a.variant,s=useRef(null);if(j){var v=withArrow(Alert,j);return/*#__PURE__*/_jsx(v,_objectSpread({},a))}logActionRequired(a);var t=deprecatedTypeMap[q]||q,u=e[t];return/*#__PURE__*/_jsxs("div",{role:"alert",className:classNames("alert d-flex","alert-".concat(t),m),onTouchStart:function handleTouchStart(){return i(!0)},onTouchEnd:function handleTouchEnd(a){h&&k&&null!==s&&void 0!==s&&s.current&&!s.current.contains(a.target)&&("_blank"===(null===k||void 0===k?void 0:k.target)?window.top.open(k.href):window.top.location.assign(k.href)),i(!1)},onTouchMove:function handleTouchMove(){return i(!1)},children:[/*#__PURE__*/_jsxs("div",{className:classNames("alert__content","d-flex","flex-grow-1",r),"data-testid":r,children:[function(){return n?/*#__PURE__*/cloneElement(n,{size:24}):d?/*#__PURE__*/_jsx(StatusIcon,{size:Size.LARGE,sentiment:t}):/*#__PURE__*/_jsx(u,{size:24})}(),/*#__PURE__*/_jsxs("div",{className:"alert__message",children:[/*#__PURE__*/_jsx(Body,{as:"span",className:"d-block",type:Typography.BODY_LARGE,children:l||/*#__PURE__*/_jsx(InlineMarkdown,{children:p})}),k&&/*#__PURE__*/_jsx(Link,{href:k.href,className:"m-t-1","aria-label":k["aria-label"],target:k.target,type:Typography.LINK_LARGE,children:k.text})]})]}),o&&/*#__PURE__*/_jsx(CloseButton,{ref:s,className:"m-l-2",onClick:o})]})},deprecatedTypeMapMessage=(_deprecatedTypeMapMes={},_defineProperty(_deprecatedTypeMapMes,Sentiment.SUCCESS,"Sentiment.POSITIVE"),_defineProperty(_deprecatedTypeMapMes,Sentiment.INFO,"Sentiment.NEUTRAL"),_defineProperty(_deprecatedTypeMapMes,Sentiment.ERROR,"Sentiment.NEGATIVE"),_deprecatedTypeMapMes),deprecatedTypes=Object.keys(deprecatedTypeMap);function logActionRequired(a){var b=a.size,c=a.type;logActionRequiredIf("Alert no longer supports any possible variations in size. Please remove the `size` prop.",!!b),logActionRequiredIf("Alert has deprecated the ".concat(c," value for the `type` prop. Please update to ").concat(deprecatedTypeMapMessage[c],"."),deprecatedTypes.includes(c))}Alert.propTypes={/** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */action:PropTypes.shape({"aria-label":PropTypes.string,href:PropTypes.string.isRequired,target:PropTypes.string,text:PropTypes.node.isRequired}),className:PropTypes.string,/** An optional icon. If not provided, we will default the icon to something appropriate for the type */icon:PropTypes.element,/** The main body of the alert. Accepts plain text and bold words specified with **double stars*/message:requiredIf(PropTypes.node,function(a){var b=a.children;return!b}),/** The presence of the onDismiss handler will trigger the visibility of the close button */onDismiss:PropTypes.func,/** The type dictates which icon and colour will be used */type:PropTypes.oneOf(["negative","neutral","positive","warning","info","error","success"]),variant:PropTypes.oneOf(["desktop","mobile"]),/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */arrow:deprecated(PropTypes.oneOf(["up-left","up-center","up-right","down-left","down-center","down-right"]),{component:"Alert",expiryDate:new Date("03-01-2021")}),/** @deprecated use `message` property instead */children:deprecated(requiredIf(PropTypes.node,function(a){var b=a.message;return!b}),{component:"Alert",message:"You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.",expiryDate:new Date("03-01-2021")}),/** @deprecated use `onDismiss` instead */dismissible:deprecated(PropTypes.bool,{component:"Alert",message:"The Alert will now be considered dismissible if an `onDismiss` hander is present.",expiryDate:new Date("03-01-2021")})},Alert.defaultProps={action:void 0,arrow:void 0,className:void 0,dismissible:void 0,icon:void 0,type:Sentiment.NEUTRAL,variant:Variant.DESKTOP};export default Alert;
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _deprecatedTypeMap,_deprecatedTypeMapMes;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{InfoCircle,Warning as AlertTriangle,CrossCircle,CheckCircle,Clock}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement,useState,useRef}from"react";import requiredIf from"react-required-if";import Body from"../body/Body";import{Sentiment,Size,Typography,Variant}from"../common";import{CloseButton}from"../common/closeButton";import Link from"../link";import StatusIcon from"../statusIcon";import{logActionRequiredIf,deprecated}from"../utilities";import InlineMarkdown from"./inlineMarkdown";import withArrow from"./withArrow";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var deprecatedTypeMap=(_deprecatedTypeMap={},_defineProperty(_deprecatedTypeMap,Sentiment.SUCCESS,Sentiment.POSITIVE),_defineProperty(_deprecatedTypeMap,Sentiment.INFO,Sentiment.NEUTRAL),_defineProperty(_deprecatedTypeMap,Sentiment.ERROR,Sentiment.NEGATIVE),_deprecatedTypeMap),Alert=function(a){var b,c=useTheme(),d=c.isModern,e=(b={},_defineProperty(b,Sentiment.POSITIVE,CheckCircle),_defineProperty(b,Sentiment.NEUTRAL,InfoCircle),_defineProperty(b,Sentiment.WARNING,AlertTriangle),_defineProperty(b,Sentiment.NEGATIVE,CrossCircle),_defineProperty(b,Sentiment.PENDING,Clock),b),f=useState(!1),g=_slicedToArray(f,2),h=g[0],i=g[1],j=a.arrow,k=a.action,l=a.children,m=a.className,n=a.icon,o=a.onDismiss,p=a.message,q=a.type,r=a.variant,s=useRef(null);if(j){var t=withArrow(Alert,j);return/*#__PURE__*/_jsx(t,_objectSpread({},a))}logActionRequired(a);var u=deprecatedTypeMap[q]||q,v=e[u];return/*#__PURE__*/_jsxs("div",{role:"alert",className:classNames("alert d-flex","alert-".concat(u),m),onTouchStart:function handleTouchStart(){return i(!0)},onTouchEnd:function handleTouchEnd(a){h&&k&&null!==s&&void 0!==s&&s.current&&!s.current.contains(a.target)&&("_blank"===(null===k||void 0===k?void 0:k.target)?window.top.open(k.href):window.top.location.assign(k.href)),i(!1)},onTouchMove:function handleTouchMove(){return i(!1)},children:[/*#__PURE__*/_jsxs("div",{className:classNames("alert__content","d-flex","flex-grow-1",r),"data-testid":r,children:[function(){return n?/*#__PURE__*/cloneElement(n,{size:24}):d?/*#__PURE__*/_jsx(StatusIcon,{size:Size.LARGE,sentiment:u}):/*#__PURE__*/_jsx(v,{size:24})}(),/*#__PURE__*/_jsxs("div",{className:"alert__message",children:[/*#__PURE__*/_jsx(Body,{as:"span",className:"d-block",type:Typography.BODY_LARGE,children:l||/*#__PURE__*/_jsx(InlineMarkdown,{children:p})}),k&&/*#__PURE__*/_jsx(Link,{href:k.href,className:"m-t-1","aria-label":k["aria-label"],target:k.target,type:Typography.LINK_LARGE,children:k.text})]})]}),o&&/*#__PURE__*/_jsx(CloseButton,{ref:s,className:"m-l-2",onClick:o})]})},deprecatedTypeMapMessage=(_deprecatedTypeMapMes={},_defineProperty(_deprecatedTypeMapMes,Sentiment.SUCCESS,"Sentiment.POSITIVE"),_defineProperty(_deprecatedTypeMapMes,Sentiment.INFO,"Sentiment.NEUTRAL"),_defineProperty(_deprecatedTypeMapMes,Sentiment.ERROR,"Sentiment.NEGATIVE"),_deprecatedTypeMapMes),deprecatedTypes=Object.keys(deprecatedTypeMap);function logActionRequired(a){var b=a.size,c=a.type;logActionRequiredIf("Alert no longer supports any possible variations in size. Please remove the `size` prop.",!!b),logActionRequiredIf("Alert has deprecated the ".concat(c," value for the `type` prop. Please update to ").concat(deprecatedTypeMapMessage[c],"."),deprecatedTypes.includes(c))}Alert.propTypes={/** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */action:PropTypes.shape({"aria-label":PropTypes.string,href:PropTypes.string.isRequired,target:PropTypes.string,text:PropTypes.node.isRequired}),className:PropTypes.string,/** An optional icon. If not provided, we will default the icon to something appropriate for the type */icon:PropTypes.element,/** The main body of the alert. Accepts plain text and bold words specified with **double stars*/message:requiredIf(PropTypes.node,function(a){var b=a.children;return!b}),/** The presence of the onDismiss handler will trigger the visibility of the close button */onDismiss:PropTypes.func,/** The type dictates which icon and colour will be used */type:PropTypes.oneOf(["negative","neutral","positive","warning","info","error","success"]),variant:PropTypes.oneOf(["desktop","mobile"]),/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */arrow:deprecated(PropTypes.oneOf(["up-left","up-center","up-right","down-left","down-center","down-right"]),{component:"Alert",expiryDate:new Date("03-01-2021")}),/** @deprecated use `message` property instead */children:deprecated(requiredIf(PropTypes.node,function(a){var b=a.message;return!b}),{component:"Alert",message:"You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.",expiryDate:new Date("03-01-2021")}),/** @deprecated use `onDismiss` instead */dismissible:deprecated(PropTypes.bool,{component:"Alert",message:"The Alert will now be considered dismissible if an `onDismiss` hander is present.",expiryDate:new Date("03-01-2021")})},Alert.defaultProps={action:void 0,arrow:void 0,className:void 0,dismissible:void 0,icon:void 0,type:Sentiment.NEUTRAL,variant:Variant.DESKTOP};export default Alert;
@@ -1,2 +1,2 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var ArrowPosition;(function(a){a.TOP_LEFT="up-left",a.TOP="up-center",a.TOP_RIGHT="up-right",a.BOTTOM_LEFT="down-left",a.BOTTOM="down-center",a.BOTTOM_RIGHT="down-right"})(ArrowPosition||(ArrowPosition={}));
2
+ export var ArrowPosition=/*#__PURE__*/function(a){return a.TOP_LEFT="up-left",a.TOP="up-center",a.TOP_RIGHT="up-right",a.BOTTOM_LEFT="down-left",a.BOTTOM="down-center",a.BOTTOM_RIGHT="down-right",a}({});
@@ -1,2 +1,2 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var AvatarType;(function(a){a.THUMBNAIL="thumbnail",a.ICON="icon",a.EMOJI="emoji",a.INITIALS="initials"})(AvatarType||(AvatarType={}));
2
+ export var AvatarType=/*#__PURE__*/function(a){return a.THUMBNAIL="thumbnail",a.ICON="icon",a.EMOJI="emoji",a.INITIALS="initials",a}({});
@@ -1 +1 @@
1
- export var Direction;(function(a){a.RTL="rtl",a.LTR="ltr",a.AUTO="auto"})(Direction||(Direction={}));
1
+ export var Direction=/*#__PURE__*/function(a){return a.RTL="rtl",a.LTR="ltr",a.AUTO="auto",a}({});
@@ -1 +1 @@
1
- export var FileType;(function(a){a.PDF=".pdf,application/pdf",a.JPG=".jpg,.jpeg,image/jpeg",a.PNG=".png,image/png",a.CSV=".csv,text/csv"})(FileType||(FileType={}));
1
+ export var FileType=/*#__PURE__*/function(a){return a.PDF=".pdf,application/pdf",a.JPG=".jpg,.jpeg,image/jpeg",a.PNG=".png,image/png",a.CSV=".csv,text/csv",a}({});
@@ -3,4 +3,4 @@ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _toConsu
3
3
  *
4
4
  * @param {Node} focusBoundaryContainer - the area that contains focused elements.
5
5
  * @returns {object} focusableEls - which contains the first focusable element and the last focusable element. First and last can be the same element if area contains one or none focusable element.
6
- */export var getFocusableElements=function(a){var b={first:a,last:a};if(null!==a&&void 0!==a&&a.querySelectorAll){var d=_toConsumableArray(a.querySelectorAll("a, button, input, textarea, select, details,[tabindex]:not([tabindex=\"-1\"])")).filter(function(a){return!a.hasAttribute("disabled")});if(0<d.length){var c=_slicedToArray(d,1);b.first=c[0],b.last=d[d.length-1]}}return b};
6
+ */export var getFocusableElements=function(a){var b={first:a,last:a};if(null!==a&&void 0!==a&&a.querySelectorAll){var c=_toConsumableArray(a.querySelectorAll("a, button, input, textarea, select, details,[tabindex]:not([tabindex=\"-1\"])")).filter(function(a){return!a.hasAttribute("disabled")});if(0<c.length){var d=_slicedToArray(c,1);b.first=d[0],b.last=c[c.length-1]}}return b};
@@ -1 +1 @@
1
- export var Breakpoint;(function(a){a[a.EXTRA_SMALL=480]="EXTRA_SMALL",a[a.SMALL=576]="SMALL",a[a.MEDIUM=768]="MEDIUM",a[a.LARGE=992]="LARGE",a[a.EXTRA_LARGE=1200]="EXTRA_LARGE"})(Breakpoint||(Breakpoint={}));
1
+ export var Breakpoint=/*#__PURE__*/function(a){return a[a.EXTRA_SMALL=480]="EXTRA_SMALL",a[a.SMALL=576]="SMALL",a[a.MEDIUM=768]="MEDIUM",a[a.LARGE=992]="LARGE",a[a.EXTRA_LARGE=1200]="EXTRA_LARGE",a}({});
@@ -1 +1 @@
1
- export var ControlType;(function(a){a.ACCENT="accent",a.POSITIVE="positive",a.NEGATIVE="negative"})(ControlType||(ControlType={}));export var Priority;(function(a){a.PRIMARY="primary",a.SECONDARY="secondary",a.TERTIARY="tertiary"})(Priority||(Priority={}));
1
+ export var ControlType=/*#__PURE__*/function(a){return a.ACCENT="accent",a.POSITIVE="positive",a.NEGATIVE="negative",a}({});export var Priority=/*#__PURE__*/function(a){return a.PRIMARY="primary",a.SECONDARY="secondary",a.TERTIARY="tertiary",a}({});
@@ -1 +1 @@
1
- export var DateMode;(function(a){a.DAY_MONTH_YEAR="day-month-year",a.MONTH_YEAR="month-year"})(DateMode||(DateMode={}));
1
+ export var DateMode=/*#__PURE__*/function(a){return a.DAY_MONTH_YEAR="day-month-year",a.MONTH_YEAR="month-year",a}({});
@@ -1 +1 @@
1
- export var Layout;(function(a){a.VERTICAL="VERTICAL",a.VERTICAL_TWO_COLUMN="VERTICAL_TWO_COLUMN",a.VERTICAL_ONE_COLUMN="VERTICAL_ONE_COLUMN",a.HORIZONTAL="HORIZONTAL",a.HORIZONTAL_JUSTIFIED="HORIZONTAL_JUSTIFIED",a.HORIZONTAL_LEFT_ALIGNED="HORIZONTAL_LEFT_ALIGNED",a.HORIZONTAL_RIGHT_ALIGNED="HORIZONTAL_RIGHT_ALIGNED"})(Layout||(Layout={}));
1
+ export var Layout=/*#__PURE__*/function(a){return a.VERTICAL="VERTICAL",a.VERTICAL_TWO_COLUMN="VERTICAL_TWO_COLUMN",a.VERTICAL_ONE_COLUMN="VERTICAL_ONE_COLUMN",a.HORIZONTAL="HORIZONTAL",a.HORIZONTAL_JUSTIFIED="HORIZONTAL_JUSTIFIED",a.HORIZONTAL_LEFT_ALIGNED="HORIZONTAL_LEFT_ALIGNED",a.HORIZONTAL_RIGHT_ALIGNED="HORIZONTAL_RIGHT_ALIGNED",a}({});
@@ -1 +1 @@
1
- export var MarkdownNodeType;(function(a){a.BLOCK_QUOTE="block_quote",a.CODE_BLOCK="code_block",a.CODE="code",a.EMPH="emph",a.HEADING="heading",a.HTML_BLOCK="html_block",a.HTML_INLINE="html_inline",a.IMAGE="image",a.ITEM="item",a.LINEBREAK="linebreak",a.LINK="link",a.LIST="list",a.PARAGRAPH="paragraph",a.SOFTBREAK="softbreak",a.STRONG="strong",a.THEMATIC_BREAK="thematic_break"})(MarkdownNodeType||(MarkdownNodeType={}));
1
+ export var MarkdownNodeType=/*#__PURE__*/function(a){return a.BLOCK_QUOTE="block_quote",a.CODE_BLOCK="code_block",a.CODE="code",a.EMPH="emph",a.HEADING="heading",a.HTML_BLOCK="html_block",a.HTML_INLINE="html_inline",a.IMAGE="image",a.ITEM="item",a.LINEBREAK="linebreak",a.LINK="link",a.LIST="list",a.PARAGRAPH="paragraph",a.SOFTBREAK="softbreak",a.STRONG="strong",a.THEMATIC_BREAK="thematic_break",a}({});
@@ -1 +1 @@
1
- export var MonthFormat;(function(a){a.SHORT="short",a.LONG="long"})(MonthFormat||(MonthFormat={}));
1
+ export var MonthFormat=/*#__PURE__*/function(a){return a.SHORT="short",a.LONG="long",a}({});
@@ -1 +1 @@
1
- export var Position;(function(a){a.BOTTOM="bottom",a.BOTTOM_LEFT="bottom-left",a.BOTTOM_RIGHT="bottom-right",a.CENTER="center",a.LEFT="left",a.LEFT_TOP="left-top",a.RIGHT="right",a.RIGHT_TOP="right-top",a.TOP="top"})(Position||(Position={}));
1
+ export var Position=/*#__PURE__*/function(a){return a.BOTTOM="bottom",a.BOTTOM_LEFT="bottom-left",a.BOTTOM_RIGHT="bottom-right",a.CENTER="center",a.LEFT="left",a.LEFT_TOP="left-top",a.RIGHT="right",a.RIGHT_TOP="right-top",a.TOP="top",a}({});
@@ -1 +1 @@
1
- export var ProfileType;(function(a){a.BUSINESS="BUSINESS",a.PERSONAL="PERSONAL"})(ProfileType||(ProfileType={}));
1
+ export var ProfileType=/*#__PURE__*/function(a){return a.BUSINESS="BUSINESS",a.PERSONAL="PERSONAL",a}({});
@@ -1 +1 @@
1
- export var Scroll;(function(a){a.CONTENT="content",a.VIEWPORT="viewport"})(Scroll||(Scroll={}));
1
+ export var Scroll=/*#__PURE__*/function(a){return a.CONTENT="content",a.VIEWPORT="viewport",a}({});
@@ -1 +1 @@
1
- export var Sentiment;(function(a){a.NEGATIVE="negative",a.NEUTRAL="neutral",a.POSITIVE="positive",a.WARNING="warning",a.PENDING="pending",a.INFO="info",a.ERROR="error",a.SUCCESS="success"})(Sentiment||(Sentiment={}));
1
+ export var Sentiment=/*#__PURE__*/function(a){return a.NEGATIVE="negative",a.NEUTRAL="neutral",a.POSITIVE="positive",a.WARNING="warning",a.PENDING="pending",a.INFO="info",a.ERROR="error",a.SUCCESS="success",a}({});
@@ -1 +1 @@
1
- export var Size;(function(a){a.EXTRA_SMALL="xs",a.SMALL="sm",a.MEDIUM="md",a.LARGE="lg",a.EXTRA_LARGE="xl"})(Size||(Size={}));
1
+ export var Size=/*#__PURE__*/function(a){return a.EXTRA_SMALL="xs",a.SMALL="sm",a.MEDIUM="md",a.LARGE="lg",a.EXTRA_LARGE="xl",a}({});
@@ -1 +1 @@
1
- export var Status;(function(a){a.PROCESSING="processing",a.FAILED="failed",a.SUCCEEDED="succeeded",a.HIDDEN="hidden",a.DONE="done",a.NOT_DONE="notDone",a.PENDING="pending"})(Status||(Status={}));
1
+ export var Status=/*#__PURE__*/function(a){return a.PROCESSING="processing",a.FAILED="failed",a.SUCCEEDED="succeeded",a.HIDDEN="hidden",a.DONE="done",a.NOT_DONE="notDone",a.PENDING="pending",a}({});
@@ -1,3 +1,3 @@
1
1
  /**
2
2
  * @deprecated use `ControlType` and `Priority` enums instead
3
- */export var Type;(function(a){a.PRIMARY="primary",a.PAY="pay",a.SECONDARY="secondary",a.DANGER="danger",a.LINK="link"})(Type||(Type={}));
3
+ */export var Type=/*#__PURE__*/function(a){return a.PRIMARY="primary",a.PAY="pay",a.SECONDARY="secondary",a.DANGER="danger",a.LINK="link",a}({});
@@ -1 +1 @@
1
- export var Typography;(function(a){a.DISPLAY_EXTRA_LARGE="display-extra-large",a.DISPLAY_LARGE="display-large",a.DISPLAY_MEDIUM="display-medium",a.DISPLAY_SMALL="display-small",a.TITLE_SCREEN="title-screen",a.TITLE_SECTION="title-section",a.TITLE_SUBSECTION="title-subsection",a.TITLE_BODY="title-body",a.TITLE_GROUP="title-group",a.BODY_LARGE="body-large",a.BODY_DEFAULT="body-default",a.BODY_DEFAULT_BOLD="body-default-bold",a.BODY_LARGE_BOLD="body-large-bold",a.LINK_LARGE="link-large",a.LINK_DEFAULT="link-default"})(Typography||(Typography={}));
1
+ export var Typography=/*#__PURE__*/function(a){return a.DISPLAY_EXTRA_LARGE="display-extra-large",a.DISPLAY_LARGE="display-large",a.DISPLAY_MEDIUM="display-medium",a.DISPLAY_SMALL="display-small",a.TITLE_SCREEN="title-screen",a.TITLE_SECTION="title-section",a.TITLE_SUBSECTION="title-subsection",a.TITLE_BODY="title-body",a.TITLE_GROUP="title-group",a.BODY_LARGE="body-large",a.BODY_DEFAULT="body-default",a.BODY_DEFAULT_BOLD="body-default-bold",a.BODY_LARGE_BOLD="body-large-bold",a.LINK_LARGE="link-large",a.LINK_DEFAULT="link-default",a}({});
@@ -1 +1 @@
1
- export var Variant;(function(a){a.DESKTOP="desktop",a.MOBILE="mobile"})(Variant||(Variant={}));
1
+ export var Variant=/*#__PURE__*/function(a){return a.DESKTOP="desktop",a.MOBILE="mobile",a}({});
@@ -1 +1 @@
1
- export var Width;(function(a){a.BLOCK="block",a.AUTO="auto"})(Width||(Width={}));
1
+ export var Width=/*#__PURE__*/function(a){return a.BLOCK="block",a.AUTO="auto",a}({});
@@ -1 +1 @@
1
- export var Theme;(function(a){a.LIGHT="light",a.DARK="dark",a.NAVY="navy",a.PERSONAL="personal",a.PERSONAL_FOREST_GREEN="personal--forest-green",a.PERSONAL_BRIGHT_GREEN="personal--bright-green",a.PERSONAL_DARK="personal--dark"})(Theme||(Theme={}));export var modernThemes=new Set(["personal","personal--forest-green","personal--bright-green","personal--dark"]);export var getThemeClassName=function(a){return"np-theme-".concat(a)};
1
+ export var Theme=/*#__PURE__*/function(a){return a.LIGHT="light",a.DARK="dark",a.NAVY="navy",a.PERSONAL="personal",a.PERSONAL_FOREST_GREEN="personal--forest-green",a.PERSONAL_BRIGHT_GREEN="personal--bright-green",a.PERSONAL_DARK="personal--dark",a}({});export var modernThemes=new Set(["personal","personal--forest-green","personal--bright-green","personal--dark"]);export var getThemeClassName=function(a){return"np-theme-".concat(a)};
@@ -1,3 +1,3 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var Presentation;// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
3
- (function(a){a.LIST="LIST",a.LIST_BLOCK="LIST_BLOCK",a.LIST_BLOCK_GRID="LIST_BLOCK_GRID"})(Presentation||(Presentation={}));export var Type;(function(a){a.NAVIGATION="NAVIGATION"})(Type||(Type={}));
2
+ export var Presentation=/*#__PURE__*/function(a){return a.LIST="LIST",a.LIST_BLOCK="LIST_BLOCK",a.LIST_BLOCK_GRID="LIST_BLOCK_GRID",a}({});// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
3
+ export var Type=/*#__PURE__*/function(a){return a.NAVIGATION="NAVIGATION",a}({});
@@ -1,2 +1,2 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var InfoPresentation;(function(a){a.POPOVER="POPOVER",a.MODAL="MODAL"})(InfoPresentation||(InfoPresentation={}));
2
+ export var InfoPresentation=/*#__PURE__*/function(a){return a.POPOVER="POPOVER",a.MODAL="MODAL",a}({});
@@ -1 +1 @@
1
- import{ChevronLeft,ChevronRight}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{useIntl}from"react-intl";import messages from"./Pagination.messages";import PaginationLink from"./paginationLink";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Type={NUMBERS_ONLY:"numbersOnly",ARROWS_ONLY:"arrowsOnly",FULL:"full"},Pagination=function(a){var b=a.type,c=a.numberOfPages,d=a.currentPageIndex,e=a.onClick,f=a.canFetchMorePages,g=a.className,h=b!==Type.NUMBERS_ONLY,i=[];if(b!==Type.ARROWS_ONLY){switch(d){case 0:i.push({index:0,active:!0}),1<c&&i.push({index:1}),2<c&&i.push({index:2});break;case c-1:2<c&&i.push({index:c-3}),1<c&&i.push({index:c-2}),i.push({index:c-1,active:!0});break;default:i.push({index:d-1},{index:d,active:!0},{index:d+1});}var k=i[0].index;0<k&&(2<k?i.unshift({label:"...",index:k-1}):2===k&&i.unshift({index:1}),i.unshift({index:0}));var l=i[i.length-1].index;l<c-1&&(l<c-3?i.push({label:"...",index:l+1}):l===c-3&&i.push({index:c-2}),i.push({index:c-1})),f&&i.push({label:"...",index:c})}var j=useIntl();return/*#__PURE__*/_jsx("nav",{role:"navigation","aria-label":j.formatMessage(messages.ariaLabel),children:/*#__PURE__*/_jsxs("ul",{className:classNames("tw-pagination",g),children:[h&&/*#__PURE__*/_jsx(PaginationLink,{pageNumber:d-1,disabled:0===d,onClick:e,children:/*#__PURE__*/_jsx(ChevronLeft,{})}),i.map(function(a){var b=a.label||a.index+1;return/*#__PURE__*/_jsx(PaginationLink,{pageNumber:a.index,active:a.active,onClick:e,children:b},a.index)}),h&&/*#__PURE__*/_jsx(PaginationLink,{pageNumber:d+1,disabled:!f&&d===c-1,onClick:e,children:/*#__PURE__*/_jsx(ChevronRight,{})})]})})};Pagination.propTypes={type:PropTypes.oneOf(["numbersOnly","arrowsOnly","full"]),numberOfPages:PropTypes.number.isRequired,currentPageIndex:PropTypes.number.isRequired,onClick:PropTypes.func.isRequired,canFetchMorePages:PropTypes.bool,className:PropTypes.string},Pagination.defaultProps={type:Type.FULL,canFetchMorePages:!1,className:void 0};export{Type as PaginationType};export default Pagination;
1
+ import{ChevronLeft,ChevronRight}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{useIntl}from"react-intl";import messages from"./Pagination.messages";import PaginationLink from"./paginationLink";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Type={NUMBERS_ONLY:"numbersOnly",ARROWS_ONLY:"arrowsOnly",FULL:"full"},Pagination=function(a){var b=a.type,c=a.numberOfPages,d=a.currentPageIndex,e=a.onClick,f=a.canFetchMorePages,g=a.className,h=b!==Type.NUMBERS_ONLY,i=[];if(b!==Type.ARROWS_ONLY){switch(d){case 0:i.push({index:0,active:!0}),1<c&&i.push({index:1}),2<c&&i.push({index:2});break;case c-1:2<c&&i.push({index:c-3}),1<c&&i.push({index:c-2}),i.push({index:c-1,active:!0});break;default:i.push({index:d-1},{index:d,active:!0},{index:d+1});}var j=i[0].index;0<j&&(2<j?i.unshift({label:"...",index:j-1}):2===j&&i.unshift({index:1}),i.unshift({index:0}));var k=i[i.length-1].index;k<c-1&&(k<c-3?i.push({label:"...",index:k+1}):k===c-3&&i.push({index:c-2}),i.push({index:c-1})),f&&i.push({label:"...",index:c})}var l=useIntl();return/*#__PURE__*/_jsx("nav",{role:"navigation","aria-label":l.formatMessage(messages.ariaLabel),children:/*#__PURE__*/_jsxs("ul",{className:classNames("tw-pagination",g),children:[h&&/*#__PURE__*/_jsx(PaginationLink,{pageNumber:d-1,disabled:0===d,onClick:e,children:/*#__PURE__*/_jsx(ChevronLeft,{})}),i.map(function(a){var b=a.label||a.index+1;return/*#__PURE__*/_jsx(PaginationLink,{pageNumber:a.index,active:a.active,onClick:e,children:b},a.index)}),h&&/*#__PURE__*/_jsx(PaginationLink,{pageNumber:d+1,disabled:!f&&d===c-1,onClick:e,children:/*#__PURE__*/_jsx(ChevronRight,{})})]})})};Pagination.propTypes={type:PropTypes.oneOf(["numbersOnly","arrowsOnly","full"]),numberOfPages:PropTypes.number.isRequired,currentPageIndex:PropTypes.number.isRequired,onClick:PropTypes.func.isRequired,canFetchMorePages:PropTypes.bool,className:PropTypes.string},Pagination.defaultProps={type:Type.FULL,canFetchMorePages:!1,className:void 0};export{Type as PaginationType};export default Pagination;
@@ -1,4 +1,5 @@
1
- import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["small","size","classNames"];import{useTheme}from"@wise/components-theming";import classnames from"classnames";import{Size}from"../common";import{jsx as _jsx}from"react/jsx-runtime";/**
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["small","size","displayInstantly","classNames"];import classnames from"classnames";import{useEffect,useState}from"react";import{Size}from"../common";// TODO: We gracefully depracated xs, lg and xl -- remove these as part of a future breaking change to this component
2
+ import{jsx as _jsx}from"react/jsx-runtime";/**
2
3
  * Loader component
3
4
  *
4
5
  * Docs link: https://transferwise.github.io/neptune-web/components/progress/Loader
@@ -7,5 +8,4 @@ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutPropert
7
8
  * @param root0.small
8
9
  * @param root0.size
9
10
  * @param root0.classNames
10
- */var Loader=function(a){var b=a.small,c=a.size,d=void 0===c?Size.EXTRA_LARGE:c,e=a.classNames,f=void 0===e?{}:e,g=_objectWithoutProperties(a,_excluded),h=useTheme(),i=h.isModern,j=function(a){return f[a]||a},k=void 0!==b&&b?Size.SMALL:d,l=getSupportedSize(k);return/*#__PURE__*/_jsx("div",{className:classnames(j("tw-loader"),j("tw-loader--".concat(l))),"data-testid":g["data-testid"],children:!i&&[,,,,,].fill(void 0).map(function(a,b){return/*#__PURE__*/ (// eslint-disable-next-line react/no-array-index-key
11
- _jsx("div",{className:j("tw-loader__stripe")},b))})})},getSupportedSize=function(a){switch(a){case Size.EXTRA_LARGE:case Size.LARGE:return Size.LARGE;case Size.SMALL:case Size.EXTRA_SMALL:return Size.SMALL;case Size.MEDIUM:default:return Size.MEDIUM;}};export default Loader;
11
+ */var Loader=function(a){var b=a.small,c=a.size,d=void 0===c?Size.MEDIUM:c,e=a.displayInstantly,f=void 0!==e&&e,g=a.classNames,h=void 0===g?{}:g,i=_objectWithoutProperties(a,_excluded),j=useState(f),k=_slicedToArray(j,2),l=k[0],m=k[1];useEffect(function(){var a,b;return f||(b=setTimeout(function(){a||m(!0)},1e3)),function(){a=!0,clearTimeout(b)}},[]);var n=function(a){return h[a]||a},o=void 0!==b&&b?Size.SMALL:d,p=getSupportedSize(o);return/*#__PURE__*/_jsx("div",{className:classnames(n("tw-loader"),n("tw-loader--".concat(p)),{"tw-loader--visible":l}),"data-testid":i["data-testid"]})},getSupportedSize=function(a){switch(a){case Size.SMALL:case Size.EXTRA_SMALL:return Size.SMALL;case Size.EXTRA_LARGE:case Size.LARGE:case Size.MEDIUM:default:return Size.MEDIUM;}};export default Loader;
@@ -1,2 +1,2 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var LogoType;(function(a){a.WISE="WISE",a.WISE_BUSINESS="WISE_BUSINESS"})(LogoType||(LogoType={}));
2
+ export var LogoType=/*#__PURE__*/function(a){return a.WISE="WISE",a.WISE_BUSINESS="WISE_BUSINESS",a}({});
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";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{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{useState,useEffect,useRef,useMemo}from"react";import{useIntl}from"react-intl";import Button from"../button";import Chevron from"../chevron";import{Position,getSimpleRandomId}from"../common";import BottomSheet from"../common/bottomSheet";import{stopPropagation}from"../common/domHelpers";import{useLayout}from"../common/hooks";import KeyCodes from"../common/keyCodes";import Panel from"../common/panel";import Drawer from"../drawer";import messages from"./Select.messages";import Option from"./option";import SearchBox from"./searchBox";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var DEFAULT_SEARCH_VALUE="",DEFAULT_OPTIONS_PAGE_SIZE=1e3,includesString=function(a,b){return a.toLowerCase().includes(b.toLowerCase())};function defaultFilterFunction(a,b){if(isPlaceholderOption(a))return!0;var c=a.label,d=a.note,e=a.secondary,f=a.currency,g=a.searchStrings;return!!c&&includesString(c,b)||!!d&&includesString(d,b)||!!e&&includesString(e,b)||!!f&&includesString(f,b)||!!g&&g.some(function(a){return includesString(a,b)})}function isActionableOption(a){return!a.header&&!a.separator&&!a.disabled}function isHeaderOption(a){return null!=a&&"header"in a}function isSparatorOption(a){return null!=a&&"separator"in a}function clamp(a,b,c){return Math.max(Math.min(b,c),a)}/**
2
2
  * No option or placeholder option is selected
3
- */var DEFAULT_SELECTED_OPTION=null;function isPlaceholderOption(a){return a===DEFAULT_SELECTED_OPTION||"placeholder"in a}var getUniqueIdForOption=function(){var a,b,c=0<arguments.length&&arguments[0]!==void 0?arguments[0]:"",d=1<arguments.length?arguments[1]:void 0;if(null!=d){var e=d.value||(null!==(a=null===(b=d.label)||void 0===b?void 0:b.replace(/\s/g,""))&&void 0!==a?a:"");return"option-".concat(c,"-").concat(e,"}")}};export default function Select(a){function b(){null!=W&&0<ka.length&&e(ka[W])}function c(a){var b,c=ka.reduce(function(a,b,c){return null==a?k(v,b)?c:null:a},null),d=null!==(b=Z.current)&&void 0!==b?b:-1,e=d;-1===d&&(null==c?X(0):e=c);var f=e+a,g=clamp(0,ka.length-1,f);X(g)}function d(a){return function(b){stopPropagation(b),e(a)}}function e(a){x(isPlaceholderOption(a)?DEFAULT_SELECTED_OPTION:a),sa()}function f(){var a,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=b.className,d=classNames(M("np-dropdown-menu"),(a={},_defineProperty(a,M("np-dropdown-menu-desktop"),!qa),_defineProperty(a,M("np-dropdown-menu-".concat(r)),!qa&&!ha),a),M(c));return/*#__PURE__*/_jsxs("ul",_objectSpread(_objectSpread({ref:fa,id:na,role:"listbox",tabIndex:"-1",className:d},G),{},{children:[!o&&!ga&&!!m&&/*#__PURE__*/_jsx(h,{}),ga&&/*#__PURE__*/_jsx(SearchBox,{ref:ca,id:oa,classNames:E,value:C||S,placeholder:D||J(messages.searchPlaceholder),focusedOptionId:getUniqueIdForOption(n,la),onChange:ra,onClick:stopPropagation}),ja.slice(0,aa).map(ta),aa<ja.length&&/*#__PURE__*/_jsx(g,{})]}))}function g(){function a(a){stopPropagation(a),ba(aa+DEFAULT_OPTIONS_PAGE_SIZE)}return/*#__PURE__*/ (/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */_jsx("li",{className:classNames(M("clickable"),M("border-bottom"),M("show-more")),onClick:a,onKeyPress:a,children:/*#__PURE__*/_jsx("a",{children:"..."})}))}function h(){var a={placeholder:m};return/*#__PURE__*/ (/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */_jsx("li",{className:classNames(M("clickable"),M("border-bottom")),onClick:d(a),onKeyPress:d(a),children:/*#__PURE__*/_jsx("a",{children:m})}))}// eslint-disable-next-line react/prop-types
3
+ */var DEFAULT_SELECTED_OPTION=null;function isPlaceholderOption(a){return a===DEFAULT_SELECTED_OPTION||"placeholder"in a}var getUniqueIdForOption=function(){var a,b,c=0<arguments.length&&arguments[0]!==void 0?arguments[0]:"",d=1<arguments.length?arguments[1]:void 0;if(null!=d){var e=d.value||(null!==(a=null===(b=d.label)||void 0===b?void 0:b.replace(/\s/g,""))&&void 0!==a?a:"");return"option-".concat(c,"-").concat(e)}};export default function Select(a){function b(){null!=W&&0<ka.length&&e(ka[W])}function c(a){var b,c=ka.reduce(function(a,b,c){return null==a?k(v,b)?c:null:a},null),d=null!==(b=Z.current)&&void 0!==b?b:-1,e=d;-1===d&&(null==c?X(0):e=c);var f=e+a,g=clamp(0,ka.length-1,f);X(g)}function d(a){return function(b){stopPropagation(b),e(a)}}function e(a){x(isPlaceholderOption(a)?DEFAULT_SELECTED_OPTION:a),sa()}function f(){var a,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=b.className,d=classNames(M("np-dropdown-menu"),(a={},_defineProperty(a,M("np-dropdown-menu-desktop"),!qa),_defineProperty(a,M("np-dropdown-menu-".concat(r)),!qa&&!ha),a),M(c));return/*#__PURE__*/_jsxs("ul",_objectSpread(_objectSpread({ref:fa,id:na,role:"listbox",tabIndex:"-1",className:d},G),{},{children:[!o&&!ga&&!!m&&/*#__PURE__*/_jsx(h,{}),ga&&/*#__PURE__*/_jsx(SearchBox,{ref:ca,id:oa,classNames:E,value:C||S,placeholder:D||J(messages.searchPlaceholder),focusedOptionId:getUniqueIdForOption(n,la),onChange:ra,onClick:stopPropagation}),ja.slice(0,aa).map(ta),aa<ja.length&&/*#__PURE__*/_jsx(g,{})]}))}function g(){function a(a){stopPropagation(a),ba(aa+DEFAULT_OPTIONS_PAGE_SIZE)}return/*#__PURE__*/ (/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */_jsx("li",{className:classNames(M("clickable"),M("border-bottom"),M("show-more")),onClick:a,onKeyPress:a,children:/*#__PURE__*/_jsx("a",{children:"..."})}))}function h(){var a={placeholder:m};return/*#__PURE__*/ (/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */_jsx("li",{className:classNames(M("clickable"),M("border-bottom")),onClick:d(a),onKeyPress:d(a),children:/*#__PURE__*/_jsx("a",{children:m})}))}// eslint-disable-next-line react/prop-types
4
4
  function i(){return/*#__PURE__*/_jsx("li",{className:M("np-separator"),"aria-hidden":!0})}// eslint-disable-next-line react/prop-types
5
5
  function j(a){var b=a.children;return/*#__PURE__*/_jsx("li",{// eslint-disable-line jsx-a11y/no-noninteractive-element-interactions
6
6
  className:classNames(M("np-dropdown-header"),M("np-text-title-group")),onClick:stopPropagation,onKeyPress:stopPropagation,children:b})}function k(a,b){return(null===a||void 0===a?void 0:a.value)===(null===b||void 0===b?void 0:b.value)}function l(a){return ja.reduce(function(b,c,d){return d<a&&isActionableOption(c)?b+1:b},0)}var m=a.placeholder,n=a.id,o=a.required,p=a.disabled,q=a.inverse,r=a.dropdownWidth,t=a.size,u=a.block,v=a.selected,w=a.search,x=a.onChange,y=a.onFocus,z=a.onBlur,A=a.options,B=a.onSearchChange,C=a.searchValue,D=a.searchPlaceholder,E=a.classNames,F=a.dropdownUp,G=a.dropdownProps,H=a.buttonProps,I=useIntl(),J=I.formatMessage,K=useTheme(),L=K.isModern,M=function(a){return E[a]||a},s=useState(!1),N=_slicedToArray(s,2),O=N[0],P=N[1],Q=useState(DEFAULT_SEARCH_VALUE),R=_slicedToArray(Q,2),S=R[0],T=R[1],U=useState(null),V=_slicedToArray(U,2),W=V[0],X=V[1],Y=useRef(),Z=useRef(),$=useState(DEFAULT_OPTIONS_PAGE_SIZE),_=_slicedToArray($,2),aa=_[0],ba=_[1],ca=useRef(null),da=useRef(null),ea=useRef(null),fa=useRef(null),ga=!!B||!!w,ha=null==r,ia=useMemo(function(){return getSimpleRandomId("np-select-")},[]),ja=useMemo(function(){return w&&S?A.filter(function(a){return isActionableOption(a)&&!isPlaceholderOption(a)}).filter(function(a){return"function"==typeof w?w(a,S):defaultFilterFunction(a,S)}):A},[A,w,S]),ka=useMemo(function(){return ja.filter(isActionableOption)},[ja]),la=ka[W],ma=n||ia,na="".concat(ma,"-listbox"),oa="".concat(ma,"-searchbox"),pa=useLayout(),qa=pa.isMobile;useEffect(function(){var a;if(0<=W)return requestAnimationFrame(function(){if(!a)if(ga){var b,c;null===(b=Y.current)||void 0===b||null===(c=b.scrollIntoView)||void 0===c?void 0:c.call(b,{block:"center"})}else{var d;null===(d=Y.current)||void 0===d?void 0:d.focus()}}),function(){a=!0}},[W,ga]);var ra=function(a){ba(DEFAULT_OPTIONS_PAGE_SIZE),T(a.target.value),B&&B(a.target.value)};useEffect(function(){O?((!qa||S)&&(ga&&!!ca.current&&ca.current.focus(),!ga&&fa.current&&(null==Z.current||Number.isNaN(Z.current))&&fa.current.focus()),Z.current=W):Z.current=null},[O,S,ga,qa,W]);var sa=function(){P(!1),X(null),ea.current&&ea.current.focus()},ta=function(a,b){var c,e=a;if(isSparatorOption(e)&&null!==e&&void 0!==e&&e.separator)return/*#__PURE__*/_jsx(i,{},b);var f=a;if(isHeaderOption(f)&&f.header)return/*#__PURE__*/_jsx(j,{children:f.header},b);var g=k(v,a),h=a,m=!h.disabled&&W===l(b),o=classNames(M("np-dropdown-item"),h.disabled?[M("disabled")]:M("clickable"),(c={},_defineProperty(c,M("active"),g),_defineProperty(c,M("np-dropdown-item--focused"),m),c)),p=h.disabled?stopPropagation:d(h);return/*#__PURE__*/ (/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */_jsx("li",{ref:m?Y:void 0,id:getUniqueIdForOption(n,a),"aria-selected":g,"aria-disabled":a.disabled,role:"option",tabIndex:"-1",className:o,onClick:p,onKeyPress:p,children:/*#__PURE__*/_jsx("a",{disabled:h.disabled,children:/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},h),{},{classNames:E}))})},b))},ua=!!A.length;return O&&(C||S)&&(ua&&null==W&&X(0),!ua&&null!=W&&X(null)),/*#__PURE__*/_jsxs("div",{// eslint-disable-line jsx-a11y/no-static-element-interactions
@@ -1,2 +1,2 @@
1
1
  // Option.tsx NEW
2
- import{useTheme}from"@wise/components-theming";import{cloneElement}from"react";import Body from"../../body";import{Typography}from"../../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";function Option(a){var b=a.label,c=a.currency,d=void 0===c?"":c,e=a.note,f=void 0===e?"":e,g=a.secondary,h=void 0===g?"":g,i=a.icon,j=a.classNames,k=void 0===j?{}:j,l=a.selected,m=void 0!==l&&l,n=useTheme(),o=n.isModern,p=function(a){return a.map(function(a){return k[a]||a}).join(" ")},q=d?"".concat(p(["currency-flag","currency-flag-".concat(d.toLowerCase()),"".concat(m?"hidden-xs":"")])):void 0,r=f?"".concat(p(["d-inline-flex align-items-center"])):void 0,s=i?/*#__PURE__*/cloneElement(i,{size:24,className:"".concat(p(["tw-icon","".concat(m&&d?"hidden-xs":"")]))}):d&&/*#__PURE__*/_jsx("i",{className:q}),t=/*#__PURE__*/_jsxs(Body,{as:"span",type:Typography.BODY_LARGE,className:r,children:[b,f&&/*#__PURE__*/_jsx(Body,{as:"span",className:o?"m-l-1":"m-l-1 body-2",children:f})]}),u=h&&/*#__PURE__*/_jsx(Body,{as:"span",className:o?"text-ellipsis":"text-ellipsis body-2",children:h});return s&&u?/*#__PURE__*/_jsxs("div",{className:"d-inline-flex",children:[/*#__PURE__*/_jsx("div",{className:"d-flex flex-column justify-content-center",children:s}),/*#__PURE__*/_jsxs("div",{className:"d-flex flex-column justify-content-center",children:[t,u]})]}):/*#__PURE__*/_jsxs(_Fragment,{children:[s,t,u]})}export default Option;
2
+ import{useTheme}from"@wise/components-theming";import{cloneElement}from"react";import Body from"../../body";import{Typography}from"../../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";function Option(a){var b=a.label,c=a.currency,d=void 0===c?"":c,e=a.note,f=void 0===e?"":e,g=a.secondary,h=void 0===g?"":g,i=a.icon,j=a.classNames,k=void 0===j?{}:j,l=a.selected,m=void 0!==l&&l,n=useTheme(),o=n.isModern,p=d?function style(a){return a.map(function(a){return k[a]||a}).join(" ")}(["currency-flag","currency-flag-".concat(d.toLowerCase())]):void 0,q=i?/*#__PURE__*/cloneElement(i,{size:24,className:"tw-icon"}):d&&/*#__PURE__*/_jsx("i",{className:p}),r=/*#__PURE__*/_jsxs(Body,{as:"span",type:Typography.BODY_LARGE,className:m?"text-ellipsis":void 0,children:[b,f&&/*#__PURE__*/_jsx(Body,{as:"span",className:o?"m-l-1":"m-l-1 body-2",children:f})]}),s=h&&/*#__PURE__*/_jsx(Body,{className:function secondaryElementClassNames(){var a;return m&&(a="text-ellipsis"),o?a:"".concat(a?a+" ":"","body-2")}(),children:h});return q?/*#__PURE__*/_jsxs("div",{className:"d-flex np-option-content",children:[/*#__PURE__*/_jsx("div",{className:"d-flex flex-column".concat(m?" justify-content-center":""),children:q}),/*#__PURE__*/_jsxs("div",{className:"d-flex flex-column",children:[r,s]})]}):/*#__PURE__*/_jsxs(_Fragment,{children:[q,r,s]})}export default Option;
@@ -1 +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";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}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 classNames from"classnames";import clamp from"lodash.clamp";import PropTypes from"prop-types";import{Component,createRef,Fragment}from"react";import{Spring}from"react-spring/renderprops.cjs";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 n=d.getTabToSelect(c,b,f);d.animateLine(d.swipedOverHalfOfContainer(g)?n:c);var l=d.calculateApplicableDragDifference({currentSelected:c,nextSelected:n,start:b,end:f}),m=!!l&&-(d.containerWidth*e)+l;d.setState(function(a){return{currentSwipe:[].concat(_toConsumableArray(a.currentSwipe),[f]),translateFrom:m||a.translateFrom,translateTo:m||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("div",{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"])},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";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}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 classNames from"classnames";import clamp from"lodash.clamp";import PropTypes from"prop-types";import{Component,createRef,Fragment}from"react";import{Spring}from"react-spring/renderprops.cjs";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("div",{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 _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _titleTypeMapping,_excluded=["as","type","className"];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 classNames from"classnames";import{Typography}from"../common";import{jsx as _jsx}from"react/jsx-runtime";var DEFAULT_TYPE=Typography.TITLE_GROUP,titleTypeMapping=(_titleTypeMapping={},_defineProperty(_titleTypeMapping,Typography.TITLE_SCREEN,"h1"),_defineProperty(_titleTypeMapping,Typography.TITLE_SECTION,"h2"),_defineProperty(_titleTypeMapping,Typography.TITLE_SUBSECTION,"h3"),_defineProperty(_titleTypeMapping,Typography.TITLE_BODY,"h4"),_defineProperty(_titleTypeMapping,Typography.TITLE_GROUP,"h5"),_titleTypeMapping);function Title(a){var b=a.as,c=a.type,d=void 0===c?DEFAULT_TYPE:c,e=a.className,f=_objectWithoutProperties(a,_excluded),g=titleTypeMapping[d];if(g!==void 0){var i=null!==b&&void 0!==b?b:"".concat(g);return/*#__PURE__*/_jsx(i,_objectSpread(_objectSpread({},f),{},{className:classNames("np-text-".concat(d),e)}))}var h=null!==b&&void 0!==b?b:"".concat(titleTypeMapping[DEFAULT_TYPE]);return/*#__PURE__*/_jsx(h,_objectSpread(_objectSpread({},f),{},{className:classNames("np-text-".concat(DEFAULT_TYPE),e)}))}export default Title;
1
+ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _titleTypeMapping,_excluded=["as","type","className"];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 classNames from"classnames";import{Typography}from"../common";import{jsx as _jsx}from"react/jsx-runtime";var DEFAULT_TYPE=Typography.TITLE_GROUP,titleTypeMapping=(_titleTypeMapping={},_defineProperty(_titleTypeMapping,Typography.TITLE_SCREEN,"h1"),_defineProperty(_titleTypeMapping,Typography.TITLE_SECTION,"h2"),_defineProperty(_titleTypeMapping,Typography.TITLE_SUBSECTION,"h3"),_defineProperty(_titleTypeMapping,Typography.TITLE_BODY,"h4"),_defineProperty(_titleTypeMapping,Typography.TITLE_GROUP,"h5"),_titleTypeMapping);function Title(a){var b=a.as,c=a.type,d=void 0===c?DEFAULT_TYPE:c,e=a.className,f=_objectWithoutProperties(a,_excluded),g=titleTypeMapping[d];if(g!==void 0){var h=null!==b&&void 0!==b?b:"".concat(g);return/*#__PURE__*/_jsx(h,_objectSpread(_objectSpread({},f),{},{className:classNames("np-text-".concat(d),e)}))}var i=null!==b&&void 0!==b?b:"".concat(titleTypeMapping[DEFAULT_TYPE]);return/*#__PURE__*/_jsx(i,_objectSpread(_objectSpread({},f),{},{className:classNames("np-text-".concat(DEFAULT_TYPE),e)}))}export default Title;
@@ -1 +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";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/anchor-is-valid */ /* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */import{Cross as CrossIcon}from"@transferwise/icons";import classNames from"classnames";import clamp from"lodash.clamp";import debounce from"lodash.debounce";import PropTypes from"prop-types";import{Component}from"react";import Chip from"../chips/Chip";import{Size,Sentiment}from"../common";import{addClickClassToDocumentOnIos,removeClickClassFromDocumentOnIos}from"../common/domHelpers";import KeyCodes from"../common/keyCodes";import InlineAlert from"../inlineAlert";import TypeaheadInput from"./typeaheadInput/TypeaheadInput";import TypeaheadOption from"./typeaheadOption/TypeaheadOption";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var DEFAULT_MIN_QUERY_LENGTH=3,SEARCH_DELAY=200,Typeahead=/*#__PURE__*/function(a){function b(a){var d;_classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"handleOnFocus",function(){var a=d.props.onFocus;d.showMenu(),a&&d.props.onFocus()}),_defineProperty(_assertThisInitialized(d),"onOptionSelected",function(a,b){a.preventDefault(),d.selectItem(b)}),_defineProperty(_assertThisInitialized(d),"handleOnChange",function(a){var b=d.state,c=b.optionsShown,e=b.selected,f=d.props,g=f.multiple,h=f.onInputChange;c||d.showMenu();var i=a.target.value;!g&&0<e.length&&d.updateSelectedValue([]),d.setState({query:i},function(){d.handleSearchDebounced(i),h&&h(i)})}),_defineProperty(_assertThisInitialized(d),"handleOnPaste",function(a){var b=d.props,c=b.allowNew,e=b.multiple,f=b.chipSeparators,g=d.state.selected;if(c&&e&&0<f.length){a.preventDefault();var j=a.clipboardData.getData("text");if(j){var h=new RegExp(f.join("|")),i=j.split(h).map(function(a){return{label:a.trim()}}).filter(function(a){return a.label});d.updateSelectedValue([].concat(_toConsumableArray(g),_toConsumableArray(i)))}}}),_defineProperty(_assertThisInitialized(d),"handleOnKeyDown",function(a){var b=d.props,c=b.showSuggestions,e=b.allowNew,f=b.multiple,g=b.chipSeparators,h=b.options,i=d.state,j=i.keyboardFocusedOptionIndex,k=i.query,l=i.selected;if(!c&&e&&f&&["Enter","Tab"].concat(_toConsumableArray(g)).includes(a.key)&&k.trim())a.preventDefault(),d.selectItem({label:k});else switch(a.keyCode){case KeyCodes.DOWN:a.preventDefault(),d.moveFocusedOption(1);break;case KeyCodes.UP:a.preventDefault(),d.moveFocusedOption(-1);break;case KeyCodes.ENTER:a.preventDefault(),h[j]?d.selectItem(h[j]):e&&k.trim()&&d.selectItem({label:k});break;case KeyCodes.BACKSPACE:f&&!k&&0<l.length&&d.updateSelectedValue(l.slice(0,-1));break;default:}}),_defineProperty(_assertThisInitialized(d),"selectItem",function(a){var b,c=d.props.multiple,e=_toConsumableArray(d.state.selected);c?(e.push(a),b=""):(e=[a],b=a.label),d.updateSelectedValue(e),d.hideMenu(),d.setState({query:b})}),_defineProperty(_assertThisInitialized(d),"stopPropagation",function(a){a.stopPropagation(),a.preventDefault(),a.nativeEvent&&a.nativeEvent.stopImmediatePropagation&&a.nativeEvent.stopImmediatePropagation()}),_defineProperty(_assertThisInitialized(d),"handleSearch",function(a){var b=d.props.onSearch;b&&b(a),d.setState(function(a){return{keyboardFocusedOptionIndex:null===a.keyboardFocusedOptionIndex?null:0}})}),_defineProperty(_assertThisInitialized(d),"handleDocumentClick",function(){if(d.state.optionsShown){d.hideMenu();var a=d.props,b=a.allowNew,c=a.onBlur,e=a.autoFillOnBlur,f=d.state.query;d.setState({isFocused:!1}),b&&e&&f.trim()&&d.selectItem({label:f}),c&&c()}}),_defineProperty(_assertThisInitialized(d),"showMenu",function(){d.setState({isFocused:!0,optionsShown:!0},function(){addClickClassToDocumentOnIos(),document.addEventListener("click",d.handleDocumentClick,!1)})}),_defineProperty(_assertThisInitialized(d),"hideMenu",function(){d.setState({optionsShown:!1,keyboardFocusedOptionIndex:null},function(){removeClickClassFromDocumentOnIos(),document.removeEventListener("click",d.handleDocumentClick,!1)})}),_defineProperty(_assertThisInitialized(d),"updateSelectedValue",function(a){var b=d.props,c=b.onChange,e=b.validateChip,f=a.some(function(a){return!e(a)});d.setState({selected:a,errorState:f},function(){c(a)})}),_defineProperty(_assertThisInitialized(d),"clear",function(a){a.preventDefault(),0<d.state.selected.length&&d.updateSelectedValue([]),d.setState({query:""})}),_defineProperty(_assertThisInitialized(d),"removeChip",function(a){var b=d.state.selected;0<b.length&&d.updateSelectedValue(_toConsumableArray(b.filter(function(b){return b!==a})))}),_defineProperty(_assertThisInitialized(d),"renderChip",function(a,b){var c=d.props.validateChip(a);return/*#__PURE__*/_jsx(Chip,{label:a.label,className:classNames("m-t-1",{"has-error":!c,"np-chip--valid":c}),onRemove:function onRemove(){return d.removeChip(a)}},b)}),_defineProperty(_assertThisInitialized(d),"renderMenu",function(a){var b=a.footer,c=a.options,e=a.id,f=a.keyboardFocusedOptionIndex,g=a.query,h=a.allowNew,i=a.showNewEntry,j=a.dropdownOpen,k=_toConsumableArray(c);return h&&g.trim()&&c.every(function(a){return a.label.trim().toUpperCase()!==g.trim().toUpperCase()})&&i&&k.push({label:g}),/*#__PURE__*/_jsx("div",{className:classNames("dropdown btn-group btn-block",{open:j}),id:"menu-".concat(e),children:/*#__PURE__*/_jsxs("ul",{className:"dropdown-menu",role:"menu","aria-labelledby":"dropdownMenu1",children:[k.map(function(a,b){return/*#__PURE__*/_jsx(TypeaheadOption,{query:g,option:a,selected:f===b,onClick:function onClick(b){d.onOptionSelected(b,a)}},"".concat(a.label).concat(b.toString()))}),b]})})});var e=a.searchDelay,f=a.initialValue,g=a.multiple;d.handleSearchDebounced=debounce(d.handleSearch,e);var h=!g&&0<f.length?f[0].label:"";return d.state={selected:f,errorState:!1,query:h,keyboardFocusedOptionIndex:null},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(a){a.multiple!==this.props.multiple&&this.setState(function(b){var c=b.selected;return!a.multiple&&0<c.length?{query:c[0].label,selected:[c[0]]}:{query:""}})}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.handleSearchDebounced.cancel()}},{key:"moveFocusedOption",value:function moveFocusedOption(a){var b=this;this.setState(function(c){var d=c.keyboardFocusedOptionIndex,e=b.props.options,f=0;return null!==d&&(f=clamp(d+a,0,e.length-1)),{keyboardFocusedOptionIndex:f}})}},{key:"render",value:function render(){var a=this.props,b=a.id,c=a.placeholder,d=a.multiple,e=a.size,f=a.addon,g=a.name,h=a.clearable,i=a.allowNew,j=a.footer,k=a.showSuggestions,l=a.showNewEntry,m=a.options,n=a.minQueryLength,o=a.autoFocus,p=a.maxHeight,q=a.alert,r=a.inputAutoComplete,s=this.state,t=s.errorState,u=s.query,v=s.selected,w=s.optionsShown,x=s.keyboardFocusedOptionIndex,y=h&&(u||0<v.length),z=w&&k&&u.length>=n,A=this.renderMenu({footer:j,options:m,keyboardFocusedOptionIndex:x,query:u,allowNew:i,showNewEntry:l,dropdownOpen:z}),B=t||q&&q.type===Sentiment.ERROR,C=!t&&q||q&&q.type===Sentiment.ERROR,D=C&&q.type===Sentiment.WARNING,E=C&&q.type===Sentiment.NEUTRAL;return/*#__PURE__*/_jsx("div",{id:b,className:classNames("typeahead","typeahead-".concat(e),{"typeahead--has-value":0<v.length,"typeahead--empty":0===v.length,"typeahead--multiple":d,open:z}),onClick:this.stopPropagation,children:/*#__PURE__*/_jsxs("div",{className:classNames("form-group",{"has-error":B,"has-warning":D,"has-info":E}),children:[/*#__PURE__*/_jsxs("div",{className:classNames("input-group input-group-".concat(e),{"input-group--has-error":B}),children:[f&&/*#__PURE__*/_jsx("span",{className:"input-group-addon input-group-addon--search",children:f}),/*#__PURE__*/_jsx(TypeaheadInput,{autoFocus:o,multiple:d,optionsShown:w,placeholder:c,selected:v,maxHeight:p,name:g,value:u,typeaheadId:b,renderChip:this.renderChip,autoComplete:r,onChange:this.handleOnChange,onKeyDown:this.handleOnKeyDown,onFocus:this.handleOnFocus,onPaste:this.handleOnPaste}),y&&/*#__PURE__*/_jsx("div",{className:"input-group-addon",children:/*#__PURE__*/_jsx("button",{type:"button",className:"btn-unstyled",onClick:this.clear,children:/*#__PURE__*/_jsx(CrossIcon,{})})})]}),C&&/*#__PURE__*/_jsx(InlineAlert,{type:q.type,children:q.message}),A]})})}}]),b}(Component);export{Typeahead as default};Typeahead.propTypes={id:PropTypes.string.isRequired,name:PropTypes.string.isRequired,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,note:PropTypes.string,secondary:PropTypes.string,value:PropTypes.object})).isRequired,initialValue:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,note:PropTypes.string,secondary:PropTypes.string})),onChange:PropTypes.func.isRequired,allowNew:PropTypes.bool,autoFocus:PropTypes.bool,clearable:PropTypes.bool,multiple:PropTypes.bool,showSuggestions:PropTypes.bool,showNewEntry:PropTypes.bool,searchDelay:PropTypes.number,maxHeight:PropTypes.number,minQueryLength:PropTypes.number,addon:PropTypes.node,placeholder:PropTypes.string,alert:PropTypes.shape({message:PropTypes.string.isRequired,type:PropTypes.oneOf(["error","warning","neutral"]).isRequired}),footer:PropTypes.node,validateChip:PropTypes.func,onSearch:PropTypes.func,onBlur:PropTypes.func,onInputChange:PropTypes.func,onFocus:PropTypes.func,chipSeparators:PropTypes.arrayOf(PropTypes.string),size:PropTypes.oneOf(["md","lg"]),inputAutoComplete:PropTypes.string,autoFillOnBlur:PropTypes.bool},Typeahead.defaultProps={allowNew:!1,autoFocus:!1,clearable:!0,multiple:!1,maxHeight:null,showSuggestions:!0,showNewEntry:!0,searchDelay:SEARCH_DELAY,minQueryLength:3,addon:null,placeholder:null,alert:null,footer:null,size:Size.MEDIUM,chipSeparators:[],initialValue:[],onSearch:null,onBlur:null,onInputChange:null,onFocus:null,validateChip:function validateChip(){return!0},inputAutoComplete:"new-password",autoFillOnBlur:!0};
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";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/anchor-is-valid */ /* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */import{Cross as CrossIcon}from"@transferwise/icons";import classNames from"classnames";import clamp from"lodash.clamp";import debounce from"lodash.debounce";import PropTypes from"prop-types";import{Component}from"react";import Chip from"../chips/Chip";import{Size,Sentiment}from"../common";import{addClickClassToDocumentOnIos,removeClickClassFromDocumentOnIos}from"../common/domHelpers";import KeyCodes from"../common/keyCodes";import InlineAlert from"../inlineAlert";import TypeaheadInput from"./typeaheadInput/TypeaheadInput";import TypeaheadOption from"./typeaheadOption/TypeaheadOption";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var DEFAULT_MIN_QUERY_LENGTH=3,SEARCH_DELAY=200,Typeahead=/*#__PURE__*/function(a){function b(a){var d;_classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"handleOnFocus",function(){var a=d.props.onFocus;d.showMenu(),a&&d.props.onFocus()}),_defineProperty(_assertThisInitialized(d),"onOptionSelected",function(a,b){a.preventDefault(),d.selectItem(b)}),_defineProperty(_assertThisInitialized(d),"handleOnChange",function(a){var b=d.state,c=b.optionsShown,e=b.selected,f=d.props,g=f.multiple,h=f.onInputChange;c||d.showMenu();var i=a.target.value;!g&&0<e.length&&d.updateSelectedValue([]),d.setState({query:i},function(){d.handleSearchDebounced(i),h&&h(i)})}),_defineProperty(_assertThisInitialized(d),"handleOnPaste",function(a){var b=d.props,c=b.allowNew,e=b.multiple,f=b.chipSeparators,g=d.state.selected;if(c&&e&&0<f.length){a.preventDefault();var h=a.clipboardData.getData("text");if(h){var i=new RegExp(f.join("|")),j=h.split(i).map(function(a){return{label:a.trim()}}).filter(function(a){return a.label});d.updateSelectedValue([].concat(_toConsumableArray(g),_toConsumableArray(j)))}}}),_defineProperty(_assertThisInitialized(d),"handleOnKeyDown",function(a){var b=d.props,c=b.showSuggestions,e=b.allowNew,f=b.multiple,g=b.chipSeparators,h=b.options,i=d.state,j=i.keyboardFocusedOptionIndex,k=i.query,l=i.selected;if(!c&&e&&f&&["Enter","Tab"].concat(_toConsumableArray(g)).includes(a.key)&&k.trim())a.preventDefault(),d.selectItem({label:k});else switch(a.keyCode){case KeyCodes.DOWN:a.preventDefault(),d.moveFocusedOption(1);break;case KeyCodes.UP:a.preventDefault(),d.moveFocusedOption(-1);break;case KeyCodes.ENTER:a.preventDefault(),h[j]?d.selectItem(h[j]):e&&k.trim()&&d.selectItem({label:k});break;case KeyCodes.BACKSPACE:f&&!k&&0<l.length&&d.updateSelectedValue(l.slice(0,-1));break;default:}}),_defineProperty(_assertThisInitialized(d),"selectItem",function(a){var b,c=d.props.multiple,e=_toConsumableArray(d.state.selected);c?(e.push(a),b=""):(e=[a],b=a.label),d.updateSelectedValue(e),d.hideMenu(),d.setState({query:b})}),_defineProperty(_assertThisInitialized(d),"stopPropagation",function(a){a.stopPropagation(),a.preventDefault(),a.nativeEvent&&a.nativeEvent.stopImmediatePropagation&&a.nativeEvent.stopImmediatePropagation()}),_defineProperty(_assertThisInitialized(d),"handleSearch",function(a){var b=d.props.onSearch;b&&b(a),d.setState(function(a){return{keyboardFocusedOptionIndex:null===a.keyboardFocusedOptionIndex?null:0}})}),_defineProperty(_assertThisInitialized(d),"handleDocumentClick",function(){if(d.state.optionsShown){d.hideMenu();var a=d.props,b=a.allowNew,c=a.onBlur,e=a.autoFillOnBlur,f=d.state.query;d.setState({isFocused:!1}),b&&e&&f.trim()&&d.selectItem({label:f}),c&&c()}}),_defineProperty(_assertThisInitialized(d),"showMenu",function(){d.setState({isFocused:!0,optionsShown:!0},function(){addClickClassToDocumentOnIos(),document.addEventListener("click",d.handleDocumentClick,!1)})}),_defineProperty(_assertThisInitialized(d),"hideMenu",function(){d.setState({optionsShown:!1,keyboardFocusedOptionIndex:null},function(){removeClickClassFromDocumentOnIos(),document.removeEventListener("click",d.handleDocumentClick,!1)})}),_defineProperty(_assertThisInitialized(d),"updateSelectedValue",function(a){var b=d.props,c=b.onChange,e=b.validateChip,f=a.some(function(a){return!e(a)});d.setState({selected:a,errorState:f},function(){c(a)})}),_defineProperty(_assertThisInitialized(d),"clear",function(a){a.preventDefault(),0<d.state.selected.length&&d.updateSelectedValue([]),d.setState({query:""})}),_defineProperty(_assertThisInitialized(d),"removeChip",function(a){var b=d.state.selected;0<b.length&&d.updateSelectedValue(_toConsumableArray(b.filter(function(b){return b!==a})))}),_defineProperty(_assertThisInitialized(d),"renderChip",function(a,b){var c=d.props.validateChip(a);return/*#__PURE__*/_jsx(Chip,{label:a.label,className:classNames("m-t-1",{"has-error":!c,"np-chip--valid":c}),onRemove:function onRemove(){return d.removeChip(a)}},b)}),_defineProperty(_assertThisInitialized(d),"renderMenu",function(a){var b=a.footer,c=a.options,e=a.id,f=a.keyboardFocusedOptionIndex,g=a.query,h=a.allowNew,i=a.showNewEntry,j=a.dropdownOpen,k=_toConsumableArray(c);return h&&g.trim()&&c.every(function(a){return a.label.trim().toUpperCase()!==g.trim().toUpperCase()})&&i&&k.push({label:g}),/*#__PURE__*/_jsx("div",{className:classNames("dropdown btn-group btn-block",{open:j}),id:"menu-".concat(e),children:/*#__PURE__*/_jsxs("ul",{className:"dropdown-menu",role:"menu","aria-labelledby":"dropdownMenu1",children:[k.map(function(a,b){return/*#__PURE__*/_jsx(TypeaheadOption,{query:g,option:a,selected:f===b,onClick:function onClick(b){d.onOptionSelected(b,a)}},"".concat(a.label).concat(b.toString()))}),b]})})});var e=a.searchDelay,f=a.initialValue,g=a.multiple;d.handleSearchDebounced=debounce(d.handleSearch,e);var h=!g&&0<f.length?f[0].label:"";return d.state={selected:f,errorState:!1,query:h,keyboardFocusedOptionIndex:null},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"UNSAFE_componentWillReceiveProps",value:function UNSAFE_componentWillReceiveProps(a){a.multiple!==this.props.multiple&&this.setState(function(b){var c=b.selected;return!a.multiple&&0<c.length?{query:c[0].label,selected:[c[0]]}:{query:""}})}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.handleSearchDebounced.cancel()}},{key:"moveFocusedOption",value:function moveFocusedOption(a){var b=this;this.setState(function(c){var d=c.keyboardFocusedOptionIndex,e=b.props.options,f=0;return null!==d&&(f=clamp(d+a,0,e.length-1)),{keyboardFocusedOptionIndex:f}})}},{key:"render",value:function render(){var a=this.props,b=a.id,c=a.placeholder,d=a.multiple,e=a.size,f=a.addon,g=a.name,h=a.clearable,i=a.allowNew,j=a.footer,k=a.showSuggestions,l=a.showNewEntry,m=a.options,n=a.minQueryLength,o=a.autoFocus,p=a.maxHeight,q=a.alert,r=a.inputAutoComplete,s=this.state,t=s.errorState,u=s.query,v=s.selected,w=s.optionsShown,x=s.keyboardFocusedOptionIndex,y=h&&(u||0<v.length),z=w&&k&&u.length>=n,A=this.renderMenu({footer:j,options:m,keyboardFocusedOptionIndex:x,query:u,allowNew:i,showNewEntry:l,dropdownOpen:z}),B=t||q&&q.type===Sentiment.ERROR,C=!t&&q||q&&q.type===Sentiment.ERROR,D=C&&q.type===Sentiment.WARNING,E=C&&q.type===Sentiment.NEUTRAL;return/*#__PURE__*/_jsx("div",{id:b,className:classNames("typeahead","typeahead-".concat(e),{"typeahead--has-value":0<v.length,"typeahead--empty":0===v.length,"typeahead--multiple":d,open:z}),onClick:this.stopPropagation,children:/*#__PURE__*/_jsxs("div",{className:classNames("form-group",{"has-error":B,"has-warning":D,"has-info":E}),children:[/*#__PURE__*/_jsxs("div",{className:classNames("input-group input-group-".concat(e),{"input-group--has-error":B}),children:[f&&/*#__PURE__*/_jsx("span",{className:"input-group-addon input-group-addon--search",children:f}),/*#__PURE__*/_jsx(TypeaheadInput,{autoFocus:o,multiple:d,optionsShown:w,placeholder:c,selected:v,maxHeight:p,name:g,value:u,typeaheadId:b,renderChip:this.renderChip,autoComplete:r,onChange:this.handleOnChange,onKeyDown:this.handleOnKeyDown,onFocus:this.handleOnFocus,onPaste:this.handleOnPaste}),y&&/*#__PURE__*/_jsx("div",{className:"input-group-addon",children:/*#__PURE__*/_jsx("button",{type:"button",className:"btn-unstyled",onClick:this.clear,children:/*#__PURE__*/_jsx(CrossIcon,{})})})]}),C&&/*#__PURE__*/_jsx(InlineAlert,{type:q.type,children:q.message}),A]})})}}]),b}(Component);export{Typeahead as default};Typeahead.propTypes={id:PropTypes.string.isRequired,name:PropTypes.string.isRequired,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,note:PropTypes.string,secondary:PropTypes.string,value:PropTypes.object})).isRequired,initialValue:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,note:PropTypes.string,secondary:PropTypes.string})),onChange:PropTypes.func.isRequired,allowNew:PropTypes.bool,autoFocus:PropTypes.bool,clearable:PropTypes.bool,multiple:PropTypes.bool,showSuggestions:PropTypes.bool,showNewEntry:PropTypes.bool,searchDelay:PropTypes.number,maxHeight:PropTypes.number,minQueryLength:PropTypes.number,addon:PropTypes.node,placeholder:PropTypes.string,alert:PropTypes.shape({message:PropTypes.string.isRequired,type:PropTypes.oneOf(["error","warning","neutral"]).isRequired}),footer:PropTypes.node,validateChip:PropTypes.func,onSearch:PropTypes.func,onBlur:PropTypes.func,onInputChange:PropTypes.func,onFocus:PropTypes.func,chipSeparators:PropTypes.arrayOf(PropTypes.string),size:PropTypes.oneOf(["md","lg"]),inputAutoComplete:PropTypes.string,autoFillOnBlur:PropTypes.bool},Typeahead.defaultProps={allowNew:!1,autoFocus:!1,clearable:!0,multiple:!1,maxHeight:null,showSuggestions:!0,showNewEntry:!0,searchDelay:SEARCH_DELAY,minQueryLength:3,addon:null,placeholder:null,alert:null,footer:null,size:Size.MEDIUM,chipSeparators:[],initialValue:[],onSearch:null,onBlur:null,onInputChange:null,onFocus:null,validateChip:function validateChip(){return!0},inputAutoComplete:"new-password",autoFillOnBlur:!0};
@@ -1,2 +1,2 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var UploadStep;(function(a){a.UPLOAD_IMAGE_STEP="uploadImageStep",a.MEDIA_UPLOAD_STEP="mediaUploadStep"})(UploadStep||(UploadStep={}));
2
+ export var UploadStep=/*#__PURE__*/function(a){return a.UPLOAD_IMAGE_STEP="uploadImageStep",a.MEDIA_UPLOAD_STEP="mediaUploadStep",a}({});
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";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{useTheme}from"@wise/components-theming";import classNames from"classnames";import{useEffect,useRef,useState}from"react";import{useIntl}from"react-intl";import Button from"../button";import{ControlType,Priority,Status}from"../common";import Modal from"../modal";import{isSizeValid}from"../upload/utils/isSizeValid";import{isTypeValid}from"../upload/utils/isTypeValid";import MESSAGES from"./UploadInput.messages";import UploadButton from"./uploadButton/UploadButton";import{DEFAULT_SIZE_LIMIT,imageFileTypes}from"./uploadButton/defaults";import UploadItem from"./uploadItem/UploadItem";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";function generateFileId(a){var b=a.name,c=a.size,d=new Date().getTime();return"".concat(b,"_").concat(c,"_").concat(d)}var UploadInput=function(a){function b(a){function b(b){return[].concat(_toConsumableArray(b),[a])}T(b),U.current=b(U.current)}function c(a,c){var d=a.name,e=generateFileId(a),f={id:e,filename:d,status:Status.FAILED,error:c};b(f),v&&v(f)}function d(){var a=new Set([Status.SUCCEEDED,Status.PENDING]),b=U.current.filter(function(b){return b.status&&a.has(b.status)});return b.length}function e(){if(!y)return!1;var a=d();return a>=y}// One or more files selected, create entries for them
2
2
  var f=a.files,g=void 0===f?[]:f,h=a.fileInputName,i=void 0===h?"file":h,j=a.className,k=a.deleteConfirm,l=a.disabled,m=a.multiple,n=void 0!==m&&m,o=a.fileTypes,p=void 0===o?imageFileTypes:o,q=a.sizeLimit,r=void 0===q?DEFAULT_SIZE_LIMIT:q,s=a.description,t=a.onUploadFile,u=a.onDeleteFile,v=a.onValidationError,w=a.onFilesChange,x=a.onDownload,y=a.maxFiles,z=a.maxFilesErrorMessage,A=a.id,B=a.sizeLimitErrorMessage,C=a.uploadButtonTitle,D=useTheme(),E=D.isModern,F=useState(null),G=_slicedToArray(F,2),H=G[0],I=G[1],J=useState(!1),K=_slicedToArray(J,2),L=K[0],M=K[1],N=useIntl(),O=N.formatMessage,P=new Set([Status.PENDING,Status.PROCESSING]),Q=useState(n||0===g.length?g:[g[0]]),R=_slicedToArray(Q,2),S=R[0],T=R[1],U=useRef(n||0===g.length?g:[g[0]]),V=function(a){function b(b){return b.filter(function(b){return a!==b&&a.id!==b.id})}T(b),U.current=b(U.current)},W=function(a,b){var c=function(c){return c.map(function(c){return c===a||c.id===a.id?_objectSpread(_objectSpread({},a),b):c})};T(c),U.current=c(U.current)},X=function(a){var b=a.id,c=a.status;c===Status.FAILED?V(a):u&&b&&(W(a,{status:Status.PROCESSING,error:void 0}),u(b).then(function(){return V(a)}).catch(function(b){W(a,{error:b})}))};// eslint-disable-line react-hooks/exhaustive-deps
3
- return useEffect(function(){M(!0)},[]),useEffect(function(){w&&L&&w(S)},[w,S]),/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsxs("div",{className:classNames("np-upload-input",j,{disabled:E&&l}),children:[S.map(function(a){return/*#__PURE__*/_jsx(UploadItem,{file:a,singleFileUpload:!n,canDelete:(!!u||a.status===Status.FAILED)&&(!a.status||!P.has(a.status)),onDelete:a.status===Status.FAILED?function(){return X(a)}:function(){return I(a)},onDownload:x},a.id)}),(n||!n&&!S.length)&&/*#__PURE__*/_jsx(UploadButton,{id:A,uploadButtonTitle:C,disabled:e()||l,multiple:n,fileTypes:p,sizeLimit:r,description:s,maxFiles:y,multipleFileInputWithFilesAdded:n&&0<S.length,onChange:function addFiles(a){for(var h=0;h<a.length;h+=1){var d=a.item(h),f=new FormData;// Returning a FormData[] array instead of FileList so we can filter out incorrect files
4
- if(d){var g=function(){var a=d.name,g=generateFileId(d),h=Array.isArray(p)?p.join(","):p;// Check if file type is valid
5
- if(!isTypeValid(d,h))return c(d,O(MESSAGES.fileTypeNotSupported)),"continue";// Check if the filesize is valid
3
+ return useEffect(function(){M(!0)},[]),useEffect(function(){w&&L&&w(S)},[w,S]),/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsxs("div",{className:classNames("np-upload-input",j,{disabled:E&&l}),children:[S.map(function(a){return/*#__PURE__*/_jsx(UploadItem,{file:a,singleFileUpload:!n,canDelete:(!!u||a.status===Status.FAILED)&&(!a.status||!P.has(a.status)),onDelete:a.status===Status.FAILED?function(){return X(a)}:function(){return I(a)},onDownload:x},a.id)}),(n||!n&&!S.length)&&/*#__PURE__*/_jsx(UploadButton,{id:A,uploadButtonTitle:C,disabled:e()||l,multiple:n,fileTypes:p,sizeLimit:r,description:s,maxFiles:y,multipleFileInputWithFilesAdded:n&&0<S.length,onChange:function addFiles(a){for(var d,f=function _loop(){var d=a.item(g),f=new FormData;// Returning a FormData[] array instead of FileList so we can filter out incorrect files
4
+ if(d){var h=d.name,j=generateFileId(d),k=Array.isArray(p)?p.join(","):p;// Check if file type is valid
5
+ if(!isTypeValid(d,k))return c(d,O(MESSAGES.fileTypeNotSupported)),"continue";// Check if the filesize is valid
6
6
  // Convert to rough bytes
7
- if(!isSizeValid(d,1e3*r)){var k=B||O(MESSAGES.fileIsTooLarge);return c(d,k),"continue"}if(e()){var l=z||O(MESSAGES.maximumFilesAlreadyUploaded,{maxFilesAllowed:y});return c(d,l),"continue"}f.append(i,d);var j={id:g,filename:a,status:Status.PENDING};if(b(j),t(f).then(function(a){var b=a.id,c=a.url,d=a.error;W(j,{id:b,url:c,error:d,status:Status.SUCCEEDED})}).catch(function(a){W(j,{error:a,status:Status.FAILED})}),!n)// Only upload a single file
8
- return"break"}();if("continue"===g)continue;if("break"===g)break}}}})]}),/*#__PURE__*/_jsx(Modal,{title:void 0===(null===k||void 0===k?void 0:k.title)?O(MESSAGES.deleteModalTitle):k.title,body:void 0===(null===k||void 0===k?void 0:k.body)?O(MESSAGES.deleteModalBody):k.body,open:!!H,footer:/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Button,{block:!0,onClick:function onClick(){I(null)},children:(null===k||void 0===k?void 0:k.cancelText)||O(MESSAGES.deleteModalCancelButtonText)}),/*#__PURE__*/_jsx(Button,{block:!0,priority:Priority.SECONDARY,type:ControlType.NEGATIVE,onClick:function onClick(){H&&X(H),I(null)},children:(null===k||void 0===k?void 0:k.confirmText)||O(MESSAGES.deleteModalConfirmButtonText)})]}),onClose:function onClose(){I(null)}})]})};export default UploadInput;
7
+ if(!isSizeValid(d,1e3*r)){var l=B||O(MESSAGES.fileIsTooLarge);return c(d,l),"continue"}if(e()){var m=z||O(MESSAGES.maximumFilesAlreadyUploaded,{maxFilesAllowed:y});return c(d,m),"continue"}f.append(i,d);var o={id:j,filename:h,status:Status.PENDING};if(b(o),t(f).then(function(a){var b=a.id,c=a.url,d=a.error;W(o,{id:b,url:c,error:d,status:Status.SUCCEEDED})}).catch(function(a){W(o,{error:a,status:Status.FAILED})}),!n)// Only upload a single file
8
+ return"break"}},g=0;g<a.length&&(d=f(),"continue"===d||"break"!==d);g+=1);}})]}),/*#__PURE__*/_jsx(Modal,{title:void 0===(null===k||void 0===k?void 0:k.title)?O(MESSAGES.deleteModalTitle):k.title,body:void 0===(null===k||void 0===k?void 0:k.body)?O(MESSAGES.deleteModalBody):k.body,open:!!H,footer:/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Button,{block:!0,onClick:function onClick(){I(null)},children:(null===k||void 0===k?void 0:k.cancelText)||O(MESSAGES.deleteModalCancelButtonText)}),/*#__PURE__*/_jsx(Button,{block:!0,priority:Priority.SECONDARY,type:ControlType.NEGATIVE,onClick:function onClick(){H&&X(H),I(null)},children:(null===k||void 0===k?void 0:k.confirmText)||O(MESSAGES.deleteModalConfirmButtonText)})]}),onClose:function onClose(){I(null)}})]})};export default UploadInput;
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";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{PlusCircle as PlusIcon,Upload as UploadIcon}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import{useRef,useState}from"react";import{useIntl}from"react-intl";import Body from"../../body";import{Typography}from"../../common";import{useDirection}from"../../common/hooks";import MESSAGES from"./UploadButton.messages";import{DEFAULT_SIZE_LIMIT,imageFileTypes}from"./defaults";import getAllowedFileTypes from"./getAllowedFileTypes";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS;(function(a){a.uploadInput="uploadInput",a.mediaBody="mediaBody"})(TEST_IDS||(TEST_IDS={}));var onDragOver=function(a){a.preventDefault()},DEFAULT_FILE_INPUT_ID="np-upload-button",UploadButton=function(a){function b(){if(e)return e;var a=C(),b="*"===a?u(MESSAGES.allFileTypes):a;return u(MESSAGES.instructions,{fileTypes:b,size:Math.round(i/1e3)})}var c=a.disabled,d=a.multiple,e=a.description,f=a.fileTypes,g=void 0===f?imageFileTypes:f,h=a.sizeLimit,i=void 0===h?DEFAULT_SIZE_LIMIT:h,j=a.maxFiles,k=a.onChange,l=a.id,m=void 0===l?DEFAULT_FILE_INPUT_ID:l,n=a.uploadButtonTitle,o=a.multipleFileInputWithFilesAdded,p=useTheme(),q=p.isModern,r=useDirection(),s=r.isRTL,t=useIntl(),u=t.formatMessage,v=useRef(null),w=useState(!1),x=_slicedToArray(w,2),y=x[0],z=x[1],A=useRef(0),B=function(){A.current=0,z(!1)},C=function(){return"*"===g?g:Array.isArray(g)?getAllowedFileTypes(g).join(", "):getAllowedFileTypes([g]).join(", ")};return/*#__PURE__*/_jsxs("div",_objectSpread(_objectSpread({className:classNames("np-upload-button-container","droppable",{"droppable-dropping":y})},!c&&{onDragEnter:function onDragEnter(a){a.preventDefault(),A.current+=1,1===A.current&&z(!0)},onDragLeave:function onDragLeave(a){a.preventDefault(),A.current-=1,0===A.current&&z(!1)},onDrop:function onDrop(a){a.preventDefault(),B(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&k(a.dataTransfer.files)},onDragOver:onDragOver}),{},{children:[/*#__PURE__*/_jsx("input",_objectSpread(_objectSpread(_objectSpread({ref:v,id:m,type:"file"},function(){var a="*"===C();return a?null:Array.isArray(g)?{accept:g.join(",")}:{accept:g}}()),d&&{multiple:!0}),{},{className:"tw-droppable-input",disabled:c,name:"file-upload","data-testid":TEST_IDS.uploadInput,onChange:function filesSelected(a){var b=a.target.files;b&&(k(b),v.current&&(v.current.value=""))}})),/*#__PURE__*/_jsx("label",{htmlFor:m,className:classNames("btn","np-upload-accent","np-upload-button",{disabled:c,"np-upload-input--square-top":o}),children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:/*#__PURE__*/_jsx(UploadIcon,{size:24,className:"text-link"})}),/*#__PURE__*/_jsxs("div",{className:"media-body text-xs-left","data-testid":TEST_IDS.mediaBody,children:[/*#__PURE__*/_jsx(Body,{type:Typography.BODY_LARGE_BOLD,className:"d-block",children:function(){return n?n:u(d?MESSAGES.uploadFiles:MESSAGES.uploadFile)}()}),function(){return/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsxs(Body,{className:classNames({"text-primary":!c,small:!q,"font-weight-normal":!q}),children:[b(),j&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("br",{}),"Maximum ".concat(j," files.")]})]})})}()]})]})}),y&&/*#__PURE__*/_jsxs("div",{className:classNames("droppable-card","droppable-dropping-card","droppable-card-content",{"np-upload-input--square-top":o}),children:[/*#__PURE__*/_jsx(PlusIcon,{className:"m-x-1",size:24}),/*#__PURE__*/_jsx("div",{children:u(MESSAGES.dropFile)})]})]}))};export default UploadButton;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";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{PlusCircle as PlusIcon,Upload as UploadIcon}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import{useRef,useState}from"react";import{useIntl}from"react-intl";import Body from"../../body";import{Typography}from"../../common";import{useDirection}from"../../common/hooks";import MESSAGES from"./UploadButton.messages";import{DEFAULT_SIZE_LIMIT,imageFileTypes}from"./defaults";import getAllowedFileTypes from"./getAllowedFileTypes";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS=/*#__PURE__*/function(a){return a.uploadInput="uploadInput",a.mediaBody="mediaBody",a}({});var onDragOver=function(a){a.preventDefault()},DEFAULT_FILE_INPUT_ID="np-upload-button",UploadButton=function(a){function b(){if(e)return e;var a=C(),b="*"===a?u(MESSAGES.allFileTypes):a;return u(MESSAGES.instructions,{fileTypes:b,size:Math.round(i/1e3)})}var c=a.disabled,d=a.multiple,e=a.description,f=a.fileTypes,g=void 0===f?imageFileTypes:f,h=a.sizeLimit,i=void 0===h?DEFAULT_SIZE_LIMIT:h,j=a.maxFiles,k=a.onChange,l=a.id,m=void 0===l?DEFAULT_FILE_INPUT_ID:l,n=a.uploadButtonTitle,o=a.multipleFileInputWithFilesAdded,p=useTheme(),q=p.isModern,r=useDirection(),s=r.isRTL,t=useIntl(),u=t.formatMessage,v=useRef(null),w=useState(!1),x=_slicedToArray(w,2),y=x[0],z=x[1],A=useRef(0),B=function(){A.current=0,z(!1)},C=function(){return"*"===g?g:Array.isArray(g)?getAllowedFileTypes(g).join(", "):getAllowedFileTypes([g]).join(", ")};return/*#__PURE__*/_jsxs("div",_objectSpread(_objectSpread({className:classNames("np-upload-button-container","droppable",{"droppable-dropping":y})},!c&&{onDragEnter:function onDragEnter(a){a.preventDefault(),A.current+=1,1===A.current&&z(!0)},onDragLeave:function onDragLeave(a){a.preventDefault(),A.current-=1,0===A.current&&z(!1)},onDrop:function onDrop(a){a.preventDefault(),B(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&k(a.dataTransfer.files)},onDragOver:onDragOver}),{},{children:[/*#__PURE__*/_jsx("input",_objectSpread(_objectSpread(_objectSpread({ref:v,id:m,type:"file"},function(){var a="*"===C();return a?null:Array.isArray(g)?{accept:g.join(",")}:{accept:g}}()),d&&{multiple:!0}),{},{className:"tw-droppable-input",disabled:c,name:"file-upload","data-testid":TEST_IDS.uploadInput,onChange:function filesSelected(a){var b=a.target.files;b&&(k(b),v.current&&(v.current.value=""))}})),/*#__PURE__*/_jsx("label",{htmlFor:m,className:classNames("btn","np-upload-accent","np-upload-button",{disabled:c,"np-upload-input--square-top":o}),children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:/*#__PURE__*/_jsx(UploadIcon,{size:24,className:"text-link"})}),/*#__PURE__*/_jsxs("div",{className:"media-body text-xs-left","data-testid":TEST_IDS.mediaBody,children:[/*#__PURE__*/_jsx(Body,{type:Typography.BODY_LARGE_BOLD,className:"d-block",children:function(){return n?n:u(d?MESSAGES.uploadFiles:MESSAGES.uploadFile)}()}),function(){return/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsxs(Body,{className:classNames({"text-primary":!c,small:!q,"font-weight-normal":!q}),children:[b(),j&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("br",{}),"Maximum ".concat(j," files.")]})]})})}()]})]})}),y&&/*#__PURE__*/_jsxs("div",{className:classNames("droppable-card","droppable-dropping-card","droppable-card-content",{"np-upload-input--square-top":o}),children:[/*#__PURE__*/_jsx(PlusIcon,{className:"m-x-1",size:24}),/*#__PURE__*/_jsx("div",{children:u(MESSAGES.dropFile)})]})]}))};export default UploadButton;
@@ -1,2 +1,2 @@
1
- import _typeof from"@babel/runtime/helpers/typeof";import{AlertCircle,CrossCircleFill}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import{useIntl}from"react-intl";import Body from"../../body";import{Size,Status,Typography,Sentiment}from"../../common";import ProcessIndicator from"../../processIndicator/ProcessIndicator";import StatusIcon from"../../statusIcon/StatusIcon";import MESSAGES from"./UploadItem.messages";import{UploadItemBody}from"./UploadItemBody";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS;(function(a){a.uploadItem="uploadItem",a.mediaBody="mediaBody"})(TEST_IDS||(TEST_IDS={}));var UploadItem=function(a){var b=a.file,c=a.canDelete,d=a.onDelete,e=a.onDownload,f=a.singleFileUpload,g=useIntl(),h=g.formatMessage,i=b.status,j=b.filename,k=b.error,l=b.url,m=useTheme(),n=m.isModern,o=[Status.SUCCEEDED,void 0].includes(i)&&!!l,p=function(){return"object"===_typeof(k)&&k.message||k||h(MESSAGES.uploadingFailed)};return/*#__PURE__*/_jsx("div",{className:classNames("np-upload-item",{"np-upload-item__link":o}),"data-testid":TEST_IDS.uploadItem,children:/*#__PURE__*/_jsxs("div",{className:"np-upload-item__body",children:[/*#__PURE__*/_jsx(UploadItemBody,{url:o?l:void 0,singleFileUpload:f,onDownload:function onDownloadFile(a){e&&(a.preventDefault(),e(b))},children:/*#__PURE__*/_jsx("div",{className:"np-upload-button",children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:function getIcon(){if(k||i===Status.FAILED)return n?/*#__PURE__*/_jsx(StatusIcon,{size:Size.SMALL,sentiment:Sentiment.NEGATIVE}):/*#__PURE__*/_jsx(AlertCircle,{size:24,className:"text-negative"});var a;switch(i){case Status.PROCESSING:case Status.PENDING:a=/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.EXTRA_SMALL,status:Status.PROCESSING});break;case Status.SUCCEEDED:case Status.DONE:default:a=n?/*#__PURE__*/_jsx(StatusIcon,{size:Size.SMALL,sentiment:Sentiment.POSITIVE}):/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.EXTRA_SMALL,status:Status.SUCCEEDED});}return n?a:/*#__PURE__*/_jsx("span",{style:{transform:"scale(0.8335)"},children:a});// Scale down ProcessIndicator to be 20px*20px to match `icons`
1
+ import _typeof from"@babel/runtime/helpers/typeof";import{AlertCircle,CrossCircleFill}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import{useIntl}from"react-intl";import Body from"../../body";import{Size,Status,Typography,Sentiment}from"../../common";import ProcessIndicator from"../../processIndicator/ProcessIndicator";import StatusIcon from"../../statusIcon/StatusIcon";import MESSAGES from"./UploadItem.messages";import{UploadItemBody}from"./UploadItemBody";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS=/*#__PURE__*/function(a){return a.uploadItem="uploadItem",a.mediaBody="mediaBody",a}({});var UploadItem=function(a){var b=a.file,c=a.canDelete,d=a.onDelete,e=a.onDownload,f=a.singleFileUpload,g=useIntl(),h=g.formatMessage,i=b.status,j=b.filename,k=b.error,l=b.url,m=useTheme(),n=m.isModern,o=[Status.SUCCEEDED,void 0].includes(i)&&!!l,p=function(){return"object"===_typeof(k)&&k.message||k||h(MESSAGES.uploadingFailed)};return/*#__PURE__*/_jsx("div",{className:classNames("np-upload-item",{"np-upload-item__link":o}),"data-testid":TEST_IDS.uploadItem,children:/*#__PURE__*/_jsxs("div",{className:"np-upload-item__body",children:[/*#__PURE__*/_jsx(UploadItemBody,{url:o?l:void 0,singleFileUpload:f,onDownload:function onDownloadFile(a){e&&(a.preventDefault(),e(b))},children:/*#__PURE__*/_jsx("div",{className:"np-upload-button",children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:function getIcon(){if(k||i===Status.FAILED)return n?/*#__PURE__*/_jsx(StatusIcon,{size:Size.SMALL,sentiment:Sentiment.NEGATIVE}):/*#__PURE__*/_jsx(AlertCircle,{size:24,className:"text-negative"});var a;switch(i){case Status.PROCESSING:case Status.PENDING:a=/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.EXTRA_SMALL,status:Status.PROCESSING});break;case Status.SUCCEEDED:case Status.DONE:default:a=n?/*#__PURE__*/_jsx(StatusIcon,{size:Size.SMALL,sentiment:Sentiment.POSITIVE}):/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.EXTRA_SMALL,status:Status.SUCCEEDED});}return n?a:/*#__PURE__*/_jsx("span",{style:{transform:"scale(0.8335)"},children:a});// Scale down ProcessIndicator to be 20px*20px to match `icons`
2
2
  }()}),/*#__PURE__*/_jsxs("div",{className:"media-body text-xs-left","data-testid":TEST_IDS.mediaBody,children:[/*#__PURE__*/_jsx(Body,{className:"text-word-break d-block text-primary",children:function getTitle(){return j||h(MESSAGES.uploadedFile)}()}),function getDescription(){if(k||i===Status.FAILED)return/*#__PURE__*/_jsx(Body,{type:Typography.BODY_DEFAULT_BOLD,className:"text-negative",children:p()});switch(i){case Status.PENDING:return/*#__PURE__*/_jsx(Body,{type:Typography.BODY_DEFAULT_BOLD,children:h(MESSAGES.uploading)});case Status.PROCESSING:return/*#__PURE__*/_jsx(Body,{children:h(MESSAGES.deleting)});case Status.SUCCEEDED:case Status.DONE:default:return/*#__PURE__*/_jsx(Body,{type:Typography.BODY_DEFAULT_BOLD,className:"text-positive",children:h(MESSAGES.uploaded)});}}()]})]})})}),c&&/*#__PURE__*/_jsx("button",{"aria-label":h(MESSAGES.removeFile,{filename:j}),className:classNames("btn","np-upload-item__remove-button","media-left",{"np-upload-item--single-file":f}),type:"button",onClick:function onClick(){return d()},children:/*#__PURE__*/_jsx(CrossCircleFill,{size:16})})]})})};export default UploadItem;
@@ -1 +1 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _deprecatedTypeMap,_deprecatedTypeMapMes;import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.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";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.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{InfoCircle,Warning as AlertTriangle,CrossCircle,CheckCircle,Clock}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement,useState,useRef}from"react";import requiredIf from"react-required-if";import Body from"../body/Body";import{Sentiment,Size,Typography,Variant}from"../common";import{CloseButton}from"../common/closeButton";import Link from"../link";import StatusIcon from"../statusIcon";import{logActionRequiredIf,deprecated}from"../utilities";import InlineMarkdown from"./inlineMarkdown";import withArrow from"./withArrow";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var deprecatedTypeMap=(_deprecatedTypeMap={},_defineProperty(_deprecatedTypeMap,Sentiment.SUCCESS,Sentiment.POSITIVE),_defineProperty(_deprecatedTypeMap,Sentiment.INFO,Sentiment.NEUTRAL),_defineProperty(_deprecatedTypeMap,Sentiment.ERROR,Sentiment.NEGATIVE),_deprecatedTypeMap),Alert=function(a){var b,c=useTheme(),d=c.isModern,e=(b={},_defineProperty(b,Sentiment.POSITIVE,CheckCircle),_defineProperty(b,Sentiment.NEUTRAL,InfoCircle),_defineProperty(b,Sentiment.WARNING,AlertTriangle),_defineProperty(b,Sentiment.NEGATIVE,CrossCircle),_defineProperty(b,Sentiment.PENDING,Clock),b),f=useState(!1),g=_slicedToArray(f,2),h=g[0],i=g[1],j=a.arrow,k=a.action,l=a.children,m=a.className,n=a.icon,o=a.onDismiss,p=a.message,q=a.type,r=a.variant,s=useRef(null);if(j){var v=withArrow(Alert,j);return/*#__PURE__*/_jsx(v,_objectSpread({},a))}logActionRequired(a);var t=deprecatedTypeMap[q]||q,u=e[t];return/*#__PURE__*/_jsxs("div",{role:"alert",className:classNames("alert d-flex","alert-".concat(t),m),onTouchStart:function handleTouchStart(){return i(!0)},onTouchEnd:function handleTouchEnd(a){h&&k&&null!==s&&void 0!==s&&s.current&&!s.current.contains(a.target)&&("_blank"===(null===k||void 0===k?void 0:k.target)?window.top.open(k.href):window.top.location.assign(k.href)),i(!1)},onTouchMove:function handleTouchMove(){return i(!1)},children:[/*#__PURE__*/_jsxs("div",{className:classNames("alert__content","d-flex","flex-grow-1",r),"data-testid":r,children:[function(){return n?/*#__PURE__*/cloneElement(n,{size:24}):d?/*#__PURE__*/_jsx(StatusIcon,{size:Size.LARGE,sentiment:t}):/*#__PURE__*/_jsx(u,{size:24})}(),/*#__PURE__*/_jsxs("div",{className:"alert__message",children:[/*#__PURE__*/_jsx(Body,{as:"span",className:"d-block",type:Typography.BODY_LARGE,children:l||/*#__PURE__*/_jsx(InlineMarkdown,{children:p})}),k&&/*#__PURE__*/_jsx(Link,{href:k.href,className:"m-t-1","aria-label":k["aria-label"],target:k.target,type:Typography.LINK_LARGE,children:k.text})]})]}),o&&/*#__PURE__*/_jsx(CloseButton,{ref:s,className:"m-l-2",onClick:o})]})},deprecatedTypeMapMessage=(_deprecatedTypeMapMes={},_defineProperty(_deprecatedTypeMapMes,Sentiment.SUCCESS,"Sentiment.POSITIVE"),_defineProperty(_deprecatedTypeMapMes,Sentiment.INFO,"Sentiment.NEUTRAL"),_defineProperty(_deprecatedTypeMapMes,Sentiment.ERROR,"Sentiment.NEGATIVE"),_deprecatedTypeMapMes),deprecatedTypes=Object.keys(deprecatedTypeMap);function logActionRequired(a){var b=a.size,c=a.type;logActionRequiredIf("Alert no longer supports any possible variations in size. Please remove the `size` prop.",!!b),logActionRequiredIf("Alert has deprecated the ".concat(c," value for the `type` prop. Please update to ").concat(deprecatedTypeMapMessage[c],"."),deprecatedTypes.includes(c))}Alert.propTypes={/** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */action:PropTypes.shape({"aria-label":PropTypes.string,href:PropTypes.string.isRequired,target:PropTypes.string,text:PropTypes.node.isRequired}),className:PropTypes.string,/** An optional icon. If not provided, we will default the icon to something appropriate for the type */icon:PropTypes.element,/** The main body of the alert. Accepts plain text and bold words specified with **double stars*/message:requiredIf(PropTypes.node,function(a){var b=a.children;return!b}),/** The presence of the onDismiss handler will trigger the visibility of the close button */onDismiss:PropTypes.func,/** The type dictates which icon and colour will be used */type:PropTypes.oneOf(["negative","neutral","positive","warning","info","error","success"]),variant:PropTypes.oneOf(["desktop","mobile"]),/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */arrow:deprecated(PropTypes.oneOf(["up-left","up-center","up-right","down-left","down-center","down-right"]),{component:"Alert",expiryDate:new Date("03-01-2021")}),/** @deprecated use `message` property instead */children:deprecated(requiredIf(PropTypes.node,function(a){var b=a.message;return!b}),{component:"Alert",message:"You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.",expiryDate:new Date("03-01-2021")}),/** @deprecated use `onDismiss` instead */dismissible:deprecated(PropTypes.bool,{component:"Alert",message:"The Alert will now be considered dismissible if an `onDismiss` hander is present.",expiryDate:new Date("03-01-2021")})},Alert.defaultProps={action:void 0,arrow:void 0,className:void 0,dismissible:void 0,icon:void 0,type:Sentiment.NEUTRAL,variant:Variant.DESKTOP};export default Alert;
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _deprecatedTypeMap,_deprecatedTypeMapMes;import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.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";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.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{InfoCircle,Warning as AlertTriangle,CrossCircle,CheckCircle,Clock}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement,useState,useRef}from"react";import requiredIf from"react-required-if";import Body from"../body/Body";import{Sentiment,Size,Typography,Variant}from"../common";import{CloseButton}from"../common/closeButton";import Link from"../link";import StatusIcon from"../statusIcon";import{logActionRequiredIf,deprecated}from"../utilities";import InlineMarkdown from"./inlineMarkdown";import withArrow from"./withArrow";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var deprecatedTypeMap=(_deprecatedTypeMap={},_defineProperty(_deprecatedTypeMap,Sentiment.SUCCESS,Sentiment.POSITIVE),_defineProperty(_deprecatedTypeMap,Sentiment.INFO,Sentiment.NEUTRAL),_defineProperty(_deprecatedTypeMap,Sentiment.ERROR,Sentiment.NEGATIVE),_deprecatedTypeMap),Alert=function(a){var b,c=useTheme(),d=c.isModern,e=(b={},_defineProperty(b,Sentiment.POSITIVE,CheckCircle),_defineProperty(b,Sentiment.NEUTRAL,InfoCircle),_defineProperty(b,Sentiment.WARNING,AlertTriangle),_defineProperty(b,Sentiment.NEGATIVE,CrossCircle),_defineProperty(b,Sentiment.PENDING,Clock),b),f=useState(!1),g=_slicedToArray(f,2),h=g[0],i=g[1],j=a.arrow,k=a.action,l=a.children,m=a.className,n=a.icon,o=a.onDismiss,p=a.message,q=a.type,r=a.variant,s=useRef(null);if(j){var t=withArrow(Alert,j);return/*#__PURE__*/_jsx(t,_objectSpread({},a))}logActionRequired(a);var u=deprecatedTypeMap[q]||q,v=e[u];return/*#__PURE__*/_jsxs("div",{role:"alert",className:classNames("alert d-flex","alert-".concat(u),m),onTouchStart:function handleTouchStart(){return i(!0)},onTouchEnd:function handleTouchEnd(a){h&&k&&null!==s&&void 0!==s&&s.current&&!s.current.contains(a.target)&&("_blank"===(null===k||void 0===k?void 0:k.target)?window.top.open(k.href):window.top.location.assign(k.href)),i(!1)},onTouchMove:function handleTouchMove(){return i(!1)},children:[/*#__PURE__*/_jsxs("div",{className:classNames("alert__content","d-flex","flex-grow-1",r),"data-testid":r,children:[function(){return n?/*#__PURE__*/cloneElement(n,{size:24}):d?/*#__PURE__*/_jsx(StatusIcon,{size:Size.LARGE,sentiment:u}):/*#__PURE__*/_jsx(v,{size:24})}(),/*#__PURE__*/_jsxs("div",{className:"alert__message",children:[/*#__PURE__*/_jsx(Body,{as:"span",className:"d-block",type:Typography.BODY_LARGE,children:l||/*#__PURE__*/_jsx(InlineMarkdown,{children:p})}),k&&/*#__PURE__*/_jsx(Link,{href:k.href,className:"m-t-1","aria-label":k["aria-label"],target:k.target,type:Typography.LINK_LARGE,children:k.text})]})]}),o&&/*#__PURE__*/_jsx(CloseButton,{ref:s,className:"m-l-2",onClick:o})]})},deprecatedTypeMapMessage=(_deprecatedTypeMapMes={},_defineProperty(_deprecatedTypeMapMes,Sentiment.SUCCESS,"Sentiment.POSITIVE"),_defineProperty(_deprecatedTypeMapMes,Sentiment.INFO,"Sentiment.NEUTRAL"),_defineProperty(_deprecatedTypeMapMes,Sentiment.ERROR,"Sentiment.NEGATIVE"),_deprecatedTypeMapMes),deprecatedTypes=Object.keys(deprecatedTypeMap);function logActionRequired(a){var b=a.size,c=a.type;logActionRequiredIf("Alert no longer supports any possible variations in size. Please remove the `size` prop.",!!b),logActionRequiredIf("Alert has deprecated the ".concat(c," value for the `type` prop. Please update to ").concat(deprecatedTypeMapMessage[c],"."),deprecatedTypes.includes(c))}Alert.propTypes={/** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */action:PropTypes.shape({"aria-label":PropTypes.string,href:PropTypes.string.isRequired,target:PropTypes.string,text:PropTypes.node.isRequired}),className:PropTypes.string,/** An optional icon. If not provided, we will default the icon to something appropriate for the type */icon:PropTypes.element,/** The main body of the alert. Accepts plain text and bold words specified with **double stars*/message:requiredIf(PropTypes.node,function(a){var b=a.children;return!b}),/** The presence of the onDismiss handler will trigger the visibility of the close button */onDismiss:PropTypes.func,/** The type dictates which icon and colour will be used */type:PropTypes.oneOf(["negative","neutral","positive","warning","info","error","success"]),variant:PropTypes.oneOf(["desktop","mobile"]),/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */arrow:deprecated(PropTypes.oneOf(["up-left","up-center","up-right","down-left","down-center","down-right"]),{component:"Alert",expiryDate:new Date("03-01-2021")}),/** @deprecated use `message` property instead */children:deprecated(requiredIf(PropTypes.node,function(a){var b=a.message;return!b}),{component:"Alert",message:"You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.",expiryDate:new Date("03-01-2021")}),/** @deprecated use `onDismiss` instead */dismissible:deprecated(PropTypes.bool,{component:"Alert",message:"The Alert will now be considered dismissible if an `onDismiss` hander is present.",expiryDate:new Date("03-01-2021")})},Alert.defaultProps={action:void 0,arrow:void 0,className:void 0,dismissible:void 0,icon:void 0,type:Sentiment.NEUTRAL,variant:Variant.DESKTOP};export default Alert;
@@ -1,2 +1,2 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var ArrowPosition;(function(a){a.TOP_LEFT="up-left",a.TOP="up-center",a.TOP_RIGHT="up-right",a.BOTTOM_LEFT="down-left",a.BOTTOM="down-center",a.BOTTOM_RIGHT="down-right"})(ArrowPosition||(ArrowPosition={}));
2
+ export var ArrowPosition=/*#__PURE__*/function(a){return a.TOP_LEFT="up-left",a.TOP="up-center",a.TOP_RIGHT="up-right",a.BOTTOM_LEFT="down-left",a.BOTTOM="down-center",a.BOTTOM_RIGHT="down-right",a}({});
@@ -1,2 +1,2 @@
1
1
  // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export var AvatarType;(function(a){a.THUMBNAIL="thumbnail",a.ICON="icon",a.EMOJI="emoji",a.INITIALS="initials"})(AvatarType||(AvatarType={}));
2
+ export var AvatarType=/*#__PURE__*/function(a){return a.THUMBNAIL="thumbnail",a.ICON="icon",a.EMOJI="emoji",a.INITIALS="initials",a}({});