@transferwise/components 40.0.0 → 40.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/build/es/no-polyfill/actionOption/ActionOption.js +1 -1
- package/build/es/no-polyfill/card/Card.js +1 -1
- package/build/es/no-polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
- package/build/es/polyfill/actionOption/ActionOption.js +1 -1
- package/build/es/polyfill/card/Card.js +1 -1
- package/build/es/polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
- package/build/umd/no-polyfill/main.js +1 -1
- package/build/umd/polyfill/main.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
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.2.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@40.1.1...@transferwise/components@40.2.0) (2022-03-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **components:** add showMediaAtAllSizes to Card ([#1360](https://github.com/transferwise/neptune-web/issues/1360)) ([062cc29](https://github.com/transferwise/neptune-web/commit/062cc299d36841cb6dbaa44f83307252c327a679))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [40.1.1](https://github.com/transferwise/neptune-web/compare/@transferwise/components@40.1.0...@transferwise/components@40.1.1) (2022-03-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **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))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [40.1.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@40.0.0...@transferwise/components@40.1.0) (2022-03-09)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* 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))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
# [40.0.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@39.14.0...@transferwise/components@40.0.0) (2022-03-09)
|
|
7
40
|
|
|
8
41
|
|
|
@@ -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
|
|
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 _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["aria-label","as","isExpanded","title","details","children","onClick","icon","id","className"];import classNames from"classnames";import PropTypes from"prop-types";import{forwardRef}from"react";import requiredIf from"react-required-if";import Chevron from"../chevron";import{Position}from"../common";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Card=/*#__PURE__*/forwardRef(function(a,b){var c=a["aria-label"],d=a.as,e=a.isExpanded,f=a.title,g=a.details,h=a.children,i=a.onClick,j=a.icon,k=a.id,l=a.className,m=_objectWithoutProperties(a,_excluded),n=!!(e&&h);return/*#__PURE__*/_jsxs(d,{ref:b,className:classNames("np-card",l,{"np-card--expanded":n,"np-card--inactive":!h,"np-card--has-icon":!!j}),id:k,"data-testid":m["data-testid"],children:[/*#__PURE__*/_jsx(Option,{"aria-label":c,as:h?"button":"div",className:classNames("np-card__button"),media:j,title:f,content:g,button:h&&/*#__PURE__*/_jsx(Chevron,{orientation:n?Position.TOP:Position.BOTTOM}),onClick:function onClick(){return h&&i(!e)}}),/*#__PURE__*/_jsx("div",{className:classNames("np-card__divider",{"np-card__divider--expanded":n})}),n&&/*#__PURE__*/_jsx("div",{className:"np-card__content",children:h})]})}),hasChildren=function(a){var b=a.children;return b};Card.propTypes={"aria-label":PropTypes.string,as:PropTypes.string,isExpanded:requiredIf(PropTypes.bool,hasChildren),title:PropTypes.node.isRequired,details:PropTypes.node.isRequired,onClick:requiredIf(PropTypes.func,hasChildren),icon:PropTypes.node.isRequired,children:PropTypes.node,id:PropTypes.string,className:PropTypes.string,"data-testid":PropTypes.string},Card.defaultProps={"aria-label":void 0,as:"div",children:null,id:null,className:null,"data-testid":null};export default Card;
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["aria-label","as","isExpanded","title","details","children","onClick","icon","id","className"];import classNames from"classnames";import PropTypes from"prop-types";import{forwardRef}from"react";import requiredIf from"react-required-if";import Chevron from"../chevron";import{Position}from"../common";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Card=/*#__PURE__*/forwardRef(function(a,b){var c=a["aria-label"],d=a.as,e=a.isExpanded,f=a.title,g=a.details,h=a.children,i=a.onClick,j=a.icon,k=a.id,l=a.className,m=_objectWithoutProperties(a,_excluded),n=!!(e&&h);return/*#__PURE__*/_jsxs(d,{ref:b,className:classNames("np-card",l,{"np-card--expanded":n,"np-card--inactive":!h,"np-card--has-icon":!!j}),id:k,"data-testid":m["data-testid"],children:[/*#__PURE__*/_jsx(Option,{"aria-label":c,as:h?"button":"div",className:classNames("np-card__button"),media:j,title:f,content:g,showMediaAtAllSizes:!0,button:h&&/*#__PURE__*/_jsx(Chevron,{orientation:n?Position.TOP:Position.BOTTOM}),onClick:function onClick(){return h&&i(!e)}}),/*#__PURE__*/_jsx("div",{className:classNames("np-card__divider",{"np-card__divider--expanded":n})}),n&&/*#__PURE__*/_jsx("div",{className:"np-card__content",children:h})]})}),hasChildren=function(a){var b=a.children;return b};Card.propTypes={"aria-label":PropTypes.string,as:PropTypes.string,isExpanded:requiredIf(PropTypes.bool,hasChildren),title:PropTypes.node.isRequired,details:PropTypes.node.isRequired,onClick:requiredIf(PropTypes.func,hasChildren),icon:PropTypes.node.isRequired,children:PropTypes.node,id:PropTypes.string,className:PropTypes.string,"data-testid":PropTypes.string},Card.defaultProps={"aria-label":void 0,as:"div",children:null,id:null,className:null,"data-testid":null};export default Card;
|
|
@@ -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:
|
|
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
|
|
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 _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["aria-label","as","isExpanded","title","details","children","onClick","icon","id","className"];import classNames from"classnames";import PropTypes from"prop-types";import{forwardRef}from"react";import requiredIf from"react-required-if";import Chevron from"../chevron";import{Position}from"../common";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Card=/*#__PURE__*/forwardRef(function(a,b){var c=a["aria-label"],d=a.as,e=a.isExpanded,f=a.title,g=a.details,h=a.children,i=a.onClick,j=a.icon,k=a.id,l=a.className,m=_objectWithoutProperties(a,_excluded),n=!!(e&&h);return/*#__PURE__*/_jsxs(d,{ref:b,className:classNames("np-card",l,{"np-card--expanded":n,"np-card--inactive":!h,"np-card--has-icon":!!j}),id:k,"data-testid":m["data-testid"],children:[/*#__PURE__*/_jsx(Option,{"aria-label":c,as:h?"button":"div",className:classNames("np-card__button"),media:j,title:f,content:g,button:h&&/*#__PURE__*/_jsx(Chevron,{orientation:n?Position.TOP:Position.BOTTOM}),onClick:function onClick(){return h&&i(!e)}}),/*#__PURE__*/_jsx("div",{className:classNames("np-card__divider",{"np-card__divider--expanded":n})}),n&&/*#__PURE__*/_jsx("div",{className:"np-card__content",children:h})]})}),hasChildren=function(a){var b=a.children;return b};Card.propTypes={"aria-label":PropTypes.string,as:PropTypes.string,isExpanded:requiredIf(PropTypes.bool,hasChildren),title:PropTypes.node.isRequired,details:PropTypes.node.isRequired,onClick:requiredIf(PropTypes.func,hasChildren),icon:PropTypes.node.isRequired,children:PropTypes.node,id:PropTypes.string,className:PropTypes.string,"data-testid":PropTypes.string},Card.defaultProps={"aria-label":void 0,as:"div",children:null,id:null,className:null,"data-testid":null};export default Card;
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["aria-label","as","isExpanded","title","details","children","onClick","icon","id","className"];import classNames from"classnames";import PropTypes from"prop-types";import{forwardRef}from"react";import requiredIf from"react-required-if";import Chevron from"../chevron";import{Position}from"../common";import Option from"../common/Option";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Card=/*#__PURE__*/forwardRef(function(a,b){var c=a["aria-label"],d=a.as,e=a.isExpanded,f=a.title,g=a.details,h=a.children,i=a.onClick,j=a.icon,k=a.id,l=a.className,m=_objectWithoutProperties(a,_excluded),n=!!(e&&h);return/*#__PURE__*/_jsxs(d,{ref:b,className:classNames("np-card",l,{"np-card--expanded":n,"np-card--inactive":!h,"np-card--has-icon":!!j}),id:k,"data-testid":m["data-testid"],children:[/*#__PURE__*/_jsx(Option,{"aria-label":c,as:h?"button":"div",className:classNames("np-card__button"),media:j,title:f,content:g,showMediaAtAllSizes:!0,button:h&&/*#__PURE__*/_jsx(Chevron,{orientation:n?Position.TOP:Position.BOTTOM}),onClick:function onClick(){return h&&i(!e)}}),/*#__PURE__*/_jsx("div",{className:classNames("np-card__divider",{"np-card__divider--expanded":n})}),n&&/*#__PURE__*/_jsx("div",{className:"np-card__content",children:h})]})}),hasChildren=function(a){var b=a.children;return b};Card.propTypes={"aria-label":PropTypes.string,as:PropTypes.string,isExpanded:requiredIf(PropTypes.bool,hasChildren),title:PropTypes.node.isRequired,details:PropTypes.node.isRequired,onClick:requiredIf(PropTypes.func,hasChildren),icon:PropTypes.node.isRequired,children:PropTypes.node,id:PropTypes.string,className:PropTypes.string,"data-testid":PropTypes.string},Card.defaultProps={"aria-label":void 0,as:"div",children:null,id:null,className:null,"data-testid":null};export default Card;
|
|
@@ -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:
|
|
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;
|