@transferwise/components 37.4.3 → 37.6.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/build/es/no-polyfill/accordion/AccordionItem/AccordionItem.js +1 -1
  3. package/build/es/no-polyfill/alert/Alert.js +1 -1
  4. package/build/es/no-polyfill/checkbox/Checkbox.js +1 -1
  5. package/build/es/no-polyfill/chip/Chip.js +2 -2
  6. package/build/es/no-polyfill/common/Option/Option.js +1 -1
  7. package/build/es/no-polyfill/common/bottomSheet/BottomSheet.js +2 -2
  8. package/build/es/no-polyfill/common/direction.js +1 -0
  9. package/build/es/no-polyfill/common/domHelpers/index.js +1 -1
  10. package/build/es/no-polyfill/common/index.js +1 -1
  11. package/build/es/no-polyfill/common/locale/index.js +5 -1
  12. package/build/es/no-polyfill/dateInput/DateInput.js +2 -2
  13. package/build/es/no-polyfill/decision/Decision.js +3 -3
  14. package/build/es/no-polyfill/drawer/Drawer.js +1 -1
  15. package/build/es/no-polyfill/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +1 -1
  16. package/build/es/no-polyfill/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +1 -1
  17. package/build/es/no-polyfill/flowNavigation/FlowNavigation.js +1 -1
  18. package/build/es/no-polyfill/index.js +3 -3
  19. package/build/es/no-polyfill/logo/Logo.js +1 -1
  20. package/build/es/no-polyfill/nudge/Nudge.js +1 -1
  21. package/build/es/no-polyfill/phoneNumberInput/PhoneNumberInput.js +1 -1
  22. package/build/es/no-polyfill/provider/Provider.js +1 -1
  23. package/build/es/no-polyfill/provider/direction/DirectionProvider.js +1 -1
  24. package/build/es/no-polyfill/provider/direction/DirectionProvider.spec.js +1 -0
  25. package/build/es/no-polyfill/provider/index.js +1 -1
  26. package/build/es/no-polyfill/radio/Radio.js +1 -1
  27. package/build/es/no-polyfill/select/option/Option.js +1 -1
  28. package/build/es/no-polyfill/snackbar/Snackbar.js +1 -1
  29. package/build/es/no-polyfill/stepper/Stepper.js +1 -1
  30. package/build/es/no-polyfill/summary/Summary.js +1 -1
  31. package/build/es/no-polyfill/switch/Switch.js +1 -1
  32. package/build/es/no-polyfill/tooltip/Tooltip.js +8 -1
  33. package/build/es/no-polyfill/tooltip/Tooltip.spec.js +1 -0
  34. package/build/es/no-polyfill/tooltip/Tooltip.story.js +1 -0
  35. package/build/es/no-polyfill/upload/Upload.js +1 -1
  36. package/build/es/no-polyfill/upload/steps/completeStep/completeStep.js +1 -1
  37. package/build/es/no-polyfill/upload/steps/processingStep/processingStep.js +1 -1
  38. package/build/es/no-polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
  39. package/build/es/no-polyfill/uploadInput/uploadItem/UploadItem.js +2 -2
  40. package/build/es/no-polyfill/utilities/index.js +1 -1
  41. package/build/es/polyfill/accordion/AccordionItem/AccordionItem.js +1 -1
  42. package/build/es/polyfill/alert/Alert.js +1 -1
  43. package/build/es/polyfill/checkbox/Checkbox.js +1 -1
  44. package/build/es/polyfill/chip/Chip.js +2 -2
  45. package/build/es/polyfill/common/Option/Option.js +1 -1
  46. package/build/es/polyfill/common/bottomSheet/BottomSheet.js +2 -2
  47. package/build/es/polyfill/common/direction.js +1 -0
  48. package/build/es/polyfill/common/domHelpers/index.js +1 -1
  49. package/build/es/polyfill/common/index.js +1 -1
  50. package/build/es/polyfill/common/locale/index.js +5 -1
  51. package/build/es/polyfill/dateInput/DateInput.js +2 -2
  52. package/build/es/polyfill/decision/Decision.js +3 -3
  53. package/build/es/polyfill/drawer/Drawer.js +1 -1
  54. package/build/es/polyfill/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +1 -1
  55. package/build/es/polyfill/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +1 -1
  56. package/build/es/polyfill/flowNavigation/FlowNavigation.js +1 -1
  57. package/build/es/polyfill/index.js +3 -3
  58. package/build/es/polyfill/logo/Logo.js +1 -1
  59. package/build/es/polyfill/nudge/Nudge.js +1 -1
  60. package/build/es/polyfill/phoneNumberInput/PhoneNumberInput.js +1 -1
  61. package/build/es/polyfill/provider/Provider.js +1 -1
  62. package/build/es/polyfill/provider/direction/DirectionProvider.js +1 -1
  63. package/build/es/polyfill/provider/direction/DirectionProvider.spec.js +1 -0
  64. package/build/es/polyfill/provider/index.js +1 -1
  65. package/build/es/polyfill/radio/Radio.js +1 -1
  66. package/build/es/polyfill/select/option/Option.js +1 -1
  67. package/build/es/polyfill/snackbar/Snackbar.js +1 -1
  68. package/build/es/polyfill/stepper/Stepper.js +1 -1
  69. package/build/es/polyfill/summary/Summary.js +1 -1
  70. package/build/es/polyfill/switch/Switch.js +1 -1
  71. package/build/es/polyfill/tooltip/Tooltip.js +8 -1
  72. package/build/es/polyfill/tooltip/Tooltip.spec.js +1 -0
  73. package/build/es/polyfill/tooltip/Tooltip.story.js +1 -0
  74. package/build/es/polyfill/upload/Upload.js +1 -1
  75. package/build/es/polyfill/upload/steps/completeStep/completeStep.js +1 -1
  76. package/build/es/polyfill/upload/steps/processingStep/processingStep.js +1 -1
  77. package/build/es/polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
  78. package/build/es/polyfill/uploadInput/uploadItem/UploadItem.js +2 -2
  79. package/build/es/polyfill/utilities/index.js +1 -1
  80. package/build/main.css +1 -1
  81. package/build/styles/accordion/Accordion.css +1 -1
  82. package/build/styles/avatar/Avatar.css +1 -1
  83. package/build/styles/badge/Badge.css +1 -1
  84. package/build/styles/button/Button.css +1 -1
  85. package/build/styles/card/Card.css +1 -1
  86. package/build/styles/checkboxButton/CheckboxButton.css +1 -1
  87. package/build/styles/chip/Chip.css +1 -1
  88. package/build/styles/circularButton/CircularButton.css +1 -1
  89. package/build/styles/common/RadioButton/RadioButton.css +1 -1
  90. package/build/styles/common/bottomSheet/BottomSheet.css +1 -1
  91. package/build/styles/common/closeButton/CloseButton.css +1 -1
  92. package/build/styles/dateLookup/DateLookup.css +1 -1
  93. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +1 -1
  94. package/build/styles/decision/Decision.css +1 -1
  95. package/build/styles/definitionList/DefinitionList.css +1 -1
  96. package/build/styles/dimmer/Dimmer.css +1 -1
  97. package/build/styles/drawer/Drawer.css +1 -1
  98. package/build/styles/emphasis/Emphasis.css +1 -1
  99. package/build/styles/flowNavigation/FlowNavigation.css +1 -1
  100. package/build/styles/flowNavigation/backButton/BackButton.css +1 -1
  101. package/build/styles/info/Info.css +1 -1
  102. package/build/styles/instructionsList/InstructionsList.css +1 -1
  103. package/build/styles/lab/mobileNav/MobileNav.css +1 -1
  104. package/build/styles/lab/pagination/Pagination.css +1 -1
  105. package/build/styles/loader/Loader.css +1 -1
  106. package/build/styles/main.css +1 -1
  107. package/build/styles/moneyInput/MoneyInput.css +1 -1
  108. package/build/styles/navigationOption/NavigationOption.css +1 -1
  109. package/build/styles/navigationOptionsList/NavigationOptionsList.css +1 -1
  110. package/build/styles/nudge/Nudge.css +1 -1
  111. package/build/styles/overlayHeader/OverlayHeader.css +1 -1
  112. package/build/styles/phoneNumberInput/PhoneNumberInput.css +1 -1
  113. package/build/styles/popover/Popover.css +1 -1
  114. package/build/styles/slidingPanel/SlidingPanel.css +1 -1
  115. package/build/styles/snackbar/Snackbar.css +1 -1
  116. package/build/styles/stepper/Stepper.css +1 -1
  117. package/build/styles/summary/Summary.css +1 -1
  118. package/build/styles/switch/Switch.css +1 -1
  119. package/build/styles/tabs/Tabs.css +1 -1
  120. package/build/styles/tile/Tile.css +1 -1
  121. package/build/styles/tooltip/Tooltip.css +1 -1
  122. package/build/styles/typeahead/Typeahead.css +1 -1
  123. package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +1 -1
  124. package/build/styles/uploadInput/UploadInput.css +1 -1
  125. package/build/styles/uploadInput/uploadButton/UploadButton.css +1 -1
  126. package/build/styles/uploadInput/uploadItem/UploadItem.css +1 -1
  127. package/build/types/common/direction.d.ts +6 -0
  128. package/build/types/common/domHelpers/index.d.ts +2 -1
  129. package/build/types/common/hooks/useDirection/useDirection.d.ts +1 -1
  130. package/build/types/common/index.d.ts +2 -0
  131. package/build/types/common/locale/index.d.ts +6 -1
  132. package/build/types/common/propsValues/position.d.ts +4 -0
  133. package/build/types/index.d.ts +4 -3
  134. package/build/types/provider/direction/DirectionProvider.d.ts +8 -18
  135. package/build/types/provider/direction/DirectionProvider.spec.d.ts +1 -0
  136. package/build/types/provider/index.d.ts +1 -0
  137. package/build/types/tooltip/Tooltip.d.ts +9 -18
  138. package/build/types/tooltip/Tooltip.spec.d.ts +1 -0
  139. package/build/types/tooltip/Tooltip.story.d.ts +12 -0
  140. package/build/umd/no-polyfill/main.js +1 -1
  141. package/build/umd/polyfill/main.js +1 -1
  142. package/package.json +8 -8
  143. package/{bin → scripts}/neptune-upgrader.js +5 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
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
+ # [37.6.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.5.0...@transferwise/components@37.6.0) (2021-09-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **DefinitionList:** use break-word for definition list text ([#1157](https://github.com/transferwise/neptune-web/issues/1157)) ([d72d039](https://github.com/transferwise/neptune-web/commit/d72d0391884e54936a0e2d1b688da19a8e287a4f))
12
+
13
+
14
+ ### Features
15
+
16
+ * force minor version bump in all affected packages ([#1160](https://github.com/transferwise/neptune-web/issues/1160)) ([f306c76](https://github.com/transferwise/neptune-web/commit/f306c7618c43a5f868c63c60c281428cd9a94411))
17
+ * force version bump to fix npm publish ([#1159](https://github.com/transferwise/neptune-web/issues/1159)) ([e1209a5](https://github.com/transferwise/neptune-web/commit/e1209a5e13269bd510d32cad5b8db253d337bb16))
18
+
19
+
20
+
21
+
22
+
23
+ # [37.5.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.4.3...@transferwise/components@37.5.0) (2021-09-22)
24
+
25
+
26
+ ### Features
27
+
28
+ * add updatePeerDependencies script on npm postversion ([#1094](https://github.com/transferwise/neptune-web/issues/1094)) ([1793a61](https://github.com/transferwise/neptune-web/commit/1793a616b917fc1895689c8dcc64ab6905a084c3))
29
+
30
+
31
+
32
+
33
+
6
34
  ## [37.4.3](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.4.2...@transferwise/components@37.4.3) (2021-09-17)
7
35
 
8
36
 
@@ -1 +1 @@
1
- import{isString}from"@transferwise/neptune-validation";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement}from"react";import Chevron from"../../chevron";import{Position,Theme}from"../../common";import{useDirection}from"../../common/hooks";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var AccordionItem=function(a){var b=a.id,c=a.title,d=a.content,e=a.onClick,f=a.open,g=a.icon,h=a.theme,i=g?/*#__PURE__*/cloneElement(g,{size:24}):null,j=useDirection(),k=j.isRTL;return/*#__PURE__*/_jsxs("div",{id:b,className:classNames("tw-accordion-item decision p-a-0","tw-accordion-item--".concat(h),{closed:!f}),children:[/*#__PURE__*/_jsx("button",{type:"button","aria-expanded":f,className:classNames("tw-accordion-item btn btn-link p-x-0 text-no-decoration p-t-3",{"p-b-3":!f,"p-b-2":f}),onClick:e,children:/*#__PURE__*/_jsxs("div",{className:"media",children:[g&&/*#__PURE__*/_jsx("div",{className:classNames("hidden-xs hidden-sm",{"media-left":!k,"media-right":k,"p-r-2":!k,"p-l-2":k}),children:i}),/*#__PURE__*/_jsx("div",{className:classNames("media-body title",{"text-xs-left":!k,"text-xs-right":k}),children:isString(c)?/*#__PURE__*/_jsx("span",{className:"h5 tw-accordion-item__title",children:c}):c}),/*#__PURE__*/_jsx("div",{className:classNames("d-flex align-items-center",{"media-right":!k,"media-left":k}),children:/*#__PURE__*/_jsx(Chevron,{orientation:f?Position.TOP:Position.BOTTOM})})]})}),/*#__PURE__*/_jsx("div",{className:"accordion-content media",children:/*#__PURE__*/_jsx("div",{className:classNames("media-body p-b-3",{"m-l-5":g||k,"m-r-5":g}),"aria-hidden":!f,children:d})})]})};AccordionItem.propTypes={content:PropTypes.node.isRequired,icon:PropTypes.node,id:PropTypes.string,open:PropTypes.bool.isRequired,onClick:PropTypes.func.isRequired,title:PropTypes.node.isRequired,theme:PropTypes.oneOf(["light","dark"])},AccordionItem.defaultProps={icon:null,id:null,theme:Theme.LIGHT};export default AccordionItem;
1
+ import{isString}from"@transferwise/neptune-validation";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement}from"react";import Chevron from"../../chevron";import{Position,Theme}from"../../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var AccordionItem=function(a){var b=a.id,c=a.title,d=a.content,e=a.onClick,f=a.open,g=a.icon,h=a.theme,i=g?/*#__PURE__*/cloneElement(g,{size:24}):null;return/*#__PURE__*/_jsxs("div",{id:b,className:classNames("tw-accordion-item decision p-a-0","tw-accordion-item--".concat(h),{closed:!f}),children:[/*#__PURE__*/_jsx("button",{type:"button","aria-expanded":f,className:classNames("tw-accordion-item btn btn-link p-x-0 text-no-decoration p-t-3",{"p-b-3":!f,"p-b-2":f}),onClick:e,children:/*#__PURE__*/_jsxs("div",{className:"media",children:[g&&/*#__PURE__*/_jsx("div",{className:classNames("hidden-xs hidden-sm media-left p-r-2"),children:i}),/*#__PURE__*/_jsx("div",{className:classNames("media-body title text-xs-left"),children:isString(c)?/*#__PURE__*/_jsx("span",{className:"title-4 tw-accordion-item__title",children:c}):c}),/*#__PURE__*/_jsx("div",{className:classNames("d-flex align-items-center media-right"),children:/*#__PURE__*/_jsx(Chevron,{orientation:f?Position.TOP:Position.BOTTOM})})]})}),/*#__PURE__*/_jsx("div",{className:"accordion-content media",children:/*#__PURE__*/_jsx("div",{className:classNames("media-body m-r-5 p-b-3",{"m-l-5":g}),"aria-hidden":!f,children:d})})]})};AccordionItem.propTypes={content:PropTypes.node.isRequired,icon:PropTypes.node,id:PropTypes.string,open:PropTypes.bool.isRequired,onClick:PropTypes.func.isRequired,title:PropTypes.node.isRequired,theme:PropTypes.oneOf(["light","dark"])},AccordionItem.defaultProps={icon:null,id:null,theme:Theme.LIGHT};export default AccordionItem;
@@ -1 +1 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _deprecatedTypeMap,_iconTypeMap,_deprecatedTypeMapMes;function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{InfoCircle,CheckCircle,Alert as AlertIcon,AlertCircle}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement,useState,useRef}from"react";import requiredIf from"react-required-if";import{Sentiment}from"../common";import CloseButton from"../common/closeButton";import{useDirection}from"../common/hooks";import{logActionRequiredIf,deprecated}from"../utilities";import InlineMarkdown from"./inlineMarkdown";import withArrow from"./withArrow";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var deprecatedTypeMap=(_deprecatedTypeMap={},_defineProperty(_deprecatedTypeMap,Sentiment.SUCCESS,Sentiment.POSITIVE),_defineProperty(_deprecatedTypeMap,Sentiment.INFO,Sentiment.NEUTRAL),_defineProperty(_deprecatedTypeMap,Sentiment.ERROR,Sentiment.NEGATIVE),_deprecatedTypeMap),iconTypeMap=(_iconTypeMap={},_defineProperty(_iconTypeMap,Sentiment.POSITIVE,CheckCircle),_defineProperty(_iconTypeMap,Sentiment.NEUTRAL,InfoCircle),_defineProperty(_iconTypeMap,Sentiment.WARNING,AlertIcon),_defineProperty(_iconTypeMap,Sentiment.NEGATIVE,AlertCircle),_iconTypeMap),Alert=function(a){var b=useState(!1),c=_slicedToArray(b,2),d=c[0],e=c[1],f=a.arrow,g=a.action,h=a.children,i=a.className,j=a.icon,k=a.onDismiss,l=a.message,m=a.type,n=useRef(null),o=useDirection(),p=o.isRTL;if(f){var t=withArrow(Alert,f);return/*#__PURE__*/_jsx(t,_objectSpread({},a))}logActionRequired(a);var q=deprecatedTypeMap[m]||m,r=iconTypeMap[q],s=j?/*#__PURE__*/cloneElement(j,{size:24}):/*#__PURE__*/_jsx(r,{size:24});return/*#__PURE__*/_jsxs("div",{role:"alert",className:classNames("alert d-flex","alert-".concat(q),i),onTouchStart:function handleTouchStart(){return e(!0)},onTouchEnd:function handleTouchEnd(a){d&&g&&null!==n&&void 0!==n&&n.current&&!n.current.contains(a.target)&&("_blank"===(null===g||void 0===g?void 0:g.target)?window.top.open(g.href):window.top.location.assign(g.href)),e(!1)},onTouchMove:function handleTouchMove(){return e(!1)},children:[s,/*#__PURE__*/_jsxs("div",{className:classNames("alert__message flex-grow-1",{"p-l-2":!p,"p-r-2":p}),children:[/*#__PURE__*/_jsx("div",{children:h||/*#__PURE__*/_jsx(InlineMarkdown,{children:l})}),g&&/*#__PURE__*/_jsx("a",{href:g.href,className:"m-t-1 d-inline-block","aria-label":g["aria-label"],target:g.target,children:g.text})]}),k&&/*#__PURE__*/_jsx(CloseButton,{ref:n,size:16,className:classNames({"m-l-2":!p,"m-r-2":p}),onClick:k})]})},deprecatedTypeMapMessage=(_deprecatedTypeMapMes={},_defineProperty(_deprecatedTypeMapMes,Sentiment.SUCCESS,"Sentiment.POSITIVE"),_defineProperty(_deprecatedTypeMapMes,Sentiment.INFO,"Sentiment.NEUTRAL"),_defineProperty(_deprecatedTypeMapMes,Sentiment.ERROR,"Sentiment.NEGATIVE"),_deprecatedTypeMapMes),deprecatedTypes=Object.keys(deprecatedTypeMap);function logActionRequired(a){var b=a.size,c=a.type;logActionRequiredIf("Alert no longer supports any possible variations in size. Please remove the `size` prop.",!!b),logActionRequiredIf("Alert has deprecated the ".concat(c," value for the `type` prop. Please update to ").concat(deprecatedTypeMapMessage[c],"."),deprecatedTypes.includes(c))}Alert.propTypes={/** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */action:PropTypes.shape({"aria-label":PropTypes.string,href:PropTypes.string.isRequired,target:PropTypes.string,text:PropTypes.node.isRequired}),className:PropTypes.string,/** An optional icon. If not provided, we will default the icon to something appropriate for the type */icon:PropTypes.element,/** The main body of the alert. Accepts plain text and bold words specified with **double stars*/message:requiredIf(PropTypes.node,function(a){var b=a.children;return!b}),/** The presence of the onDismiss handler will trigger the visibility of the close button */onDismiss:PropTypes.func,/** The type dictates which icon and colour will be used */type:PropTypes.oneOf(["negative","neutral","positive","warning","info","error","success"]),/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */arrow:deprecated(PropTypes.oneOf(["up-left","up-center","up-right","down-left","down-center","down-right"]),{component:"Alert",expiryDate:new Date("03-01-2021")}),/** @deprecated use `message` property instead */children:deprecated(requiredIf(PropTypes.node,function(a){var b=a.message;return!b}),{component:"Alert",message:"You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.",expiryDate:new Date("03-01-2021")}),/** @deprecated use `onDismiss` instead */dismissible:deprecated(PropTypes.bool,{component:"Alert",message:"The Alert will now be considered dismissible if an `onDismiss` hander is present.",expiryDate:new Date("03-01-2021")})},Alert.defaultProps={action:void 0,arrow:void 0,className:void 0,dismissible:void 0,icon:void 0,type:Sentiment.NEUTRAL};export default Alert;
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _deprecatedTypeMap,_iconTypeMap,_deprecatedTypeMapMes;function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{InfoCircle,CheckCircle,Alert as AlertIcon,AlertCircle}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement,useState,useRef}from"react";import requiredIf from"react-required-if";import{Sentiment}from"../common";import CloseButton from"../common/closeButton";import{logActionRequiredIf,deprecated}from"../utilities";import InlineMarkdown from"./inlineMarkdown";import withArrow from"./withArrow";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var deprecatedTypeMap=(_deprecatedTypeMap={},_defineProperty(_deprecatedTypeMap,Sentiment.SUCCESS,Sentiment.POSITIVE),_defineProperty(_deprecatedTypeMap,Sentiment.INFO,Sentiment.NEUTRAL),_defineProperty(_deprecatedTypeMap,Sentiment.ERROR,Sentiment.NEGATIVE),_deprecatedTypeMap),iconTypeMap=(_iconTypeMap={},_defineProperty(_iconTypeMap,Sentiment.POSITIVE,CheckCircle),_defineProperty(_iconTypeMap,Sentiment.NEUTRAL,InfoCircle),_defineProperty(_iconTypeMap,Sentiment.WARNING,AlertIcon),_defineProperty(_iconTypeMap,Sentiment.NEGATIVE,AlertCircle),_iconTypeMap),Alert=function(a){var b=useState(!1),c=_slicedToArray(b,2),d=c[0],e=c[1],f=a.arrow,g=a.action,h=a.children,i=a.className,j=a.icon,k=a.onDismiss,l=a.message,m=a.type,n=useRef(null);if(f){var r=withArrow(Alert,f);return/*#__PURE__*/_jsx(r,_objectSpread({},a))}logActionRequired(a);var o=deprecatedTypeMap[m]||m,p=iconTypeMap[o],q=j?/*#__PURE__*/cloneElement(j,{size:24}):/*#__PURE__*/_jsx(p,{size:24});return/*#__PURE__*/_jsxs("div",{role:"alert",className:classNames("alert d-flex","alert-".concat(o),i),onTouchStart:function handleTouchStart(){return e(!0)},onTouchEnd:function handleTouchEnd(a){d&&g&&null!==n&&void 0!==n&&n.current&&!n.current.contains(a.target)&&("_blank"===(null===g||void 0===g?void 0:g.target)?window.top.open(g.href):window.top.location.assign(g.href)),e(!1)},onTouchMove:function handleTouchMove(){return e(!1)},children:[q,/*#__PURE__*/_jsxs("div",{className:"alert__message flex-grow-1 p-l-2",children:[/*#__PURE__*/_jsx("div",{children:h||/*#__PURE__*/_jsx(InlineMarkdown,{children:l})}),g&&/*#__PURE__*/_jsx("a",{href:g.href,className:"m-t-1 d-inline-block","aria-label":g["aria-label"],target:g.target,children:g.text})]}),k&&/*#__PURE__*/_jsx(CloseButton,{ref:n,size:16,className:"m-l-2",onClick:k})]})},deprecatedTypeMapMessage=(_deprecatedTypeMapMes={},_defineProperty(_deprecatedTypeMapMes,Sentiment.SUCCESS,"Sentiment.POSITIVE"),_defineProperty(_deprecatedTypeMapMes,Sentiment.INFO,"Sentiment.NEUTRAL"),_defineProperty(_deprecatedTypeMapMes,Sentiment.ERROR,"Sentiment.NEGATIVE"),_deprecatedTypeMapMes),deprecatedTypes=Object.keys(deprecatedTypeMap);function logActionRequired(a){var b=a.size,c=a.type;logActionRequiredIf("Alert no longer supports any possible variations in size. Please remove the `size` prop.",!!b),logActionRequiredIf("Alert has deprecated the ".concat(c," value for the `type` prop. Please update to ").concat(deprecatedTypeMapMessage[c],"."),deprecatedTypes.includes(c))}Alert.propTypes={/** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */action:PropTypes.shape({"aria-label":PropTypes.string,href:PropTypes.string.isRequired,target:PropTypes.string,text:PropTypes.node.isRequired}),className:PropTypes.string,/** An optional icon. If not provided, we will default the icon to something appropriate for the type */icon:PropTypes.element,/** The main body of the alert. Accepts plain text and bold words specified with **double stars*/message:requiredIf(PropTypes.node,function(a){var b=a.children;return!b}),/** The presence of the onDismiss handler will trigger the visibility of the close button */onDismiss:PropTypes.func,/** The type dictates which icon and colour will be used */type:PropTypes.oneOf(["negative","neutral","positive","warning","info","error","success"]),/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */arrow:deprecated(PropTypes.oneOf(["up-left","up-center","up-right","down-left","down-center","down-right"]),{component:"Alert",expiryDate:new Date("03-01-2021")}),/** @deprecated use `message` property instead */children:deprecated(requiredIf(PropTypes.node,function(a){var b=a.message;return!b}),{component:"Alert",message:"You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.",expiryDate:new Date("03-01-2021")}),/** @deprecated use `onDismiss` instead */dismissible:deprecated(PropTypes.bool,{component:"Alert",message:"The Alert will now be considered dismissible if an `onDismiss` hander is present.",expiryDate:new Date("03-01-2021")})},Alert.defaultProps={action:void 0,arrow:void 0,className:void 0,dismissible:void 0,icon:void 0,type:Sentiment.NEUTRAL};export default Alert;
@@ -1 +1 @@
1
- import classNames from"classnames";import PropTypes from"prop-types";import CheckboxButton from"../checkboxButton";import{useDirection}from"../common/hooks";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Checkbox=function(a){var b=a.id,c=a.checked,d=a.required,e=a.disabled,f=a.readOnly,g=a.label,h=a.secondary,i=a.onChange,j=a.onFocus,k=a.onBlur,l=useDirection(),m=l.isRTL,n=d&&!e&&!f&&!c,o=classNames("np-checkbox",{checkbox:!0,"checkbox-lg":h,"has-error":n,disabled:e});return/*#__PURE__*/_jsx("div",{id:b,className:o,children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx(CheckboxButton,{className:classNames({"has-error":n,"p-r-2":!m,"p-l-2":m}),checked:c,disabled:e||f,onFocus:j,onChange:function onChange(){return i(!c)},onBlur:k}),/*#__PURE__*/_jsxs("span",{className:"np-checkbox__text",children:[g,d&&"*",h&&/*#__PURE__*/_jsx("small",{children:h})]})]})})};Checkbox.propTypes={id:PropTypes.string,checked:PropTypes.bool,required:PropTypes.bool,disabled:PropTypes.bool,readOnly:PropTypes.bool,label:PropTypes.node.isRequired,secondary:PropTypes.string,onFocus:PropTypes.func,onChange:PropTypes.func.isRequired,onBlur:PropTypes.func},Checkbox.defaultProps={id:null,checked:!1,required:!1,disabled:!1,readOnly:!1,secondary:null,onFocus:null,onBlur:null};export default Checkbox;
1
+ import classNames from"classnames";import PropTypes from"prop-types";import CheckboxButton from"../checkboxButton";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Checkbox=function(a){var b=a.id,c=a.checked,d=a.required,e=a.disabled,f=a.readOnly,g=a.label,h=a.secondary,i=a.onChange,j=a.onFocus,k=a.onBlur,l=d&&!e&&!f&&!c,m=classNames("np-checkbox",{checkbox:!0,"checkbox-lg":h,"has-error":l,disabled:e});return/*#__PURE__*/_jsx("div",{id:b,className:m,children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx(CheckboxButton,{className:classNames("p-r-2",{"has-error":l}),checked:c,disabled:e||f,onFocus:j,onChange:function onChange(){return i(!c)},onBlur:k}),/*#__PURE__*/_jsxs("span",{className:"np-checkbox__text",children:[g,d&&"*",h&&/*#__PURE__*/_jsx("small",{children:h})]})]})})};Checkbox.propTypes={id:PropTypes.string,checked:PropTypes.bool,required:PropTypes.bool,disabled:PropTypes.bool,readOnly:PropTypes.bool,label:PropTypes.node.isRequired,secondary:PropTypes.string,onFocus:PropTypes.func,onChange:PropTypes.func.isRequired,onBlur:PropTypes.func},Checkbox.defaultProps={id:null,checked:!1,required:!1,disabled:!1,readOnly:!1,secondary:null,onFocus:null,onBlur:null};export default Checkbox;
@@ -1,4 +1,4 @@
1
- import{Cross as CrossIcon}from"@transferwise/icons";import classNames from"classnames";import{useDirection}from"../common/hooks";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{Cross as CrossIcon}from"@transferwise/icons";import classNames from"classnames";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * `Chip` component
3
3
  *
4
4
  * Docs link: https://transferwise.github.io/neptune-web/components/internal/Chip
@@ -8,4 +8,4 @@ import{Cross as CrossIcon}from"@transferwise/icons";import classNames from"class
8
8
  * @param root0.onRemove
9
9
  * @param root0.hasError
10
10
  * @param root0.className
11
- */var Chip=function(a){var b=a.label,c=a.onRemove,d=a.hasError,e=a.className,f=void 0===e?void 0:e,g=useDirection(),h=g.isRTL;return/*#__PURE__*/_jsxs("div",{className:classNames("chip","d-inline-flex","align-items-center","m-t-1",{"has-error":void 0!==d&&d,"p-r-1 p-l-2":!h,"p-l-1 p-r-2":h},f),children:[b,/*#__PURE__*/_jsx("button",{type:"button",className:classNames("btn-unstyled chip-remove",{"m-l-2":!h,"m-r-2":h}),onClick:c,children:/*#__PURE__*/_jsx(CrossIcon,{})})]})};export default Chip;
11
+ */var Chip=function(a){var b=a.label,c=a.onRemove,d=a.hasError,e=a.className,f=void 0===e?void 0:e;return/*#__PURE__*/_jsxs("div",{className:classNames("chip","d-inline-flex","align-items-center","m-t-1","p-r-1","p-l-2",{"has-error":void 0!==d&&d},f),children:[b,/*#__PURE__*/_jsx("button",{type:"button",className:"btn-unstyled chip-remove m-l-2",onClick:c,children:/*#__PURE__*/_jsx(CrossIcon,{})})]})};export default Chip;
@@ -1 +1 @@
1
- import classNames from"classnames";import PropTypes from"prop-types";import requiredIf from"react-required-if";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Option=function(a){var b=a.as,c=a.href,d=a.target,e=a.media,f=a.title,g=a.content,h=a.onClick,i=a.htmlFor,j=a.disabled,k=a.button,l=a.decision,m=a.complex,n=a.className,o=a.inverseMediaCircle,p=a.showMediaAtAllSizes,q=a.showMediaCircle;return/*#__PURE__*/_jsxs(b,{className:classNames(n,"media",{"decision-complex":m,decision:l,disabled:j,"tw-option__sm-media":p}),href:c,htmlFor:i,target:d,disabled:j&&"button"===b,onClick:h,children:[e&&/*#__PURE__*/_jsx("div",{className:"media-left",children:q?/*#__PURE__*/_jsx("div",{className:classNames("circle circle-sm text-primary",{"circle-inverse":o}),children:e}):/*#__PURE__*/_jsx("div",{className:"tw-option__no-media-circle",children:e})}),/*#__PURE__*/_jsxs("div",{className:"media-body",children:[/*#__PURE__*/_jsx("div",{className:"h5",children:f}),g&&/*#__PURE__*/_jsx("div",{className:"decision__content",children:g})]}),/*#__PURE__*/_jsx("div",{className:"media-right",children:k})]})};Option.propTypes={media:PropTypes.node,htmlFor:PropTypes.string,title:PropTypes.node.isRequired,content:PropTypes.node,onClick:PropTypes.func,href:requiredIf(PropTypes.string,function(a){return"a"===a.as}),target:PropTypes.oneOf(["_self","_blank","_parent","_top"]),as:PropTypes.string,disabled:PropTypes.bool,button:PropTypes.node,decision:PropTypes.bool,complex:PropTypes.bool,inverseMediaCircle:PropTypes.bool,className:PropTypes.string,showMediaAtAllSizes:PropTypes.bool,showMediaCircle:PropTypes.bool},Option.defaultProps={as:"label",media:"",content:null,htmlFor:null,disabled:!1,button:null,onClick:null,href:null,target:void 0,decision:!0,complex:!1,inverseMediaCircle:!0,className:null,showMediaAtAllSizes:!1,showMediaCircle:!0};export default Option;
1
+ import classNames from"classnames";import PropTypes from"prop-types";import requiredIf from"react-required-if";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Option=function(a){var b=a.as,c=a.href,d=a.target,e=a.media,f=a.title,g=a.content,h=a.onClick,i=a.htmlFor,j=a.disabled,k=a.button,l=a.decision,m=a.complex,n=a.className,o=a.inverseMediaCircle,p=a.showMediaAtAllSizes,q=a.showMediaCircle;return/*#__PURE__*/_jsxs(b,{className:classNames(n,"media",{"decision-complex":m,decision:l,disabled:j,"tw-option__sm-media":p}),href:c,htmlFor:i,target:d,disabled:j&&"button"===b,onClick:h,children:[e&&/*#__PURE__*/_jsx("div",{className:"media-left",children:q?/*#__PURE__*/_jsx("div",{className:classNames("circle circle-sm text-primary",{"circle-inverse":o}),children:e}):/*#__PURE__*/_jsx("div",{className:"tw-option__no-media-circle",children:e})}),/*#__PURE__*/_jsxs("div",{className:"media-body",children:[/*#__PURE__*/_jsx("div",{className:"title-4",children:f}),g&&/*#__PURE__*/_jsx("div",{className:"decision__content",children:g})]}),/*#__PURE__*/_jsx("div",{className:"media-right",children:k})]})};Option.propTypes={media:PropTypes.node,htmlFor:PropTypes.string,title:PropTypes.node.isRequired,content:PropTypes.node,onClick:PropTypes.func,href:requiredIf(PropTypes.string,function(a){return"a"===a.as}),target:PropTypes.oneOf(["_self","_blank","_parent","_top"]),as:PropTypes.string,disabled:PropTypes.bool,button:PropTypes.node,decision:PropTypes.bool,complex:PropTypes.bool,inverseMediaCircle:PropTypes.bool,className:PropTypes.string,showMediaAtAllSizes:PropTypes.bool,showMediaCircle:PropTypes.bool},Option.defaultProps={as:"label",media:"",content:null,htmlFor:null,disabled:!1,button:null,onClick:null,href:null,target:void 0,decision:!0,complex:!1,inverseMediaCircle:!0,className:null,showMediaAtAllSizes:!1,showMediaCircle:!0};export default Option;
@@ -1,4 +1,4 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import classNames from"classnames";import{useRef,useState}from"react";import Dimmer from"../../dimmer";import SlidingPanel from"../../slidingPanel";import CloseButton from"../closeButton";import{isServerSideRendering}from"../domHelpers";import{useConditionalListener}from"../hooks";import{Position}from"../propsValues/position";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var INITIAL_Y_POSITION=0,CONTENT_SCROLL_THRESHOLD=1,MOVE_OFFSET_THRESHOLD=50,BottomSheet=function(a){function b(a){null!==g.current&&(g.current.style.transform="translateY(".concat(a,"px)"))}function c(){m(!1),o.current=INITIAL_Y_POSITION,null!==g.current&&g.current.style.removeProperty("transform"),a.onClose&&a.onClose()}function d(){// stop moving component
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import classNames from"classnames";import{useRef,useState}from"react";import Dimmer from"../../dimmer";import SlidingPanel from"../../slidingPanel";import CloseButton from"../closeButton";import{isServerSide}from"../domHelpers";import{useConditionalListener}from"../hooks";import{Position}from"../propsValues/position";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var INITIAL_Y_POSITION=0,CONTENT_SCROLL_THRESHOLD=1,MOVE_OFFSET_THRESHOLD=50,BottomSheet=function(a){function b(a){null!==g.current&&(g.current.style.transform="translateY(".concat(a,"px)"))}function c(){m(!1),o.current=INITIAL_Y_POSITION,null!==g.current&&g.current.style.removeProperty("transform"),a.onClose&&a.onClose()}function d(){// stop moving component
2
2
  cancelAnimationFrame(n.current),m(!1),o.current>MOVE_OFFSET_THRESHOLD&&e()?c():b(INITIAL_Y_POSITION),o.current=INITIAL_Y_POSITION}function e(){var a;return(null===i||void 0===i||null===(a=i.current)||void 0===a?void 0:a.scrollTop)!==void 0&&i.current.scrollTop<=CONTENT_SCROLL_THRESHOLD}/**
3
3
  * Calculates how hard user moves component,
4
4
  * result value used to determine whether to hide component or re-position to default state
@@ -7,4 +7,4 @@ cancelAnimationFrame(n.current),m(!1),o.current>MOVE_OFFSET_THRESHOLD&&e()?c():b
7
7
  */function f(a){return a-p.current}/**
8
8
  * Set `max-height` for content part (in order to keep it scrollable for content overflow cases) of the component
9
9
  * and ensures space for safe zone (32px) at the top.
10
- */var g=useRef(null),h=useRef(null),i=useRef(null),j=useState(!1),k=_slicedToArray(j,2),l=k[0],m=k[1],n=useRef(0),o=useRef(0),p=useRef(0);useConditionalListener({attachListener:a.open&&!isServerSideRendering(),callback:function callback(){if(null!==h.current){var a=h.current.classList;e()?a.remove("np-bottom-sheet--top-bar--shadow"):a.add("np-bottom-sheet--top-bar--shadow")}},eventType:"scroll",parent:isServerSideRendering()?void 0:document});var q=function(a){return function(b){p.current=(a?b.touches[0]:b).clientY,m(!0)}},r=function(a){return function(c){if(l){var d=a?c.touches[0]:c,h=d.clientY,i=f(h);i>INITIAL_Y_POSITION&&e()&&(o.current=i,n.current=requestAnimationFrame(function(){n.current!==void 0&&null!==g.current&&b(i)}))}}};return/*#__PURE__*/_jsx(Dimmer,{open:a.open,fadeContentOnEnter:!0,fadeContentOnExit:!0,onClose:c,children:/*#__PURE__*/_jsxs(SlidingPanel,{ref:g,open:a.open,position:Position.BOTTOM,className:classNames("np-bottom-sheet",a.className),role:"dialog",onTouchStart:q(!0),onTouchMove:r(!0),onTouchEnd:d,onMouseDown:q(!1),onMouseMove:r(!1),onMouseUp:d,children:[/*#__PURE__*/_jsxs("div",{ref:h,className:"np-bottom-sheet--top-bar",children:[/*#__PURE__*/_jsx("div",{className:"np-bottom-sheet--handler"}),/*#__PURE__*/_jsx(CloseButton,{size:16,className:"sr-only np-bottom-sheet--close-btn",onClick:c})]}),/*#__PURE__*/_jsx("div",{ref:i,style:function(){var a=isServerSideRendering()?0:window.innerHeight,b="".concat(100*(.01*a),"px");return{maxHeight:"calc(".concat(b," - ").concat("64px"," - ").concat("32px",")")}}(),className:"np-bottom-sheet--content",children:a.children})]})})};export default BottomSheet;
10
+ */var g=useRef(null),h=useRef(null),i=useRef(null),j=useState(!1),k=_slicedToArray(j,2),l=k[0],m=k[1],n=useRef(0),o=useRef(0),p=useRef(0);useConditionalListener({attachListener:a.open&&!isServerSide(),callback:function callback(){if(null!==h.current){var a=h.current.classList;e()?a.remove("np-bottom-sheet--top-bar--shadow"):a.add("np-bottom-sheet--top-bar--shadow")}},eventType:"scroll",parent:isServerSide()?void 0:document});var q=function(a){return function(b){p.current=(a?b.touches[0]:b).clientY,m(!0)}},r=function(a){return function(c){if(l){var d=a?c.touches[0]:c,h=d.clientY,i=f(h);i>INITIAL_Y_POSITION&&e()&&(o.current=i,n.current=requestAnimationFrame(function(){n.current!==void 0&&null!==g.current&&b(i)}))}}};return/*#__PURE__*/_jsx(Dimmer,{open:a.open,fadeContentOnEnter:!0,fadeContentOnExit:!0,onClose:c,children:/*#__PURE__*/_jsxs(SlidingPanel,{ref:g,open:a.open,position:Position.BOTTOM,className:classNames("np-bottom-sheet",a.className),role:"dialog",onTouchStart:q(!0),onTouchMove:r(!0),onTouchEnd:d,onMouseDown:q(!1),onMouseMove:r(!1),onMouseUp:d,children:[/*#__PURE__*/_jsxs("div",{ref:h,className:"np-bottom-sheet--top-bar",children:[/*#__PURE__*/_jsx("div",{className:"np-bottom-sheet--handler"}),/*#__PURE__*/_jsx(CloseButton,{size:16,className:"sr-only np-bottom-sheet--close-btn",onClick:c})]}),/*#__PURE__*/_jsx("div",{ref:i,style:function(){var a=isServerSide()?0:window.innerHeight,b="".concat(100*(.01*a),"px");return{maxHeight:"calc(".concat(b," - ").concat("64px"," - ").concat("32px",")")}}(),className:"np-bottom-sheet--content",children:a.children})]})})};export default BottomSheet;
@@ -0,0 +1 @@
1
+ export var Direction;(function(a){a.RTL="rtl",a.LTR="ltr",a.AUTO="auto"})(Direction||(Direction={}));
@@ -1 +1 @@
1
- export function isServerSideRendering(){return"undefined"==typeof window}export{addClickClassToDocumentOnIos,removeClickClassFromDocumentOnIos}from"./documentIosClick";
1
+ export function isServerSide(){return"undefined"==typeof window}export function isBrowser(){return!isServerSide()}export{addClickClassToDocumentOnIos,removeClickClassFromDocumentOnIos}from"./documentIosClick";
@@ -1,2 +1,2 @@
1
- export{default as HistoryNavigator}from"./historyNavigator";export{addNoScrollBodyClass,removeNoScrollBodyClass}from"./DOMOperations";export*from"./theme";// Props
1
+ export{default as HistoryNavigator}from"./historyNavigator";export{isServerSide,isBrowser}from"./domHelpers";export{addNoScrollBodyClass,removeNoScrollBodyClass}from"./DOMOperations";export*from"./theme";export*from"./direction";// Props
2
2
  export{Priority,ControlType}from"./propsValues/control";export{Breakpoint}from"./propsValues/breakpoint";export*from"./propsValues/size";export*from"./propsValues/width";export{Type}from"./propsValues/type";export{DateMode}from"./propsValues/dateMode";export{MonthFormat}from"./propsValues/monthFormat";export{Position}from"./propsValues/position";export{Layout}from"./propsValues/layouts";export{Status}from"./propsValues/status";export{Sentiment}from"./propsValues/sentiment";export{ProfileType}from"./propsValues/profileType";export{Scroll}from"./propsValues/scroll";export{MarkdownNodeType}from"./propsValues/markdownNodeType";export{FileType}from"./fileType";export{Key}from"./key";export*from"./locale";export*from"./commonProps";
@@ -6,7 +6,11 @@
6
6
  * Default locale
7
7
  *
8
8
  * @type {string}
9
- */export var DEFAULT_LOCALE="en-GB";export var SUPPORTED_RTL=["he-IL"];export var SUPPORTED_LANGUAGES=["en","ja","de","es","fr","hu","id","it","pl","pt","ro","ru","tr","uk","zh"];/**
9
+ */export var DEFAULT_LOCALE="en-GB";/**
10
+ * Array of languages that are written from the right to the left
11
+ *
12
+ * @type {string[]}
13
+ */export var RTL_LANGUAGES=["ar","iw"];export var SUPPORTED_LANGUAGES=["en","ja","de","es","fr","hu","id","it","pl","pt","ro","ru","tr","uk","zh"];/**
10
14
  * Verifies and adjusts locale (replace `_` with `-`)
11
15
  * Returns null if locale is unrecognized by {Intl.Locale}
12
16
  *
@@ -1,4 +1,4 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import classNames from"classnames";import PropTypes from"prop-types";import{useState}from"react";import{useIntl}from"react-intl";import{Size,DateMode,MonthFormat}from"../common";import{getMonthNames,isDateValid,isMonthAndYearFormat}from"../common/dateUtils";import{useDirection}from"../common/hooks";import Select from"../select";import messages from"./DateInput.messages";import{explodeDate,convertToLocalMidnight}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MonthBeforeDay=new Set(["en-US","ja-JP"]),INITIAL_DEFAULT_STATE={year:null,month:null,day:null},DateInput=function(a){var b,c,d,e=a.disabled,f=a.size,g=a.value,h=a.dayLabel,i=a.monthLabel,j=a.yearLabel,k=a.monthFormat,l=a.mode,m=a.onChange,n=a.onFocus,o=a.onBlur,p=a.placeholders,q=a.id,r=useDirection(),s=r.isRTL,t=useIntl(),u=t.locale,v=t.formatMessage,w=function(){return g&&isDateValid(g)?"string"==typeof g?convertToLocalMidnight(g):g:null},x=function(a){var b=INITIAL_DEFAULT_STATE;if(g&&isDateValid(g)){var c=w();b=explodeDate(c),isMonthAndYearFormat(g)&&(b.day=null)}return b[a]},y=useState(function(){return x("day")}),z=_slicedToArray(y,2),A=z[0],B=z[1],C=useState(function(){return x("month")}),D=_slicedToArray(C,2),E=D[0],F=D[1],G=useState(function(){return x("year")}),H=_slicedToArray(G,2),I=H[0],J=H[1],K=useState(w),L=_slicedToArray(K,2),M=L[0],N=L[1];h=h||v(messages.dayLabel),i=i||v(messages.monthLabel),j=j||v(messages.yearLabel),p={day:(null===(b=p)||void 0===b?void 0:b.day)||"DD",month:(null===(c=p)||void 0===c?void 0:c.month)||v(messages.monthLabel),year:(null===(d=p)||void 0===d?void 0:d.year)||"YYYY"};var O=function(a){if(!isDateValid(a))return"";switch(l){case DateMode.MONTH_YEAR:return[a.getFullYear(),"0".concat(a.getMonth()+1).slice(-2)].join("-");case DateMode.DAY_MONTH_YEAR:default:return[a.getFullYear(),"0".concat(a.getMonth()+1).slice(-2),"0".concat(a.getDate()).slice(-2)].join("-");}},P=function(){var a=getMonthNames(u,k);return/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:i}),/*#__PURE__*/_jsx(Select,{name:"month",className:"form-control",disabled:e,placeholder:p.month,options:Q(),size:f,selected:null===E?null:{value:E,label:a[E]},onChange:function(a){return T(a)}})]})},Q=function(){var a=[],b=getMonthNames(u,k);return b.forEach(function(b,c){a.push({value:c,label:b})}),a},R=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:A,b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:E,c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:I,d=null!=a&&null!=b&&null!=c?new Date(c,b,a):null,e=isDateValid(d)?d:null;e||V(INITIAL_DEFAULT_STATE),l===DateMode.MONTH_YEAR?0<=b&&c&&(b!==E||c!==I)&&V(e):a&&0<=b&&c&&(a!==A||b!==E||c!==I)&&V(e)},S=function(a){var b=W(a.target.value,E,I),c=b.checkedDay;B(c),R(c,E,I)},T=function(a){if(!a)return F(null),void R(A,null,I);var b=a?a.value:0,c=W(A,b,I),d=c.checkedDay;F(b),A&&d!==A&&B(d),R(d,b,I)},U=function(a){var b=a.target.value,c=4<b.length?b.slice(0,4):b;if(4===c.toString().length){// Correct day based on year and month.
2
- var d=W(A,E,b),e=d.checkedDay;A&&e!==A&&B(e),J(c),R(e,E,c)}else J(c),R(A,E,null)},V=function(a){a!==M&&(N(a),m(O(a)||null))},W=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,d=a,e=new Date(c||2e3,b+1,0).getDate();return a||(d=null),(a&&0>a||"00"===a)&&(d=1),(a&&b||31<a)&&(d=a>e?e:a),{checkedDay:d,checkedMonth:b,checkedYear:c}},X=l===DateMode.MONTH_YEAR,Y=classNames({"col-sm-8":X,"col-sm-5":!X,"pull-right":s}),Z=MonthBeforeDay.has(u);return/*#__PURE__*/_jsx("div",{className:"tw-date",id:q,onFocus:function onFocus(a){return shouldPropagateOnFocus(a)?n&&n():a.stopPropagation()},onBlur:function onBlur(a){return shouldPropagateOnBlur(a)?o&&o():a.stopPropagation()},children:/*#__PURE__*/_jsxs("div",{className:"row",children:[Z&&/*#__PURE__*/_jsx("div",{className:Y,children:P()}),!X&&/*#__PURE__*/_jsx("div",{className:classNames("col-sm-3",{"pull-right":s}),children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(f),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:h}),/*#__PURE__*/_jsx("input",{type:"number",name:"day",className:"form-control",value:A||"",placeholder:p.day,disabled:e,onChange:function(a){return S(a)}})]})})}),!Z&&/*#__PURE__*/_jsx("div",{className:Y,children:P()}),/*#__PURE__*/_jsx("div",{className:"col-sm-4",children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(f),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:j}),/*#__PURE__*/_jsx("input",{type:"number",name:"year",className:"form-control",placeholder:p.year,value:I||"",disabled:e,onChange:function(a){return U(a)}})]})})})]})})};// Should only propagate if the relatedTarget is not part of this DateInput component.
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import classNames from"classnames";import PropTypes from"prop-types";import{useState}from"react";import{useIntl}from"react-intl";import{Size,DateMode,MonthFormat}from"../common";import{getMonthNames,isDateValid,isMonthAndYearFormat}from"../common/dateUtils";import Select from"../select";import messages from"./DateInput.messages";import{explodeDate,convertToLocalMidnight}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MonthBeforeDay=new Set(["en-US","ja-JP"]),INITIAL_DEFAULT_STATE={year:null,month:null,day:null},DateInput=function(a){var b,c,d,e=a.disabled,f=a.size,g=a.value,h=a.dayLabel,i=a.monthLabel,j=a.yearLabel,k=a.monthFormat,l=a.mode,m=a.onChange,n=a.onFocus,o=a.onBlur,p=a.placeholders,q=a.id,r=useIntl(),s=r.locale,t=r.formatMessage,u=function(){return g&&isDateValid(g)?"string"==typeof g?convertToLocalMidnight(g):g:null},v=function(a){var b=INITIAL_DEFAULT_STATE;if(g&&isDateValid(g)){var c=u();b=explodeDate(c),isMonthAndYearFormat(g)&&(b.day=null)}return b[a]},w=useState(function(){return v("day")}),x=_slicedToArray(w,2),y=x[0],z=x[1],A=useState(function(){return v("month")}),B=_slicedToArray(A,2),C=B[0],D=B[1],E=useState(function(){return v("year")}),F=_slicedToArray(E,2),G=F[0],H=F[1],I=useState(u),J=_slicedToArray(I,2),K=J[0],L=J[1];h=h||t(messages.dayLabel),i=i||t(messages.monthLabel),j=j||t(messages.yearLabel),p={day:(null===(b=p)||void 0===b?void 0:b.day)||"DD",month:(null===(c=p)||void 0===c?void 0:c.month)||t(messages.monthLabel),year:(null===(d=p)||void 0===d?void 0:d.year)||"YYYY"};var M=function(a){if(!isDateValid(a))return"";switch(l){case DateMode.MONTH_YEAR:return[a.getFullYear(),"0".concat(a.getMonth()+1).slice(-2)].join("-");case DateMode.DAY_MONTH_YEAR:default:return[a.getFullYear(),"0".concat(a.getMonth()+1).slice(-2),"0".concat(a.getDate()).slice(-2)].join("-");}},N=function(){var a=getMonthNames(s,k);return/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:i}),/*#__PURE__*/_jsx(Select,{name:"month",className:"form-control",disabled:e,placeholder:p.month,options:O(),size:f,selected:null===C?null:{value:C,label:a[C]},onChange:function(a){return R(a)}})]})},O=function(){var a=[],b=getMonthNames(s,k);return b.forEach(function(b,c){a.push({value:c,label:b})}),a},P=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:y,b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:C,c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:G,d=null!=a&&null!=b&&null!=c?new Date(c,b,a):null,e=isDateValid(d)?d:null;e||T(INITIAL_DEFAULT_STATE),l===DateMode.MONTH_YEAR?0<=b&&c&&(b!==C||c!==G)&&T(e):a&&0<=b&&c&&(a!==y||b!==C||c!==G)&&T(e)},Q=function(a){var b=U(a.target.value,C,G),c=b.checkedDay;z(c),P(c,C,G)},R=function(a){if(!a)return D(null),void P(y,null,G);var b=a?a.value:0,c=U(y,b,G),d=c.checkedDay;D(b),y&&d!==y&&z(d),P(d,b,G)},S=function(a){var b=a.target.value,c=4<b.length?b.slice(0,4):b;if(4===c.toString().length){// Correct day based on year and month.
2
+ var d=U(y,C,b),e=d.checkedDay;y&&e!==y&&z(e),H(c),P(e,C,c)}else H(c),P(y,C,null)},T=function(a){a!==K&&(L(a),m(M(a)||null))},U=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,d=a,e=new Date(c||2e3,b+1,0).getDate();return a||(d=null),(a&&0>a||"00"===a)&&(d=1),(a&&b||31<a)&&(d=a>e?e:a),{checkedDay:d,checkedMonth:b,checkedYear:c}},V=l===DateMode.MONTH_YEAR,W=classNames({"col-sm-8":V,"col-sm-5":!V}),X=MonthBeforeDay.has(s);return/*#__PURE__*/_jsx("div",{className:"tw-date",id:q,onFocus:function onFocus(a){return shouldPropagateOnFocus(a)?n&&n():a.stopPropagation()},onBlur:function onBlur(a){return shouldPropagateOnBlur(a)?o&&o():a.stopPropagation()},children:/*#__PURE__*/_jsxs("div",{className:"row",children:[X&&/*#__PURE__*/_jsx("div",{className:W,children:N()}),!V&&/*#__PURE__*/_jsx("div",{className:"col-sm-3",children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(f),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:h}),/*#__PURE__*/_jsx("input",{type:"number",name:"day",className:"form-control",value:y||"",placeholder:p.day,disabled:e,onChange:function(a){return Q(a)}})]})})}),!X&&/*#__PURE__*/_jsx("div",{className:W,children:N()}),/*#__PURE__*/_jsx("div",{className:"col-sm-4",children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(f),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:j}),/*#__PURE__*/_jsx("input",{type:"number",name:"year",className:"form-control",placeholder:p.year,value:G||"",disabled:e,onChange:function(a){return S(a)}})]})})})]})})};// Should only propagate if the relatedTarget is not part of this DateInput component.
3
3
  function shouldPropagateOnFocus(a){var b=a.target,c=a.relatedTarget,d=b.closest(".tw-date"),e=c&&c.closest(".tw-date");return d!==e}// Should only propagate if the relatedTarget or the activeElement is not part of this DateInput component.
4
4
  function shouldPropagateOnBlur(a){var b=a.target,c=a.relatedTarget,d=b.closest(".tw-date"),e=c||(document.activeElement===b?null:document.activeElement),f=e&&e.closest(".tw-date");return d!==f}DateInput.propTypes={disabled:PropTypes.bool,size:PropTypes.oneOf(["sm","md","lg"]),value:PropTypes.oneOfType([PropTypes.string,PropTypes.instanceOf(Date)]),onChange:PropTypes.func.isRequired,onFocus:PropTypes.func,onBlur:PropTypes.func,dayLabel:PropTypes.string,monthLabel:PropTypes.string,yearLabel:PropTypes.string,monthFormat:PropTypes.oneOf(["long","short"]),mode:PropTypes.oneOf(["day-month-year","month-year"]),placeholders:PropTypes.shape({day:PropTypes.node,month:PropTypes.node,year:PropTypes.node}),id:PropTypes.string},DateInput.defaultProps={disabled:!1,size:Size.MEDIUM,value:null,onFocus:null,onBlur:null,monthFormat:MonthFormat.LONG,mode:DateMode.DAY_MONTH_YEAR,id:""};export default DateInput;
@@ -1,5 +1,5 @@
1
- import classNames from"classnames";import PropTypes from"prop-types";import requiredIf from"react-required-if";import{Size,Breakpoint}from"../common";import{useDirection}from"../common/hooks";import NavigationOption from"../navigationOption";import SizeSwapper from"../sizeSwapper";import Tile from"../tile";import{Presentation,Type}from"./decisionEnums";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var Decision=function(a){var b=a.options,c=a.presentation,d=a.type,e=a.size,f=useDirection(),g=f.isRTL;if(d===Type.NAVIGATION){var h=Presentation.LIST_BLOCK,i=Presentation.LIST_BLOCK_GRID;if(c===h||c===i){var j=e===Size.SMALL,k=c===i,l=[{items:[],layout:SizeSwapper.Layout.COLUMN},{items:[],breakpoint:j?Breakpoint.EXTRA_SMALL:Breakpoint.SMALL,wrap:k}];return b.forEach(function(a,b){var c=a.description,d=a.disabled,e=a.href,f=a.target,g=a.media,h=g.block,i=g.list,m=a.onClick,n=a.title;l[0].items.push(/*#__PURE__*/_jsx(NavigationOption// eslint-disable-next-line react/no-array-index-key
2
- ,{complex:!1,content:c,disabled:d,href:e,target:f,media:i,showMediaAtAllSizes:!0,title:n,onClick:m},"nav-".concat(b))),l[1].items.push(/*#__PURE__*/_jsx(Tile// eslint-disable-next-line react/no-array-index-key
3
- ,{className:classNames("np-decision__tile".concat(j?"--small":""),{"np-decision__tile--fixed-width":k}),description:c,disabled:d,href:e,target:f,media:h,size:j?Size.SMALL:Size.MEDIUM,title:n,onClick:m},"tile-".concat(b)))}),/*#__PURE__*/_jsx("div",{className:classNames("np-decision",{"np-decision--small":j,"np-decision--grid":k,"np-decision--rtl":g}),children:/*#__PURE__*/_jsx(SizeSwapper,{items:l})})}// LIST
1
+ import classNames from"classnames";import PropTypes from"prop-types";import requiredIf from"react-required-if";import{Size,Breakpoint}from"../common";import NavigationOption from"../navigationOption";import SizeSwapper from"../sizeSwapper";import Tile from"../tile";import{Presentation,Type}from"./decisionEnums";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var Decision=function(a){var b=a.options,c=a.presentation,d=a.type,e=a.size;if(d===Type.NAVIGATION){var f=Presentation.LIST_BLOCK,g=Presentation.LIST_BLOCK_GRID;if(c===f||c===g){var h=e===Size.SMALL,i=c===g,j=[{items:[],layout:SizeSwapper.Layout.COLUMN},{items:[],breakpoint:h?Breakpoint.EXTRA_SMALL:Breakpoint.SMALL,wrap:i}];return b.forEach(function(a,b){var c=a.description,d=a.disabled,e=a.href,f=a.target,g=a.media,k=g.block,l=g.list,m=a.onClick,n=a.title;j[0].items.push(/*#__PURE__*/_jsx(NavigationOption// eslint-disable-next-line react/no-array-index-key
2
+ ,{complex:!1,content:c,disabled:d,href:e,target:f,media:l,showMediaAtAllSizes:!0,title:n,onClick:m},"nav-".concat(b))),j[1].items.push(/*#__PURE__*/_jsx(Tile// eslint-disable-next-line react/no-array-index-key
3
+ ,{className:classNames("np-decision__tile".concat(h?"--small":""),{"np-decision__tile--fixed-width":i}),description:c,disabled:d,href:e,target:f,media:k,size:h?Size.SMALL:Size.MEDIUM,title:n,onClick:m},"tile-".concat(b)))}),/*#__PURE__*/_jsx("div",{className:classNames("np-decision",{"np-decision--small":h,"np-decision--grid":i}),children:/*#__PURE__*/_jsx(SizeSwapper,{items:j})})}// LIST
4
4
  return b.map(function(a,b){var c=a.title,d=a.description,e=a.disabled,f=a.href,g=a.target,h=a.media.list,i=a.onClick;return/*#__PURE__*/_jsx(NavigationOption// eslint-disable-next-line react/no-array-index-key
5
5
  ,{complex:!1,content:d,disabled:e,href:f,target:g,media:h,showMediaAtAllSizes:!0,title:c,onClick:i},"nav-".concat(b))})}return/*#__PURE__*/_jsx(_Fragment,{})};Decision.propTypes={/** A list of elements to be rendered */options:PropTypes.arrayOf(PropTypes.shape({description:PropTypes.node,disabled:PropTypes.bool,href:requiredIf(PropTypes.string,function(a){return a.type===Type.NAVIGATION}),target:PropTypes.oneOf(["_self","_blank","_parent","_top"]),media:PropTypes.shape({block:PropTypes.node.isRequired,list:PropTypes.node.isRequired}),onClick:PropTypes.func.isRequired,title:PropTypes.node.isRequired})).isRequired,/** Handles the display mode of the component */presentation:PropTypes.oneOf(["LIST","LIST_BLOCK","LIST_BLOCK_GRID"]),/** Size currently affects only Tile dimension */size:PropTypes.oneOf(["sm","md"]),/** Decide which kind of element type needs to be rendered ex: Navigation Options or in the future Radio or Checkbox Options */type:PropTypes.oneOf(["NAVIGATION"])},Decision.defaultProps={presentation:Presentation.LIST,size:Size.MEDIUM,type:Type.NAVIGATION};export default Decision;
@@ -1 +1 @@
1
- import classNames from"classnames";import PropTypes from"prop-types";import CloseButton from"../common/closeButton";import{Position}from"../common/propsValues/position";import Dimmer from"../dimmer";import SlidingPanel from"../slidingPanel";import{logActionRequiredIf}from"../utilities";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Drawer=function(a){var b=a.children,c=a.footerContent,d=a.headerTitle,e=a.onClose,f=a.open,g=a.position;return logActionRequiredIf("Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.",!e),/*#__PURE__*/_jsx(Dimmer,{open:f,onClose:e,children:/*#__PURE__*/_jsx(SlidingPanel,{open:f,position:g,children:/*#__PURE__*/_jsxs("div",{className:"np-drawer",children:[/*#__PURE__*/_jsxs("div",{className:classNames("np-drawer-header",{"np-drawer-header--withborder":d}),children:[/*#__PURE__*/_jsx(CloseButton,{onClick:e}),d&&/*#__PURE__*/_jsx("div",{className:"np-drawer-header--title h3",children:d})]}),b&&/*#__PURE__*/_jsx("div",{className:classNames("np-drawer-content"),children:b}),c&&/*#__PURE__*/_jsx("div",{className:classNames("np-drawer-footer"),children:c})]})})})};Drawer.propTypes={/** The content to appear in the drawer body. */children:PropTypes.node,/** The content to appear in the drawer footer. */footerContent:PropTypes.node,/** The content to appear in the drawer header. */headerTitle:PropTypes.string,/** The action to perform on close click. */onClose:PropTypes.func,/** The status of Drawer either open or not. */open:PropTypes.bool,/** The placement of Drawer on the screen either left or right. */position:PropTypes.oneOf(["left","right"])},Drawer.defaultProps={children:null,footerContent:null,headerTitle:null,onClose:null,open:!1,position:Position.RIGHT};export default Drawer;
1
+ import classNames from"classnames";import PropTypes from"prop-types";import CloseButton from"../common/closeButton";import{Position}from"../common/propsValues/position";import Dimmer from"../dimmer";import SlidingPanel from"../slidingPanel";import{logActionRequiredIf}from"../utilities";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Drawer=function(a){var b=a.children,c=a.footerContent,d=a.headerTitle,e=a.onClose,f=a.open,g=a.position;return logActionRequiredIf("Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.",!e),/*#__PURE__*/_jsx(Dimmer,{open:f,onClose:e,children:/*#__PURE__*/_jsx(SlidingPanel,{open:f,position:g,children:/*#__PURE__*/_jsxs("div",{className:"np-drawer",children:[/*#__PURE__*/_jsxs("div",{className:classNames("np-drawer-header",{"np-drawer-header--withborder":d}),children:[/*#__PURE__*/_jsx(CloseButton,{onClick:e}),d&&/*#__PURE__*/_jsx("div",{className:"np-drawer-header--title title-3",children:d})]}),b&&/*#__PURE__*/_jsx("div",{className:classNames("np-drawer-content"),children:b}),c&&/*#__PURE__*/_jsx("div",{className:classNames("np-drawer-footer"),children:c})]})})})};Drawer.propTypes={/** The content to appear in the drawer body. */children:PropTypes.node,/** The content to appear in the drawer footer. */footerContent:PropTypes.node,/** The content to appear in the drawer header. */headerTitle:PropTypes.string,/** The action to perform on close click. */onClose:PropTypes.func,/** The status of Drawer either open or not. */open:PropTypes.bool,/** The placement of Drawer on the screen either left or right. */position:PropTypes.oneOf(["left","right"])},Drawer.defaultProps={children:null,footerContent:null,headerTitle:null,onClose:null,open:!1,position:Position.RIGHT};export default Drawer;
@@ -1 +1 @@
1
- import PropTypes from"prop-types";import{Layout}from"../common";import{prepFields}from"../common/requirements";import DefinitionList from"../definitionList";import createDefinitions from"./utils/createDefinitions";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 DynamicFieldDefinitionList=function(a){var b=a.model,c=a.title,d=a.layout,e=a.fields;return/*#__PURE__*/_jsxs(_Fragment,{children:[c&&/*#__PURE__*/_jsx("div",{className:"m-t-1",children:/*#__PURE__*/_jsx("div",{className:"p-t-3 h4",children:c})}),/*#__PURE__*/_jsx(DefinitionList,{layout:d,definitions:createDefinitions(prepFields(e),b)})]})};DynamicFieldDefinitionList.propTypes={model:PropTypes.shape({}).isRequired,fields:PropTypes.shape({}).isRequired,title:PropTypes.string,layout:PropTypes.oneOf(["VERTICAL_TWO_COLUMN","VERTICAL_ONE_COLUMN","HORIZONTAL_JUSTIFIED","HORIZONTAL_LEFT_ALIGNED"])},DynamicFieldDefinitionList.defaultProps={title:null,layout:Layout.VERTICAL_TWO_COLUMN};export default DynamicFieldDefinitionList;
1
+ import PropTypes from"prop-types";import{Layout}from"../common";import{prepFields}from"../common/requirements";import DefinitionList from"../definitionList";import createDefinitions from"./utils/createDefinitions";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 DynamicFieldDefinitionList=function(a){var b=a.model,c=a.title,d=a.layout,e=a.fields;return/*#__PURE__*/_jsxs(_Fragment,{children:[c&&/*#__PURE__*/_jsx("div",{className:"m-t-1",children:/*#__PURE__*/_jsx("div",{className:"p-t-3 title-4",children:c})}),/*#__PURE__*/_jsx(DefinitionList,{layout:d,definitions:createDefinitions(prepFields(e),b)})]})};DynamicFieldDefinitionList.propTypes={model:PropTypes.shape({}).isRequired,fields:PropTypes.shape({}).isRequired,title:PropTypes.string,layout:PropTypes.oneOf(["VERTICAL_TWO_COLUMN","VERTICAL_ONE_COLUMN","HORIZONTAL_JUSTIFIED","HORIZONTAL_LEFT_ALIGNED"])},DynamicFieldDefinitionList.defaultProps={title:null,layout:Layout.VERTICAL_TWO_COLUMN};export default DynamicFieldDefinitionList;
@@ -2,7 +2,7 @@ import{formatDate,formatNumber}from"@transferwise/formatting";import classNames
2
2
  *
3
3
  * @param {Array} options
4
4
  * @param {string|number} value
5
- */import{jsx as _jsx}from"react/jsx-runtime";var getValueLabel=function(a,b){var c=a.find(function(a){return a.value===b});return c&&c.label?c.label:b},mask=function(a){return Array(a.length+1).join("*")},FormattedValue=function(a){var b=a.field,c=a.value,d=useIntl(),e=d.locale,f=[];switch(b.tagClassName&&b.tagClassName.h3&&(f.push("h3"),f.push("formatted-value__h3-custom-alignment")),b.control){case"select":case"radio":return/*#__PURE__*/_jsx("span",{children:getValueLabel(b.values,c)});case"date":return/*#__PURE__*/_jsx("span",{children:formatDate(c instanceof Date?c:new Date(c),e)});case"number":return/*#__PURE__*/_jsx("span",{children:formatNumber(c,e)});case"password":return/*#__PURE__*/_jsx("span",{children:mask(c)});case"file":return/*#__PURE__*/_jsx("div",{className:"thumbnail",children:/*#__PURE__*/_jsx("img",{alt:b.title,src:c})});case"checkbox":return/*#__PURE__*/_jsx("span",{children:JSON.stringify(c)});default:return/*#__PURE__*/_jsx("span",{className:classNames(f),children:formatUsingPattern(c,b.displayFormat)});}};/**
5
+ */import{jsx as _jsx}from"react/jsx-runtime";var getValueLabel=function(a,b){var c=a.find(function(a){return a.value===b});return c&&c.label?c.label:b},mask=function(a){return Array(a.length+1).join("*")},FormattedValue=function(a){var b=a.field,c=a.value,d=useIntl(),e=d.locale,f=[];switch(b.tagClassName&&b.tagClassName.h3&&(f.push("title-3"),f.push("formatted-value__h3-custom-alignment")),b.control){case"select":case"radio":return/*#__PURE__*/_jsx("span",{children:getValueLabel(b.values,c)});case"date":return/*#__PURE__*/_jsx("span",{children:formatDate(c instanceof Date?c:new Date(c),e)});case"number":return/*#__PURE__*/_jsx("span",{children:formatNumber(c,e)});case"password":return/*#__PURE__*/_jsx("span",{children:mask(c)});case"file":return/*#__PURE__*/_jsx("div",{className:"thumbnail",children:/*#__PURE__*/_jsx("img",{alt:b.title,src:c})});case"checkbox":return/*#__PURE__*/_jsx("span",{children:JSON.stringify(c)});default:return/*#__PURE__*/_jsx("span",{className:classNames(f),children:formatUsingPattern(c,b.displayFormat)});}};/**
6
6
  *
7
7
  * @param {string} value
8
8
  */FormattedValue.propTypes={field:PropTypes.shape({control:PropTypes.string.isRequired,displayFormat:PropTypes.string,refreshRequirementsOnChange:PropTypes.bool,title:PropTypes.string.isRequired,type:PropTypes.string.isRequired,width:PropTypes.string,tagClassName:PropTypes.shape({h3:PropTypes.bool}),values:PropTypes.arrayOf(PropTypes.shape({value:PropTypes.any}))}).isRequired,value:PropTypes.any.isRequired};export default FormattedValue;
@@ -1,2 +1,2 @@
1
1
  import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import classNames from"classnames";import PropTypes from"prop-types";import{useRef}from"react";import{Breakpoint,Layout}from"../common";import CloseButton from"../common/closeButton";import{useClientWidth}from"../common/hooks";import Header from"../header";import Logo from"../logo";import Stepper from"../stepper";import AnimatedLabel from"./animatedLabel";import BackButton from"./backButton";// Size switches on parent container which may or may not have the same size as the window.
2
- 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 containerBreakpoints={"np-flow-navigation--sm":Breakpoint.SMALL,"np-flow-navigation--lg":Breakpoint.LARGE},FlowNavigation=function(a){var b=a.activeStep,c=a.avatar,d=a.logo,e=a.onClose,f=a.onGoBack,g=a.done,h=a.steps,i=useRef(null),j=useClientWidth({ref:i}),k=_slicedToArray(j,1),l=k[0],m=e&&/*#__PURE__*/_jsx(CloseButton,{onClick:e}),n=l<Breakpoint.SMALL,o=g?null:c;return/*#__PURE__*/_jsx("div",{ref:i,className:classNames("np-flow-navigation d-flex align-items-center justify-content-center p-y-3",{"np-flow-navigation--border-bottom":!g}),children:/*#__PURE__*/_jsx(Header,{className:classNames("np-flow-navigation__content p-x-3",{"np-flow-navigation--hidden":!l,"np-flow-navigation--xs-max":n},Object.keys(containerBreakpoints).filter(function(a){return l>=containerBreakpoints[a]})),leftContent:n?function getLeftContentSmall(){var a=f&&0<b;return/*#__PURE__*/_jsxs(_Fragment,{children:[a&&/*#__PURE__*/_jsx(BackButton,{label:/*#__PURE__*/_jsx(AnimatedLabel,{className:"m-x-1",labels:h.map(function(a){return a.label}),activeLabel:b-1}),onClick:f}),/*#__PURE__*/_jsx("div",{className:classNames("np-flow-navigation--flag",{"np-flow-navigation--flag__hidden":a,"np-flow-navigation--flag__display":!a})})]})}():d,rightContent:/*#__PURE__*/_jsxs(_Fragment,{children:[o,o&&m&&/*#__PURE__*/_jsx("span",{className:"separator"}),m]}),bottomContent:!g&&/*#__PURE__*/_jsx(Stepper,{activeStep:b,steps:h,className:classNames("np-flow-navigation__stepper")}),layout:l<Breakpoint.LARGE?Layout.VERTICAL:Layout.HORIZONTAL})})};FlowNavigation.defaultProps={activeStep:0,avatar:void 0,logo:/*#__PURE__*/_jsx(Logo,{}),onGoBack:void 0,onClose:void 0,done:!1},FlowNavigation.propTypes={activeStep:PropTypes.number,/** An Avatar */avatar:PropTypes.element,logo:PropTypes.node,/** Called when the close button is clicked. If not provided the close button won't show */onClose:PropTypes.func,/** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */onGoBack:PropTypes.func,done:PropTypes.bool,/** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */steps:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.node.isRequired,onClick:PropTypes.func,hoverLabel:PropTypes.node})).isRequired};export default FlowNavigation;
2
+ 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 containerBreakpoints={"np-flow-navigation--sm":Breakpoint.SMALL,"np-flow-navigation--lg":Breakpoint.LARGE},FlowNavigation=function(a){var b=a.activeStep,c=a.avatar,d=a.logo,e=a.onClose,f=a.onGoBack,g=a.done,h=a.steps,i=useRef(null),j=useClientWidth({ref:i}),k=_slicedToArray(j,1),l=k[0],m=e&&/*#__PURE__*/_jsx(CloseButton,{onClick:e}),n=l<Breakpoint.SMALL,o=g?null:c;return/*#__PURE__*/_jsx("div",{ref:i,className:classNames("np-flow-navigation d-flex align-items-center justify-content-center p-y-3",{"np-flow-navigation--border-bottom":!g}),children:/*#__PURE__*/_jsx(Header,{className:classNames("np-flow-navigation__content p-x-3",{"np-flow-navigation--hidden":!l,"np-flow-navigation--xs-max":n},Object.keys(containerBreakpoints).filter(function(a){return l>=containerBreakpoints[a]})),leftContent:n?function getLeftContentSmall(){return/*#__PURE__*/_jsx(_Fragment,{children:f&&0<b?/*#__PURE__*/_jsx(BackButton,{label:/*#__PURE__*/_jsx(AnimatedLabel,{className:"m-x-1",labels:h.map(function(a){return a.label}),activeLabel:b-1}),onClick:f}):d})}():d,rightContent:/*#__PURE__*/_jsxs(_Fragment,{children:[o,o&&m&&/*#__PURE__*/_jsx("span",{className:"separator"}),m]}),bottomContent:!g&&/*#__PURE__*/_jsx(Stepper,{activeStep:b,steps:h,className:classNames("np-flow-navigation__stepper")}),layout:l<Breakpoint.LARGE?Layout.VERTICAL:Layout.HORIZONTAL})})};FlowNavigation.defaultProps={activeStep:0,avatar:void 0,logo:/*#__PURE__*/_jsx(Logo,{}),onGoBack:void 0,onClose:void 0,done:!1},FlowNavigation.propTypes={activeStep:PropTypes.number,/** An Avatar */avatar:PropTypes.element,logo:PropTypes.node,/** Called when the close button is clicked. If not provided the close button won't show */onClose:PropTypes.func,/** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */onGoBack:PropTypes.func,done:PropTypes.bool,/** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */steps:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.node.isRequired,onClick:PropTypes.func,hoverLabel:PropTypes.node})).isRequired};export default FlowNavigation;
@@ -2,12 +2,12 @@
2
2
  * Types
3
3
  */ /**
4
4
  * Components
5
- */export{default as Provider}from"./provider";export{default as Badge}from"./badge";export{default as Checkbox}from"./checkbox";export{default as CheckboxButton}from"./checkboxButton";export{default as Loader}from"./loader";export{default as Radio}from"./radio";export{default as Select}from"./select";export{default as MoneyInput}from"./moneyInput";export{default as Tooltip}from"./tooltip";export{default as Stepper}from"./stepper";export{default as FlowNavigation}from"./flowNavigation";export{default as Popover}from"./popover";export{default as Money}from"./money";export{default as Modal}from"./modal";export{default as RadioOption}from"./radioOption";export{default as CheckboxOption}from"./checkboxOption";export{default as NavigationOption}from"./navigationOption";export{default as NavigationOptionsList}from"./navigationOptionsList";export{default as DateLookup}from"./dateLookup";export{default as PhoneNumberInput}from"./phoneNumberInput";export{default as DateInput}from"./dateInput";export{default as InstructionsList}from"./instructionsList";export{default as ProcessIndicator}from"./processIndicator";export{default as Upload}from"./upload";export{default as DefinitionList}from"./definitionList";export{default as DynamicFieldDefinitionList}from"./dynamicFieldDefinitionList";export{default as Emphasis}from"./emphasis";export{default as Avatar}from"./avatar";export{default as Button}from"./button";export{default as CircularButton}from"./circularButton";export{default as RadioGroup}from"./radioGroup";export{default as Alert}from"./alert";export{default as InputWithDisplayFormat}from"./inputWithDisplayFormat";export{default as TextareaWithDisplayFormat}from"./textareaWithDisplayFormat";export{default as Chevron}from"./chevron";export{default as Accordion}from"./accordion";export{default as Dimmer}from"./dimmer";export{default as SlidingPanel}from"./slidingPanel";export{default as Drawer}from"./drawer";export{default as Sticky}from"./sticky";export{default as Chip}from"./chip";export{default as Typeahead}from"./typeahead";export{default as SnackbarPortal}from"./snackbar/Snackbar";export{default as SnackbarProvider}from"./snackbar/SnackbarProvider";export{SnackbarConsumer,SnackbarContext}from"./snackbar/SnackbarContext";export{default as Tabs}from"./tabs";export{default as OverlayHeader}from"./overlayHeader";export{default as Image}from"./image";export{default as Markdown}from"./markdown";export{default as Card}from"./card";export{default as Summary}from"./summary";export{default as Switch}from"./switch";export{default as SwitchOption}from"./switchOption";export{default as Decision}from"./decision";export{default as Nudge}from"./nudge";export{default as InlineAlert}from"./inlineAlert";export{default as AvatarWrapper}from"./avatarWrapper";export{default as Info}from"./info";export{default as Logo}from"./logo";export{default as BottomSheet}from"./common/bottomSheet";export{default as ActionOption}from"./actionOption";export{default as Link}from"./link";export{default as UploadInput}from"./uploadInput";/**
5
+ */export{default as Provider,DirectionProvider}from"./provider";export{default as Badge}from"./badge";export{default as Checkbox}from"./checkbox";export{default as CheckboxButton}from"./checkboxButton";export{default as Loader}from"./loader";export{default as Radio}from"./radio";export{default as Select}from"./select";export{default as MoneyInput}from"./moneyInput";export{default as Tooltip}from"./tooltip";export{default as Stepper}from"./stepper";export{default as FlowNavigation}from"./flowNavigation";export{default as Popover}from"./popover";export{default as Money}from"./money";export{default as Modal}from"./modal";export{default as RadioOption}from"./radioOption";export{default as CheckboxOption}from"./checkboxOption";export{default as NavigationOption}from"./navigationOption";export{default as NavigationOptionsList}from"./navigationOptionsList";export{default as DateLookup}from"./dateLookup";export{default as PhoneNumberInput}from"./phoneNumberInput";export{default as DateInput}from"./dateInput";export{default as InstructionsList}from"./instructionsList";export{default as ProcessIndicator}from"./processIndicator";export{default as Upload}from"./upload";export{default as DefinitionList}from"./definitionList";export{default as DynamicFieldDefinitionList}from"./dynamicFieldDefinitionList";export{default as Emphasis}from"./emphasis";export{default as Avatar}from"./avatar";export{default as Button}from"./button";export{default as CircularButton}from"./circularButton";export{default as RadioGroup}from"./radioGroup";export{default as Alert}from"./alert";export{default as InputWithDisplayFormat}from"./inputWithDisplayFormat";export{default as TextareaWithDisplayFormat}from"./textareaWithDisplayFormat";export{default as Chevron}from"./chevron";export{default as Accordion}from"./accordion";export{default as Dimmer}from"./dimmer";export{default as SlidingPanel}from"./slidingPanel";export{default as Drawer}from"./drawer";export{default as Sticky}from"./sticky";export{default as Chip}from"./chip";export{default as Typeahead}from"./typeahead";export{default as SnackbarPortal}from"./snackbar/Snackbar";export{default as SnackbarProvider}from"./snackbar/SnackbarProvider";export{SnackbarConsumer,SnackbarContext}from"./snackbar/SnackbarContext";export{default as Tabs}from"./tabs";export{default as OverlayHeader}from"./overlayHeader";export{default as Image}from"./image";export{default as Markdown}from"./markdown";export{default as Card}from"./card";export{default as Summary}from"./summary";export{default as Switch}from"./switch";export{default as SwitchOption}from"./switchOption";export{default as Decision}from"./decision";export{default as Nudge}from"./nudge";export{default as InlineAlert}from"./inlineAlert";export{default as AvatarWrapper}from"./avatarWrapper";export{default as Info}from"./info";export{default as Logo}from"./logo";export{default as BottomSheet}from"./common/bottomSheet";export{default as ActionOption}from"./actionOption";export{default as Link}from"./link";export{default as UploadInput}from"./uploadInput";/**
6
6
  * Hooks
7
7
  */export{default as useSnackbar}from"./snackbar/useSnackbar";/**
8
8
  * Enums
9
- */export{Size,Width,Sentiment,Priority,ControlType,Type,Theme,DateMode,MonthFormat,Position,Scroll,ProfileType,Breakpoint,Layout,Status,MarkdownNodeType}from"./common";export{AvatarType}from"./avatar";export{InfoPresentation}from"./info";export{UploadStep}from"./upload";export{DecisionPresentation,DecisionType}from"./decision";export{AlertArrowPosition}from"./alert/withArrow";export{LogoType}from"./logo";export{FileType}from"./common";/**
9
+ */export{Direction,Size,Width,Sentiment,Priority,ControlType,Type,Theme,DateMode,MonthFormat,Position,Scroll,ProfileType,Breakpoint,Layout,Status,MarkdownNodeType}from"./common";export{AvatarType}from"./avatar";export{InfoPresentation}from"./info";export{UploadStep}from"./upload";export{DecisionPresentation,DecisionType}from"./decision";export{AlertArrowPosition}from"./alert/withArrow";export{LogoType}from"./logo";export{FileType}from"./common";/**
10
10
  * Utils
11
- */export{SUPPORTED_LANGUAGES,DEFAULT_LANG,DEFAULT_LOCALE,adjustLocale,getLangFromLocale,getCountryFromLocale}from"./common";/**
11
+ */export{SUPPORTED_LANGUAGES,RTL_LANGUAGES,DEFAULT_LANG,DEFAULT_LOCALE,adjustLocale,getLangFromLocale,getCountryFromLocale,isServerSide,isBrowser}from"./common";/**
12
12
  * Translations
13
13
  */export{default as translations}from"./i18n";
@@ -1 +1 @@
1
- import classNames from"classnames";import PropTypes from"prop-types";import{LogoType}from"./logoTypes";import{jsx as _jsx}from"react/jsx-runtime";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"},Logo=function(a){var b=a.className,c=a.inverse,d=a.type,e=logoPaths["".concat(d).concat(c?"_INVERSE":"")];return/*#__PURE__*/_jsx("img",{className:classNames("np-logo",b),alt:d===LogoType.WISE?"Wise":"Wise business",src:"".concat(baseUrl).concat(e)})};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 _slicedToArray from"@babel/runtime/helpers/slicedToArray";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 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"},Logo=function(a){var b=a.className,c=a.inverse,d=a.type,e=useClientWidth({ref:isServerSide()?void 0:window}),f=_slicedToArray(e,1),g=f[0],h=g<Breakpoint.SMALL,i=h?logoPaths.WISE_FLAG:logoPaths["".concat(d).concat(c?"_INVERSE":"")];return/*#__PURE__*/_jsx("img",{className:classNames("np-logo",b),alt:d===LogoType.WISE?"Wise":"Wise business",src:"".concat(baseUrl).concat(i)})};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{Cross as CrossIcon}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{useDirection}from"../common/hooks";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Nudge=function(a){var b=a.media,c=a.title,d=a.link,e=a.href,f=a.onClick,g=a.onDismiss,h=a.id,i=a.className,j=useDirection(),k=j.isRTL;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-nudge media",i),id:h,children:[/*#__PURE__*/_jsx("div",{className:classNames({"media-left":!k,"media-right":k}),children:b}),/*#__PURE__*/_jsxs("div",{className:"media-body",children:[/*#__PURE__*/_jsx("div",{className:"tw-nudge__title media-heading h5",children:c}),/*#__PURE__*/_jsx("a",{href:e,className:"tw-nudge__link",onClick:f,children:d})]}),/*#__PURE__*/_jsx("div",{className:classNames({"media-right":!k,"media-left":k}),children:/*#__PURE__*/_jsx("button",{type:"button",className:"close","aria-label":"close",onClick:g,children:/*#__PURE__*/_jsx(CrossIcon,{})})})]})};Nudge.propTypes={media:PropTypes.node.isRequired,title:PropTypes.node.isRequired,link:PropTypes.node.isRequired,href:PropTypes.string.isRequired,onClick:PropTypes.func,onDismiss:PropTypes.func.isRequired,id:PropTypes.string,className:PropTypes.string},Nudge.defaultProps={id:null,className:null,onClick:void 0};export default Nudge;
1
+ import classNames from"classnames";import PropTypes from"prop-types";import CloseButton from"../common/closeButton";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Nudge=function(a){var b=a.media,c=a.title,d=a.link,e=a.href,f=a.onClick,g=a.onDismiss,h=a.id,i=a.className;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-nudge media",i),id:h,children:[/*#__PURE__*/_jsx("div",{className:"media-left",children:b}),/*#__PURE__*/_jsxs("div",{className:"media-body",children:[/*#__PURE__*/_jsx("div",{className:"tw-nudge__title media-heading title-4",children:c}),/*#__PURE__*/_jsx("a",{href:e,className:"tw-nudge__link",onClick:f,children:d})]}),/*#__PURE__*/_jsx("div",{className:"media-right",children:/*#__PURE__*/_jsx(CloseButton,{size:16,onClick:g})})]})};Nudge.propTypes={media:PropTypes.node.isRequired,title:PropTypes.node.isRequired,link:PropTypes.node.isRequired,href:PropTypes.string.isRequired,onClick:PropTypes.func,onDismiss:PropTypes.func.isRequired,id:PropTypes.string,className:PropTypes.string},Nudge.defaultProps={id:null,className:null,onClick:void 0};export default Nudge;
@@ -1 +1 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{isArray}from"@transferwise/neptune-validation";import classNames from"classnames";import PropTypes from"prop-types";import{useState,useEffect}from"react";import{useIntl}from"react-intl";import{Size}from"../common";import{useDirection}from"../common/hooks";import Select from"../select";import countries from"./data/countries";import{explodeNumberModel,filterOptionsForQuery,isValidPhoneNumber,cleanNumber,setDefaultPrefix,isStringNumeric,sortArrayByProperty,groupCountriesByPrefix}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var ALLOWED_PHONE_CHARS=/^$|^[\d-\s]+$/,PhoneNumberInput=function(a){var b=a.onChange,c=a.searchPlaceholder,d=a.disabled,e=a.required,f=a.size,g=a.placeholder,h=a.onFocus,i=a.onBlur,j=a.countryCode,k=useIntl(),l=k.locale,m=useDirection(),n=m.isRTL,o=function(){var b=a.initialValue,c=b?cleanNumber(b):null;return c&&isValidPhoneNumber(c)?c:null},p=useState(o()),q=_slicedToArray(p,2),r=q[0],s=q[1],t=useState(o()),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useState(""),y=_slicedToArray(x,2),z=y[0],A=y[1],B=groupCountriesByPrefix(sortArrayByProperty(countries,"iso3")),C=groupCountriesByPrefix(sortArrayByProperty(countries,"phone")),D=function(a){var b=setDefaultPrefix(l,j),c="";if(a){var d=explodeNumberModel(a);b=d.prefix,c=d.suffix}return{prefix:b,suffix:c}},E=function getSelectOptions(){var a=filterOptionsForQuery(isStringNumeric(z)?C:B,z);return a.map(function(a){var b=a.phone,c=a.iso3,d=a.iso2,e="";return c?e=isArray(c)?c.join(", "):c:d&&(e=isArray(d)?d.join(", "):d),{value:b,label:b,note:e}})}();useEffect(function(){var a=isValidPhoneNumber(r)?cleanNumber(r):null;a!==v&&(b(a),w({newbroadcastValue:a}))},[r]);var F=D(r),G=F.prefix,H=F.suffix;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-telephone",{"tw-telephone--rtl":n}),children:[/*#__PURE__*/_jsx("div",{className:"tw-telephone__country-select",children:/*#__PURE__*/_jsx(Select,{options:E,selected:{value:G,label:G},placeholder:"Select an option...",searchPlaceholder:c,searchValue:z,required:e,disabled:d,size:f,onChange:function handleChangeSelect(a){var b=D(r),c=b.suffix,d=a.value;A(""),s(d+c)},onSearchChange:function onSearchChange(a){return A(a)}})}),/*#__PURE__*/_jsx("div",{className:"tw-telephone__number-input",children:/*#__PURE__*/_jsx("div",{className:"input-group input-group-".concat(f),children:/*#__PURE__*/_jsx("input",{name:"phoneNumber",inputMode:"numeric",value:H,type:"text",className:"form-control",disabled:d,required:e,placeholder:g,onChange:function handleInputChange(a){var b=a.target.value;if(ALLOWED_PHONE_CHARS.test(b)){var c=D(r),d=c.prefix;s(d+b)}},onPaste:function handlePaste(a){if(a.nativeEvent.clipboardData){var b=(a.nativeEvent.clipboardData.getData("text/plain")||"").replace(/(\s|-)+/g,""),c=E.find(function(a){var c=a.value;return new RegExp("^\\".concat(c)).test(b)});c&&ALLOWED_PHONE_CHARS.test(b.replace(c.value,""))&&s(b)}},onFocus:h,onBlur:i})})})]})};PhoneNumberInput.propTypes={required:PropTypes.bool,disabled:PropTypes.bool,initialValue:PropTypes.string,onChange:PropTypes.func.isRequired,onFocus:PropTypes.func,onBlur:PropTypes.func,countryCode:PropTypes.string,searchPlaceholder:PropTypes.string,size:PropTypes.oneOf(["sm","md","lg"]),placeholder:PropTypes.string},PhoneNumberInput.defaultProps={required:!1,disabled:!1,initialValue:null,onFocus:function onFocus(){},onBlur:function onBlur(){},countryCode:null,searchPlaceholder:"Prefix",size:Size.MEDIUM,placeholder:""};export default PhoneNumberInput;
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{isArray}from"@transferwise/neptune-validation";import PropTypes from"prop-types";import{useState,useEffect}from"react";import{useIntl}from"react-intl";import{Size}from"../common";import Select from"../select";import countries from"./data/countries";import{explodeNumberModel,filterOptionsForQuery,isValidPhoneNumber,cleanNumber,setDefaultPrefix,isStringNumeric,sortArrayByProperty,groupCountriesByPrefix}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var ALLOWED_PHONE_CHARS=/^$|^[\d-\s]+$/,PhoneNumberInput=function(a){var b=a.onChange,c=a.searchPlaceholder,d=a.disabled,e=a.required,f=a.size,g=a.placeholder,h=a.onFocus,i=a.onBlur,j=a.countryCode,k=useIntl(),l=k.locale,m=function(){var b=a.initialValue,c=b?cleanNumber(b):null;return c&&isValidPhoneNumber(c)?c:null},n=useState(m()),o=_slicedToArray(n,2),p=o[0],q=o[1],r=useState(m()),s=_slicedToArray(r,2),t=s[0],u=s[1],v=useState(""),w=_slicedToArray(v,2),x=w[0],y=w[1],z=groupCountriesByPrefix(sortArrayByProperty(countries,"iso3")),A=groupCountriesByPrefix(sortArrayByProperty(countries,"phone")),B=function(a){var b=setDefaultPrefix(l,j),c="";if(a){var d=explodeNumberModel(a);b=d.prefix,c=d.suffix}return{prefix:b,suffix:c}},C=function getSelectOptions(){var a=filterOptionsForQuery(isStringNumeric(x)?A:z,x);return a.map(function(a){var b=a.phone,c=a.iso3,d=a.iso2,e="";return c?e=isArray(c)?c.join(", "):c:d&&(e=isArray(d)?d.join(", "):d),{value:b,label:b,note:e}})}();useEffect(function(){var a=isValidPhoneNumber(p)?cleanNumber(p):null;a!==t&&(b(a),u({newbroadcastValue:a}))},[p]);var D=B(p),E=D.prefix,F=D.suffix;return/*#__PURE__*/_jsxs("div",{className:"tw-telephone",children:[/*#__PURE__*/_jsx("div",{className:"tw-telephone__country-select",children:/*#__PURE__*/_jsx(Select,{options:C,selected:{value:E,label:E},placeholder:"Select an option...",searchPlaceholder:c,searchValue:x,required:e,disabled:d,size:f,onChange:function handleChangeSelect(a){var b=B(p),c=b.suffix,d=a.value;y(""),q(d+c)},onSearchChange:function onSearchChange(a){return y(a)}})}),/*#__PURE__*/_jsx("div",{className:"tw-telephone__number-input",children:/*#__PURE__*/_jsx("div",{className:"input-group input-group-".concat(f),children:/*#__PURE__*/_jsx("input",{name:"phoneNumber",inputMode:"numeric",value:F,type:"text",className:"form-control",disabled:d,required:e,placeholder:g,onChange:function handleInputChange(a){var b=a.target.value;if(ALLOWED_PHONE_CHARS.test(b)){var c=B(p),d=c.prefix;q(d+b)}},onPaste:function handlePaste(a){if(a.nativeEvent.clipboardData){var b=(a.nativeEvent.clipboardData.getData("text/plain")||"").replace(/(\s|-)+/g,""),c=C.find(function(a){var c=a.value;return new RegExp("^\\".concat(c)).test(b)});c&&ALLOWED_PHONE_CHARS.test(b.replace(c.value,""))&&q(b)}},onFocus:h,onBlur:i})})})]})};PhoneNumberInput.propTypes={required:PropTypes.bool,disabled:PropTypes.bool,initialValue:PropTypes.string,onChange:PropTypes.func.isRequired,onFocus:PropTypes.func,onBlur:PropTypes.func,countryCode:PropTypes.string,searchPlaceholder:PropTypes.string,size:PropTypes.oneOf(["sm","md","lg"]),placeholder:PropTypes.string},PhoneNumberInput.defaultProps={required:!1,disabled:!1,initialValue:null,onFocus:function onFocus(){},onBlur:function onBlur(){},countryCode:null,searchPlaceholder:"Prefix",size:Size.MEDIUM,placeholder:""};export default PhoneNumberInput;
@@ -1 +1 @@
1
- import PropTypes from"prop-types";import{IntlProvider}from"react-intl";import{DEFAULT_LOCALE,adjustLocale}from"../common/locale";import en from"../i18n/en.json";import{DirectionProvider}from"./direction";import{jsx as _jsx}from"react/jsx-runtime";var Provider=function(a){var b,c=a.i18n,d=a.children,e=c.locale,f=c.messages,g=c.defaultRichTextElements,h=adjustLocale(e);return null===h?(console.warn("Unsupported locale value was provided: '".concat(e,"', defaulting to '").concat(DEFAULT_LOCALE,"'")),b={locale:DEFAULT_LOCALE,messages:en}):b={locale:h,messages:f},/*#__PURE__*/_jsx(DirectionProvider,{locale:b.locale,children:/*#__PURE__*/_jsx(IntlProvider,{defaultLocale:DEFAULT_LOCALE,locale:b.locale,messages:b.messages,defaultRichTextElements:g,children:d})})};Provider.propTypes={i18n:PropTypes.shape({locale:PropTypes.string.isRequired,messages:PropTypes.shape({}).isRequired,defaultRichTextElements:PropTypes.shape({})}).isRequired,children:PropTypes.node},Provider.defaultProps={children:void 0};export default Provider;
1
+ import PropTypes from"prop-types";import{IntlProvider}from"react-intl";import{DEFAULT_LOCALE,RTL_LANGUAGES,adjustLocale,Direction}from"../common";import en from"../i18n/en.json";import{DirectionProvider}from"./direction";import{jsx as _jsx}from"react/jsx-runtime";var Provider=function(a){var b,c=a.i18n,d=a.children,e=c.locale,f=c.messages,g=c.defaultRichTextElements,h=adjustLocale(e);null===h?(console.warn("Unsupported locale value was provided: '".concat(e,"', defaulting to '").concat(DEFAULT_LOCALE,"'")),b={locale:DEFAULT_LOCALE,messages:en}):b={locale:h,messages:f};var i=RTL_LANGUAGES.includes(b.locale)?Direction.RTL:Direction.LTR;return/*#__PURE__*/_jsx(DirectionProvider,{direction:i,children:/*#__PURE__*/_jsx(IntlProvider,{defaultLocale:DEFAULT_LOCALE,locale:b.locale,messages:b.messages,defaultRichTextElements:g,children:d})})};Provider.propTypes={i18n:PropTypes.shape({locale:PropTypes.string.isRequired,messages:PropTypes.shape({}).isRequired,defaultRichTextElements:PropTypes.shape({})}).isRequired,children:PropTypes.node},Provider.defaultProps={children:void 0};export default Provider;
@@ -1 +1 @@
1
- import PropTypes from"prop-types";import{createContext}from"react";import{DEFAULT_LOCALE,SUPPORTED_RTL}from"../../common/locale";import{jsx as _jsx}from"react/jsx-runtime";export var DirectionContext=/*#__PURE__*/createContext("ltr");export var DirectionProvider=function(a){var b=a.locale,c=a.children;return/*#__PURE__*/_jsx(DirectionContext.Provider,{value:SUPPORTED_RTL.includes(b)?"rtl":"ltr",children:c})};DirectionProvider.propTypes={children:PropTypes.node,locale:PropTypes.string},DirectionProvider.defaultProps={children:null,locale:DEFAULT_LOCALE};
1
+ import{createContext}from"react";import{isBrowser,Direction}from"../../common";import{jsx as _jsx}from"react/jsx-runtime";var DEFAULT_DIRECTION=Direction.LTR;export var DirectionContext=/*#__PURE__*/createContext(DEFAULT_DIRECTION);export var DirectionProvider=function(a){var b=a.direction,c=void 0===b?DEFAULT_DIRECTION:b,d=a.children,e=void 0===d?void 0:d;return isBrowser()&&(document.documentElement.dir=c),/*#__PURE__*/_jsx(DirectionContext.Provider,{value:c,children:e})};
@@ -0,0 +1 @@
1
+ import{Direction}from"../../common";import{useDirection}from"../../common/hooks";import{render}from"../../test-utils";import{DirectionProvider}from".";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsx as _jsx}from"react/jsx-runtime";describe("DirectionProvider",function(){beforeEach(function(){document.documentElement.removeAttribute("dir")}),it.each([[Direction.LTR,!1],[Direction.RTL,!0]])("store direction %s in React Context",function(a,b){var c=null;render(/*#__PURE__*/_jsx(DirectionProvider,{direction:a,children:/*#__PURE__*/_jsx(function TestComponent(){return c=useDirection(),/*#__PURE__*/_jsx(_Fragment,{})},{})})),expect(c).not.toBeNull(),expect(c).toHaveProperty("direction",a),expect(c).toHaveProperty("isRTL",b)}),it("attaches `dir` attribute to `html` tag",function(){expect(document.documentElement).not.toHaveAttribute("dir"),render(/*#__PURE__*/_jsx(DirectionProvider,{})),expect(document.documentElement).toHaveAttribute("dir","ltr"),render(/*#__PURE__*/_jsx(DirectionProvider,{direction:"rtl"})),expect(document.documentElement).toHaveAttribute("dir","rtl")})});
@@ -1 +1 @@
1
- export{default}from"./Provider";
1
+ export{DirectionProvider}from"./direction/DirectionProvider";export{default}from"./Provider";
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","id","disabled","avatar","secondary"];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 PropTypes from"prop-types";import RadioButton from"../common/RadioButton";import{useDirection}from"../common/hooks";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.avatar,f=a.secondary,g=_objectWithoutProperties(a,_excluded),h=useDirection(),i=h.isRTL;return/*#__PURE__*/_jsx("div",{className:classNames("radio np-radio",{"radio-lg":f,disabled:d}),disabled:d,children:/*#__PURE__*/_jsxs("label",{htmlFor:c,children:[/*#__PURE__*/_jsx("span",{className:classNames("np-radio-button",{"p-r-2":!i,"p-l-2":i}),children:/*#__PURE__*/_jsx(RadioButton,_objectSpread({id:c,disabled:d},g))}),/*#__PURE__*/_jsxs("span",{className:"np-radio__text",children:[b,f&&/*#__PURE__*/_jsx("small",{children:f})]}),e&&/*#__PURE__*/_jsx("span",{className:classNames("np-radio__avatar",{"m-l-auto":!i,"m-r-auto":i}),children:e})]})})};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])},Radio.defaultProps={avatar:void 0,checked:!1,disabled:!1,id:null,secondary:null,value:""};export default Radio;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","id","disabled","avatar","secondary"];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 PropTypes from"prop-types";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.avatar,f=a.secondary,g=_objectWithoutProperties(a,_excluded);return/*#__PURE__*/_jsx("div",{className:classNames("radio np-radio",{"radio-lg":f,disabled:d}),disabled:d,children:/*#__PURE__*/_jsxs("label",{htmlFor:c,children:[/*#__PURE__*/_jsx("span",{className:"np-radio-button p-r-2",children:/*#__PURE__*/_jsx(RadioButton,_objectSpread({id:c,disabled:d},g))}),/*#__PURE__*/_jsxs("span",{className:"np-radio__text",children:[b,f&&/*#__PURE__*/_jsx("small",{children:f})]}),e&&/*#__PURE__*/_jsx("span",{className:"np-radio__avatar m-l-auto",children:e})]})})};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])},Radio.defaultProps={avatar:void 0,checked:!1,disabled:!1,id:null,secondary:null,value:""};export default Radio;
@@ -1 +1 @@
1
- import PropTypes from"prop-types";import{cloneElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Option=function(a){var b=a.currency,c=a.label,d=a.note,e=a.secondary,f=a.icon,g=a.classNames,h=a.selected,i=function(a){return a.map(function(a){return g[a]||a}).join(" ")},j=b?"".concat(i(["currency-flag","currency-flag-".concat(b.toLowerCase()),"".concat(h?"hidden-xs":"")])):null;return/*#__PURE__*/_jsxs("span",{children:[b?/*#__PURE__*/_jsx("i",{className:j}):f&&/*#__PURE__*/cloneElement(f,{size:24,className:"".concat(i(["tw-icon"]))}),c,d&&/*#__PURE__*/_jsx("span",{className:"small m-l-1",children:d}),e&&/*#__PURE__*/_jsx("span",{className:"small text-ellipsis",children:e})]})};Option.propTypes={label:PropTypes.node.isRequired,currency:PropTypes.string,note:PropTypes.node,secondary:PropTypes.node,icon:PropTypes.node,classNames:PropTypes.objectOf(PropTypes.string),selected:PropTypes.bool},Option.defaultProps={currency:"",note:"",secondary:"",icon:null,classNames:{},selected:!1};export default Option;
1
+ import PropTypes from"prop-types";import{cloneElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Option=function(a){var b=a.currency,c=a.label,d=a.note,e=a.secondary,f=a.icon,g=a.classNames,h=a.selected,i=function(a){return a.map(function(a){return g[a]||a}).join(" ")},j=b?"".concat(i(["currency-flag","currency-flag-".concat(b.toLowerCase()),"".concat(h?"hidden-xs":"")])):null;return/*#__PURE__*/_jsxs("span",{className:"d-flex align-items-center",children:[b?/*#__PURE__*/_jsx("i",{className:j}):f&&/*#__PURE__*/cloneElement(f,{size:24,className:"".concat(i(["tw-icon"]))}),c,d&&/*#__PURE__*/_jsx("span",{className:"small m-l-1",children:d}),e&&/*#__PURE__*/_jsx("span",{className:"small text-ellipsis",children:e})]})};Option.propTypes={label:PropTypes.node.isRequired,currency:PropTypes.string,note:PropTypes.node,secondary:PropTypes.node,icon:PropTypes.node,classNames:PropTypes.objectOf(PropTypes.string),selected:PropTypes.bool},Option.defaultProps={currency:"",note:"",secondary:"",icon:null,classNames:{},selected:!1};export default Option;
@@ -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";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import classNames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import CSSTransition from"react-transition-group/CSSTransition";import{Theme}from"../common";import{DirectionContext}from"../provider/direction";import withNextPortal from"../withNextPortal/withNextPortal";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var CSS_TRANSITION_DURATION=400;export var Snackbar=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"setLeaveTimeout",function(){var b=a.props.timeout;a.timeout=setTimeout(function(){a.setState({visible:!1})},b)}),a.state={visible:!1,text:""},a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentWillUnmount",value:function componentWillUnmount(){clearTimeout(this.timeout),clearTimeout(this.transitionTimeout)}},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(a,b){return!!a.text&&(a.timestamp!==this.props.timestamp||b.visible!==this.state.visible||b.text!==this.state.text)}},{key:"componentDidUpdate",value:function componentDidUpdate(a){var b=this,c=this.props,d=c.action,e=c.text,f=c.theme,g=c.timestamp;a.text?a.timestamp!==g&&(clearTimeout(this.timeout),this.state.visible?this.setState({visible:!1},function(){b.transitionTimeout=setTimeout(function(){b.setState({visible:!0,action:d,text:e,theme:f}),b.setLeaveTimeout()},CSS_TRANSITION_DURATION)}):(this.setState({visible:!0,action:d,text:e,theme:f}),this.setLeaveTimeout())):this.setState({visible:!0,action:d,text:e,theme:f},function(){b.setLeaveTimeout()})}},{key:"render",value:function render(){var a="rtl"===this.context,b=this.state,c=b.action,d=b.text,e=b.theme,f=b.visible,g=this.props.timeout;return/*#__PURE__*/_jsx("div",{className:classNames("snackbar",{"snackbar--rtl":a}),children:/*#__PURE__*/_jsx(CSSTransition,{in:f,classNames:"snackbar__text-container",timeout:{appear:0,enter:g,exit:CSS_TRANSITION_DURATION},unmountOnExit:!0,children:/*#__PURE__*/_jsxs("span",{className:"snackbar__text snackbar__text--".concat(e),children:[d,c?/*#__PURE__*/_jsx("button",{type:"button",className:"snackbar__text__action",onClick:c.onClick,children:c.label}):null]})})})}}]),b}(Component);Snackbar.contextType=DirectionContext,Snackbar.propTypes={action:PropTypes.shape({label:PropTypes.string.isRequired,onClick:PropTypes.func.isRequired}),text:PropTypes.node.isRequired,theme:PropTypes.oneOf(["light","dark"]),timeout:PropTypes.number.isRequired,timestamp:PropTypes.number.isRequired},Snackbar.defaultProps={action:null,theme:Theme.LIGHT};export default withNextPortal(Snackbar);
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";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import PropTypes from"prop-types";import{Component}from"react";import CSSTransition from"react-transition-group/CSSTransition";import{Theme}from"../common";import{DirectionContext}from"../provider/direction";import withNextPortal from"../withNextPortal/withNextPortal";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var CSS_TRANSITION_DURATION=400;export var Snackbar=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"setLeaveTimeout",function(){var b=a.props.timeout;a.timeout=setTimeout(function(){a.setState({visible:!1})},b)}),a.state={visible:!1,text:""},a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentWillUnmount",value:function componentWillUnmount(){clearTimeout(this.timeout),clearTimeout(this.transitionTimeout)}},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(a,b){return!!a.text&&(a.timestamp!==this.props.timestamp||b.visible!==this.state.visible||b.text!==this.state.text)}},{key:"componentDidUpdate",value:function componentDidUpdate(a){var b=this,c=this.props,d=c.action,e=c.text,f=c.theme,g=c.timestamp;a.text?a.timestamp!==g&&(clearTimeout(this.timeout),this.state.visible?this.setState({visible:!1},function(){b.transitionTimeout=setTimeout(function(){b.setState({visible:!0,action:d,text:e,theme:f}),b.setLeaveTimeout()},CSS_TRANSITION_DURATION)}):(this.setState({visible:!0,action:d,text:e,theme:f}),this.setLeaveTimeout())):this.setState({visible:!0,action:d,text:e,theme:f},function(){b.setLeaveTimeout()})}},{key:"render",value:function render(){var a=this.state,b=a.action,c=a.text,d=a.theme,e=a.visible,f=this.props.timeout;return/*#__PURE__*/_jsx("div",{className:"snackbar",children:/*#__PURE__*/_jsx(CSSTransition,{in:e,classNames:"snackbar__text-container",timeout:{appear:0,enter:f,exit:CSS_TRANSITION_DURATION},unmountOnExit:!0,children:/*#__PURE__*/_jsxs("span",{className:"snackbar__text snackbar__text--".concat(d),children:[c,b?/*#__PURE__*/_jsx("button",{type:"button",className:"snackbar__text__action",onClick:b.onClick,children:b.label}):null]})})})}}]),b}(Component);Snackbar.contextType=DirectionContext,Snackbar.propTypes={action:PropTypes.shape({label:PropTypes.string.isRequired,onClick:PropTypes.func.isRequired}),text:PropTypes.node.isRequired,theme:PropTypes.oneOf(["light","dark"]),timeout:PropTypes.number.isRequired,timestamp:PropTypes.number.isRequired},Snackbar.defaultProps={action:null,theme:Theme.LIGHT};export default withNextPortal(Snackbar);
@@ -1 +1 @@
1
- import classNames from"classnames";import PropTypes from"prop-types";import{Position}from"../common";import Tooltip from"../tooltip";import{isTouchDevice}from"./deviceDetection";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";function clamp(a,b,c){return Math.max(Math.min(b,c),a)}/* eslint-disable react/no-array-index-key */var Stepper=function(a){var b=a.steps,c=a.activeStep,d=a.className;if(0===b.length)return null;var e=clamp(0,b.length-1,c),f=1/(b.length-1),g=e/(b.length-1),h=Math.max(g-f,0),i=Math.min(e,1)*f;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-stepper",d),children:[/*#__PURE__*/_jsxs("div",{className:"progress",children:[/*#__PURE__*/_jsx("div",{className:"progress-bar-filler",style:{width:"".concat(100*h,"%")}}),/*#__PURE__*/_jsx("div",{className:"progress-bar-ending",style:{width:"".concat(100*i,"%")}})]}),/*#__PURE__*/_jsx("ul",{className:"tw-stepper-steps p-t-1 m-b-0",children:b.map(function renderStep(a,b){var c=b===e,d=a.onClick&&!c,g=/*#__PURE__*/_jsx("button",{type:"button",className:"btn-unstyled tw-stepper__step-label",disabled:!d,onClick:function onClick(){return d&&a.onClick()},children:/*#__PURE__*/_jsx("small",{children:a.label})});return/*#__PURE__*/_jsx("li",{style:{left:"".concat(100*(b*f),"%")},className:"\n hidden-xs\n tw-stepper__step\n ".concat(c?"tw-stepper__step--active":"","\n ").concat(d?"tw-stepper__step--clickable":"","\n "),children:a.hoverLabel&&!isTouchDevice()?/*#__PURE__*/_jsx(Tooltip,{position:Position.BOTTOM,label:a.hoverLabel,children:g}):g},b)})})]})};/* eslint-enable react/no-array-index-key */Stepper.propTypes={steps:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.node.isRequired,onClick:PropTypes.func,hoverLabel:PropTypes.node})).isRequired,activeStep:PropTypes.number,className:PropTypes.string},Stepper.defaultProps={activeStep:0,className:void 0};export default Stepper;
1
+ import classNames from"classnames";import PropTypes from"prop-types";import{Position}from"../common";import Tooltip from"../tooltip";import{isTouchDevice}from"./deviceDetection";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";function clamp(a,b,c){return Math.max(Math.min(b,c),a)}/* eslint-disable react/no-array-index-key */var Stepper=function(a){var b=a.steps,c=a.activeStep,d=a.className;if(0===b.length)return null;var e=clamp(0,b.length-1,c),f=1/(b.length-1),g=e/(b.length-1),h=Math.max(g-f,0),i=Math.min(e,1)*f;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-stepper",d),children:[/*#__PURE__*/_jsxs("div",{className:"progress",children:[/*#__PURE__*/_jsx("div",{className:"progress-bar-filler",style:{width:"".concat(100*h,"%")}}),/*#__PURE__*/_jsx("div",{className:"progress-bar-ending",style:{width:"".concat(100*i,"%")}})]}),/*#__PURE__*/_jsx("ul",{className:"tw-stepper-steps p-t-1 m-b-0",children:b.map(function renderStep(a,b){var c=b===e,d=a.onClick&&!c,f=/*#__PURE__*/_jsx("button",{type:"button",className:"btn-unstyled tw-stepper__step-label",disabled:!d,onClick:function onClick(){return d&&a.onClick()},children:/*#__PURE__*/_jsx("small",{children:a.label})});return/*#__PURE__*/_jsx("li",{className:"\n hidden-xs\n tw-stepper__step\n ".concat(c?"tw-stepper__step--active":"","\n ").concat(d?"tw-stepper__step--clickable":"","\n "),children:a.hoverLabel&&!isTouchDevice()?/*#__PURE__*/_jsx(Tooltip,{position:Position.BOTTOM,label:a.hoverLabel,children:f}):f},b)})})]})};/* eslint-enable react/no-array-index-key */Stepper.propTypes={steps:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.node.isRequired,onClick:PropTypes.func,hoverLabel:PropTypes.node})).isRequired,activeStep:PropTypes.number,className:PropTypes.string},Stepper.defaultProps={activeStep:0,className:void 0};export default Stepper;
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";var _statusLabels;import{CheckCircle as CheckCircleIcon,PendingCircle as PendingCircleIcon}from"@transferwise/icons";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{Status,Size}from"../common";import{useDirection}from"../common/hooks";import Info from"../info";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=useIntl(),p=useDirection(),q=p.isRTL,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&&o.formatMessage(messages[statusLabels[m]]),children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__icon",children:[r,u&&/*#__PURE__*/_jsx(u,{size:16,filled:!0,className:"np-summary-icon__".concat(m)})]}),/*#__PURE__*/_jsxs("div",{className:classNames("np-summary__body",{"m-l-2":!q,"m-r-2":q}),children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__title d-flex",children:[/*#__PURE__*/_jsx("strong",{children:n}),l&&/*#__PURE__*/_jsx(Info,{"aria-label":l["aria-label"],className:classNames({"m-l-1":!q,"m-r-1":q},"hidden-xs"),content:l.content,presentation:l.presentation,title:l.title,onClick:l.onClick})]}),g&&/*#__PURE__*/_jsx("div",{className:"np-summary__description",children:g}),b&&/*#__PURE__*/_jsx("a",{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:Size.LARGE,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
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";var _statusLabels;import{CheckCircle as CheckCircleIcon,PendingCircle as PendingCircleIcon}from"@transferwise/icons";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{Status,Size}from"../common";import Info from"../info";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=useIntl(),p=j;if(i){var q,r=null===i||void 0===i||null===(q=i.props)||void 0===q?void 0:q.size;p=24===r?i:/*#__PURE__*/cloneElement(i,{size:24})}var s=m&&BadgeIcons[m];return/*#__PURE__*/_jsxs(c,{className:classNames("np-summary d-flex align-items-start",d),"aria-label":m&&o.formatMessage(messages[statusLabels[m]]),children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__icon",children:[p,s&&/*#__PURE__*/_jsx(s,{size:16,filled:!0,className:"np-summary-icon__".concat(m)})]}),/*#__PURE__*/_jsxs("div",{className:"np-summary__body m-l-2",children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__title d-flex",children:[/*#__PURE__*/_jsx("strong",{children:n}),l&&/*#__PURE__*/_jsx(Info,{"aria-label":l["aria-label"],className:"m-l-1 hidden-xs",content:l.content,presentation:l.presentation,title:l.title,onClick:l.onClick})]}),g&&/*#__PURE__*/_jsx("div",{className:"np-summary__description",children:g}),b&&/*#__PURE__*/_jsx("a",{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:Size.LARGE,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{CheckCircle,CrossCircle}from"@transferwise/icons";import classnames from"classnames";import{useDirection}from"../common/hooks";import KeyCodes from"../common/keyCodes";import{logActionRequiredIf}from"../utilities";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Switch=function(a){var b=useDirection(),c=b.isRTL,d=a.checked,e=a.className,f=a.id,g=a.onClick,h=a.disabled,i=a["aria-label"],j=i?void 0:a["aria-labelledby"];return logActionRequiredIf("Switch now expects either `aria-label` or `aria-labelledby`, and will soon make these props required. Please update your usage to provide one or the other.",!i&&!j),/*#__PURE__*/_jsxs("span",{className:classnames("np-switch",{"np-switch--rtl":c,"np-switch--unchecked":!d,"np-switch--checked":d,"np-switch--disabled":h},e),tabIndex:0,role:"switch","aria-checked":d,"aria-label":i,"aria-labelledby":j,id:f,"aria-disabled":h,onClick:h?void 0:g,onKeyDown:h?void 0:function handleKeyDown(a){("32"===a.code||a.keyCode===KeyCodes.SPACE)&&(a.preventDefault(),g())},children:[/*#__PURE__*/_jsx("span",{className:"np-switch--thumb",children:d?/*#__PURE__*/_jsx(CheckCircle,{filled:!0,size:24}):/*#__PURE__*/_jsx(CrossCircle,{filled:!0,size:24})}),/*#__PURE__*/_jsx("input",{type:"checkbox",checked:d,readOnly:!0})]})};export default Switch;
1
+ import{CheckCircle,CrossCircle}from"@transferwise/icons";import classnames from"classnames";import KeyCodes from"../common/keyCodes";import{logActionRequiredIf}from"../utilities";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Switch=function(a){var b=a.checked,c=a.className,d=a.id,e=a.onClick,f=a.disabled,g=a["aria-label"],h=g?void 0:a["aria-labelledby"];return logActionRequiredIf("Switch now expects either `aria-label` or `aria-labelledby`, and will soon make these props required. Please update your usage to provide one or the other.",!g&&!h),/*#__PURE__*/_jsxs("span",{className:classnames("np-switch",{"np-switch--unchecked":!b,"np-switch--checked":b,"np-switch--disabled":f},c),tabIndex:0,role:"switch","aria-checked":b,"aria-label":g,"aria-labelledby":h,id:d,"aria-disabled":f,onClick:f?void 0:e,onKeyDown:f?void 0:function handleKeyDown(a){("32"===a.code||a.keyCode===KeyCodes.SPACE)&&(a.preventDefault(),e())},children:[/*#__PURE__*/_jsx("span",{className:"np-switch--thumb",children:b?/*#__PURE__*/_jsx(CheckCircle,{filled:!0,size:24}):/*#__PURE__*/_jsx(CrossCircle,{filled:!0,size:24})}),/*#__PURE__*/_jsx("input",{type:"checkbox",checked:b,readOnly:!0})]})};export default Switch;
@@ -1 +1,8 @@
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";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import PropTypes from"prop-types";import{Component}from"react";import{Position}from"../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";function getTooltipStyle(a,b,c,d){return c===Position.TOP?{top:"".concat(a.offsetTop-b.offsetHeight-d,"px"),left:"".concat(a.offsetLeft+a.offsetWidth/2-b.offsetWidth/2,"px")}:c===Position.LEFT?{top:"".concat(a.offsetTop+a.offsetHeight/2-b.offsetHeight/2,"px"),left:"".concat(a.offsetLeft-b.offsetWidth-d,"px")}:c===Position.RIGHT?{top:"".concat(a.offsetTop+a.offsetHeight/2-b.offsetHeight/2,"px"),left:"".concat(a.offsetLeft+a.offsetWidth+d,"px")}:c===Position.BOTTOM?{top:"".concat(a.offsetTop+a.offsetHeight+d,"px"),left:"".concat(a.offsetLeft+a.offsetWidth/2-b.offsetWidth/2,"px")}:{}}var Tooltip=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"ensureHidden",function(b){a.state.show||(b.stopPropagation(),a.hide())}),a.state={show:!1,tooltipId:null},a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentDidMount",value:function componentDidMount(){this.setState({tooltipId:Math.random().toString(36).slice(7)})}},{key:"show",value:function show(){this.setState(function(){return{show:!0}})}},{key:"hide",value:function hide(){this.setState(function(){return{show:!1}})}},{key:"render",value:function render(){var a=this,b=this.state.tooltipId,c=this.props,d=c.position,e=c.children,f=c.label,g=c.offset,h=this.elementReference&&this.tooltipReference?getTooltipStyle(this.elementReference,this.tooltipReference,d,g):{};return/*#__PURE__*/_jsxs("span",{ref:function ref(b){a.elementReference=b},"aria-describedby":b,className:"tw-tooltip-container",onMouseOver:function onMouseOver(){return a.show()},onFocus:function onFocus(){return a.show()},onMouseOut:function onMouseOut(){return a.hide()},onBlur:function onBlur(){return a.hide()},children:[/*#__PURE__*/_jsxs("div",{ref:function ref(b){a.tooltipReference=b},className:"tooltip fade ".concat(d," ").concat(this.state.show?"in":""),role:"tooltip",style:h,id:b,onMouseOver:this.ensureHidden,onFocus:this.ensureHidden,children:[/*#__PURE__*/_jsx("div",{className:"tooltip-arrow"}),/*#__PURE__*/_jsx("div",{className:"tooltip-inner",children:f})]}),e]})}}]),b}(Component);Tooltip.propTypes={children:PropTypes.oneOfType([PropTypes.element,PropTypes.arrayOf(PropTypes.element),PropTypes.string]).isRequired,position:PropTypes.oneOf(["top","bottom","left","right"]),label:PropTypes.node.isRequired,offset:PropTypes.number},Tooltip.defaultProps={position:Position.TOP,offset:0};export default Tooltip;
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}/* eslint-disable @typescript-eslint/ban-ts-comment */import classNames from"classnames";import{cloneElement,useRef,useState,useEffect}from"react";import{usePopper}from"react-popper";import{Position}from"../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var Tooltip=function(a){var b=a.position,c=void 0===b?Position.TOP:b,d=a.children,e=void 0===d?void 0:d,f=a.label,g=a.className,h=useState(!1),i=_slicedToArray(h,2),j=i[0],k=i[1],l=useRef(null),m=useState(null),n=_slicedToArray(m,2),o=n[0],p=n[1],q=useState(null),r=_slicedToArray(q,2),s=r[0],t=r[1],u=[];u.push({name:"arrow",options:{element:o,options:{padding:8// 8px from the edges of the popper
2
+ }}}),u.push({name:"offset",options:{offset:[0,16]}}),u.push({name:"flip",options:{fallbackPlacements:Position.TOP}});var v=usePopper(l.current,s,{placement:c,modifiers:u}),w=v.styles,x=v.attributes,y=v.forceUpdate;// If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),
3
+ // it is most simple just to always position before opening
4
+ return useEffect(function(){j&&y&&y()},[j]),/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx("span",{ref:l,className:"d-inline-block",children:e?/*#__PURE__*/cloneElement(e,{/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */onMouseOver:function onMouseOver(){var a;if(null!==e&&void 0!==e&&null!==(a=e.props)&&void 0!==a&&a.onMouseOver){var b;null===e||void 0===e||null===(b=e.props)||void 0===b?void 0:b.onMouseOver()}k(!0)},onFocus:function onFocus(){var a;null!==e&&void 0!==e&&null!==(a=e.props)&&void 0!==a&&a.onFocus&&e.props.onFocus(),k(!0)},onMouseOut:function onMouseOut(){var a;null!==e&&void 0!==e&&null!==(a=e.props)&&void 0!==a&&a.onMouseOver&&e.props.onMouseOver(),k(!1)},onBlur:function onBlur(){var a;null!==e&&void 0!==e&&null!==(a=e.props)&&void 0!==a&&a.onBlur&&e.props.onBlur(),k(!1)}/* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */}):null}),j?/*#__PURE__*/_jsx("div",_objectSpread(_objectSpread({// @ts-expect-error
5
+ ref:t,className:classNames("np-panel","np-panel--open",g)// eslint-disable-next-line react/forbid-dom-props
6
+ ,style:_objectSpread({},w.popper)},x.popper),{},{children:/*#__PURE__*/_jsxs("div",{className:"np-panel__content tooltip-inner",children:[f,/*#__PURE__*/_jsx("div",{// @ts-expect-error
7
+ ref:p,className:classNames("np-panel__arrow")// eslint-disable-next-line react/forbid-dom-props
8
+ ,style:w.arrow})]})})):null]})};export default Tooltip;
@@ -0,0 +1 @@
1
+ import{render,screen,fireEvent,userEvent}from"../test-utils";import Tooltip from".";import{jsx as _jsx}from"react/jsx-runtime";describe("Tooltip",function(){var a=/*#__PURE__*/_jsx("span",{children:"Hover over me!"});it("wraps anchor as a children and renders it",function(){render(/*#__PURE__*/_jsx(Tooltip,{label:"Tooltip",children:a})),expect(screen.getByText("Hover over me!")).toBeInTheDocument()}),it("appears onMouseOver",function(){render(/*#__PURE__*/_jsx(Tooltip,{label:"Tooltip",children:a})),expect(screen.queryByText("Tooltip")).not.toBeInTheDocument(),userEvent.hover(screen.getByText("Hover over me!")),expect(screen.getByText("Tooltip")).toBeInTheDocument()}),it("hides onMouseOut",function(){render(/*#__PURE__*/_jsx(Tooltip,{label:"Tooltip",children:a})),userEvent.hover(screen.getByText("Hover over me!")),expect(screen.getByText("Tooltip")).toBeInTheDocument(),userEvent.unhover(screen.getByText("Hover over me!"))}),it("appears onFocus",function(){render(/*#__PURE__*/_jsx(Tooltip,{label:"Tooltip",children:a})),expect(screen.queryByText("Tooltip")).not.toBeInTheDocument(),fireEvent.focus(screen.getByText("Hover over me!")),expect(screen.getByText("Tooltip")).toBeInTheDocument()}),it("hides onBlur",function(){render(/*#__PURE__*/_jsx(Tooltip,{label:"Tooltip",children:a})),fireEvent.blur(screen.getByText("Hover over me!")),expect(screen.queryByText("Tooltip")).not.toBeInTheDocument()})});
@@ -0,0 +1 @@
1
+ import{select,text}from"@storybook/addon-knobs";import Button from"../button";import{Position}from"../common";import Tooltip from"./Tooltip";import{jsx as _jsx}from"react/jsx-runtime";export default{component:Tooltip,title:"Tooltip"};export var Basic=function(){var a=text("label","Hey edit me!!!!!!"),b=select("position",[Position.BOTTOM,Position.TOP,Position.LEFT,Position.RIGHT],Position.BOTTOM);return/*#__PURE__*/_jsx("div",{className:"text-xs-center",children:/*#__PURE__*/_jsx(Tooltip,{label:a,position:b,children:/*#__PURE__*/_jsx(Button,{children:"Hover me"})})})};