@transferwise/components 39.14.0 → 40.1.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/CHANGELOG.md CHANGED
@@ -3,6 +3,43 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [40.1.1](https://github.com/transferwise/neptune-web/compare/@transferwise/components@40.1.0...@transferwise/components@40.1.1) (2022-03-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **UploadInput:** passed `id` to the label over the input button ([#1354](https://github.com/transferwise/neptune-web/issues/1354)) ([2cdeb45](https://github.com/transferwise/neptune-web/commit/2cdeb454c1b4924fd42a686c0e2bdb4a905bbfd1))
12
+
13
+
14
+
15
+
16
+
17
+ # [40.1.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@40.0.0...@transferwise/components@40.1.0) (2022-03-09)
18
+
19
+
20
+ ### Features
21
+
22
+ * integrate ActionButton side ActionOption instead of link ([#1351](https://github.com/transferwise/neptune-web/issues/1351)) ([b2e0e01](https://github.com/transferwise/neptune-web/commit/b2e0e010c7695f3225fbfb3d3fb7b91faae4401a))
23
+
24
+
25
+
26
+
27
+
28
+ # [40.0.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@39.14.0...@transferwise/components@40.0.0) (2022-03-09)
29
+
30
+
31
+ * feat!: TypeScript setup and types generation for `@transferwise/dynamic-flows` (#1346) ([23496bf](https://github.com/transferwise/neptune-web/commit/23496bfb68c3381ee0a70f49198ec851c71b25ff)), closes [#1346](https://github.com/transferwise/neptune-web/issues/1346)
32
+
33
+
34
+ ### BREAKING CHANGES
35
+
36
+ * fix import of translations (`import { translations } from '@transferwise/dynamic-flows';`)
37
+ remove custom types or mock from `global.d.ts` / `declarations.d.ts` files
38
+
39
+
40
+
41
+
42
+
6
43
  # [39.14.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@39.13.0...@transferwise/components@39.14.0) (2022-03-07)
7
44
 
8
45
 
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import classNames from"classnames";import Button from"../button";import{ControlType,Priority,Size}from"../common";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";var ActionOption=function(a){var b=a.action,c=a.disabled,d=a.onClick,e=a.media,f=a.title,g=a.content,h=a.complex,i=a.className,j=a.showMediaAtAllSizes,k={media:e,title:f,content:g,complex:h,disabled:c,showMediaAtAllSizes:j,className:classNames("tw-action-option",i)};return/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},k),{},{button:/*#__PURE__*/_jsx(Button,{className:"p-x-0","aria-label":function getAriaLabel(){var a=[];return"string"==typeof f&&a.push(f),"string"==typeof b&&a.push(b),a.join(", ")||void 0}(),type:ControlType.ACCENT,priority:Priority.TERTIARY,size:Size.SMALL,disabled:c,onClick:d,children:b})}))};export default ActionOption;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import classNames from"classnames";import ActionButton from"../actionButton";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";var ActionOption=function(a){var b=a.action,c=a.disabled,d=a.onClick,e=a.media,f=a.title,g=a.content,h=a.complex,i=a.className,j=a.showMediaAtAllSizes,k={media:e,title:f,content:g,complex:h,disabled:c,showMediaAtAllSizes:j,className:classNames("tw-action-option",i)};return/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},k),{},{button:/*#__PURE__*/_jsx(ActionButton,{disabled:c,"aria-label":function getAriaLabel(){var a=[];return"string"==typeof f&&a.push(f),"string"==typeof b&&a.push(b),a.join(", ")||void 0}(),text:b,onClick:d})}))};export default ActionOption;
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{PlusCircle as PlusIcon,Upload as UploadIcon}from"@transferwise/icons";import classNames from"classnames";import{useRef,useState}from"react";import{useIntl}from"react-intl";import{useDirection}from"../../common/hooks";import MESSAGES from"./UploadButton.messages";import{DEFAULT_SIZE_LIMIT,imageFileTypes}from"./defaults";import getAllowedFileTypes from"./getAllowedFileTypes";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS;(function(a){a.uploadInput="uploadInput",a.mediaBody="mediaBody"})(TEST_IDS||(TEST_IDS={}));var onDragOver=function(a){a.preventDefault()},DEFAULT_FILE_INPUT_ID="np-upload-button",UploadButton=function(a){function b(){if(e)return e;var a=z(),b="*"===a?r(MESSAGES.allFileTypes):a;return r(MESSAGES.instructions,{fileTypes:b,size:Math.round(i/1e3)})}var c=a.disabled,d=a.multiple,e=a.description,f=a.fileTypes,g=void 0===f?imageFileTypes:f,h=a.sizeLimit,i=void 0===h?DEFAULT_SIZE_LIMIT:h,j=a.maxFiles,k=a.onChange,l=a.id,m=void 0===l?DEFAULT_FILE_INPUT_ID:l,n=a.uploadButtonTitle,o=useDirection(),p=o.isRTL,q=useIntl(),r=q.formatMessage,s=useRef(null),t=useState(!1),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useRef(0),y=function(){x.current=0,w(!1)},z=function(){return"*"===g?g:Array.isArray(g)?getAllowedFileTypes(g).join(", "):getAllowedFileTypes([g]).join(", ")};return/*#__PURE__*/_jsxs("div",_objectSpread(_objectSpread({className:classNames("np-upload-button-container","droppable",{"droppable-dropping":v})},!c&&{onDragEnter:function onDragEnter(a){a.preventDefault(),x.current+=1,1===x.current&&w(!0)},onDragLeave:function onDragLeave(a){a.preventDefault(),x.current-=1,0===x.current&&w(!1)},onDrop:function onDrop(a){a.preventDefault(),y(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&k(a.dataTransfer.files)},onDragOver:onDragOver}),{},{children:[/*#__PURE__*/_jsx("input",_objectSpread(_objectSpread(_objectSpread({ref:s,id:m,type:"file"},function(){var a="*"===z();return a?null:Array.isArray(g)?{accept:g.join(",")}:{accept:g}}()),d&&{multiple:!0}),{},{className:"tw-droppable-input",disabled:c,name:"file-upload","data-testid":TEST_IDS.uploadInput,onChange:function filesSelected(a){var b=a.target.files;b&&(k(b),s.current&&(s.current.value=""))}})),/*#__PURE__*/_jsx("label",{htmlFor:"np-upload-button",className:classNames("btn","np-upload-accent","np-upload-button",{disabled:c}),children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:/*#__PURE__*/_jsx(UploadIcon,{size:24,className:"text-link"})}),/*#__PURE__*/_jsxs("div",{className:"media-body text-xs-left","data-testid":TEST_IDS.mediaBody,children:[/*#__PURE__*/_jsx("div",{children:function(){return n?n:r(d?MESSAGES.uploadFiles:MESSAGES.uploadFile)}()}),function(){return/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsxs("small",{className:classNames("np-upload-description",{"text-primary":!c}),children:[b(),j&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("br",{}),"Maximum ".concat(j," files.")]})]})})}()]})]})}),v&&/*#__PURE__*/_jsxs("div",{className:"droppable-card droppable-dropping-card droppable-card-content",children:[/*#__PURE__*/_jsx(PlusIcon,{filled:!0,size:24,className:"text-info m-x-1"}),/*#__PURE__*/_jsx("div",{className:"text-info",children:r(MESSAGES.dropFile)})]})]}))};export default UploadButton;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{PlusCircle as PlusIcon,Upload as UploadIcon}from"@transferwise/icons";import classNames from"classnames";import{useRef,useState}from"react";import{useIntl}from"react-intl";import{useDirection}from"../../common/hooks";import MESSAGES from"./UploadButton.messages";import{DEFAULT_SIZE_LIMIT,imageFileTypes}from"./defaults";import getAllowedFileTypes from"./getAllowedFileTypes";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS;(function(a){a.uploadInput="uploadInput",a.mediaBody="mediaBody"})(TEST_IDS||(TEST_IDS={}));var onDragOver=function(a){a.preventDefault()},DEFAULT_FILE_INPUT_ID="np-upload-button",UploadButton=function(a){function b(){if(e)return e;var a=z(),b="*"===a?r(MESSAGES.allFileTypes):a;return r(MESSAGES.instructions,{fileTypes:b,size:Math.round(i/1e3)})}var c=a.disabled,d=a.multiple,e=a.description,f=a.fileTypes,g=void 0===f?imageFileTypes:f,h=a.sizeLimit,i=void 0===h?DEFAULT_SIZE_LIMIT:h,j=a.maxFiles,k=a.onChange,l=a.id,m=void 0===l?DEFAULT_FILE_INPUT_ID:l,n=a.uploadButtonTitle,o=useDirection(),p=o.isRTL,q=useIntl(),r=q.formatMessage,s=useRef(null),t=useState(!1),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useRef(0),y=function(){x.current=0,w(!1)},z=function(){return"*"===g?g:Array.isArray(g)?getAllowedFileTypes(g).join(", "):getAllowedFileTypes([g]).join(", ")};return/*#__PURE__*/_jsxs("div",_objectSpread(_objectSpread({className:classNames("np-upload-button-container","droppable",{"droppable-dropping":v})},!c&&{onDragEnter:function onDragEnter(a){a.preventDefault(),x.current+=1,1===x.current&&w(!0)},onDragLeave:function onDragLeave(a){a.preventDefault(),x.current-=1,0===x.current&&w(!1)},onDrop:function onDrop(a){a.preventDefault(),y(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&k(a.dataTransfer.files)},onDragOver:onDragOver}),{},{children:[/*#__PURE__*/_jsx("input",_objectSpread(_objectSpread(_objectSpread({ref:s,id:m,type:"file"},function(){var a="*"===z();return a?null:Array.isArray(g)?{accept:g.join(",")}:{accept:g}}()),d&&{multiple:!0}),{},{className:"tw-droppable-input",disabled:c,name:"file-upload","data-testid":TEST_IDS.uploadInput,onChange:function filesSelected(a){var b=a.target.files;b&&(k(b),s.current&&(s.current.value=""))}})),/*#__PURE__*/_jsx("label",{htmlFor:m,className:classNames("btn","np-upload-accent","np-upload-button",{disabled:c}),children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:/*#__PURE__*/_jsx(UploadIcon,{size:24,className:"text-link"})}),/*#__PURE__*/_jsxs("div",{className:"media-body text-xs-left","data-testid":TEST_IDS.mediaBody,children:[/*#__PURE__*/_jsx("div",{children:function(){return n?n:r(d?MESSAGES.uploadFiles:MESSAGES.uploadFile)}()}),function(){return/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsxs("small",{className:classNames("np-upload-description",{"text-primary":!c}),children:[b(),j&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("br",{}),"Maximum ".concat(j," files.")]})]})})}()]})]})}),v&&/*#__PURE__*/_jsxs("div",{className:"droppable-card droppable-dropping-card droppable-card-content",children:[/*#__PURE__*/_jsx(PlusIcon,{filled:!0,size:24,className:"text-info m-x-1"}),/*#__PURE__*/_jsx("div",{className:"text-info",children:r(MESSAGES.dropFile)})]})]}))};export default UploadButton;
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.array.join.js";import classNames from"classnames";import Button from"../button";import{ControlType,Priority,Size}from"../common";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";var ActionOption=function(a){var b=a.action,c=a.disabled,d=a.onClick,e=a.media,f=a.title,g=a.content,h=a.complex,i=a.className,j=a.showMediaAtAllSizes,k={media:e,title:f,content:g,complex:h,disabled:c,showMediaAtAllSizes:j,className:classNames("tw-action-option",i)};return/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},k),{},{button:/*#__PURE__*/_jsx(Button,{className:"p-x-0","aria-label":function getAriaLabel(){var a=[];return"string"==typeof f&&a.push(f),"string"==typeof b&&a.push(b),a.join(", ")||void 0}(),type:ControlType.ACCENT,priority:Priority.TERTIARY,size:Size.SMALL,disabled:c,onClick:d,children:b})}))};export default ActionOption;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.array.join.js";import classNames from"classnames";import ActionButton from"../actionButton";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";var ActionOption=function(a){var b=a.action,c=a.disabled,d=a.onClick,e=a.media,f=a.title,g=a.content,h=a.complex,i=a.className,j=a.showMediaAtAllSizes,k={media:e,title:f,content:g,complex:h,disabled:c,showMediaAtAllSizes:j,className:classNames("tw-action-option",i)};return/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},k),{},{button:/*#__PURE__*/_jsx(ActionButton,{disabled:c,"aria-label":function getAriaLabel(){var a=[];return"string"==typeof f&&a.push(f),"string"==typeof b&&a.push(b),a.join(", ")||void 0}(),text:b,onClick:d})}))};export default ActionOption;
@@ -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.symbol.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import{PlusCircle as PlusIcon,Upload as UploadIcon}from"@transferwise/icons";import classNames from"classnames";import{useRef,useState}from"react";import{useIntl}from"react-intl";import{useDirection}from"../../common/hooks";import MESSAGES from"./UploadButton.messages";import{DEFAULT_SIZE_LIMIT,imageFileTypes}from"./defaults";import getAllowedFileTypes from"./getAllowedFileTypes";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS;(function(a){a.uploadInput="uploadInput",a.mediaBody="mediaBody"})(TEST_IDS||(TEST_IDS={}));var onDragOver=function(a){a.preventDefault()},DEFAULT_FILE_INPUT_ID="np-upload-button",UploadButton=function(a){function b(){if(e)return e;var a=z(),b="*"===a?r(MESSAGES.allFileTypes):a;return r(MESSAGES.instructions,{fileTypes:b,size:Math.round(i/1e3)})}var c=a.disabled,d=a.multiple,e=a.description,f=a.fileTypes,g=void 0===f?imageFileTypes:f,h=a.sizeLimit,i=void 0===h?DEFAULT_SIZE_LIMIT:h,j=a.maxFiles,k=a.onChange,l=a.id,m=void 0===l?DEFAULT_FILE_INPUT_ID:l,n=a.uploadButtonTitle,o=useDirection(),p=o.isRTL,q=useIntl(),r=q.formatMessage,s=useRef(null),t=useState(!1),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useRef(0),y=function(){x.current=0,w(!1)},z=function(){return"*"===g?g:Array.isArray(g)?getAllowedFileTypes(g).join(", "):getAllowedFileTypes([g]).join(", ")};return/*#__PURE__*/_jsxs("div",_objectSpread(_objectSpread({className:classNames("np-upload-button-container","droppable",{"droppable-dropping":v})},!c&&{onDragEnter:function onDragEnter(a){a.preventDefault(),x.current+=1,1===x.current&&w(!0)},onDragLeave:function onDragLeave(a){a.preventDefault(),x.current-=1,0===x.current&&w(!1)},onDrop:function onDrop(a){a.preventDefault(),y(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&k(a.dataTransfer.files)},onDragOver:onDragOver}),{},{children:[/*#__PURE__*/_jsx("input",_objectSpread(_objectSpread(_objectSpread({ref:s,id:m,type:"file"},function(){var a="*"===z();return a?null:Array.isArray(g)?{accept:g.join(",")}:{accept:g}}()),d&&{multiple:!0}),{},{className:"tw-droppable-input",disabled:c,name:"file-upload","data-testid":TEST_IDS.uploadInput,onChange:function filesSelected(a){var b=a.target.files;b&&(k(b),s.current&&(s.current.value=""))}})),/*#__PURE__*/_jsx("label",{htmlFor:"np-upload-button",className:classNames("btn","np-upload-accent","np-upload-button",{disabled:c}),children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:/*#__PURE__*/_jsx(UploadIcon,{size:24,className:"text-link"})}),/*#__PURE__*/_jsxs("div",{className:"media-body text-xs-left","data-testid":TEST_IDS.mediaBody,children:[/*#__PURE__*/_jsx("div",{children:function(){return n?n:r(d?MESSAGES.uploadFiles:MESSAGES.uploadFile)}()}),function(){return/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsxs("small",{className:classNames("np-upload-description",{"text-primary":!c}),children:[b(),j&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("br",{}),"Maximum ".concat(j," files.")]})]})})}()]})]})}),v&&/*#__PURE__*/_jsxs("div",{className:"droppable-card droppable-dropping-card droppable-card-content",children:[/*#__PURE__*/_jsx(PlusIcon,{filled:!0,size:24,className:"text-info m-x-1"}),/*#__PURE__*/_jsx("div",{className:"text-info",children:r(MESSAGES.dropFile)})]})]}))};export default UploadButton;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import{PlusCircle as PlusIcon,Upload as UploadIcon}from"@transferwise/icons";import classNames from"classnames";import{useRef,useState}from"react";import{useIntl}from"react-intl";import{useDirection}from"../../common/hooks";import MESSAGES from"./UploadButton.messages";import{DEFAULT_SIZE_LIMIT,imageFileTypes}from"./defaults";import getAllowedFileTypes from"./getAllowedFileTypes";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var TEST_IDS;(function(a){a.uploadInput="uploadInput",a.mediaBody="mediaBody"})(TEST_IDS||(TEST_IDS={}));var onDragOver=function(a){a.preventDefault()},DEFAULT_FILE_INPUT_ID="np-upload-button",UploadButton=function(a){function b(){if(e)return e;var a=z(),b="*"===a?r(MESSAGES.allFileTypes):a;return r(MESSAGES.instructions,{fileTypes:b,size:Math.round(i/1e3)})}var c=a.disabled,d=a.multiple,e=a.description,f=a.fileTypes,g=void 0===f?imageFileTypes:f,h=a.sizeLimit,i=void 0===h?DEFAULT_SIZE_LIMIT:h,j=a.maxFiles,k=a.onChange,l=a.id,m=void 0===l?DEFAULT_FILE_INPUT_ID:l,n=a.uploadButtonTitle,o=useDirection(),p=o.isRTL,q=useIntl(),r=q.formatMessage,s=useRef(null),t=useState(!1),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useRef(0),y=function(){x.current=0,w(!1)},z=function(){return"*"===g?g:Array.isArray(g)?getAllowedFileTypes(g).join(", "):getAllowedFileTypes([g]).join(", ")};return/*#__PURE__*/_jsxs("div",_objectSpread(_objectSpread({className:classNames("np-upload-button-container","droppable",{"droppable-dropping":v})},!c&&{onDragEnter:function onDragEnter(a){a.preventDefault(),x.current+=1,1===x.current&&w(!0)},onDragLeave:function onDragLeave(a){a.preventDefault(),x.current-=1,0===x.current&&w(!1)},onDrop:function onDrop(a){a.preventDefault(),y(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&k(a.dataTransfer.files)},onDragOver:onDragOver}),{},{children:[/*#__PURE__*/_jsx("input",_objectSpread(_objectSpread(_objectSpread({ref:s,id:m,type:"file"},function(){var a="*"===z();return a?null:Array.isArray(g)?{accept:g.join(",")}:{accept:g}}()),d&&{multiple:!0}),{},{className:"tw-droppable-input",disabled:c,name:"file-upload","data-testid":TEST_IDS.uploadInput,onChange:function filesSelected(a){var b=a.target.files;b&&(k(b),s.current&&(s.current.value=""))}})),/*#__PURE__*/_jsx("label",{htmlFor:m,className:classNames("btn","np-upload-accent","np-upload-button",{disabled:c}),children:/*#__PURE__*/_jsxs("div",{className:"media",children:[/*#__PURE__*/_jsx("div",{className:"np-upload-icon media-left",children:/*#__PURE__*/_jsx(UploadIcon,{size:24,className:"text-link"})}),/*#__PURE__*/_jsxs("div",{className:"media-body text-xs-left","data-testid":TEST_IDS.mediaBody,children:[/*#__PURE__*/_jsx("div",{children:function(){return n?n:r(d?MESSAGES.uploadFiles:MESSAGES.uploadFile)}()}),function(){return/*#__PURE__*/_jsx(_Fragment,{children:/*#__PURE__*/_jsxs("small",{className:classNames("np-upload-description",{"text-primary":!c}),children:[b(),j&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("br",{}),"Maximum ".concat(j," files.")]})]})})}()]})]})}),v&&/*#__PURE__*/_jsxs("div",{className:"droppable-card droppable-dropping-card droppable-card-content",children:[/*#__PURE__*/_jsx(PlusIcon,{filled:!0,size:24,className:"text-info m-x-1"}),/*#__PURE__*/_jsx("div",{className:"text-info",children:r(MESSAGES.dropFile)})]})]}))};export default UploadButton;