@transferwise/components 43.6.9 → 43.7.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.
- package/build/es/no-polyfill/avatarWrapper/AvatarWrapper.js +1 -1
- package/build/es/no-polyfill/checkbox/Checkbox.js +1 -1
- package/build/es/no-polyfill/chips/Chip.js +1 -1
- package/build/es/no-polyfill/common/closeButton/CloseButton.js +1 -1
- package/build/es/no-polyfill/common/theme.js +1 -1
- package/build/es/no-polyfill/header/Header.story.js +1 -1
- package/build/es/no-polyfill/index.js +1 -1
- package/build/es/no-polyfill/info/Info.js +1 -1
- package/build/es/no-polyfill/logo/Logo.js +1 -1
- package/build/es/no-polyfill/radio/Radio.js +1 -1
- package/build/es/no-polyfill/summary/Summary.js +1 -1
- package/build/es/no-polyfill/typeahead/Typeahead.js +1 -1
- package/build/es/no-polyfill/upload/Upload.js +1 -1
- package/build/es/no-polyfill/upload/steps/completeStep/completeStep.js +1 -1
- package/build/es/no-polyfill/upload/steps/processingStep/processingStep.js +1 -1
- package/build/es/no-polyfill/upload/steps/uploadImageStep/uploadImageStep.js +1 -1
- package/build/es/no-polyfill/uploadInput/UploadInput.js +1 -1
- package/build/es/no-polyfill/uploadInput/uploadItem/UploadItem.js +2 -2
- package/build/es/polyfill/avatarWrapper/AvatarWrapper.js +1 -1
- package/build/es/polyfill/checkbox/Checkbox.js +1 -1
- package/build/es/polyfill/chips/Chip.js +1 -1
- package/build/es/polyfill/common/closeButton/CloseButton.js +1 -1
- package/build/es/polyfill/common/theme.js +1 -1
- package/build/es/polyfill/header/Header.story.js +1 -1
- package/build/es/polyfill/index.js +1 -1
- package/build/es/polyfill/info/Info.js +1 -1
- package/build/es/polyfill/logo/Logo.js +1 -1
- package/build/es/polyfill/radio/Radio.js +1 -1
- package/build/es/polyfill/summary/Summary.js +1 -1
- package/build/es/polyfill/typeahead/Typeahead.js +1 -1
- package/build/es/polyfill/upload/Upload.js +1 -1
- package/build/es/polyfill/upload/steps/completeStep/completeStep.js +1 -1
- package/build/es/polyfill/upload/steps/processingStep/processingStep.js +1 -1
- package/build/es/polyfill/upload/steps/uploadImageStep/uploadImageStep.js +1 -1
- package/build/es/polyfill/uploadInput/UploadInput.js +1 -1
- package/build/es/polyfill/uploadInput/uploadItem/UploadItem.js +2 -2
- package/build/main.css +1 -1
- package/build/styles/accordion/Accordion.css +1 -1
- package/build/styles/actionButton/ActionButton.css +1 -1
- package/build/styles/card/Card.css +1 -1
- package/build/styles/chips/Chip.css +1 -1
- package/build/styles/circularButton/CircularButton.css +1 -1
- package/build/styles/common/Option/Option.css +1 -1
- package/build/styles/common/bottomSheet/BottomSheet.css +1 -1
- package/build/styles/common/panel/Panel.css +1 -1
- package/build/styles/criticalBanner/CriticalCommsBanner.css +1 -1
- package/build/styles/dateLookup/DateLookup.css +1 -1
- package/build/styles/definitionList/DefinitionList.css +1 -1
- package/build/styles/dimmer/Dimmer.css +1 -1
- package/build/styles/emphasis/Emphasis.css +1 -1
- package/build/styles/flowNavigation/FlowNavigation.css +1 -1
- package/build/styles/info/Info.css +1 -1
- package/build/styles/lab/pagination/Pagination.css +1 -1
- package/build/styles/logo/Logo.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/modal/Modal.css +1 -1
- package/build/styles/moneyInput/MoneyInput.css +1 -1
- package/build/styles/overlayHeader/OverlayHeader.css +1 -1
- package/build/styles/slidingPanel/SlidingPanel.css +1 -1
- package/build/styles/snackbar/Snackbar.css +1 -1
- package/build/styles/statusIcon/StatusIcon.css +1 -1
- package/build/styles/stepper/Stepper.css +1 -1
- package/build/styles/tile/Tile.css +1 -1
- package/build/styles/typeahead/Typeahead.css +1 -1
- package/build/styles/uploadInput/UploadInput.css +1 -1
- package/build/styles/uploadInput/uploadButton/UploadButton.css +1 -1
- package/build/types/avatarWrapper/AvatarWrapper.d.ts +5 -1
- package/build/types/common/theme.d.ts +6 -2
- package/build/types/index.d.ts +1 -0
- package/build/umd/no-polyfill/main.js +1 -1
- package/build/umd/polyfill/main.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.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";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{QuestionMarkCircle as HelpCircleIcon}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{useState}from"react";import{Size,Position}from"../common";import Modal from"../modal";import Popover from"../popover";import{InfoPresentation}from"./infoPresentations";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Info=function(a){var b=a.className,
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.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";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{QuestionMarkCircle as HelpCircleIcon}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{useState}from"react";import{Size,Position}from"../common";import Modal from"../modal";import Popover from"../popover";import{InfoPresentation}from"./infoPresentations";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Info=function(a){var b=useTheme(),c=b.isModern,d=a.className,e=a.content,f=a.onClick,g=a.presentation,h=a.size,i=a.title,j=useState(!1),k=_slicedToArray(j,2),l=k[0],m=k[1],n=g===InfoPresentation.MODAL,o=h===Size.SMALL,p={"aria-label":a["aria-label"],className:"btn-unstyled ".concat(c?"np-info-centered":""),children:/*#__PURE__*/_jsx(HelpCircleIcon,{size:o?16:24})};return/*#__PURE__*/_jsx("span",{className:classNames(d,"np-info",{"np-info__small":o,"np-info__large":!o}),children:n?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("button",_objectSpread({type:"button",onClick:function onClick(){m(!l),f&&f()}},p)),/*#__PURE__*/_jsx(Modal,{body:e,open:l,title:i,onClose:function onClose(){return m(!1)}})]}):/*#__PURE__*/_jsx(Popover,{content:e,preferredPlacement:Position.BOTTOM,title:i,children:/*#__PURE__*/_jsx("button",_objectSpread(_objectSpread({type:"button"},p),{},{onClick:function onClick(){f&&f()}}))})})};Info.propTypes={"aria-label":PropTypes.string.isRequired,/** Extra classes applied to Info */className:PropTypes.string,/** Content displayed inside a Popover a Modal */content:PropTypes.node,onClick:PropTypes.func,/** Decides whether to display content in a Popover or a Modal */presentation:PropTypes.oneOf(["MODAL","POPOVER"]),/** Decides the size of help Icon */size:PropTypes.oneOf(["sm","lg"]),/** Title displayed inside a Popover a Modal */title:PropTypes.node},Info.defaultProps={className:void 0,content:void 0,onClick:void 0,presentation:InfoPresentation.POPOVER,size:Size.SMALL,title:void 0};export default Info;
|
|
@@ -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"core-js/modules/es.array.concat.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.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 React from"react";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{Breakpoint}from"../common";import{isServerSide}from"../common/domHelpers";import{useClientWidth}from"../common/hooks";import{LogoType}from"./logoTypes";import{jsx as _jsx}from"react/jsx-runtime";var LogoFlagInverse=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M6.66 6.36 0 12.72h11.323l1.182-2.772H6.768l3.588-3.588-2.084-3.588h9.733L9.025 24h3.373L22.56 0H2.922l3.739 6.36z",fill:"#9fe870"})}))};LogoFlagInverse.defaultProps={width:"23",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoFlag=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M6.66 6.36 0 12.72h11.323l1.182-2.772H6.768l3.588-3.588-2.084-3.588h9.733L9.025 24h3.373L22.56 0H2.922l3.739 6.36z",fill:"#163300"})}))};LogoFlag.defaultProps={width:"23",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWiseBusinessInverse=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M119.48 8.004h-2.403v14.557h2.403V8.004zM37.642 22.561l2.655-14.557h3.508l-2.656 14.557h-3.507zM17.549 8.004h3.407l1.103 10.524 4.459-10.524H29.9l1.178 10.624 4.31-10.624h3.382l-6.164 14.557h-3.858L27.496 12.54l-4.26 10.022h-3.733L17.55 8.004zM2.574 8.004l2.27 3.86-4.043 3.865h6.877l.718-1.684h-3.48l2.177-2.177-1.269-2.18h5.905L6.283 22.562h2.045l6.164-14.557H2.574zM78.501 9.87c-2.685 0-4.946 2.43-4.946 5.455 0 2.968 2.261 5.399 4.946 5.399 2.714 0 4.862-2.431 4.862-5.399 0-3.024-2.148-5.455-4.862-5.455zm0 13.059c-2.148 0-4.013-1.216-5.03-2.714v2.346h-2.319V1.531h2.403v8.678c1.046-1.413 2.855-2.572 4.946-2.572 4.184 0 7.265 3.448 7.265 7.66s-3.081 7.632-7.265 7.632zm21.536-.368h-2.318v-1.583c-.989 1.187-2.459 1.922-4.24 1.922-3.56 0-5.596-2.544-5.596-6.133V8.004h2.374v8.876c0 2.318 1.272 3.844 3.59 3.844 2.148 0 3.788-1.611 3.788-3.788V8.004h2.402v14.557zm8.674.368c-3.534 0-6.106-1.894-6.502-4.975h2.431c.311 1.696 1.979 2.742 4.071 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.534-.509-5.682-1.357-5.682-4.098 0-2.092 1.809-4.325 5.71-4.325 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.345-3.505-2.345-1.922 0-3.307.904-3.307 2.035 0 1.045.82 1.413 3.674 1.865 3.223.509 5.88 1.13 5.88 4.438 0 2.911-2.488 4.749-5.964 4.749zm25.948-.368h-2.374v-8.847c0-2.233-1.244-3.872-3.562-3.872-2.205 0-3.816 1.639-3.816 3.815v8.904h-2.402V8.004h2.317v1.583c.99-1.215 2.488-1.95 4.24-1.95 3.562 0 5.597 2.544 5.597 6.162v8.762zm13.879-8.791c-.594-2.374-2.573-3.957-4.693-3.957-2.006 0-4.126 1.47-4.748 3.957h9.441zm2.317 4.269c-1.017 3.109-3.505 4.861-6.868 4.861-4.184 0-7.462-3.335-7.462-7.603 0-4.212 3.278-7.66 7.32-7.66 3.76 0 7.378 3.109 7.35 8.282h-12.24c.311 3.024 2.629 4.805 5.032 4.805 2.063 0 3.533-.99 4.324-2.685h2.544zm8.394 4.89c-3.533 0-6.106-1.894-6.501-4.975h2.431c.31 1.696 1.978 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.533-.509-5.682-1.357-5.682-4.098 0-2.092 1.809-4.325 5.71-4.325 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.345-3.505-2.345-1.922 0-3.307.904-3.307 2.035 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438 0 2.911-2.487 4.749-5.964 4.749zm13.652 0c-3.533 0-6.105-1.894-6.501-4.975h2.431c.311 1.696 1.979 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.395-1.78-3.957-2.261-3.533-.509-5.681-1.357-5.681-4.098 0-2.092 1.809-4.325 5.71-4.325 3.363 0 5.624 1.696 5.935 4.55h-2.43c-.34-1.554-1.725-2.345-3.505-2.345-1.923 0-3.308.904-3.308 2.035 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438-.001 2.911-2.487 4.749-5.964 4.749zM57.207 13.867c.352-1.804 2.105-3.233 4.21-3.233 1.83 0 3.207 1.329 3.207 3.233h-7.417zm10.9.45c0-3.909-2.73-6.665-6.54-6.665-4.86 0-8.118 3.534-8.118 8.57 0 3.932 2.756 6.664 6.64 6.664 3.533 0 6.163-1.703 7.24-4.435h-3.933c-.526.853-1.628 1.378-2.982 1.378-2.079 0-3.382-1.378-3.508-3.332H67.88a10.08 10.08 0 0 0 .227-2.18zm-25.204 8.219.701-3.758c2.156.425 2.48-.777 3.032-3.709l.275-1.453c.778-4.084 2.355-6.113 6.865-5.562l-.701 3.758c-2.156-.426-2.53 1.202-3.006 3.732l-.276 1.453c-.776 4.135-2.405 6.09-6.89 5.539z",fill:"#9fe870"})}))};LogoWiseBusinessInverse.defaultProps={width:"180",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWiseBusiness=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M119.48 8.004h-2.403v14.557h2.403V8.004zM37.642 22.561l2.655-14.557h3.508l-2.656 14.557h-3.507zM17.549 8.004h3.407l1.103 10.524 4.459-10.524H29.9l1.178 10.624 4.31-10.624h3.382l-6.164 14.557h-3.858L27.496 12.54l-4.26 10.021h-3.733L17.55 8.004zM2.574 8.004l2.27 3.86-4.043 3.865h6.877l.718-1.684h-3.48l2.177-2.177-1.269-2.18h5.905L6.283 22.562h2.045l6.164-14.557H2.574zM78.501 9.87c-2.685 0-4.946 2.43-4.946 5.455 0 2.968 2.261 5.399 4.946 5.399 2.714 0 4.862-2.431 4.862-5.399 0-3.024-2.148-5.455-4.862-5.455zm0 13.059c-2.148 0-4.013-1.216-5.03-2.714v2.346h-2.319V1.531h2.403v8.678c1.046-1.413 2.855-2.572 4.946-2.572 4.184 0 7.265 3.448 7.265 7.66s-3.081 7.632-7.265 7.632zm21.536-.368h-2.318v-1.583c-.989 1.188-2.459 1.922-4.24 1.922-3.56 0-5.596-2.544-5.596-6.133V8.004h2.374v8.876c0 2.318 1.272 3.844 3.59 3.844 2.148 0 3.788-1.611 3.788-3.788V8.004h2.402v14.557zm8.674.368c-3.534 0-6.106-1.894-6.502-4.975h2.431c.311 1.696 1.979 2.742 4.071 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.534-.509-5.682-1.357-5.682-4.099 0-2.091 1.809-4.324 5.71-4.324 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.346-3.505-2.346-1.922 0-3.307.905-3.307 2.036 0 1.045.82 1.413 3.674 1.865 3.223.509 5.88 1.13 5.88 4.438 0 2.911-2.488 4.749-5.964 4.749zm25.948-.368h-2.374v-8.847c0-2.233-1.244-3.873-3.562-3.873-2.205 0-3.816 1.64-3.816 3.816v8.904h-2.402V8.004h2.317v1.583c.99-1.215 2.488-1.95 4.24-1.95 3.562 0 5.597 2.544 5.597 6.162v8.762zm13.879-8.791c-.594-2.374-2.573-3.957-4.693-3.957-2.007 0-4.127 1.47-4.748 3.957h9.441zm2.317 4.269c-1.017 3.109-3.505 4.861-6.868 4.861-4.184 0-7.463-3.335-7.463-7.603 0-4.212 3.279-7.66 7.321-7.66 3.76 0 7.378 3.109 7.35 8.282h-12.24c.311 3.024 2.629 4.805 5.032 4.805 2.063 0 3.533-.99 4.324-2.685h2.544zm8.394 4.89c-3.533 0-6.106-1.894-6.501-4.975h2.431c.31 1.696 1.978 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.533-.509-5.682-1.357-5.682-4.099 0-2.091 1.809-4.324 5.71-4.324 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.346-3.505-2.346-1.922 0-3.307.905-3.307 2.036 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438 0 2.911-2.487 4.749-5.964 4.749zm13.652 0c-3.533 0-6.105-1.894-6.501-4.975h2.431c.311 1.696 1.979 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.395-1.78-3.957-2.261-3.533-.509-5.681-1.357-5.681-4.099 0-2.091 1.809-4.324 5.71-4.324 3.363 0 5.624 1.696 5.935 4.55h-2.43c-.34-1.554-1.725-2.346-3.505-2.346-1.923 0-3.308.905-3.308 2.036 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438-.001 2.911-2.487 4.749-5.964 4.749zM57.207 13.867c.352-1.804 2.105-3.233 4.21-3.233 1.83 0 3.207 1.329 3.207 3.233h-7.417zm10.9.45c0-3.909-2.73-6.665-6.54-6.665-4.86 0-8.118 3.533-8.118 8.57 0 3.932 2.756 6.664 6.64 6.664 3.533 0 6.163-1.703 7.24-4.435h-3.933c-.526.852-1.628 1.378-2.982 1.378-2.079 0-3.382-1.378-3.508-3.332H67.88a10.08 10.08 0 0 0 .227-2.18zm-25.204 8.219.701-3.758c2.156.425 2.48-.777 3.032-3.709l.275-1.453c.778-4.084 2.355-6.114 6.865-5.562l-.701 3.758c-2.156-.426-2.53 1.202-3.006 3.732l-.276 1.453c-.776 4.135-2.405 6.09-6.89 5.539z",fill:"#163300"})}))};LogoWiseBusiness.defaultProps={width:"180",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWiseInverse=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M93.669 10.69c0-5.382-3.75-9.167-9.007-9.167-6.692 0-11.177 4.862-11.177 11.805 0 5.418 3.786 9.167 9.132 9.167 4.862 0 8.486-2.35 9.975-6.1h-5.4c-.718 1.167-2.243 1.902-4.108 1.902-2.871 0-4.665-1.902-4.827-4.593h15.107c.197-1.022.305-1.901.305-3.014zm-14.999-.628c.484-2.475 2.889-4.449 5.795-4.449 2.512 0 4.413 1.83 4.413 4.45H78.67zM58.971 22.01l.969-5.166c2.96.592 3.409-1.077 4.18-5.095l.377-1.992c1.076-5.615 3.247-8.414 9.455-7.66l-.97 5.167c-2.96-.592-3.48 1.65-4.143 5.13l-.377 1.992c-1.077 5.687-3.32 8.378-9.49 7.625zm-7.248.019 3.66-20.022h4.826l-3.642 20.022h-4.844zM24.076 2.007h4.683l1.525 14.478L36.42 2.007h4.646L42.7 16.629l5.92-14.622h4.665l-8.486 20.022h-5.31L37.765 8.25 31.9 22.03h-5.131L24.076 2.007zM6.584 7.317l-5.561 5.31h9.454l.987-2.313h-4.79L9.67 7.317 7.93 4.321h8.127l-7.5 17.708h2.817L19.86 2.007H3.463l3.121 5.31z",fill:"#9fe870"})}))};LogoWiseInverse.defaultProps={width:"95",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWise=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M93.668 10.69c0-5.382-3.75-9.167-9.006-9.167-6.692 0-11.177 4.862-11.177 11.805 0 5.418 3.786 9.167 9.132 9.167 4.862 0 8.486-2.35 9.975-6.1h-5.4c-.718 1.167-2.243 1.902-4.109 1.902-2.87 0-4.664-1.902-4.826-4.593h15.106c.198-1.022.305-1.901.305-3.014zm-14.998-.628c.484-2.475 2.888-4.449 5.795-4.449 2.511 0 4.413 1.83 4.413 4.45H78.67zM58.971 22.01l.969-5.166c2.96.592 3.409-1.077 4.18-5.095l.377-1.992c1.076-5.615 3.247-8.414 9.455-7.66l-.97 5.167c-2.96-.592-3.48 1.65-4.143 5.13l-.377 1.992c-1.077 5.687-3.32 8.378-9.49 7.625zm-7.248.019 3.66-20.022h4.826l-3.642 20.022h-4.844zM24.076 2.007h4.683l1.525 14.478L36.42 2.007h4.646L42.7 16.629l5.92-14.622h4.665l-8.486 20.022h-5.31L37.764 8.25 31.9 22.03h-5.132l-2.69-20.022zM6.584 7.317l-5.561 5.31h9.454l.987-2.314h-4.79L9.67 7.317 7.93 4.321h8.127l-7.5 17.708h2.817L19.86 2.007H3.463l3.121 5.31z",fill:"#163300"})}))};LogoWise.defaultProps={width:"95",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var baseUrl="https://wise.com/public-resources/assets/logos/wise/",logoPaths={WISE:"brand_logo.svg",WISE_BUSINESS:"brand_logo_business.svg",WISE_INVERSE:"brand_logo_inverse.svg",WISE_BUSINESS_INVERSE:"brand_logo_business_inverse.svg",WISE_FLAG:"brand_flag.svg"},svgPaths={WISE:LogoWise,WISE_BUSINESS:LogoWiseBusiness,WISE_INVERSE:LogoWiseInverse,WISE_BUSINESS_INVERSE:LogoWiseBusinessInverse,WISE_FLAG:LogoFlag,WISE_FLAG_INVERSE:LogoFlagInverse},Logo=function(a){var b=a.className,c=a.inverse,d=a.type,e=useTheme(),f=e.isModern,g=useClientWidth({ref:isServerSide()?void 0:window}),h=_slicedToArray(g,1),i=h[0],j=i<Breakpoint.SMALL,k=j?logoPaths.WISE_FLAG:logoPaths["".concat(d).concat(c?"_INVERSE":"")],l=j?svgPaths["WISE_FLAG".concat(c?"_INVERSE":"")]:svgPaths["".concat(d).concat(c?"_INVERSE":"")];return f?/*#__PURE__*/_jsx(l,{}):/*#__PURE__*/_jsx("img",{className:classNames("np-logo",b),alt:d===LogoType.WISE?"Wise":"Wise business",src:"".concat(baseUrl).concat(k)})};Logo.propTypes={/** Extra classes applied to Logo */className:PropTypes.string,/** If true, will use dark colours for dark on light theme */inverse:PropTypes.bool,/** What type of logo to display */type:PropTypes.oneOf(["WISE","WISE_BUSINESS"])},Logo.defaultProps={className:void 0,inverse:!1,type:LogoType.WISE};export default Logo;
|
|
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"core-js/modules/es.array.concat.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.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 React from"react";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{Breakpoint}from"../common";import{isServerSide}from"../common/domHelpers";import{useClientWidth}from"../common/hooks";import{LogoType}from"./logoTypes";import{jsx as _jsx}from"react/jsx-runtime";var LogoFlagInverse=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M6.66 6.36 0 12.72h11.323l1.182-2.772H6.768l3.588-3.588-2.084-3.588h9.733L9.025 24h3.373L22.56 0H2.922l3.739 6.36z",fill:"#9fe870"})}))};LogoFlagInverse.defaultProps={width:"23",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoFlag=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M6.66 6.36 0 12.72h11.323l1.182-2.772H6.768l3.588-3.588-2.084-3.588h9.733L9.025 24h3.373L22.56 0H2.922l3.739 6.36z",fill:"#163300"})}))};LogoFlag.defaultProps={width:"23",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWiseBusinessInverse=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M119.48 8.004h-2.403v14.557h2.403V8.004zM37.642 22.561l2.655-14.557h3.508l-2.656 14.557h-3.507zM17.549 8.004h3.407l1.103 10.524 4.459-10.524H29.9l1.178 10.624 4.31-10.624h3.382l-6.164 14.557h-3.858L27.496 12.54l-4.26 10.022h-3.733L17.55 8.004zM2.574 8.004l2.27 3.86-4.043 3.865h6.877l.718-1.684h-3.48l2.177-2.177-1.269-2.18h5.905L6.283 22.562h2.045l6.164-14.557H2.574zM78.501 9.87c-2.685 0-4.946 2.43-4.946 5.455 0 2.968 2.261 5.399 4.946 5.399 2.714 0 4.862-2.431 4.862-5.399 0-3.024-2.148-5.455-4.862-5.455zm0 13.059c-2.148 0-4.013-1.216-5.03-2.714v2.346h-2.319V1.531h2.403v8.678c1.046-1.413 2.855-2.572 4.946-2.572 4.184 0 7.265 3.448 7.265 7.66s-3.081 7.632-7.265 7.632zm21.536-.368h-2.318v-1.583c-.989 1.187-2.459 1.922-4.24 1.922-3.56 0-5.596-2.544-5.596-6.133V8.004h2.374v8.876c0 2.318 1.272 3.844 3.59 3.844 2.148 0 3.788-1.611 3.788-3.788V8.004h2.402v14.557zm8.674.368c-3.534 0-6.106-1.894-6.502-4.975h2.431c.311 1.696 1.979 2.742 4.071 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.534-.509-5.682-1.357-5.682-4.098 0-2.092 1.809-4.325 5.71-4.325 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.345-3.505-2.345-1.922 0-3.307.904-3.307 2.035 0 1.045.82 1.413 3.674 1.865 3.223.509 5.88 1.13 5.88 4.438 0 2.911-2.488 4.749-5.964 4.749zm25.948-.368h-2.374v-8.847c0-2.233-1.244-3.872-3.562-3.872-2.205 0-3.816 1.639-3.816 3.815v8.904h-2.402V8.004h2.317v1.583c.99-1.215 2.488-1.95 4.24-1.95 3.562 0 5.597 2.544 5.597 6.162v8.762zm13.879-8.791c-.594-2.374-2.573-3.957-4.693-3.957-2.006 0-4.126 1.47-4.748 3.957h9.441zm2.317 4.269c-1.017 3.109-3.505 4.861-6.868 4.861-4.184 0-7.462-3.335-7.462-7.603 0-4.212 3.278-7.66 7.32-7.66 3.76 0 7.378 3.109 7.35 8.282h-12.24c.311 3.024 2.629 4.805 5.032 4.805 2.063 0 3.533-.99 4.324-2.685h2.544zm8.394 4.89c-3.533 0-6.106-1.894-6.501-4.975h2.431c.31 1.696 1.978 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.533-.509-5.682-1.357-5.682-4.098 0-2.092 1.809-4.325 5.71-4.325 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.345-3.505-2.345-1.922 0-3.307.904-3.307 2.035 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438 0 2.911-2.487 4.749-5.964 4.749zm13.652 0c-3.533 0-6.105-1.894-6.501-4.975h2.431c.311 1.696 1.979 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.395-1.78-3.957-2.261-3.533-.509-5.681-1.357-5.681-4.098 0-2.092 1.809-4.325 5.71-4.325 3.363 0 5.624 1.696 5.935 4.55h-2.43c-.34-1.554-1.725-2.345-3.505-2.345-1.923 0-3.308.904-3.308 2.035 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438-.001 2.911-2.487 4.749-5.964 4.749zM57.207 13.867c.352-1.804 2.105-3.233 4.21-3.233 1.83 0 3.207 1.329 3.207 3.233h-7.417zm10.9.45c0-3.909-2.73-6.665-6.54-6.665-4.86 0-8.118 3.534-8.118 8.57 0 3.932 2.756 6.664 6.64 6.664 3.533 0 6.163-1.703 7.24-4.435h-3.933c-.526.853-1.628 1.378-2.982 1.378-2.079 0-3.382-1.378-3.508-3.332H67.88a10.08 10.08 0 0 0 .227-2.18zm-25.204 8.219.701-3.758c2.156.425 2.48-.777 3.032-3.709l.275-1.453c.778-4.084 2.355-6.113 6.865-5.562l-.701 3.758c-2.156-.426-2.53 1.202-3.006 3.732l-.276 1.453c-.776 4.135-2.405 6.09-6.89 5.539z",fill:"#9fe870"})}))};LogoWiseBusinessInverse.defaultProps={width:"180",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWiseBusiness=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M119.48 8.004h-2.403v14.557h2.403V8.004zM37.642 22.561l2.655-14.557h3.508l-2.656 14.557h-3.507zM17.549 8.004h3.407l1.103 10.524 4.459-10.524H29.9l1.178 10.624 4.31-10.624h3.382l-6.164 14.557h-3.858L27.496 12.54l-4.26 10.021h-3.733L17.55 8.004zM2.574 8.004l2.27 3.86-4.043 3.865h6.877l.718-1.684h-3.48l2.177-2.177-1.269-2.18h5.905L6.283 22.562h2.045l6.164-14.557H2.574zM78.501 9.87c-2.685 0-4.946 2.43-4.946 5.455 0 2.968 2.261 5.399 4.946 5.399 2.714 0 4.862-2.431 4.862-5.399 0-3.024-2.148-5.455-4.862-5.455zm0 13.059c-2.148 0-4.013-1.216-5.03-2.714v2.346h-2.319V1.531h2.403v8.678c1.046-1.413 2.855-2.572 4.946-2.572 4.184 0 7.265 3.448 7.265 7.66s-3.081 7.632-7.265 7.632zm21.536-.368h-2.318v-1.583c-.989 1.188-2.459 1.922-4.24 1.922-3.56 0-5.596-2.544-5.596-6.133V8.004h2.374v8.876c0 2.318 1.272 3.844 3.59 3.844 2.148 0 3.788-1.611 3.788-3.788V8.004h2.402v14.557zm8.674.368c-3.534 0-6.106-1.894-6.502-4.975h2.431c.311 1.696 1.979 2.742 4.071 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.534-.509-5.682-1.357-5.682-4.099 0-2.091 1.809-4.324 5.71-4.324 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.346-3.505-2.346-1.922 0-3.307.905-3.307 2.036 0 1.045.82 1.413 3.674 1.865 3.223.509 5.88 1.13 5.88 4.438 0 2.911-2.488 4.749-5.964 4.749zm25.948-.368h-2.374v-8.847c0-2.233-1.244-3.873-3.562-3.873-2.205 0-3.816 1.64-3.816 3.816v8.904h-2.402V8.004h2.317v1.583c.99-1.215 2.488-1.95 4.24-1.95 3.562 0 5.597 2.544 5.597 6.162v8.762zm13.879-8.791c-.594-2.374-2.573-3.957-4.693-3.957-2.007 0-4.127 1.47-4.748 3.957h9.441zm2.317 4.269c-1.017 3.109-3.505 4.861-6.868 4.861-4.184 0-7.463-3.335-7.463-7.603 0-4.212 3.279-7.66 7.321-7.66 3.76 0 7.378 3.109 7.35 8.282h-12.24c.311 3.024 2.629 4.805 5.032 4.805 2.063 0 3.533-.99 4.324-2.685h2.544zm8.394 4.89c-3.533 0-6.106-1.894-6.501-4.975h2.431c.31 1.696 1.978 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.396-1.78-3.957-2.261-3.533-.509-5.682-1.357-5.682-4.099 0-2.091 1.809-4.324 5.71-4.324 3.364 0 5.625 1.696 5.936 4.55h-2.431c-.339-1.554-1.724-2.346-3.505-2.346-1.922 0-3.307.905-3.307 2.036 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438 0 2.911-2.487 4.749-5.964 4.749zm13.652 0c-3.533 0-6.105-1.894-6.501-4.975h2.431c.311 1.696 1.979 2.742 4.07 2.742 2.261 0 3.646-1.103 3.646-2.375 0-1.017-.395-1.78-3.957-2.261-3.533-.509-5.681-1.357-5.681-4.099 0-2.091 1.809-4.324 5.71-4.324 3.363 0 5.624 1.696 5.935 4.55h-2.43c-.34-1.554-1.725-2.346-3.505-2.346-1.923 0-3.308.905-3.308 2.036 0 1.045.82 1.413 3.675 1.865 3.222.509 5.879 1.13 5.879 4.438-.001 2.911-2.487 4.749-5.964 4.749zM57.207 13.867c.352-1.804 2.105-3.233 4.21-3.233 1.83 0 3.207 1.329 3.207 3.233h-7.417zm10.9.45c0-3.909-2.73-6.665-6.54-6.665-4.86 0-8.118 3.533-8.118 8.57 0 3.932 2.756 6.664 6.64 6.664 3.533 0 6.163-1.703 7.24-4.435h-3.933c-.526.852-1.628 1.378-2.982 1.378-2.079 0-3.382-1.378-3.508-3.332H67.88a10.08 10.08 0 0 0 .227-2.18zm-25.204 8.219.701-3.758c2.156.425 2.48-.777 3.032-3.709l.275-1.453c.778-4.084 2.355-6.114 6.865-5.562l-.701 3.758c-2.156-.426-2.53 1.202-3.006 3.732l-.276 1.453c-.776 4.135-2.405 6.09-6.89 5.539z",fill:"#163300"})}))};LogoWiseBusiness.defaultProps={width:"180",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWiseInverse=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M93.669 10.69c0-5.382-3.75-9.167-9.007-9.167-6.692 0-11.177 4.862-11.177 11.805 0 5.418 3.786 9.167 9.132 9.167 4.862 0 8.486-2.35 9.975-6.1h-5.4c-.718 1.167-2.243 1.902-4.108 1.902-2.871 0-4.665-1.902-4.827-4.593h15.107c.197-1.022.305-1.901.305-3.014zm-14.999-.628c.484-2.475 2.889-4.449 5.795-4.449 2.512 0 4.413 1.83 4.413 4.45H78.67zM58.971 22.01l.969-5.166c2.96.592 3.409-1.077 4.18-5.095l.377-1.992c1.076-5.615 3.247-8.414 9.455-7.66l-.97 5.167c-2.96-.592-3.48 1.65-4.143 5.13l-.377 1.992c-1.077 5.687-3.32 8.378-9.49 7.625zm-7.248.019 3.66-20.022h4.826l-3.642 20.022h-4.844zM24.076 2.007h4.683l1.525 14.478L36.42 2.007h4.646L42.7 16.629l5.92-14.622h4.665l-8.486 20.022h-5.31L37.765 8.25 31.9 22.03h-5.131L24.076 2.007zM6.584 7.317l-5.561 5.31h9.454l.987-2.313h-4.79L9.67 7.317 7.93 4.321h8.127l-7.5 17.708h2.817L19.86 2.007H3.463l3.121 5.31z",fill:"#9fe870"})}))};LogoWiseInverse.defaultProps={width:"95",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var LogoWise=function(a){return/*#__PURE__*/_jsx("svg",_objectSpread(_objectSpread({},a),{},{children:/*#__PURE__*/_jsx("path",{d:"M93.668 10.69c0-5.382-3.75-9.167-9.006-9.167-6.692 0-11.177 4.862-11.177 11.805 0 5.418 3.786 9.167 9.132 9.167 4.862 0 8.486-2.35 9.975-6.1h-5.4c-.718 1.167-2.243 1.902-4.109 1.902-2.87 0-4.664-1.902-4.826-4.593h15.106c.198-1.022.305-1.901.305-3.014zm-14.998-.628c.484-2.475 2.888-4.449 5.795-4.449 2.511 0 4.413 1.83 4.413 4.45H78.67zM58.971 22.01l.969-5.166c2.96.592 3.409-1.077 4.18-5.095l.377-1.992c1.076-5.615 3.247-8.414 9.455-7.66l-.97 5.167c-2.96-.592-3.48 1.65-4.143 5.13l-.377 1.992c-1.077 5.687-3.32 8.378-9.49 7.625zm-7.248.019 3.66-20.022h4.826l-3.642 20.022h-4.844zM24.076 2.007h4.683l1.525 14.478L36.42 2.007h4.646L42.7 16.629l5.92-14.622h4.665l-8.486 20.022h-5.31L37.764 8.25 31.9 22.03h-5.132l-2.69-20.022zM6.584 7.317l-5.561 5.31h9.454l.987-2.314h-4.79L9.67 7.317 7.93 4.321h8.127l-7.5 17.708h2.817L19.86 2.007H3.463l3.121 5.31z",fill:"#163300"})}))};LogoWise.defaultProps={width:"95",height:"24",fill:"none",xmlns:"http://www.w3.org/2000/svg"};var baseUrl="https://wise.com/public-resources/assets/logos/wise/",logoPaths={WISE:"brand_logo.svg",WISE_BUSINESS:"brand_logo_business.svg",WISE_INVERSE:"brand_logo_inverse.svg",WISE_BUSINESS_INVERSE:"brand_logo_business_inverse.svg",WISE_FLAG:"brand_flag.svg"},svgPaths={WISE:LogoWise,WISE_BUSINESS:LogoWiseBusiness,WISE_INVERSE:LogoWiseInverse,WISE_BUSINESS_INVERSE:LogoWiseBusinessInverse,WISE_FLAG:LogoFlag,WISE_FLAG_INVERSE:LogoFlagInverse},Logo=function(a){var b=a.className,c=a.inverse,d=a.type,e=useTheme(),f=e.isModern,g=useClientWidth({ref:isServerSide()?void 0:window}),h=_slicedToArray(g,1),i=h[0],j=i<Breakpoint.SMALL,k=j?logoPaths.WISE_FLAG:logoPaths["".concat(d).concat(c?"_INVERSE":"")],l=j?svgPaths["WISE_FLAG".concat(c?"_INVERSE":"")]:svgPaths["".concat(d).concat(c?"_INVERSE":"")];return f?/*#__PURE__*/_jsx(l,{className:"np-logo-svg"}):/*#__PURE__*/_jsx("img",{className:classNames("np-logo",b),alt:d===LogoType.WISE?"Wise":"Wise business",src:"".concat(baseUrl).concat(k)})};Logo.propTypes={/** Extra classes applied to Logo */className:PropTypes.string,/** If true, will use dark colours for dark on light theme */inverse:PropTypes.bool,/** What type of logo to display */type:PropTypes.oneOf(["WISE","WISE_BUSINESS"])},Logo.defaultProps={className:void 0,inverse:!1,type:LogoType.WISE};export default Logo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","id","disabled","className","avatar","secondary"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.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";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 Body from"../body/Body";import{Typography}from"../common";import RadioButton from"../common/RadioButton";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Radio=function(a){var b=a.label,c=a.id,d=a.disabled,e=a.className,f=a.avatar,g=a.secondary,h=_objectWithoutProperties(a,_excluded),i=useTheme(),j=i.isModern;return/*#__PURE__*/_jsx("div",{className:classNames("radio np-radio",{"radio-lg":g},e),children:/*#__PURE__*/_jsxs("label",{className:classNames({disabled:d}),htmlFor:c,children:[/*#__PURE__*/_jsx("span",{className:classNames(j?"
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","id","disabled","className","avatar","secondary"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.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";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 Body from"../body/Body";import{Typography}from"../common";import RadioButton from"../common/RadioButton";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Radio=function(a){var b=a.label,c=a.id,d=a.disabled,e=a.className,f=a.avatar,g=a.secondary,h=_objectWithoutProperties(a,_excluded),i=useTheme(),j=i.isModern;return/*#__PURE__*/_jsx("div",{className:classNames("radio np-radio",{"radio-lg":g,disabled:j&&d},e),children:/*#__PURE__*/_jsxs("label",{className:classNames({disabled:d}),htmlFor:c,children:[/*#__PURE__*/_jsx("span",{className:classNames(j?"m-r-2":"p-r-2","np-radio-button"),children:/*#__PURE__*/_jsx(RadioButton,_objectSpread({id:c,disabled:d},h))}),/*#__PURE__*/_jsxs(Body,{as:"span",type:g?Typography.BODY_LARGE_BOLD:Typography.BODY_DEFAULT,className:"np-radio__text",children:[b,g&&/*#__PURE__*/_jsx(Body,{as:"span",children:g})]}),f&&/*#__PURE__*/_jsx("span",{className:"np-radio__avatar m-l-auto",children:f})]})})};Radio.propTypes={avatar:PropTypes.element,checked:PropTypes.bool,disabled:PropTypes.bool,id:PropTypes.string,label:PropTypes.string.isRequired,name:PropTypes.string.isRequired,onChange:PropTypes.func.isRequired,secondary:PropTypes.string,value:PropTypes.oneOfType([PropTypes.number,PropTypes.string]),className:PropTypes.string},Radio.defaultProps={avatar:void 0,checked:!1,disabled:!1,id:null,secondary:null,value:"",className:void 0};export default Radio;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";var _statusLabels;import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import{CheckCircleFill as CheckCircleIcon,ClockFill as PendingCircleIcon}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement}from"react";import{useIntl}from"react-intl";import requiredIf from"react-required-if";import Body from"../body";import{Status,Size,Typography}from"../common";import Info from"../info";import Link from"../link/Link";import{deprecated}from"../utilities";import messages from"./Summary.messages";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var BadgeIcons={done:CheckCircleIcon,pending:PendingCircleIcon},statusLabels=(_statusLabels={},_defineProperty(_statusLabels,Status.NOT_DONE,"statusNotDone"),_defineProperty(_statusLabels,Status.DONE,"statusDone"),_defineProperty(_statusLabels,Status.PENDING,"statusPending"),_statusLabels),expiryDate=new Date("03-01-2021"),Summary=function(a){var b=a.action,c=a.as,d=a.className,e=a.content,f=a.description,g=void 0===f?e:f,h=a.help,i=a.icon,j=a.illustration,k=a.info,l=void 0===k?h:k,m=a.status,n=a.title,o=useTheme(),p=o.isModern,q=useIntl(),r=j;if(i){var s,t=null===i||void 0===i||null===(s=i.props)||void 0===s?void 0:s.size;r=24===t?i:/*#__PURE__*/cloneElement(i,{size:24})}var u=m&&BadgeIcons[m];return/*#__PURE__*/_jsxs(c,{className:classNames("np-summary d-flex align-items-start",d),"aria-label":m&&q.formatMessage(messages[statusLabels[m]]),children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__icon",children:[r,u
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";var _statusLabels,_statusMapping;import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import{CheckCircleFill as CheckCircleIcon,ClockFill as PendingCircleIcon}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement}from"react";import{useIntl}from"react-intl";import requiredIf from"react-required-if";import Body from"../body";import{Status,Size,Typography,Sentiment}from"../common";import Info from"../info";import Link from"../link/Link";import StatusIcon from"../statusIcon";import{deprecated}from"../utilities";import messages from"./Summary.messages";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var BadgeIcons={done:CheckCircleIcon,pending:PendingCircleIcon},statusLabels=(_statusLabels={},_defineProperty(_statusLabels,Status.NOT_DONE,"statusNotDone"),_defineProperty(_statusLabels,Status.DONE,"statusDone"),_defineProperty(_statusLabels,Status.PENDING,"statusPending"),_statusLabels),statusMapping=(_statusMapping={},_defineProperty(_statusMapping,Status.DONE,Sentiment.POSITIVE),_defineProperty(_statusMapping,Status.PENDING,Sentiment.PENDING),_statusMapping),expiryDate=new Date("03-01-2021"),Summary=function(a){var b=a.action,c=a.as,d=a.className,e=a.content,f=a.description,g=void 0===f?e:f,h=a.help,i=a.icon,j=a.illustration,k=a.info,l=void 0===k?h:k,m=a.status,n=a.title,o=useTheme(),p=o.isModern,q=useIntl(),r=j;if(i){var s,t=null===i||void 0===i||null===(s=i.props)||void 0===s?void 0:s.size;r=24===t?i:/*#__PURE__*/cloneElement(i,{size:24})}var u=m&&BadgeIcons[m];return/*#__PURE__*/_jsxs(c,{className:classNames("np-summary d-flex align-items-start",d),"aria-label":m&&q.formatMessage(messages[statusLabels[m]]),children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__icon",children:[r,u&&(p?/*#__PURE__*/_jsx(u,{size:16,className:"np-summary-icon__".concat(m)}):/*#__PURE__*/_jsx("div",{children:/*#__PURE__*/_jsx(StatusIcon,{size:Size.SMALL,sentiment:statusMapping[m]})}))]}),/*#__PURE__*/_jsxs("div",{className:"np-summary__body m-l-2",children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__title d-flex",children:[/*#__PURE__*/_jsx(Body,{as:"span",type:Typography.BODY_LARGE_BOLD,className:"text-primary m-b-1",children:n}),l&&/*#__PURE__*/_jsx(Info,{"aria-label":l["aria-label"],className:"m-l-1 hidden-xs",content:l.content,presentation:l.presentation,size:p?Size.LARGE:Size.SMALL,title:l.title,onClick:l.onClick})]}),g&&/*#__PURE__*/_jsx(Body,{as:"span",type:Typography.BODY_DEFAULT,className:"d-block np-summary__description",children:g}),b&&/*#__PURE__*/_jsx(Link,{href:b.href,target:b.target,className:"np-summary__action","aria-label":b["aria-label"],onClick:b.onClick,children:b.text})]}),l&&/*#__PURE__*/_jsx(Info,{"aria-label":l["aria-label"],className:"m-l-2 hidden-sm hidden-md hidden-lg hidden-xl",content:l.content,presentation:l.presentation,size:p?Size.LARGE:Size.SMALL,title:l.title,onClick:l.onClick})]})};Summary.propTypes={/** Action displayed at the bottom of the Summary */action:PropTypes.shape({text:PropTypes.node.isRequired,href:PropTypes.string.isRequired,"aria-label":PropTypes.string,target:PropTypes.string,onClick:PropTypes.func}),/** Decides which html element should wrap the Summary */as:PropTypes.string,/** Extra classes applied to Summary */className:PropTypes.string,/** @deprecated please use description instead */content:deprecated(PropTypes.node,{component:"Summary",newProp:"description",expiryDate:expiryDate}),/** Summary description */description:PropTypes.node,/** @deprecated please use info instead */help:deprecated(PropTypes.shape({content:PropTypes.node.isRequired,title:PropTypes.node}),{component:"Summary",newProp:"info",expiryDate:expiryDate}),/** Infos displayed on help Icon click inside Popover or Modal */info:PropTypes.shape({"aria-label":PropTypes.string.isRequired,content:PropTypes.node.isRequired,onClick:PropTypes.func,presentation:PropTypes.oneOf(["POPOVER","MODAL"]),title:PropTypes.node}),/** @deprecated please use icon instead */illustration:deprecated(PropTypes.node,{component:"Summary",newProp:"icon",expiryDate:expiryDate}),/** Main Summary Icon */icon:requiredIf(PropTypes.node,function(a){var b=a.illustration;return!b}),/** Decides the badge applied to Icon */status:PropTypes.oneOf(["notDone","done","pending"]),/** Summary title */title:PropTypes.node.isRequired},Summary.defaultProps={action:null,as:"div",className:null,content:null,help:null,illustration:null,status:null};export default Summary;
|
|
@@ -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";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.string.split.js";import"core-js/modules/es.string.trim.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";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.function.name.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}/* 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}),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:"input-group input-group-".concat(e),children:[f&&/*#__PURE__*/_jsx("span",{className:"input-group-addon",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";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.string.split.js";import"core-js/modules/es.string.trim.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";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.function.name.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}/* 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",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,4 +1,4 @@
|
|
|
1
|
-
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";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";var _UPLOAD_STEP_COMPONEN;import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import _regeneratorRuntime from"@babel/runtime/regenerator";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{Plus as PlusIcon}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import{injectIntl}from"react-intl";import{Status,Typography}from"../common";import Title from"../title";import messages from"./Upload.messages";import{UploadImageStep,MediaUploadStep,ProcessingStep,CompleteStep}from"./steps";import{UploadStep}from"./uploadSteps";import{postData,asyncFileRead,isSizeValid,isTypeValid,getFileType}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PROCESS_STATE=["error","success"],ANIMATION_FIX=10,MAX_SIZE_DEFAULT=5e6,UPLOAD_STEP_COMPONENTS=(_UPLOAD_STEP_COMPONEN={},_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.UPLOAD_IMAGE_STEP,UploadImageStep),_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.MEDIA_UPLOAD_STEP,MediaUploadStep),_UPLOAD_STEP_COMPONEN),Upload=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"onAnimationCompleted",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function b(a){var c,e,f,g,h,i,j;return _regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:c=d.state,e=c.response,f=c.isProcessing,g=c.fileName,h=d.props.animationDelay,f&&a===Status.SUCCEEDED&&(i=d.props.onSuccess,d.timeouts=setTimeout(function(){d.setState({isProcessing:!1,isComplete:!0},function(){return i?i(e,g):{}})},h)),f&&a===Status.FAILED&&(j=d.props.onFailure,d.timeouts=setTimeout(function(){d.setState({isProcessing:!1,isComplete:!0},function(){return j?j(e):{}})},h));case 4:case"end":return b.stop();}},b)}));return function(){return a.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(d),"asyncPost",function(a){var b=d.props,c=b.httpOptions,e=b.fetcher,f=c||{},g=f.fileInputName,h=void 0===g?a.name:g,i=f.data,j=void 0===i?{}:i,k=new FormData;return k.append(h,a),Object.keys(j).forEach(function(a){return k.append(a,j[a])}),postData(d.prepareHttpOptions(c),k,e)}),_defineProperty(_assertThisInitialized(d),"asyncResponse",function(a,b){d.timeouts=setTimeout(function(){d.setState({response:a,isError:b===PROCESS_STATE[0],isSuccess:b===PROCESS_STATE[1]})},ANIMATION_FIX)}),_defineProperty(_assertThisInitialized(d),"prepareHttpOptions",function(a){if(!a.url)throw new Error("You must supply a URL to post image data asynchronously");return a}),_defineProperty(_assertThisInitialized(d),"handleOnClear",function(a){a.preventDefault();var b=d.props.onCancel;b&&b(),d.reset()}),_defineProperty(_assertThisInitialized(d),"reset",function(){d.dragCounter=0,clearTimeout(d.timeouts),d.setState({isComplete:!1,isError:!1,isProcessing:!1,isSuccess:!1})}),_defineProperty(_assertThisInitialized(d),"showDataImage",function(a){var b=d.state.isImage;b&&d.setState({uploadedImage:a})}),_defineProperty(_assertThisInitialized(d),"fileDropped",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function b(a){var c,e,f,g,h,i,j,k,l,m;return _regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c=d.props,e=c.httpOptions,f=c.maxSize,g=c.onStart,h=c.usDisabled,i=c.usAccept,j=d.state.isProcessing,!(h||j)){b.next=4;break}return b.abrupt("return",!1);case 4:if(a){b.next=6;break}throw new Error("Could not retrieve file");case 6:return d.setState({fileName:a.name,isDroppable:!1,isProcessing:!0}),g&&g(a),k=null,b.prev=9,b.next=12,asyncFileRead(a);case 12:k=b.sent,b.next=18;break;case 15:b.prev=15,b.t0=b["catch"](9),d.asyncResponse(b.t0,PROCESS_STATE[0]);case 18:if(k){b.next=20;break}return b.abrupt("return",!1);case 20:if(d.setState({isImage:getFileType(a,k).includes("image")}),isTypeValid(a,i,k)){b.next=25;break}return l={status:415,statusText:"Unsupported Media Type"},d.asyncResponse(l,PROCESS_STATE[0]),b.abrupt("return",!1);case 25:if(isSizeValid(a,f)){b.next=29;break}return m={status:413,statusText:"Request Entity Too Large"},d.asyncResponse(m,PROCESS_STATE[0]),b.abrupt("return",!1);case 29:if(!e){b.next=33;break}return b.next=32,d.asyncPost(a).then(function(a){return d.asyncResponse(a,"success")}).then(function(){return d.showDataImage(k),!0}).catch(function(a){return d.asyncResponse(a,PROCESS_STATE[0]),!1});case 32:return b.abrupt("return",b.sent);case 33:return d.showDataImage(k),d.asyncResponse(k,"success"),b.abrupt("return",!0);case 36:case"end":return b.stop();}},b,null,[[9,15]])}));return function(){return a.apply(this,arguments)}}()),d.dragCounter=0,d.timeouts=null,d.state={fileName:"",isComplete:!1,isError:!1,isImage:!1,isProcessing:!1,isSuccess:!1,response:null,uploadedImage:null},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"getErrorMessage",value:function getErrorMessage(a){return 413===a?this.props.csTooLargeMessage||this.props.intl.formatMessage(messages.csTooLargeMessage):415===a?this.props.csWrongTypeMessage||this.props.intl.formatMessage(messages.csWrongTypeMessage):this.props.csFailureText||this.props.intl.formatMessage(messages.csFailureText)}},{key:"onDragLeave",value:function onDragLeave(a){a.preventDefault(),this.dragCounter-=1,0===this.dragCounter&&this.setState({isDroppable:!1})}},{key:"onDragEnter",value:function onDragEnter(a){a.preventDefault(),this.dragCounter+=1;var b=this.props.usDisabled,c=this.state.isProcessing;1!==this.dragCounter||b||c||this.setState({isDroppable:!0})}},{key:"onDrop",value:function onDrop(a){var b=this.state.isProcessing;a.preventDefault(),b||this.reset(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&this.fileDropped(a.dataTransfer.files[0])}},{key:"render",value:function render(){var a=this,b=this.props,c=b.usDropMessage,d=b.usAccept,e=b.usButtonText,f=b.usDisabled,g=b.usHelpImage,h=b.usLabel,i=b.usPlaceholder,j=b.psButtonText,k=b.psProcessingText,l=b.csButtonText,m=b.csSuccessText,n=b.size,o=b.uploadStep,p=b.intl,q=this.state,r=q.response,s=q.fileName,t=q.isComplete,u=q.isDroppable,v=q.isError,w=q.isImage,x=q.isProcessing,y=q.isSuccess,z=q.uploadedImage,A=UPLOAD_STEP_COMPONENTS[o]||UploadImageStep;return/*#__PURE__*/_jsxs("div",{className:classNames({droppable:!0,"tw-droppable-sm droppable-sm":"sm"===n,"tw-droppable-md droppable-md":"md"===n||!n,"tw-droppable-lg droppable-lg":"lg"===n,"droppable-dropping":u,"droppable-processing":x,"droppable-complete":t}),onDragEnter:function onDragEnter(b){return a.onDragEnter(b)},onDragLeave:function onDragLeave(b){return a.onDragLeave(b)},onDrop:function onDrop(b){return a.onDrop(b)},onDragOver:function onDragOver(a){return a.preventDefault()},children:[!x&&!t&&/*#__PURE__*/_jsx(A,{fileDropped:function fileDropped(b){return a.fileDropped(b)},isComplete:t,usAccept:d,usButtonText:e||p.formatMessage(messages.usButtonText),usDisabled:f,usHelpImage:g,usLabel:h,usPlaceholder:i||p.formatMessage(messages.usPlaceholder)}),x&&/*#__PURE__*/_jsx(ProcessingStep,{isComplete:t,isError:v,isSuccess:y,psButtonText:j||p.formatMessage(messages.psButtonText),psProcessingText:k||p.formatMessage(messages.psProcessingText),onAnimationCompleted:function onAnimationCompleted(b){return a.onAnimationCompleted(b)},onClear:function onClear(b){return a.handleOnClear(b)}}),(y||v||t)&&/*#__PURE__*/_jsx(CompleteStep,{fileName:s,isComplete:t,isError:v,isImage:w,csButtonText:l||p.formatMessage(messages.csButtonText),csFailureText:this.getErrorMessage(null===r||void 0===r?void 0:r.status),csSuccessText:m||p.formatMessage(messages.csSuccessText),uploadedImage:z,onClear:function onClear(b){return a.handleOnClear(b)}}),!x&&/*#__PURE__*/_jsx("div",{className:"droppable-dropping-card droppable-card",children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"circle circle-sm p-t-1 text-primary",children:/*#__PURE__*/_jsx(PlusIcon,{})}),/*#__PURE__*/_jsx(Title,{type:Typography.TITLE_BODY,className:"m-t-3",children:c||p.formatMessage(messages.usDropMessage)})]})})]})}}]),b}(Component);/*
|
|
1
|
+
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";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";var _UPLOAD_STEP_COMPONEN;import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import _regeneratorRuntime from"@babel/runtime/regenerator";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{Plus as PlusIcon}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import{injectIntl}from"react-intl";import{Status,Typography}from"../common";import Title from"../title";import messages from"./Upload.messages";import{UploadImageStep,MediaUploadStep,ProcessingStep,CompleteStep}from"./steps";import{UploadStep}from"./uploadSteps";import{postData,asyncFileRead,isSizeValid,isTypeValid,getFileType}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PROCESS_STATE=["error","success"],ANIMATION_FIX=10,MAX_SIZE_DEFAULT=5e6,UPLOAD_STEP_COMPONENTS=(_UPLOAD_STEP_COMPONEN={},_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.UPLOAD_IMAGE_STEP,UploadImageStep),_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.MEDIA_UPLOAD_STEP,MediaUploadStep),_UPLOAD_STEP_COMPONEN),Upload=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"onAnimationCompleted",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function b(a){var c,e,f,g,h,i,j;return _regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:c=d.state,e=c.response,f=c.isProcessing,g=c.fileName,h=d.props.animationDelay,f&&a===Status.SUCCEEDED&&(i=d.props.onSuccess,d.timeouts=setTimeout(function(){d.setState({isProcessing:!1,isComplete:!0},function(){return i?i(e,g):{}})},h)),f&&a===Status.FAILED&&(j=d.props.onFailure,d.timeouts=setTimeout(function(){d.setState({isProcessing:!1,isComplete:!0},function(){return j?j(e):{}})},h));case 4:case"end":return b.stop();}},b)}));return function(){return a.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(d),"asyncPost",function(a){var b=d.props,c=b.httpOptions,e=b.fetcher,f=c||{},g=f.fileInputName,h=void 0===g?a.name:g,i=f.data,j=void 0===i?{}:i,k=new FormData;return k.append(h,a),Object.keys(j).forEach(function(a){return k.append(a,j[a])}),postData(d.prepareHttpOptions(c),k,e)}),_defineProperty(_assertThisInitialized(d),"asyncResponse",function(a,b){d.timeouts=setTimeout(function(){d.setState({response:a,isError:b===PROCESS_STATE[0],isSuccess:b===PROCESS_STATE[1]})},ANIMATION_FIX)}),_defineProperty(_assertThisInitialized(d),"prepareHttpOptions",function(a){if(!a.url)throw new Error("You must supply a URL to post image data asynchronously");return a}),_defineProperty(_assertThisInitialized(d),"handleOnClear",function(a){a.preventDefault();var b=d.props.onCancel;b&&b(),d.reset()}),_defineProperty(_assertThisInitialized(d),"reset",function(){d.dragCounter=0,clearTimeout(d.timeouts),d.setState({isComplete:!1,isError:!1,isProcessing:!1,isSuccess:!1})}),_defineProperty(_assertThisInitialized(d),"showDataImage",function(a){var b=d.state.isImage;b&&d.setState({uploadedImage:a})}),_defineProperty(_assertThisInitialized(d),"fileDropped",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function b(a){var c,e,f,g,h,i,j,k,l,m;return _regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c=d.props,e=c.httpOptions,f=c.maxSize,g=c.onStart,h=c.usDisabled,i=c.usAccept,j=d.state.isProcessing,!(h||j)){b.next=4;break}return b.abrupt("return",!1);case 4:if(a){b.next=6;break}throw new Error("Could not retrieve file");case 6:return d.setState({fileName:a.name,isDroppable:!1,isProcessing:!0}),g&&g(a),k=null,b.prev=9,b.next=12,asyncFileRead(a);case 12:k=b.sent,b.next=18;break;case 15:b.prev=15,b.t0=b["catch"](9),d.asyncResponse(b.t0,PROCESS_STATE[0]);case 18:if(k){b.next=20;break}return b.abrupt("return",!1);case 20:if(d.setState({isImage:getFileType(a,k).includes("image")}),isTypeValid(a,i,k)){b.next=25;break}return l={status:415,statusText:"Unsupported Media Type"},d.asyncResponse(l,PROCESS_STATE[0]),b.abrupt("return",!1);case 25:if(isSizeValid(a,f)){b.next=29;break}return m={status:413,statusText:"Request Entity Too Large"},d.asyncResponse(m,PROCESS_STATE[0]),b.abrupt("return",!1);case 29:if(!e){b.next=33;break}return b.next=32,d.asyncPost(a).then(function(a){return d.asyncResponse(a,"success")}).then(function(){return d.showDataImage(k),!0}).catch(function(a){return d.asyncResponse(a,PROCESS_STATE[0]),!1});case 32:return b.abrupt("return",b.sent);case 33:return d.showDataImage(k),d.asyncResponse(k,"success"),b.abrupt("return",!0);case 36:case"end":return b.stop();}},b,null,[[9,15]])}));return function(){return a.apply(this,arguments)}}()),d.dragCounter=0,d.timeouts=null,d.state={fileName:"",isComplete:!1,isError:!1,isImage:!1,isProcessing:!1,isSuccess:!1,response:null,uploadedImage:null},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"getErrorMessage",value:function getErrorMessage(a){return 413===a?this.props.csTooLargeMessage||this.props.intl.formatMessage(messages.csTooLargeMessage):415===a?this.props.csWrongTypeMessage||this.props.intl.formatMessage(messages.csWrongTypeMessage):this.props.csFailureText||this.props.intl.formatMessage(messages.csFailureText)}},{key:"onDragLeave",value:function onDragLeave(a){a.preventDefault(),this.dragCounter-=1,0===this.dragCounter&&this.setState({isDroppable:!1})}},{key:"onDragEnter",value:function onDragEnter(a){a.preventDefault(),this.dragCounter+=1;var b=this.props.usDisabled,c=this.state.isProcessing;1!==this.dragCounter||b||c||this.setState({isDroppable:!0})}},{key:"onDrop",value:function onDrop(a){var b=this.state.isProcessing;a.preventDefault(),b||this.reset(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&this.fileDropped(a.dataTransfer.files[0])}},{key:"render",value:function render(){var a=this,b=this.props,c=b.usDropMessage,d=b.usAccept,e=b.usButtonText,f=b.usDisabled,g=b.usHelpImage,h=b.usLabel,i=b.usPlaceholder,j=b.psButtonText,k=b.psProcessingText,l=b.csButtonText,m=b.csSuccessText,n=b.size,o=b.uploadStep,p=b.intl,q=this.state,r=q.response,s=q.fileName,t=q.isComplete,u=q.isDroppable,v=q.isError,w=q.isImage,x=q.isProcessing,y=q.isSuccess,z=q.uploadedImage,A=UPLOAD_STEP_COMPONENTS[o]||UploadImageStep;return/*#__PURE__*/_jsxs("div",{className:classNames("droppable-area",{droppable:!0,"tw-droppable-sm droppable-sm":"sm"===n,"tw-droppable-md droppable-md":"md"===n||!n,"tw-droppable-lg droppable-lg":"lg"===n,"droppable-dropping":u,"droppable-processing":x,"droppable-complete":t,"droppable-negative":v}),onDragEnter:function onDragEnter(b){return a.onDragEnter(b)},onDragLeave:function onDragLeave(b){return a.onDragLeave(b)},onDrop:function onDrop(b){return a.onDrop(b)},onDragOver:function onDragOver(a){return a.preventDefault()},children:[!x&&!t&&/*#__PURE__*/_jsx(A,{fileDropped:function fileDropped(b){return a.fileDropped(b)},isComplete:t,usAccept:d,usButtonText:e||p.formatMessage(messages.usButtonText),usDisabled:f,usHelpImage:g,usLabel:h,usPlaceholder:i||p.formatMessage(messages.usPlaceholder)}),x&&/*#__PURE__*/_jsx(ProcessingStep,{isComplete:t,isError:v,isSuccess:y,psButtonText:j||p.formatMessage(messages.psButtonText),psProcessingText:k||p.formatMessage(messages.psProcessingText),onAnimationCompleted:function onAnimationCompleted(b){return a.onAnimationCompleted(b)},onClear:function onClear(b){return a.handleOnClear(b)}}),(y||v||t)&&/*#__PURE__*/_jsx(CompleteStep,{fileName:s,isComplete:t,isError:v,isImage:w,csButtonText:l||p.formatMessage(messages.csButtonText),csFailureText:this.getErrorMessage(null===r||void 0===r?void 0:r.status),csSuccessText:m||p.formatMessage(messages.csSuccessText),uploadedImage:z,onClear:function onClear(b){return a.handleOnClear(b)}}),!x&&/*#__PURE__*/_jsx("div",{className:"droppable-dropping-card droppable-card",children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"circle circle-sm p-t-1 text-primary",children:/*#__PURE__*/_jsx(PlusIcon,{size:"16"})}),/*#__PURE__*/_jsx(Title,{type:Typography.TITLE_BODY,className:"m-t-3",children:c||p.formatMessage(messages.usDropMessage)})]})})]})}}]),b}(Component);/*
|
|
2
2
|
* This delay is required for the isError/isSuccess to be fired after isProcessing so the processIndicator, will be
|
|
3
3
|
* rendered first and then updated with the right status.
|
|
4
4
|
*/Upload.propTypes={animationDelay:PropTypes.number,csButtonText:PropTypes.string,csFailureText:PropTypes.string,csSuccessText:PropTypes.string,csTooLargeMessage:PropTypes.string,csWrongTypeMessage:PropTypes.string,httpOptions:PropTypes.shape({url:PropTypes.string.isRequired,method:PropTypes.oneOf(["POST","PUT","PATCH"]),fileInputName:PropTypes.string,data:PropTypes.object,headers:PropTypes.object}),/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AlertCircle as AlertCircleIcon,Document as DocumentIcon}from"@transferwise/icons";import PropTypes from"prop-types";import{Priority,Typography}from"../../..";import Body from"../../../body";import Button from"../../../button";import Title from"../../../title";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var CompleteStep=function(a){var b=a.csButtonText,
|
|
1
|
+
import{AlertCircle as AlertCircleIcon,Document as DocumentIcon}from"@transferwise/icons";import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import{Priority,Typography}from"../../..";import Body from"../../../body";import Button from"../../../button";import{Sentiment,Size}from"../../../common";import StatusIcon from"../../../statusIcon";import Title from"../../../title";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var CompleteStep=function(a){var b=useTheme(),c=b.isModern,d=a.csButtonText,e=a.csFailureText,f=a.csSuccessText,g=a.fileName,h=a.isComplete,i=a.isError,j=a.isImage,k=a.onClear,l=a.uploadedImage;return/*#__PURE__*/_jsx("div",{className:"droppable-complete-card droppable-card","aria-hidden":!h,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"droppable-card-content d-flex flex-column align-items-center",children:i?/*#__PURE__*/_jsxs(_Fragment,{children:[c?/*#__PURE__*/_jsx(StatusIcon,{size:Size.LARGE,sentiment:Sentiment.NEGATIVE}):/*#__PURE__*/_jsx(AlertCircleIcon,{size:24,className:"text-negative"}),e&&/*#__PURE__*/_jsx("p",{className:classNames("m-t-2",{"m-b-0":c}),children:e})]}):/*#__PURE__*/_jsxs(_Fragment,{children:[j&&l?/*#__PURE__*/_jsx("img",{src:l,alt:"OK",className:"thumbnail "}):/*#__PURE__*/_jsx(DocumentIcon,{}),g&&/*#__PURE__*/_jsx(Body,{as:"p",className:"m-b-0",children:g}),f&&/*#__PURE__*/_jsx(Title,{className:"caption m-t-1",type:Typography.TITLE_BODY,children:f})]})}),d&&/*#__PURE__*/_jsx(Button,{priority:c?Priority.PRIMARY:Priority.SECONDARY,className:classNames({"m-t-1":c&&!i,"m-t-2":c&&i,"m-t-3":!c}),onClick:function onClick(a){return k(a)},children:d})]})})};CompleteStep.propTypes={csButtonText:PropTypes.string.isRequired,csSuccessText:PropTypes.string.isRequired,csFailureText:PropTypes.string.isRequired,fileName:PropTypes.string.isRequired,isComplete:PropTypes.bool.isRequired,isError:PropTypes.bool.isRequired,isImage:PropTypes.bool.isRequired,onClear:PropTypes.func.isRequired,uploadedImage:PropTypes.string},CompleteStep.defaultProps={uploadedImage:null};export default CompleteStep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import PropTypes from"prop-types";import Button from"../../../button";import{Status,Size,Typography}from"../../../common";import ProcessIndicator from"../../../processIndicator";import Title from"../../../title";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var ProcessingStep=function(a){var b=a.isComplete,c=a.isError,d=a.isSuccess,e=a.onAnimationCompleted,f=a.onClear,g=a.psButtonText,h=a.psProcessingText,i=Status.PROCESSING;return c&&(
|
|
1
|
+
import{useTheme}from"@wise/components-theming";import classNames from"classnames";import PropTypes from"prop-types";import Button from"../../../button";import{Status,Size,Typography}from"../../../common";import ProcessIndicator from"../../../processIndicator";import Title from"../../../title";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var ProcessingStep=function(a){var b=a.isComplete,c=a.isError,d=a.isSuccess,e=a.onAnimationCompleted,f=a.onClear,g=a.psButtonText,h=a.psProcessingText,i=useTheme(),j=i.isModern,k=Status.PROCESSING;return c&&(k=Status.FAILED),d&&(k=Status.SUCCEEDED),/*#__PURE__*/_jsx("div",{className:"droppable-processing-card droppable-card","aria-hidden":b,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.Small,status:k,onAnimationCompleted:function onAnimationCompleted(a){return e(a)}}),/*#__PURE__*/_jsx(Title,{className:classNames({"m-t-3":!j,"m-b-3":!j,"m-t-2":j,"m-b-2":j}),type:Typography.TITLE_BODY,children:h}),g&&/*#__PURE__*/_jsx(Button,{onClick:function onClick(a){return f(a)},children:g})]})})};ProcessingStep.propTypes={isComplete:PropTypes.bool.isRequired,isError:PropTypes.bool.isRequired,isSuccess:PropTypes.bool.isRequired,onAnimationCompleted:PropTypes.func.isRequired,onClear:PropTypes.func.isRequired,psButtonText:PropTypes.string.isRequired,psProcessingText:PropTypes.string.isRequired};export default ProcessingStep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.construct.js";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{Upload as UploadIcon}from"@transferwise/icons";import PropTypes from"prop-types";import{createRef,PureComponent}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var UploadImageStep=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"onManualUpload",function(){var b=a.props.fileDropped;if(a.uploadInputRef&&a.uploadInputRef.current){var c=a.uploadInputRef.current.files[0];b(c)}}),_defineProperty(_assertThisInitialized(a),"getImage",function(){var b=a.props,c=b.usHelpImage,d=b.usLabel;return c?"string"==typeof c?/*#__PURE__*/_jsx("img",{src:c,alt:d,className:"thumbnail text-xs-center"}):c:/*#__PURE__*/_jsx("div",{className:"circle circle-sm circle-inverse p-t-1",children:/*#__PURE__*/_jsx(UploadIcon,{size:24})})}),a.uploadInputRef=/*#__PURE__*/createRef(),a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"render",value:function render(){var a=this,b=this.props,c=b.isComplete,d=b.usAccept,e=b.usButtonText,f=b.usDisabled,g=b.usLabel,h=b.usPlaceholder;return/*#__PURE__*/_jsx("div",{children:/*#__PURE__*/_jsx("div",{className:"droppable-default-card","aria-hidden":c,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"m-b-3",children:this.getImage()}),g&&/*#__PURE__*/_jsx("h4",{className:"np-text-title-body m-b-1",children:g}),h&&/*#__PURE__*/_jsx("p",{className:"
|
|
1
|
+
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.construct.js";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{Upload as UploadIcon}from"@transferwise/icons";import PropTypes from"prop-types";import{createRef,PureComponent}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var UploadImageStep=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"onManualUpload",function(){var b=a.props.fileDropped;if(a.uploadInputRef&&a.uploadInputRef.current){var c=a.uploadInputRef.current.files[0];b(c)}}),_defineProperty(_assertThisInitialized(a),"getImage",function(){var b=a.props,c=b.usHelpImage,d=b.usLabel;return c?"string"==typeof c?/*#__PURE__*/_jsx("img",{src:c,alt:d,className:"thumbnail text-xs-center"}):c:/*#__PURE__*/_jsx("div",{className:"circle circle-sm circle-inverse p-t-1",children:/*#__PURE__*/_jsx(UploadIcon,{size:24})})}),a.uploadInputRef=/*#__PURE__*/createRef(),a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"render",value:function render(){var a=this,b=this.props,c=b.isComplete,d=b.usAccept,e=b.usButtonText,f=b.usDisabled,g=b.usLabel,h=b.usPlaceholder;return/*#__PURE__*/_jsx("div",{children:/*#__PURE__*/_jsx("div",{className:"droppable-default-card","aria-hidden":c,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"m-b-3",children:this.getImage()}),g&&/*#__PURE__*/_jsx("h4",{className:"np-text-title-body m-b-1",children:g}),h&&/*#__PURE__*/_jsx("p",{className:"np-text-body-large m-b-3",children:"".concat(h)}),/*#__PURE__*/_jsxs("label",{className:"btn btn-primary btn-md ".concat(f?"disabled":""),children:[e?/*#__PURE__*/_jsx("span",{children:e}):/*#__PURE__*/_jsx(UploadIcon,{size:24,className:"m-r-0"}),/*#__PURE__*/_jsx("input",{ref:this.uploadInputRef,type:"file",accept:"*"===d?null:d,className:"tw-droppable-input hidden",disabled:f,name:"file-upload",onChange:function onChange(){return a.onManualUpload()}})]})]})})})}}]),b}(PureComponent);UploadImageStep.propTypes={fileDropped:PropTypes.func.isRequired,isComplete:PropTypes.bool.isRequired,usAccept:PropTypes.string.isRequired,usButtonText:PropTypes.string.isRequired,usDisabled:PropTypes.bool.isRequired,usHelpImage:PropTypes.node.isRequired,usLabel:PropTypes.string.isRequired,usPlaceholder:PropTypes.string.isRequired};export default UploadImageStep;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.set.js";import"core-js/modules/es.string.iterator.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.join.js";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),children:[S.map(function(a){return/*#__PURE__*/_jsx(UploadItem,{file:a,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
|
|
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,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&&(e()||l),multiple:n,fileTypes:p,sizeLimit:r,description:s,maxFiles:y,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
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
5
|
if(!isTypeValid(d,h))return c(d,O(MESSAGES.fileTypeNotSupported)),"continue";// Check if the filesize is valid
|
|
6
6
|
// Convert to rough bytes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _typeof from"@babel/runtime/helpers/typeof";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import{AlertCircle,CrossCircleFill}from"@transferwise/icons";import classNames from"classnames";import{useIntl}from"react-intl";import Body from"../../body";import{Size,Status,Typography}from"../../common";import ProcessIndicator from"../../processIndicator/ProcessIndicator";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=useIntl(),g=f.formatMessage,h=b.status,i=b.filename,j=b.error,k=b.url,l=[Status.SUCCEEDED,void 0].includes(h)&&!!k,
|
|
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 i||g(MESSAGES.uploadedFile)}()}),function getDescription(){if(j||h===Status.FAILED)return/*#__PURE__*/_jsx(Body,{type:Typography.BODY_DEFAULT_BOLD,className:"text-negative",children:
|
|
1
|
+
import _typeof from"@babel/runtime/helpers/typeof";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";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=useIntl(),g=f.formatMessage,h=b.status,i=b.filename,j=b.error,k=b.url,l=useTheme(),m=l.isModern,n=[Status.SUCCEEDED,void 0].includes(h)&&!!k,o=function(){return"object"===_typeof(j)&&j.message||j||g(MESSAGES.uploadingFailed)};return/*#__PURE__*/_jsx("div",{className:classNames("np-upload-item",{"np-upload-item__link":n}),"data-testid":TEST_IDS.uploadItem,children:/*#__PURE__*/_jsxs("div",{className:"np-upload-item__body",children:[/*#__PURE__*/_jsx(UploadItemBody,{url:n?k:void 0,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(j||h===Status.FAILED)return m?/*#__PURE__*/_jsx(StatusIcon,{size:Size.SMALL,sentiment:Sentiment.NEGATIVE}):/*#__PURE__*/_jsx(AlertCircle,{size:24,className:"text-negative"});var a;switch(h){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=m?/*#__PURE__*/_jsx(StatusIcon,{size:Size.SMALL,sentiment:Sentiment.POSITIVE}):/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.EXTRA_SMALL,status:Status.SUCCEEDED});}return m?a:/*#__PURE__*/_jsx("span",{style:{transform:"scale(0.8335)"},children:a});// Scale down ProcessIndicator to be 20px*20px to match `icons`
|
|
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 i||g(MESSAGES.uploadedFile)}()}),function getDescription(){if(j||h===Status.FAILED)return/*#__PURE__*/_jsx(Body,{type:Typography.BODY_DEFAULT_BOLD,className:"text-negative",children:o()});switch(h){case Status.PENDING:return/*#__PURE__*/_jsx(Body,{type:Typography.BODY_DEFAULT_BOLD,children:g(MESSAGES.uploading)});case Status.PROCESSING:return/*#__PURE__*/_jsx(Body,{children:g(MESSAGES.deleting)});case Status.SUCCEEDED:case Status.DONE:default:return/*#__PURE__*/_jsx(Body,{type:Typography.BODY_DEFAULT_BOLD,className:"text-positive",children:g(MESSAGES.uploaded)});}}()]})]})})}),c&&/*#__PURE__*/_jsx("button",{"aria-label":g(MESSAGES.removeFile,{filename:i}),className:"btn np-upload-item__remove-button media-left",type:"button",onClick:function onClick(){return d()},children:/*#__PURE__*/_jsx(CrossCircleFill,{size:16})})]})})};export default UploadItem;
|