@transferwise/components 37.0.1-beta.11 → 37.0.1-beta.25

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 (120) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/build/es/no-polyfill/dateInput/DateInput.js +3 -3
  3. package/build/es/no-polyfill/dateInput/DateInput.messages.js +1 -0
  4. package/build/es/no-polyfill/dimmer/Dimmer.js +2 -2
  5. package/build/es/no-polyfill/drawer/Drawer.js +1 -1
  6. package/build/es/no-polyfill/i18n/en.json +3 -2
  7. package/build/es/no-polyfill/link/Link.js +3 -9
  8. package/build/es/no-polyfill/link/Link.spec.js +1 -0
  9. package/build/es/no-polyfill/link/Link.story.js +1 -0
  10. package/build/es/no-polyfill/modal/Modal.js +1 -1
  11. package/build/es/no-polyfill/nudge/Nudge.js +1 -1
  12. package/build/es/no-polyfill/stepper/deviceDetection.js +2 -1
  13. package/build/es/no-polyfill/switch/Switch.js +1 -1
  14. package/build/es/no-polyfill/switch/Switch.story.js +1 -1
  15. package/build/es/no-polyfill/tabs/Tabs.js +1 -1
  16. package/build/es/no-polyfill/upload/Upload.js +1 -1
  17. package/build/es/no-polyfill/upload/steps/completeStep/completeStep.js +1 -1
  18. package/build/es/no-polyfill/upload/steps/processingStep/processingStep.js +1 -1
  19. package/build/es/no-polyfill/upload/utils/index.js +1 -1
  20. package/build/es/no-polyfill/withNextPortal/withNextPortal.js +1 -1
  21. package/build/es/polyfill/dateInput/DateInput.js +3 -3
  22. package/build/es/polyfill/dateInput/DateInput.messages.js +1 -0
  23. package/build/es/polyfill/dimmer/Dimmer.js +2 -2
  24. package/build/es/polyfill/drawer/Drawer.js +1 -1
  25. package/build/es/polyfill/i18n/en.json +3 -2
  26. package/build/es/polyfill/link/Link.js +3 -9
  27. package/build/es/polyfill/link/Link.spec.js +1 -0
  28. package/build/es/polyfill/link/Link.story.js +1 -0
  29. package/build/es/polyfill/modal/Modal.js +1 -1
  30. package/build/es/polyfill/nudge/Nudge.js +1 -1
  31. package/build/es/polyfill/stepper/deviceDetection.js +2 -1
  32. package/build/es/polyfill/switch/Switch.js +1 -1
  33. package/build/es/polyfill/switch/Switch.story.js +1 -1
  34. package/build/es/polyfill/tabs/Tabs.js +1 -1
  35. package/build/es/polyfill/upload/Upload.js +1 -1
  36. package/build/es/polyfill/upload/steps/completeStep/completeStep.js +1 -1
  37. package/build/es/polyfill/upload/steps/processingStep/processingStep.js +1 -1
  38. package/build/es/polyfill/upload/utils/index.js +1 -1
  39. package/build/es/polyfill/withNextPortal/withNextPortal.js +1 -1
  40. package/build/i18n/en.json +3 -2
  41. package/build/main.css +1 -2929
  42. package/build/styles/accordion/Accordion.css +1 -40
  43. package/build/styles/actionOption/ActionOption.css +1 -3
  44. package/build/styles/avatar/Avatar.css +1 -166
  45. package/build/styles/badge/Badge.css +1 -59
  46. package/build/styles/button/Button.css +1 -14
  47. package/build/styles/card/Card.css +1 -33
  48. package/build/styles/checkboxButton/CheckboxButton.css +1 -19
  49. package/build/styles/chip/Chip.css +1 -23
  50. package/build/styles/circularButton/CircularButton.css +1 -124
  51. package/build/styles/common/Option/Option.css +1 -11
  52. package/build/styles/common/RadioButton/RadioButton.css +1 -8
  53. package/build/styles/common/bottomSheet/BottomSheet.css +1 -31
  54. package/build/styles/common/closeButton/CloseButton.css +1 -18
  55. package/build/styles/common/panel/Panel.css +1 -52
  56. package/build/styles/dateInput/DateInput.css +1 -3
  57. package/build/styles/dateLookup/DateLookup.css +1 -36
  58. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +1 -23
  59. package/build/styles/decision/Decision.css +1 -33
  60. package/build/styles/definitionList/DefinitionList.css +1 -26
  61. package/build/styles/dimmer/Dimmer.css +1 -43
  62. package/build/styles/drawer/Drawer.css +1 -65
  63. package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +1 -5
  64. package/build/styles/emphasis/Emphasis.css +1 -21
  65. package/build/styles/flowNavigation/FlowNavigation.css +1 -75
  66. package/build/styles/flowNavigation/animatedLabel/AnimatedLabel.css +1 -27
  67. package/build/styles/flowNavigation/backButton/BackButton.css +1 -9
  68. package/build/styles/image/Image.css +1 -13
  69. package/build/styles/info/Info.css +1 -29
  70. package/build/styles/instructionsList/InstructionsList.css +1 -19
  71. package/build/styles/lab/mobileNav/MobileNav.css +1 -164
  72. package/build/styles/lab/pagination/Pagination.css +1 -51
  73. package/build/styles/link/Link.css +1 -4
  74. package/build/styles/loader/Loader.css +1 -580
  75. package/build/styles/logo/Logo.css +1 -4
  76. package/build/styles/main.css +1 -2929
  77. package/build/styles/modal/Modal.css +1 -159
  78. package/build/styles/moneyInput/MoneyInput.css +1 -50
  79. package/build/styles/navigationOption/NavigationOption.css +1 -23
  80. package/build/styles/navigationOptionsList/NavigationOptionsList.css +1 -8
  81. package/build/styles/nudge/Nudge.css +1 -16
  82. package/build/styles/overlayHeader/OverlayHeader.css +1 -12
  83. package/build/styles/phoneNumberInput/PhoneNumberInput.css +1 -23
  84. package/build/styles/popover/Popover.css +1 -62
  85. package/build/styles/slidingPanel/SlidingPanel.css +1 -58
  86. package/build/styles/snackbar/Snackbar.css +1 -75
  87. package/build/styles/stepper/Stepper.css +1 -93
  88. package/build/styles/summary/Summary.css +1 -46
  89. package/build/styles/switch/Switch.css +1 -45
  90. package/build/styles/tabs/Tabs.css +1 -80
  91. package/build/styles/tile/Tile.css +1 -53
  92. package/build/styles/tooltip/Tooltip.css +1 -28
  93. package/build/styles/typeahead/Typeahead.css +1 -142
  94. package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +1 -11
  95. package/build/styles/upload/Upload.css +1 -15
  96. package/build/styles/uploadInput/UploadInput.css +1 -6
  97. package/build/styles/uploadInput/uploadButton/UploadButton.css +1 -45
  98. package/build/styles/uploadInput/uploadItem/UploadItem.css +1 -48
  99. package/build/types/{link/Link.messages.d.ts → dateInput/DateInput.messages.d.ts} +8 -5
  100. package/build/types/link/Link.d.ts +1 -7
  101. package/build/types/link/Link.spec.d.ts +1 -0
  102. package/build/types/link/Link.story.d.ts +9 -0
  103. package/build/types/modal/Modal.d.ts +0 -1
  104. package/build/types/nudge/Nudge.d.ts +1 -0
  105. package/build/types/switch/Switch.story.d.ts +1 -0
  106. package/build/types/test-utils/index.d.ts +6 -4
  107. package/build/types/upload/Upload.d.ts +1 -1
  108. package/build/types/upload/utils/index.d.ts +0 -1
  109. package/build/types/withNextPortal/withNextPortal.d.ts +1 -2
  110. package/build/umd/no-polyfill/main.js +1 -1
  111. package/build/umd/polyfill/main.js +1 -1
  112. package/package.json +5 -5
  113. package/build/es/no-polyfill/link/Link.messages.js +0 -1
  114. package/build/es/no-polyfill/upload/utils/generateErrorMessage/generateErrorMessage.js +0 -1
  115. package/build/es/no-polyfill/upload/utils/generateErrorMessage/index.js +0 -1
  116. package/build/es/polyfill/link/Link.messages.js +0 -1
  117. package/build/es/polyfill/upload/utils/generateErrorMessage/generateErrorMessage.js +0 -1
  118. package/build/es/polyfill/upload/utils/generateErrorMessage/index.js +0 -1
  119. package/build/types/upload/utils/generateErrorMessage/generateErrorMessage.d.ts +0 -1
  120. package/build/types/upload/utils/generateErrorMessage/index.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,181 @@
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.4.2](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.4.1...@transferwise/components@37.4.2) (2021-09-15)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix wrong peerdependency version, again ([#1144](https://github.com/transferwise/neptune-web/issues/1144)) ([77a11cc](https://github.com/transferwise/neptune-web/commit/77a11cce599f2a8ebb17995f35033f5a2ac40044))
12
+
13
+
14
+
15
+
16
+
17
+ ## [37.4.1](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.4.0...@transferwise/components@37.4.1) (2021-09-14)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * update peerdependencies to support latest neptune-css and components ([#1143](https://github.com/transferwise/neptune-web/issues/1143)) ([3b59c71](https://github.com/transferwise/neptune-web/commit/3b59c71c4da291acb1d95b8dc5e07d01b415b96b))
23
+
24
+
25
+
26
+
27
+
28
+ # [37.4.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.13...@transferwise/components@37.4.0) (2021-09-14)
29
+
30
+
31
+ ### Features
32
+
33
+ * [VUX-950] Update persist async to work with `blob` type ([6f958f6](https://github.com/transferwise/neptune-web/commit/6f958f69ea88bfcecf1cedf85600b2bd5eb71151))
34
+
35
+
36
+
37
+
38
+
39
+ ## [37.3.13](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.12...@transferwise/components@37.3.13) (2021-09-14)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * **Upload:** re-render translated messages on language change ([#1135](https://github.com/transferwise/neptune-web/issues/1135)) ([e375eaa](https://github.com/transferwise/neptune-web/commit/e375eaa3279dbb88cd8d8411c9477caa89aa45db))
45
+
46
+
47
+
48
+
49
+
50
+ ## [37.3.12](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.11...@transferwise/components@37.3.12) (2021-09-14)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * update drawer padding ([#1130](https://github.com/transferwise/neptune-web/issues/1130)) ([fc50a09](https://github.com/transferwise/neptune-web/commit/fc50a09a03c11258f3c73639230a325d3d165f01))
56
+
57
+
58
+
59
+
60
+
61
+ ## [37.3.11](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.10...@transferwise/components@37.3.11) (2021-09-13)
62
+
63
+
64
+ ### Bug Fixes
65
+
66
+ * adjusting padding for tabs with auto width ([#1139](https://github.com/transferwise/neptune-web/issues/1139)) ([168a9e0](https://github.com/transferwise/neptune-web/commit/168a9e0cd23687b5e1cd2a26d4c70bf795cb7189))
67
+
68
+
69
+
70
+
71
+
72
+ ## [37.3.10](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.9...@transferwise/components@37.3.10) (2021-09-13)
73
+
74
+ **Note:** Version bump only for package @transferwise/components
75
+
76
+
77
+
78
+
79
+
80
+ ## [37.3.9](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.8...@transferwise/components@37.3.9) (2021-09-09)
81
+
82
+
83
+ ### Bug Fixes
84
+
85
+ * dimmer color for Angular comp and fix .on-scroll on unmount and update BT ([#1140](https://github.com/transferwise/neptune-web/issues/1140)) ([b146e9d](https://github.com/transferwise/neptune-web/commit/b146e9d9169660666c3f4bd564834965069427ed))
86
+
87
+
88
+
89
+
90
+
91
+ ## [37.3.8](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.7...@transferwise/components@37.3.8) (2021-09-06)
92
+
93
+ **Note:** Version bump only for package @transferwise/components
94
+
95
+
96
+
97
+
98
+
99
+ ## [37.3.7](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.6...@transferwise/components@37.3.7) (2021-09-06)
100
+
101
+
102
+ ### Bug Fixes
103
+
104
+ * add background color to keyline ([#1133](https://github.com/transferwise/neptune-web/issues/1133)) ([f170263](https://github.com/transferwise/neptune-web/commit/f170263e6f62d715077787b694977c4b0ab63e36))
105
+
106
+
107
+
108
+
109
+
110
+ ## [37.3.6](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.5...@transferwise/components@37.3.6) (2021-09-03)
111
+
112
+
113
+ ### Bug Fixes
114
+
115
+ * Switch disabled state ([#1124](https://github.com/transferwise/neptune-web/issues/1124)) ([556f1dd](https://github.com/transferwise/neptune-web/commit/556f1dda5667f2d6bc8ff95f4c39c6de5185f4bb))
116
+
117
+
118
+
119
+
120
+
121
+ ## [37.3.5](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.4...@transferwise/components@37.3.5) (2021-09-02)
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * fixing incorrect title text wrapping in drawer ([#1126](https://github.com/transferwise/neptune-web/issues/1126)) ([c91ecd7](https://github.com/transferwise/neptune-web/commit/c91ecd79a0dfe0986f725a3d7ec3e6812b2807c6))
127
+
128
+
129
+
130
+
131
+
132
+ ## [37.3.4](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.3...@transferwise/components@37.3.4) (2021-09-02)
133
+
134
+ **Note:** Version bump only for package @transferwise/components
135
+
136
+
137
+
138
+
139
+
140
+ ## [37.3.3](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.2...@transferwise/components@37.3.3) (2021-09-02)
141
+
142
+ **Note:** Version bump only for package @transferwise/components
143
+
144
+
145
+
146
+
147
+
148
+ ## [37.3.2](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.1...@transferwise/components@37.3.2) (2021-09-02)
149
+
150
+
151
+ ### Bug Fixes
152
+
153
+ * remove unused closeOnClick prop from Modal ([#1117](https://github.com/transferwise/neptune-web/issues/1117)) ([3b6cc4b](https://github.com/transferwise/neptune-web/commit/3b6cc4b6d7c1eb8cd536c02254e051d4beb0fa2e))
154
+
155
+
156
+
157
+
158
+
159
+ ## [37.3.1](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.3.0...@transferwise/components@37.3.1) (2021-08-26)
160
+
161
+
162
+ ### Bug Fixes
163
+
164
+ * localize placeholders and labels in DateInput ([#1110](https://github.com/transferwise/neptune-web/issues/1110)) ([0338ad6](https://github.com/transferwise/neptune-web/commit/0338ad64bba0dffd653196d8804fff34d432601b))
165
+
166
+
167
+
168
+
169
+
170
+ # [37.3.0](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.2.1...@transferwise/components@37.3.0) (2021-08-25)
171
+
172
+
173
+ ### Features
174
+
175
+ * add onClick to the Nudge ([#1108](https://github.com/transferwise/neptune-web/issues/1108)) ([265021c](https://github.com/transferwise/neptune-web/commit/265021cb9a060ccfd40458f4c065e87e3c5b0276))
176
+
177
+
178
+
179
+
180
+
6
181
  ## [37.2.1](https://github.com/transferwise/neptune-web/compare/@transferwise/components@37.2.0...@transferwise/components@37.2.1) (2021-08-18)
7
182
 
8
183
  **Note:** Version bump only for package @transferwise/components
@@ -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{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=a.disabled,c=a.size,d=a.value,e=a.dayLabel,f=a.monthLabel,g=a.yearLabel,h=a.monthFormat,i=a.mode,j=a.onChange,k=a.onFocus,l=a.onBlur,m=a.placeholders,n=a.id,o=useDirection(),p=o.isRTL,q=useIntl(),r=q.locale,s=function(){return d&&isDateValid(d)?"string"==typeof d?convertToLocalMidnight(d):d:null},t=function(a){var b=INITIAL_DEFAULT_STATE;if(d&&isDateValid(d)){var c=s();b=explodeDate(c),isMonthAndYearFormat(d)&&(b.day=null)}return b[a]},u=useState(function(){return t("day")}),v=_slicedToArray(u,2),w=v[0],x=v[1],y=useState(function(){return t("month")}),z=_slicedToArray(y,2),A=z[0],B=z[1],C=useState(function(){return t("year")}),D=_slicedToArray(C,2),E=D[0],F=D[1],G=useState(s),H=_slicedToArray(G,2),I=H[0],J=H[1],K=function(a){if(!isDateValid(a))return"";switch(i){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("-");}},L=function(){var a=getMonthNames(r,h);return/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:f}),/*#__PURE__*/_jsx(Select,{name:"month",className:"form-control",disabled:b,placeholder:m.month,options:M(),size:c,selected:null===A?null:{value:A,label:a[A]},onChange:function(a){return P(a)}})]})},M=function(){var a=[],b=getMonthNames(r,h);return b.forEach(function(b,c){a.push({value:c,label:b})}),a},N=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:w,b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:A,c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:E,d=null!=a&&null!=b&&null!=c?new Date(c,b,a):null,e=isDateValid(d)?d:null;e||R(INITIAL_DEFAULT_STATE),i===DateMode.MONTH_YEAR?0<=b&&c&&(b!==A||c!==E)&&R(e):a&&0<=b&&c&&(a!==w||b!==A||c!==E)&&R(e)},O=function(a){var b=S(a.target.value,A,E),c=b.checkedDay;x(c),N(c,A,E)},P=function(a){if(!a)return B(null),void N(w,null,E);var b=a?a.value:0,c=S(w,b,E),d=c.checkedDay;B(b),w&&d!==w&&x(d),N(d,b,E)},Q=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=S(w,A,b),e=d.checkedDay;w&&e!==w&&x(e),F(c),N(e,A,c)}else F(c),N(w,A,null)},R=function(a){a!==I&&(J(a),j(K(a)||null))},S=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}},T=i===DateMode.MONTH_YEAR,U=classNames({"col-sm-8":T,"col-sm-5":!T,"pull-right":p}),V=MonthBeforeDay.has(r);return/*#__PURE__*/_jsx("div",{className:"tw-date",id:n,onFocus:function onFocus(a){return shouldPropagateOnFocus(a)?k&&k():a.stopPropagation()},onBlur:function onBlur(a){return shouldPropagateOnBlur(a)?l&&l():a.stopPropagation()},children:/*#__PURE__*/_jsxs("div",{className:"row",children:[V&&/*#__PURE__*/_jsx("div",{className:U,children:L()}),!T&&/*#__PURE__*/_jsx("div",{className:classNames("col-sm-3",{"pull-right":p}),children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(c),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:e}),/*#__PURE__*/_jsx("input",{type:"number",name:"day",className:"form-control",value:w||"",placeholder:m.day,disabled:b,onChange:function(a){return O(a)}})]})})}),!V&&/*#__PURE__*/_jsx("div",{className:U,children:L()}),/*#__PURE__*/_jsx("div",{className:"col-sm-4",children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(c),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:g}),/*#__PURE__*/_jsx("input",{type:"number",name:"year",className:"form-control",placeholder:m.year,value:E||"",disabled:b,onChange:function(a){return Q(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{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.
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
- 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,dayLabel:"Day",monthLabel:"Month",yearLabel:"Year",monthFormat:MonthFormat.LONG,mode:DateMode.DAY_MONTH_YEAR,placeholders:{day:"DD",month:"Month",year:"YYYY"},id:""};export default DateInput;
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;
@@ -0,0 +1 @@
1
+ import{defineMessages}from"react-intl";export default defineMessages({monthLabel:{id:"neptune.DateInput.month.label"},dayLabel:{id:"neptune.DateInput.day.label"},yearLabel:{id:"neptune.DateInput.year.label"}});
@@ -1,5 +1,5 @@
1
1
  import classNames from"classnames";import PropTypes from"prop-types";import{useEffect,useRef}from"react";import CSSTransition from"react-transition-group/CSSTransition";import{addNoScrollBodyClass,removeNoScrollBodyClass}from"../common";import{isIosDevice}from"../common/deviceDetection";import FocusBoundary from"../common/focusBoundary";import withNextPortal from"../withNextPortal/withNextPortal";import DimmerManager from"./dimmerManager";import{jsx as _jsx}from"react/jsx-runtime";export var EXIT_ANIMATION=350;var dimmerManager=new DimmerManager,handleTouchMove=function(a){var b=a.target.className.startsWith("dimmer");// disable scroll on iOS devices for Dimmer area
2
2
  // this is because of bug in WebKit https://bugs.webkit.org/show_bug.cgi?id=220908
3
3
  // note: scrolling still works for children(s) as expected
4
- isIosDevice()&&b&&(a.stopPropagation(),a.preventDefault())},Dimmer=function(a){var b=a.children,c=a.className,d=a.disableClickToClose,e=a.fadeContentOnEnter,f=a.fadeContentOnExit,g=a.transparent,h=a.onClose,i=a.open,j=a.scrollable,k=useRef(),l=!d&&h?function closeOnClick(a){a.target===k.current&&h(a)}:void 0,m=function(a){"Escape"!==a.key||(a.stopPropagation(),h&&dimmerManager.isTop(k)&&h(a))};return useEffect(function(){return i&&(document.addEventListener("keydown",m),k.current&&k.current.addEventListener("touchmove",handleTouchMove),!g&&addNoScrollBodyClass()),function(){document.removeEventListener("keydown",m),k.current&&k.current.removeEventListener("touchmove",handleTouchMove),removeNoScrollBodyClass()}},[i]),/*#__PURE__*/_jsx(CSSTransition,{in:i,appear:!0// Wait for animation to finish before unmount.
5
- ,timeout:{enter:0,exit:EXIT_ANIMATION},classNames:{enter:classNames({"dimmer--enter-fade":e}),enterDone:classNames("dimmer--enter-done",{"dimmer--enter-fade":e}),exit:classNames("dimmer--exit",{"dimmer--exit-fade":f})},unmountOnExit:!0,onEnter:function onEnter(){return dimmerManager.add(k)},onExited:function onExited(){return dimmerManager.remove(k)},children:/*#__PURE__*/_jsx("div",{ref:k,className:classNames("dimmer",{"dimmer--scrollable":j,"dimmer--transparent":g},c),role:"presentation",onClick:l,children:/*#__PURE__*/_jsx(FocusBoundary,{children:b})})})};Dimmer.propTypes={children:PropTypes.node,className:PropTypes.string,disableClickToClose:PropTypes.bool,fadeContentOnEnter:PropTypes.bool,fadeContentOnExit:PropTypes.bool,/** Sets the background to transparent and prevents body scroll locking */transparent:PropTypes.bool,onClose:PropTypes.func,open:PropTypes.bool,scrollable:PropTypes.bool},Dimmer.defaultProps={children:null,className:void 0,disableClickToClose:!1,fadeContentOnEnter:!1,fadeContentOnExit:!1,transparent:!1,onClose:void 0,open:!1,scrollable:!1};export{Dimmer};export default withNextPortal(Dimmer);
4
+ isIosDevice()&&b&&(a.stopPropagation(),a.preventDefault())},Dimmer=function(a){var b=a.children,c=a.className,d=a.disableClickToClose,e=a.fadeContentOnEnter,f=a.fadeContentOnExit,g=a.transparent,h=a.onClose,i=a.open,j=a.scrollable,k=useRef(),l=!d&&h?function closeOnClick(a){a.target===k.current&&h(a)}:void 0,m=function(a){"Escape"!==a.key||(a.stopPropagation(),h&&dimmerManager.isTop(k)&&h(a))};return useEffect(function(){return i&&(document.addEventListener("keydown",m),k.current&&k.current.addEventListener("touchmove",handleTouchMove)),function(){document.removeEventListener("keydown",m),k.current&&k.current.removeEventListener("touchmove",handleTouchMove)}},[i]),/*#__PURE__*/_jsx(CSSTransition,{in:i,appear:!0// Wait for animation to finish before unmount.
5
+ ,timeout:{enter:0,exit:EXIT_ANIMATION},classNames:{enter:classNames({"dimmer--enter-fade":e}),enterDone:classNames("dimmer--enter-done",{"dimmer--enter-fade":e}),exit:classNames("dimmer--exit",{"dimmer--exit-fade":f})},unmountOnExit:!0,onEnter:function onEnter(){return dimmerManager.add(k)},onExited:function onExited(){return dimmerManager.remove(k)},children:/*#__PURE__*/_jsx(DimmerContentWrapper,{scrollBody:!g,children:/*#__PURE__*/_jsx("div",{ref:k,className:classNames("dimmer",{"dimmer--scrollable":j,"dimmer--transparent":g},c),role:"presentation",onClick:l,children:/*#__PURE__*/_jsx(FocusBoundary,{children:b})})})})};export var DimmerContentWrapper=function(a){var b=a.children,c=a.scrollBody;return useEffect(function(){return c&&addNoScrollBodyClass(),function(){c&&removeNoScrollBodyClass()}},[]),b};Dimmer.propTypes={children:PropTypes.node,className:PropTypes.string,disableClickToClose:PropTypes.bool,fadeContentOnEnter:PropTypes.bool,fadeContentOnExit:PropTypes.bool,/** Sets the background to transparent and prevents body scroll locking */transparent:PropTypes.bool,onClose:PropTypes.func,open:PropTypes.bool,scrollable:PropTypes.bool},Dimmer.defaultProps={children:null,className:void 0,disableClickToClose:!1,fadeContentOnEnter:!1,fadeContentOnExit:!1,transparent:!1,onClose:void 0,open:!1,scrollable:!1};export{Dimmer};export default withNextPortal(Dimmer);
@@ -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-p-x",{"np-drawer-header--withborder":d}),children:[/*#__PURE__*/_jsx(CloseButton,{className:"np-drawer-header",onClick:e}),d&&/*#__PURE__*/_jsx("div",{className:"align-heading m-l-2",children:/*#__PURE__*/_jsx("div",{className:"np-drawer-header--title h3",children:d})})]}),b&&/*#__PURE__*/_jsx("div",{className:classNames("np-drawer-content","np-drawer-p-x","np-drawer-p-y"),children:b}),c&&/*#__PURE__*/_jsx("div",{className:classNames("np-drawer-footer","np-drawer-p-x"),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 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,8 +1,9 @@
1
1
  {
2
2
  "neptune.ClearButton.ariaLabel": "Clear",
3
3
  "neptune.CloseButton.ariaLabel": "Close",
4
- "neptune.Link.ariaLabel": "Open link",
5
- "neptune.Link.ariaLabelNewTab": "Open link in a new tab",
4
+ "neptune.DateInput.day.label": "Day",
5
+ "neptune.DateInput.month.label": "Month",
6
+ "neptune.DateInput.year.label": "Year",
6
7
  "neptune.MoneyInput.Select.placeholder": "Select an option...",
7
8
  "neptune.Pagination.ariaLabel": "Pagination navigation",
8
9
  "neptune.PaginationLink.ariaLabel.active": "Go to page {pageNumber}",
@@ -1,12 +1,6 @@
1
- import{NavigateAway as NavigateAwayIcon}from"@transferwise/icons";import classNames from"classnames";import{useIntl}from"react-intl";import messages from"./Link.messages";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{NavigateAway as NavigateAwayIcon}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
  * Standard Link component with navigate away icon
3
3
  *
4
- * Docs link: https://transferwise.github.io/neptune-web/components/content/Link
4
+ * Documentation: https://transferwise.github.io/neptune-web/components/content/Link
5
5
  *
6
- * @param root0
7
- * @param root0.className
8
- * @param root0.children
9
- * @param root0.href
10
- * @param root0.target
11
- * @param root0.'aria-label'
12
- */var Link=function(a){var b=a.className,c=a.children,d=a.href,e=a.target,f=a["aria-label"],g=useIntl(),h=g.formatMessage,i="_blank"===e;return/*#__PURE__*/_jsxs("a",{href:d,target:e,className:classNames("np-link d-inline-flex",b),"aria-label":function getAriaLabel(){return f||h(i?messages.ariaLabelNewTab:messages.ariaLabel)}(),rel:i?"noreferrer":void 0,children:[c,i&&/*#__PURE__*/_jsx(NavigateAwayIcon,{className:"m-l-05"})]})};export default Link;
6
+ */var Link=function(a){var b=a.className,c=a.children,d=a.href,e=a.target,f=a["aria-label"],g="_blank"===e;return/*#__PURE__*/_jsxs("a",{href:d,target:e,className:classNames("np-link d-inline-flex",b),"aria-label":f,rel:g?"noreferrer":void 0,children:[c,g&&/*#__PURE__*/_jsx(NavigateAwayIcon,{className:"m-l-05"})]})};export default Link;
@@ -0,0 +1 @@
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"@testing-library/jest-dom";import{render,screen}from"../test-utils";import Link from".";import{jsx as _jsx}from"react/jsx-runtime";describe("Link",function(){var a={className:"a-class",href:"/test"};it("renders Link component",function(){render(/*#__PURE__*/_jsx(Link,_objectSpread(_objectSpread({},a),{},{children:"link text"})));var b=screen.getByRole("link",{name:"link text"});expect(b).toHaveAttribute("href",a.href),expect(b).toHaveClass(a.className),expect(b).not.toHaveAttribute("target"),expect(b).not.toHaveAttribute("rel")}),it("renders target and rel attributes when target is _blank",function(){render(/*#__PURE__*/_jsx(Link,_objectSpread(_objectSpread({},a),{},{target:"_blank",children:"link text"})));var b=screen.getByText("link text");expect(b).toHaveAttribute("target","_blank"),expect(b).toHaveAttribute("rel","noreferrer")}),it("renders with the provided aria-label",function(){render(/*#__PURE__*/_jsx(Link,_objectSpread(_objectSpread({},a),{},{"aria-label":"make me accessible",children:"link text"})));var b=screen.getByText("link text");expect(b).toHaveAttribute("aria-label","make me accessible")})});
@@ -0,0 +1 @@
1
+ import Link from".";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";export default{component:Link,title:"Link"};export var Basic=function(){return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsxs("p",{children:["Lorem Ipsum is simply dummy text of the printing and typesetting industry"," ",/*#__PURE__*/_jsx(Link,{"aria-label":"Click here for more details",href:"#",children:"content"}),". Lorem Ipsum has been the industry standard dummy text ever since the 1500s."]}),/*#__PURE__*/_jsxs("p",{children:["Lorem Ipsum is simply dummy text of the printing and typesetting industry"," ",/*#__PURE__*/_jsx(Link,{href:"https://wise.com",target:"_blank",children:"https://wise.com"}),". Lorem Ipsum has been the industry standard dummy text ever since the 1500s."]})]})};
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["title","body","footer","onClose","className","open","size","closeOnClick","scroll","position"];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 CSSTransition from"react-transition-group/CSSTransition";import{Size,Position,Scroll}from"../common";import CloseButton from"../common/closeButton";import Dimmer from"../dimmer";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var TRANSITION_DURATION_IN_MILLISECONDS=150,Modal=function(a){var b=a.title,c=a.body,d=a.footer,e=a.onClose,f=a.className,g=a.open,h=a.size,i=a.closeOnClick,j=a.scroll,k=a.position,l=_objectWithoutProperties(a,_excluded),m=function(a){return f.split(" ").includes(a)},n=m("compact"),o=m("no-divider");return/*#__PURE__*/_jsx(Dimmer,{open:g,scrollable:j===Scroll.CONTENT,className:classNames("d-flex","justify-content-center"),onClose:e,children:/*#__PURE__*/_jsx(CSSTransition,{appear:!0,in:g,classNames:{enterDone:"in"},timeout:TRANSITION_DURATION_IN_MILLISECONDS,unmountOnExit:!0,children:/*#__PURE__*/_jsx("div",_objectSpread(_objectSpread({className:classNames("tw-modal",{"tw-modal--content":j===Scroll.CONTENT,"align-self-center":k===Position.CENTER},"fade","outline-none",f)},l),{},{children:/*#__PURE__*/_jsx("div",{className:classNames("tw-modal-dialog","d-flex",_defineProperty({},"tw-modal-".concat(h),h)),"aria-modal":!0,role:"dialog",children:/*#__PURE__*/_jsxs("div",{className:classNames("tw-modal-content","d-flex","flex-column","justify-content-between",{"tw-modal-compact":n,"tw-modal-no-title":!b}),children:[/*#__PURE__*/_jsxs("div",{className:classNames("tw-modal-header","d-flex","align-items-center","justify-content-between","flex-wrap",{"modal--withoutborder":!b||o}),children:[/*#__PURE__*/_jsx("h4",{className:"tw-modal-title",children:b}),/*#__PURE__*/_jsx(CloseButton,{onClick:e})]}),/*#__PURE__*/_jsx("div",{className:"tw-modal-body",children:c}),d&&/*#__PURE__*/_jsx("div",{className:classNames("tw-modal-footer","d-flex","align-items-center","flex-wrap",{"modal--withoutborder":o}),children:d})]})})}))})})};Modal.propTypes={title:PropTypes.node,body:PropTypes.node.isRequired,footer:PropTypes.node,size:PropTypes.oneOf(["sm","md","lg","xl"]),onClose:PropTypes.func.isRequired,className:PropTypes.string,open:PropTypes.bool.isRequired,closeOnClick:PropTypes.bool,scroll:PropTypes.oneOf(["content","viewport"]),position:PropTypes.oneOf(["top","center"])},Modal.defaultProps={title:null,footer:null,size:Size.MEDIUM,className:"",closeOnClick:!0,scroll:Scroll.VIEWPORT,position:Position.CENTER};export default Modal;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["title","body","footer","onClose","className","open","size","scroll","position"];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 CSSTransition from"react-transition-group/CSSTransition";import{Size,Position,Scroll}from"../common";import CloseButton from"../common/closeButton";import Dimmer from"../dimmer";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var TRANSITION_DURATION_IN_MILLISECONDS=150,Modal=function(a){var b=a.title,c=a.body,d=a.footer,e=a.onClose,f=a.className,g=a.open,h=a.size,i=a.scroll,j=a.position,k=_objectWithoutProperties(a,_excluded),l=function(a){return f.split(" ").includes(a)},m=l("compact"),n=l("no-divider");return/*#__PURE__*/_jsx(Dimmer,{open:g,scrollable:i===Scroll.CONTENT,className:classNames("d-flex","justify-content-center"),onClose:e,children:/*#__PURE__*/_jsx(CSSTransition,{appear:!0,in:g,classNames:{enterDone:"in"},timeout:TRANSITION_DURATION_IN_MILLISECONDS,unmountOnExit:!0,children:/*#__PURE__*/_jsx("div",_objectSpread(_objectSpread({className:classNames("tw-modal",{"tw-modal--content":i===Scroll.CONTENT,"align-self-center":j===Position.CENTER},"fade","outline-none",f)},k),{},{children:/*#__PURE__*/_jsx("div",{className:classNames("tw-modal-dialog","d-flex",_defineProperty({},"tw-modal-".concat(h),h)),"aria-modal":!0,role:"dialog",children:/*#__PURE__*/_jsxs("div",{className:classNames("tw-modal-content","d-flex","flex-column","justify-content-between",{"tw-modal-compact":m,"tw-modal-no-title":!b}),children:[/*#__PURE__*/_jsxs("div",{className:classNames("tw-modal-header","d-flex","align-items-center","justify-content-between","flex-wrap",{"modal--withoutborder":!b||n}),children:[/*#__PURE__*/_jsx("h4",{className:"tw-modal-title",children:b}),/*#__PURE__*/_jsx(CloseButton,{onClick:e})]}),/*#__PURE__*/_jsx("div",{className:"tw-modal-body",children:c}),d&&/*#__PURE__*/_jsx("div",{className:classNames("tw-modal-footer","d-flex","align-items-center","flex-wrap",{"modal--withoutborder":n}),children:d})]})})}))})})};Modal.propTypes={title:PropTypes.node,body:PropTypes.node.isRequired,footer:PropTypes.node,size:PropTypes.oneOf(["sm","md","lg","xl"]),onClose:PropTypes.func.isRequired,className:PropTypes.string,open:PropTypes.bool.isRequired,scroll:PropTypes.oneOf(["content","viewport"]),position:PropTypes.oneOf(["top","center"])},Modal.defaultProps={title:null,footer:null,size:Size.MEDIUM,className:"",scroll:Scroll.VIEWPORT,position:Position.CENTER};export default Modal;
@@ -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.onDismiss,g=a.id,h=a.className,i=useDirection(),j=i.isRTL;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-nudge media",h),id:g,children:[/*#__PURE__*/_jsx("div",{className:classNames({"media-left":!j,"media-right":j}),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",children:d})]}),/*#__PURE__*/_jsx("div",{className:classNames({"media-right":!j,"media-left":j}),children:/*#__PURE__*/_jsx("button",{type:"button",className:"close","aria-label":"close",onClick:f,children:/*#__PURE__*/_jsx(CrossIcon,{})})})]})};Nudge.propTypes={media:PropTypes.node.isRequired,title:PropTypes.node.isRequired,link:PropTypes.node.isRequired,href:PropTypes.string.isRequired,onDismiss:PropTypes.func.isRequired,id:PropTypes.string,className:PropTypes.string},Nudge.defaultProps={id:null,className:null};export default Nudge;
1
+ import classNames from"classnames";import PropTypes from"prop-types";import CloseButton from"../common/closeButton";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(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,3 +1,4 @@
1
- function supportsTouchEvents(){var a="undefined"!=typeof window&&window.ontouchstart!==void 0,b="undefined"!=typeof navigator&&navigator.maxTouchPoints,c="undefined"!=typeof window&&window.DocumentTouch&&document instanceof window.DocumentTouch;return!!(a||b||c)}function userAgentSuggestsTouchDevice(){var a=["android","iemobile","iphone","ipad","ipod","blackberry","bada"].map(function(a){return"(".concat(a,")")}).join("|"),b=new RegExp(a,"ig");return"undefined"!=typeof navigator&&!!navigator.userAgent.match(b)}// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
1
+ function supportsTouchEvents(){var a="undefined"!=typeof window&&window.ontouchstart!==void 0,b="undefined"!=typeof navigator&&navigator.maxTouchPoints,c="undefined"!=typeof window&&window.DocumentTouch&&document instanceof window.DocumentTouch;// eslint-disable-next-line compat/compat
2
+ return!!(a||b||c)}function userAgentSuggestsTouchDevice(){var a=["android","iemobile","iphone","ipad","ipod","blackberry","bada"].map(function(a){return"(".concat(a,")")}).join("|"),b=new RegExp(a,"ig");return"undefined"!=typeof navigator&&!!navigator.userAgent.match(b)}// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
2
3
  // Only use this for small vanity changes where it still works either way.
3
4
  export function isTouchDevice(){return supportsTouchEvents()||userAgentSuggestsTouchDevice()}
@@ -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},e),tabIndex:0,role:"switch","aria-checked":d,"aria-label":i,"aria-labelledby":j,id:f,"aria-disabled":h,onClick:g,onKeyDown: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{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 +1 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useState}from"react";import Switch from"./Switch";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export default{component:Switch,title:"Switch"};export var Basic=function(){var a=useState(!1),b=_slicedToArray(a,2),c=b[0],d=b[1];return/*#__PURE__*/_jsxs("div",{className:"d-flex flex-column",children:[/*#__PURE__*/_jsx("label",{id:"labelID",htmlFor:"switchId",children:"A switch with a label"}),/*#__PURE__*/_jsx(Switch,{checked:c,className:"a-class-name","aria-labelledby":"labelID",id:"switchId",onClick:function onClick(){return d(!c)}}),/*#__PURE__*/_jsx(Switch,{checked:c,className:"a-class-name m-t-4","aria-label":"I'm a switch without label",onClick:function onClick(){return d(!c)}})]})};
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useState}from"react";import Switch from"./Switch";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export default{component:Switch,title:"Switch"};export var Basic=function(){var a=useState(!1),b=_slicedToArray(a,2),c=b[0],d=b[1];return/*#__PURE__*/_jsxs("div",{className:"d-flex flex-column",children:[/*#__PURE__*/_jsx("label",{id:"labelID",htmlFor:"switchId",children:"A switch with a label"}),/*#__PURE__*/_jsx(Switch,{checked:c,className:"a-class-name","aria-labelledby":"labelID",id:"switchId",onClick:function onClick(){return d(!c)}}),/*#__PURE__*/_jsx(Switch,{checked:c,className:"a-class-name m-t-4","aria-label":"I'm a switch without label",onClick:function onClick(){return d(!c)}})]})};export var Disabled=function(){var a=useState(!1),b=_slicedToArray(a,2),c=b[0],d=b[1];return/*#__PURE__*/_jsxs("div",{className:"d-flex flex-column",children:[/*#__PURE__*/_jsx(Switch,{checked:c,disabled:!0,className:"a-class-name","aria-labelledby":"labelID",id:"switchId",onClick:function onClick(){return d(!c)}}),/*#__PURE__*/_jsx(Switch,{checked:!c,disabled:!0,className:"a-class-name","aria-labelledby":"labelID",id:"switchId",onClick:function onClick(){return d(!c)}})]})};
@@ -1 +1 @@
1
- import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import classNames from"classnames";import clamp from"lodash.clamp";import PropTypes from"prop-types";import{Component,Fragment}from"react";import{Spring}from"react-spring/renderprops.cjs";import{Size,Width}from"../common";import KeyCodes from"../common/keyCodes";import Tab from"./Tab";import TabList from"./TabList";import TabPanel from"./TabPanel";import{getElasticDragDifference,getSwipeDifference,swipedLeftToRight,swipedRightToLeft,swipeShouldChangeTab,getVelocity}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MIN_INDEX=0,enabledTabsFilter=function(a){return!a.disabled},SpacerWidth={default:0,xs:8,sm:16,md:24,lg:32},Tabs=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"container",null),_defineProperty(_assertThisInitialized(d),"containerWidth",0),_defineProperty(_assertThisInitialized(d),"tabRefs",[]),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setContainerWidth(d.container),d.setState(function(a){var b=a.selectedTabIndex;return{translateTo:-(d.containerWidth*b)}})}),_defineProperty(_assertThisInitialized(d),"setContainerRefAndWidth",function(a){d.container=a,d.setContainerWidth(a)}),_defineProperty(_assertThisInitialized(d),"setContainerWidth",function(a){if(a){var b=a.getBoundingClientRect(),c=b.width;d.containerWidth=c}}),_defineProperty(_assertThisInitialized(d),"isTabDisabled",function(a){var b=d.props.tabs;return b[a]&&b[a].disabled}),_defineProperty(_assertThisInitialized(d),"getAllTabsWidth",function(){return d.tabRefs.map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"getDistanceToSelectedTab",function(a){return d.tabRefs.filter(function(b,c){return c<a}).map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"setTabWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.headerWidth,e=b.selected,f=d.getAllTabsWidth();!a&&(c===Width.BLOCK||d.containerWidth<f)&&d.setState({fullWidthTabs:!0,translateLineX:"".concat(100*e,"%")}),a&&c===Width.AUTO&&d.containerWidth>=f&&d.setState({fullWidthTabs:!1,translateLineX:"".concat(d.getDistanceToSelectedTab(e),"px")})}),_defineProperty(_assertThisInitialized(d),"getTabLineWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.selected,e=b.tabs;if(a)return"".concat(100*(1/e.length),"%");var f=d.tabRefs[c]||d.tabRefs[d.tabRefs.length-1],g=f?f.getBoundingClientRect().width:0;return"".concat(g,"px")}),_defineProperty(_assertThisInitialized(d),"getTabToSelect",function(a,b,c){var e=a;if(swipedLeftToRight(b,c)){if(e-=1,e>MIN_INDEX&&d.isTabDisabled(e))return d.getTabToSelect(e,b,c);}else if(swipedRightToLeft(b,c)&&(e+=1,e<d.MAX_INDEX&&d.isTabDisabled(e)))return d.getTabToSelect(e,b,c);return e=clamp(e,Math.max(a-1,MIN_INDEX),Math.min(a+1,d.MAX_INDEX)),d.isTabDisabled(e)?a:e}),_defineProperty(_assertThisInitialized(d),"swipedOverHalfOfContainer",function(a){return .5<=a/d.containerWidth}),_defineProperty(_assertThisInitialized(d),"calculateApplicableDragDifference",function(a){var b=a.currentSelected,c=a.nextSelected,e=a.start,f=a.end,g=getSwipeDifference(e,f),h=getElasticDragDifference(g);return swipedLeftToRight(e,f)?b>MIN_INDEX&&b!==c?Math.min(g,d.containerWidth):h:!!swipedRightToLeft(e,f)&&(b<d.MAX_INDEX&&b!==c?-Math.min(g,d.containerWidth):-h)}),_defineProperty(_assertThisInitialized(d),"switchTab",function(a){var b=d.props.onTabSelect;b(a)}),_defineProperty(_assertThisInitialized(d),"animateToTab",function(a,b){d.animateLine(a),d.animatePanel(d.getTabIndexWithoutDisabledTabs(a),b)}),_defineProperty(_assertThisInitialized(d),"animateLine",function(a){d.setState(function(b){return{translateLineX:b.fullWidthTabs?"".concat(100*a,"%"):"".concat(d.getDistanceToSelectedTab(a),"px")}})}),_defineProperty(_assertThisInitialized(d),"animatePanel",function(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=d.state.translateTo,e=c,f=-(d.containerWidth*a);d.setState({selectedTabIndex:a,isAnimating:!b&&e!==f,translateFrom:e,translateTo:f})}),_defineProperty(_assertThisInitialized(d),"disableScroll",function(a){var b=d.state.isSwiping;b&&a.preventDefault()}),_defineProperty(_assertThisInitialized(d),"handleTabClick",function(a){return function(){d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"onKeyDown",function(a){return function(b){b&&b.keyCode===KeyCodes.ENTER&&d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){var b={x:a.nativeEvent.touches[0].clientX,y:a.nativeEvent.touches[0].clientY,time:Date.now()};d.setState({start:b,currentSwipe:[b]}),a.persist()}),_defineProperty(_assertThisInitialized(d),"handleTouchMove",function(a){var b=d.state.start,c=d.props.selected,e=d.getTabIndexWithoutDisabledTabs(c),f={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},g=getSwipeDifference(b,f),h=getSwipeDifference(b,f,"y"),i=d.state,j=i.isScrolling,k=i.isSwiping;if(a.persist(),j||k||(g>h?k=!0:j=!0),d.setState({isScrolling:j,isSwiping:k}),k){var n=d.getTabToSelect(c,b,f);d.animateLine(d.swipedOverHalfOfContainer(g)?n:c);var l=d.calculateApplicableDragDifference({currentSelected:c,nextSelected:n,start:b,end:f}),m=!!l&&-(d.containerWidth*e)+l;d.setState(function(a){return{currentSwipe:[].concat(_toConsumableArray(a.currentSwipe),[f]),translateFrom:m||a.translateFrom,translateTo:m||a.translateTo}})}}),_defineProperty(_assertThisInitialized(d),"handleTouchEnd",function(a){var b=d.state,c=b.start,e=b.isSwiping,f=d.props.selected,g={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},h=getSwipeDifference(c,g),i=getVelocity([].concat(_toConsumableArray(d.state.currentSwipe),[g]));d.setState({currentSwipe:[]});var j=f;a.persist(),e&&((swipeShouldChangeTab(c,g)||d.swipedOverHalfOfContainer(h))&&(j=d.getTabToSelect(j,c,g)),j===f?d.animateToTab(j):(d.switchTab(j),d.setState({lastSwipeVelocity:i}))),d.setState({isSwiping:!1,isScrolling:!1})}),d.state={start:null,translateX:0,translateFrom:0,translateTo:0,translateLineX:null,isAnimating:!1,isSwiping:!1,isScrolling:!1,lastSwipeVelocity:0,fullWidthTabs:a.headerWidth===Width.BLOCK},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"filteredTabsLength",get:function get(){return this.props.tabs.filter(enabledTabsFilter).length}},{key:"MAX_INDEX",get:function get(){return this.props.tabs.length-1}},{key:"componentDidMount",value:function componentDidMount(){var a=this.props.selected;this.setTabWidth(),this.switchTab(clamp(a,MIN_INDEX,this.MAX_INDEX)),this.animateToTab(clamp(a,MIN_INDEX,this.MAX_INDEX),!0),document.body.addEventListener("touchmove",this.disableScroll,{passive:!1}),document.body.addEventListener("touchforcechange",this.disableScroll,{passive:!1}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function componentDidUpdate(a,b){var c=this.props.selected,d=a.selected,e=this.props.tabs[c],f=e&&e.disabled,g=a.tabs[d],h=g&&g.disabled,i=this.props.tabs.length,j=a.tabs.length,k=this.props.tabs.filter(enabledTabsFilter).length,l=a.tabs.filter(enabledTabsFilter).length,m=this.props.headerWidth,n=a.headerWidth,o=this.props.animatePanelsOnClick,p=!o&&!b.isSwiping;(m!==n||i!==j)&&this.setTabWidth(),(c!==d||k!==l||f!==h)&&this.animateToTab(clamp(c,MIN_INDEX,this.MAX_INDEX),c===d||p)}},{key:"componentWillUnmount",value:function componentWillUnmount(){document.body.removeEventListener("touchmove",this.disableScroll),document.body.removeEventListener("touchforcechange",this.disableScroll),window.removeEventListener("resize",this.handleResize)}},{key:"getTabIndexWithoutDisabledTabs",value:function getTabIndexWithoutDisabledTabs(a){return a-this.props.tabs.slice(0,a).filter(function(a){return!enabledTabsFilter(a)}).length}},{key:"render",value:function render(){var a=this,b=this.props,c=b.tabs,d=b.changeTabOnSwipe,e=b.name,f=b.selected,g=b.className,h=b.transitionSpacing,i=this.state,j=i.isSwiping,k=i.translateLineX,l=i.isAnimating,m=i.translateFrom,n=i.translateTo,o=i.lastSwipeVelocity,p=i.fullWidthTabs,q=SpacerWidth[h],r=this.filteredTabsLength,s=Math.abs(-m-this.containerWidth*f),t=j?1-s/this.containerWidth:1-Math.abs(s/this.containerWidth-1),u=(Number.isNaN(t)?0:t)*Math.min(10*Math.E,10*o*Math.E),v=l||j,w=r*this.containerWidth+2*q,x=function(a){var b=a.id;return 0<q&&/*#__PURE__*/_jsx("div",{style:{width:q,display:v?"block":"none"}},b)};return/*#__PURE__*/_jsxs("div",{className:classNames("tabs",g),onTouchStart:d?this.handleTouchStart:void 0,onTouchEnd:d?this.handleTouchEnd:void 0,onTouchMove:d?this.handleTouchMove:void 0,children:[/*#__PURE__*/_jsxs(TabList,{children:[c.map(function(b,d){var g=b.title,h=b.disabled;return/*#__PURE__*/_jsx(Tab,_objectSpread(_objectSpread({ref:function ref(b){a.tabRefs[d]=b},id:"".concat(e,"-tab-").concat(d),panelId:"".concat(e,"-panel-").concat(d),selected:f===d,disabled:h,focusTab:function focusTab(){a.tabRefs[d].focus()},onClick:h?null:a.handleTabClick(d),onKeyDown:a.onKeyDown(d)},p?{style:{width:"".concat(100*(1/c.length),"%")}}:{}),{},{children:g}),g)}),k?/*#__PURE__*/_jsx("div",{className:classNames("tabs__line"),style:{width:this.getTabLineWidth(),transform:"translateX(".concat(k,")")}}):null]}),/*#__PURE__*/_jsx("div",{ref:this.setContainerRefAndWidth,className:"tabs__panel-container",style:{overflow:v?"hidden":"visible"},children:/*#__PURE__*/_jsx(Spring,{from:{transform:"translateX(".concat(m-q,"px)")},to:{transform:"translateX(".concat(n-q,"px)")},config:{precision:j?1:.01,velocity:j?0:u,clamp:!0},onRest:function onRest(){l&&a.setState({isAnimating:!1,lastSwipeVelocity:0})},children:function children(b){return/*#__PURE__*/_jsx("div",{className:"tabs__slider",style:{width:v?"".concat(w,"px"):"100%",transform:v?b.transform:"translateX(0px)"},children:c.map(function(b,d){var g=b.content,h=b.disabled;return h?null:/*#__PURE__*/_jsxs(Fragment,{children:[d===f&&/*#__PURE__*/_jsx(x,{id:"left-spacer"}),/*#__PURE__*/_jsx(TabPanel,{tabId:"".concat(e,"-tab-").concat(d),id:"".concat(e,"-panel-").concat(d),style:{width:v?"".concat(a.containerWidth,"px"):"100%",display:v||d===f?"block":"none"},children:g},c[d].title),d===f&&/*#__PURE__*/_jsx(x,{id:"right-spacer"})]},"".concat(c[d].title,"-fragment"))})})}})})]})}}]),b}(Component),SpacerSizes=_objectSpread(_objectSpread({},Size),{},{NONE:"default"});Tabs.propTypes={tabs:PropTypes.arrayOf(PropTypes.shape({title:PropTypes.string.isRequired,content:PropTypes.node.isRequired,disabled:PropTypes.bool.isRequired})).isRequired,selected:PropTypes.number.isRequired,onTabSelect:PropTypes.func.isRequired,name:PropTypes.string.isRequired,animatePanelsOnClick:PropTypes.bool,changeTabOnSwipe:PropTypes.bool,className:PropTypes.string,transitionSpacing:PropTypes.oneOf(["default","xs","sm","md","lg"]),headerWidth:PropTypes.oneOf(["auto","block"])},Tabs.defaultProps={animatePanelsOnClick:!1,changeTabOnSwipe:!0,className:"",transitionSpacing:SpacerSizes.NONE,headerWidth:Width.BLOCK};export default Tabs;
1
+ import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import classNames from"classnames";import clamp from"lodash.clamp";import PropTypes from"prop-types";import{Component,Fragment}from"react";import{Spring}from"react-spring/renderprops.cjs";import{Size,Width}from"../common";import KeyCodes from"../common/keyCodes";import Tab from"./Tab";import TabList from"./TabList";import TabPanel from"./TabPanel";import{getElasticDragDifference,getSwipeDifference,swipedLeftToRight,swipedRightToLeft,swipeShouldChangeTab,getVelocity}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MIN_INDEX=0,enabledTabsFilter=function(a){return!a.disabled},SpacerWidth={default:0,xs:8,sm:16,md:24,lg:32},Tabs=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"container",null),_defineProperty(_assertThisInitialized(d),"containerWidth",0),_defineProperty(_assertThisInitialized(d),"tabRefs",[]),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setContainerWidth(d.container),d.setState(function(a){var b=a.selectedTabIndex;return{translateTo:-(d.containerWidth*b)}})}),_defineProperty(_assertThisInitialized(d),"setContainerRefAndWidth",function(a){d.container=a,d.setContainerWidth(a)}),_defineProperty(_assertThisInitialized(d),"setContainerWidth",function(a){if(a){var b=a.getBoundingClientRect(),c=b.width;d.containerWidth=c}}),_defineProperty(_assertThisInitialized(d),"isTabDisabled",function(a){var b=d.props.tabs;return b[a]&&b[a].disabled}),_defineProperty(_assertThisInitialized(d),"getAllTabsWidth",function(){return d.tabRefs.map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"getDistanceToSelectedTab",function(a){return d.tabRefs.filter(function(b,c){return c<a}).map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"setTabWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.headerWidth,e=b.selected,f=d.getAllTabsWidth();!a&&(c===Width.BLOCK||d.containerWidth<f)&&d.setState({fullWidthTabs:!0,translateLineX:"".concat(100*e,"%")}),a&&c===Width.AUTO&&d.containerWidth>=f&&d.setState({fullWidthTabs:!1,translateLineX:"".concat(d.getDistanceToSelectedTab(e),"px")})}),_defineProperty(_assertThisInitialized(d),"getTabLineWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.selected,e=b.tabs;if(a)return"".concat(100*(1/e.length),"%");var f=d.tabRefs[c]||d.tabRefs[d.tabRefs.length-1],g=f?f.getBoundingClientRect().width:0;return"".concat(g,"px")}),_defineProperty(_assertThisInitialized(d),"getTabToSelect",function(a,b,c){var e=a;if(swipedLeftToRight(b,c)){if(e-=1,e>MIN_INDEX&&d.isTabDisabled(e))return d.getTabToSelect(e,b,c);}else if(swipedRightToLeft(b,c)&&(e+=1,e<d.MAX_INDEX&&d.isTabDisabled(e)))return d.getTabToSelect(e,b,c);return e=clamp(e,Math.max(a-1,MIN_INDEX),Math.min(a+1,d.MAX_INDEX)),d.isTabDisabled(e)?a:e}),_defineProperty(_assertThisInitialized(d),"swipedOverHalfOfContainer",function(a){return .5<=a/d.containerWidth}),_defineProperty(_assertThisInitialized(d),"calculateApplicableDragDifference",function(a){var b=a.currentSelected,c=a.nextSelected,e=a.start,f=a.end,g=getSwipeDifference(e,f),h=getElasticDragDifference(g);return swipedLeftToRight(e,f)?b>MIN_INDEX&&b!==c?Math.min(g,d.containerWidth):h:!!swipedRightToLeft(e,f)&&(b<d.MAX_INDEX&&b!==c?-Math.min(g,d.containerWidth):-h)}),_defineProperty(_assertThisInitialized(d),"switchTab",function(a){var b=d.props.onTabSelect;b(a)}),_defineProperty(_assertThisInitialized(d),"animateToTab",function(a,b){d.animateLine(a),d.animatePanel(d.getTabIndexWithoutDisabledTabs(a),b)}),_defineProperty(_assertThisInitialized(d),"animateLine",function(a){d.setState(function(b){return{translateLineX:b.fullWidthTabs?"".concat(100*a,"%"):"".concat(d.getDistanceToSelectedTab(a),"px")}})}),_defineProperty(_assertThisInitialized(d),"animatePanel",function(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=d.state.translateTo,e=c,f=-(d.containerWidth*a);d.setState({selectedTabIndex:a,isAnimating:!b&&e!==f,translateFrom:e,translateTo:f})}),_defineProperty(_assertThisInitialized(d),"disableScroll",function(a){var b=d.state.isSwiping;b&&a.preventDefault()}),_defineProperty(_assertThisInitialized(d),"handleTabClick",function(a){return function(){d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"onKeyDown",function(a){return function(b){b&&b.keyCode===KeyCodes.ENTER&&d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){var b={x:a.nativeEvent.touches[0].clientX,y:a.nativeEvent.touches[0].clientY,time:Date.now()};d.setState({start:b,currentSwipe:[b]}),a.persist()}),_defineProperty(_assertThisInitialized(d),"handleTouchMove",function(a){var b=d.state.start,c=d.props.selected,e=d.getTabIndexWithoutDisabledTabs(c),f={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},g=getSwipeDifference(b,f),h=getSwipeDifference(b,f,"y"),i=d.state,j=i.isScrolling,k=i.isSwiping;if(a.persist(),j||k||(g>h?k=!0:j=!0),d.setState({isScrolling:j,isSwiping:k}),k){var n=d.getTabToSelect(c,b,f);d.animateLine(d.swipedOverHalfOfContainer(g)?n:c);var l=d.calculateApplicableDragDifference({currentSelected:c,nextSelected:n,start:b,end:f}),m=!!l&&-(d.containerWidth*e)+l;d.setState(function(a){return{currentSwipe:[].concat(_toConsumableArray(a.currentSwipe),[f]),translateFrom:m||a.translateFrom,translateTo:m||a.translateTo}})}}),_defineProperty(_assertThisInitialized(d),"handleTouchEnd",function(a){var b=d.state,c=b.start,e=b.isSwiping,f=d.props.selected,g={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},h=getSwipeDifference(c,g),i=getVelocity([].concat(_toConsumableArray(d.state.currentSwipe),[g]));d.setState({currentSwipe:[]});var j=f;a.persist(),e&&((swipeShouldChangeTab(c,g)||d.swipedOverHalfOfContainer(h))&&(j=d.getTabToSelect(j,c,g)),j===f?d.animateToTab(j):(d.switchTab(j),d.setState({lastSwipeVelocity:i}))),d.setState({isSwiping:!1,isScrolling:!1})}),d.state={start:null,translateX:0,translateFrom:0,translateTo:0,translateLineX:null,isAnimating:!1,isSwiping:!1,isScrolling:!1,lastSwipeVelocity:0,fullWidthTabs:a.headerWidth===Width.BLOCK},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"filteredTabsLength",get:function get(){return this.props.tabs.filter(enabledTabsFilter).length}},{key:"MAX_INDEX",get:function get(){return this.props.tabs.length-1}},{key:"componentDidMount",value:function componentDidMount(){var a=this.props.selected;this.setTabWidth(),this.switchTab(clamp(a,MIN_INDEX,this.MAX_INDEX)),this.animateToTab(clamp(a,MIN_INDEX,this.MAX_INDEX),!0),document.body.addEventListener("touchmove",this.disableScroll,{passive:!1}),document.body.addEventListener("touchforcechange",this.disableScroll,{passive:!1}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function componentDidUpdate(a,b){var c=this.props.selected,d=a.selected,e=this.props.tabs[c],f=e&&e.disabled,g=a.tabs[d],h=g&&g.disabled,i=this.props.tabs.length,j=a.tabs.length,k=this.props.tabs.filter(enabledTabsFilter).length,l=a.tabs.filter(enabledTabsFilter).length,m=this.props.headerWidth,n=a.headerWidth,o=this.props.animatePanelsOnClick,p=!o&&!b.isSwiping;(m!==n||i!==j)&&this.setTabWidth(),(c!==d||k!==l||f!==h)&&this.animateToTab(clamp(c,MIN_INDEX,this.MAX_INDEX),c===d||p)}},{key:"componentWillUnmount",value:function componentWillUnmount(){document.body.removeEventListener("touchmove",this.disableScroll),document.body.removeEventListener("touchforcechange",this.disableScroll),window.removeEventListener("resize",this.handleResize)}},{key:"getTabIndexWithoutDisabledTabs",value:function getTabIndexWithoutDisabledTabs(a){return a-this.props.tabs.slice(0,a).filter(function(a){return!enabledTabsFilter(a)}).length}},{key:"render",value:function render(){var a=this,b=this.props,c=b.tabs,d=b.changeTabOnSwipe,e=b.name,f=b.selected,g=b.className,h=b.transitionSpacing,i=b.headerWidth,j=this.state,k=j.isSwiping,l=j.translateLineX,m=j.isAnimating,n=j.translateFrom,o=j.translateTo,p=j.lastSwipeVelocity,q=j.fullWidthTabs,r=SpacerWidth[h],s=this.filteredTabsLength,t=Math.abs(-n-this.containerWidth*f),u=k?1-t/this.containerWidth:1-Math.abs(t/this.containerWidth-1),v=(Number.isNaN(u)?0:u)*Math.min(10*Math.E,10*p*Math.E),w=m||k,x=s*this.containerWidth+2*r,y=function(a){var b=a.id;return 0<r&&/*#__PURE__*/_jsx("div",{style:{width:r,display:w?"block":"none"}},b)};return/*#__PURE__*/_jsxs("div",{className:classNames("tabs",g,{"tabs--auto-width":i===Width.AUTO}),onTouchStart:d?this.handleTouchStart:void 0,onTouchEnd:d?this.handleTouchEnd:void 0,onTouchMove:d?this.handleTouchMove:void 0,children:[/*#__PURE__*/_jsxs(TabList,{children:[c.map(function(b,d){var g=b.title,h=b.disabled;return/*#__PURE__*/_jsx(Tab,_objectSpread(_objectSpread({ref:function ref(b){a.tabRefs[d]=b},id:"".concat(e,"-tab-").concat(d),panelId:"".concat(e,"-panel-").concat(d),selected:f===d,disabled:h,focusTab:function focusTab(){a.tabRefs[d].focus()},onClick:h?null:a.handleTabClick(d),onKeyDown:a.onKeyDown(d)},q?{style:{width:"".concat(100*(1/c.length),"%")}}:{}),{},{children:g}),g)}),l?/*#__PURE__*/_jsx("div",{className:classNames("tabs__line"),style:{width:this.getTabLineWidth(),transform:"translateX(".concat(l,")")}}):null]}),/*#__PURE__*/_jsx("div",{ref:this.setContainerRefAndWidth,className:"tabs__panel-container",style:{overflow:w?"hidden":"visible"},children:/*#__PURE__*/_jsx(Spring,{from:{transform:"translateX(".concat(n-r,"px)")},to:{transform:"translateX(".concat(o-r,"px)")},config:{precision:k?1:.01,velocity:k?0:v,clamp:!0},onRest:function onRest(){m&&a.setState({isAnimating:!1,lastSwipeVelocity:0})},children:function children(b){return/*#__PURE__*/_jsx("div",{className:"tabs__slider",style:{width:w?"".concat(x,"px"):"100%",transform:w?b.transform:"translateX(0px)"},children:c.map(function(b,d){var g=b.content,h=b.disabled;return h?null:/*#__PURE__*/_jsxs(Fragment,{children:[d===f&&/*#__PURE__*/_jsx(y,{id:"left-spacer"}),/*#__PURE__*/_jsx(TabPanel,{tabId:"".concat(e,"-tab-").concat(d),id:"".concat(e,"-panel-").concat(d),style:{width:w?"".concat(a.containerWidth,"px"):"100%",display:w||d===f?"block":"none"},children:g},c[d].title),d===f&&/*#__PURE__*/_jsx(y,{id:"right-spacer"})]},"".concat(c[d].title,"-fragment"))})})}})})]})}}]),b}(Component),SpacerSizes=_objectSpread(_objectSpread({},Size),{},{NONE:"default"});Tabs.propTypes={tabs:PropTypes.arrayOf(PropTypes.shape({title:PropTypes.string.isRequired,content:PropTypes.node.isRequired,disabled:PropTypes.bool.isRequired})).isRequired,selected:PropTypes.number.isRequired,onTabSelect:PropTypes.func.isRequired,name:PropTypes.string.isRequired,animatePanelsOnClick:PropTypes.bool,changeTabOnSwipe:PropTypes.bool,className:PropTypes.string,transitionSpacing:PropTypes.oneOf(["default","xs","sm","md","lg"]),headerWidth:PropTypes.oneOf(["auto","block"])},Tabs.defaultProps={animatePanelsOnClick:!1,changeTabOnSwipe:!0,className:"",transitionSpacing:SpacerSizes.NONE,headerWidth:Width.BLOCK};export default Tabs;
@@ -1,4 +1,4 @@
1
- import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _UPLOAD_STEP_COMPONEN;import _regeneratorRuntime from"@babel/runtime/regenerator";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import{Plus as PlusIcon}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{PureComponent}from"react";import{injectIntl}from"react-intl";import{Status}from"../common";import messages from"./Upload.messages";import{UploadImageStep,MediaUploadStep,ProcessingStep,CompleteStep}from"./steps";import{UploadStep}from"./uploadSteps";import{postData,asyncFileRead,isSizeValid,generateErrorMessage,isTypeValid,getFileType}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PROCESS_STATE=["error","success"],ANIMATION_FIX=10,MAX_SIZE_DEFAULT=5e6,UPLOAD_STEP_COMPONENTS=(_UPLOAD_STEP_COMPONEN={},_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.UPLOAD_IMAGE_STEP,UploadImageStep),_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.MEDIA_UPLOAD_STEP,MediaUploadStep),_UPLOAD_STEP_COMPONEN),Upload=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"onAnimationCompleted",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function a(b){var c,e,f,g,h,i,j;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:c=d.state,e=c.response,f=c.isProcessing,g=c.fileName,h=d.props.animationDelay,f&&b===Status.SUCCEEDED&&(i=d.props.onSuccess,d.timeouts=setTimeout(function(){d.setState({isProcessing:!1,isComplete:!0},function(){return i?i(e,g):{}})},h)),f&&b===Status.FAILED&&(j=d.props.onFailure,d.timeouts=setTimeout(function(){d.setState({errorMessage:generateErrorMessage(e.status,d.errorMessage),isProcessing:!1,isComplete:!0},function(){return j?j(e):{}})},h));case 4:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(d),"asyncPost",function(a){var b=d.props.httpOptions,c=b||{},e=c.fileInputName,f=void 0===e?a.name:e,g=c.data,h=void 0===g?{}:g,i=new FormData;return i.append(f,a),Object.keys(h).forEach(function(a){return i.append(a,h[a])}),postData(d.prepareHttpOptions(b),i)}),_defineProperty(_assertThisInitialized(d),"asyncResponse",function(a,b){d.timeouts=setTimeout(function(){d.setState({response:a,isError:b===PROCESS_STATE[0],isSuccess:b===PROCESS_STATE[1]})},ANIMATION_FIX)}),_defineProperty(_assertThisInitialized(d),"prepareHttpOptions",function(a){if(!a.url)throw new Error("You must supply a URL to post image data asynchronously");return a}),_defineProperty(_assertThisInitialized(d),"handleOnClear",function(a){a.preventDefault();var b=d.props.onCancel;b&&b(),d.reset()}),_defineProperty(_assertThisInitialized(d),"reset",function(){d.dragCounter=0,clearTimeout(d.timeouts),d.setState({isComplete:!1,isError:!1,isProcessing:!1,isSuccess:!1})}),_defineProperty(_assertThisInitialized(d),"showDataImage",function(a){var b=d.state.isImage;b&&d.setState({uploadedImage:a})}),_defineProperty(_assertThisInitialized(d),"fileDropped",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function a(b){var c,e,f,g,h,i,j,k,l;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(c=d.props,e=c.httpOptions,f=c.maxSize,g=c.onStart,h=c.usDisabled,i=c.usAccept,!h){a.next=3;break}return a.abrupt("return",!1);case 3:if(b){a.next=5;break}throw new Error("Could not retrieve file");case 5:return d.setState({fileName:b.name,isDroppable:!1,isProcessing:!0}),g&&g(b),j=null,a.prev=8,a.next=11,asyncFileRead(b);case 11:j=a.sent,a.next=17;break;case 14:a.prev=14,a.t0=a["catch"](8),d.asyncResponse(a.t0,PROCESS_STATE[0]);case 17:if(j){a.next=19;break}return a.abrupt("return",!1);case 19:if(d.setState({isImage:getFileType(b,j).includes("image")}),isTypeValid(b,i,j)){a.next=24;break}return k={status:415,statusText:"Unsupported Media Type"},d.asyncResponse(k,PROCESS_STATE[0]),a.abrupt("return",!1);case 24:if(isSizeValid(b,f)){a.next=28;break}return l={status:413,statusText:"Request Entity Too Large"},d.asyncResponse(l,PROCESS_STATE[0]),a.abrupt("return",!1);case 28:return e&&d.asyncPost(b).then(function(a){return d.asyncResponse(a,"success")}).then(function(){return d.showDataImage(j),!0}).catch(function(a){return d.asyncResponse(a,PROCESS_STATE[0]),!1}),d.showDataImage(j),d.asyncResponse(j,"success"),a.abrupt("return",!0);case 32:case"end":return a.stop();}},a,null,[[8,14]])}));return function(){return a.apply(this,arguments)}}()),d.formatMessage=d.props.intl.formatMessage,d.dragCounter=0,d.errorMessage={413:a.csTooLargeMessage||d.formatMessage(messages.csTooLargeMessage),415:a.csWrongTypeMessage||d.formatMessage(messages.csWrongTypeMessage),unknownError:a.csFailureText||d.formatMessage(messages.csFailureText)},d.timeouts=null,d.state={errorMessage:"",fileName:"",isComplete:!1,isError:!1,isImage:!1,isProcessing:!1,isSuccess:!1,response:null,uploadedImage:null},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"onDragLeave",value:function onDragLeave(a){a.preventDefault(),this.dragCounter-=1,0===this.dragCounter&&this.setState({isDroppable:!1})}},{key:"onDragEnter",value:function onDragEnter(a){a.preventDefault(),this.dragCounter+=1;var b=this.props.usDisabled;1!==this.dragCounter||b||this.setState({isDroppable:!0})}},{key:"onDrop",value:function onDrop(a){a.preventDefault(),this.reset(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&this.fileDropped(a.dataTransfer.files[0])}},{key:"render",value:function render(){var a=this,b=this.props,c=b.usDropMessage,d=b.usAccept,e=b.usButtonText,f=b.usDisabled,g=b.usHelpImage,h=b.usLabel,i=b.usPlaceholder,j=b.psButtonText,k=b.psProcessingText,l=b.csButtonText,m=b.csSuccessText,n=b.size,o=b.uploadStep,p=this.state,q=p.errorMessage,r=p.fileName,s=p.isComplete,t=p.isDroppable,u=p.isError,v=p.isImage,w=p.isProcessing,x=p.isSuccess,y=p.uploadedImage,z=UPLOAD_STEP_COMPONENTS[o]||UploadImageStep;return/*#__PURE__*/_jsxs("div",{className:classNames({droppable:!0,"tw-droppable-sm droppable-sm":"sm"===n,"tw-droppable-md droppable-md":"md"===n||!n,"tw-droppable-lg droppable-lg":"lg"===n,"droppable-dropping":t,"droppable-processing":w,"droppable-complete":s}),onDragEnter:function onDragEnter(b){return a.onDragEnter(b)},onDragLeave:function onDragLeave(b){return a.onDragLeave(b)},onDrop:function onDrop(b){return a.onDrop(b)},onDragOver:function onDragOver(a){return a.preventDefault()},children:[!w&&!s&&/*#__PURE__*/_jsx(z,{fileDropped:function fileDropped(b){return a.fileDropped(b)},isComplete:s,usAccept:d,usButtonText:e||this.formatMessage(messages.usButtonText),usDisabled:f,usHelpImage:g,usLabel:h,usPlaceholder:i||this.formatMessage(messages.usPlaceholder)}),w&&/*#__PURE__*/_jsx(ProcessingStep,{isComplete:s,isError:u,isSuccess:x,psButtonText:j||this.formatMessage(messages.psButtonText),psProcessingText:k||this.formatMessage(messages.psProcessingText),onAnimationCompleted:function onAnimationCompleted(b){return a.onAnimationCompleted(b)},onClear:function onClear(b){return a.handleOnClear(b)}}),(x||u||s)&&/*#__PURE__*/_jsx(CompleteStep,{fileName:r,isComplete:s,isError:u,isImage:v,csButtonText:l||this.formatMessage(messages.csButtonText),csFailureText:q,csSuccessText:m||this.formatMessage(messages.csSuccessText),uploadedImage:y,onClear:function onClear(b){return a.handleOnClear(b)}}),!w&&/*#__PURE__*/_jsx("div",{className:"droppable-dropping-card droppable-card",children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"circle circle-sm p-t-1 text-info",children:/*#__PURE__*/_jsx(PlusIcon,{})}),/*#__PURE__*/_jsx("h4",{className:"m-t-3",children:c||this.formatMessage(messages.usDropMessage)})]})})]})}}]),b}(PureComponent);/*
1
+ import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";var _UPLOAD_STEP_COMPONEN;import _regeneratorRuntime from"@babel/runtime/regenerator";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import{Plus as PlusIcon}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import{injectIntl}from"react-intl";import{Status}from"../common";import messages from"./Upload.messages";import{UploadImageStep,MediaUploadStep,ProcessingStep,CompleteStep}from"./steps";import{UploadStep}from"./uploadSteps";import{postData,asyncFileRead,isSizeValid,isTypeValid,getFileType}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var PROCESS_STATE=["error","success"],ANIMATION_FIX=10,MAX_SIZE_DEFAULT=5e6,UPLOAD_STEP_COMPONENTS=(_UPLOAD_STEP_COMPONEN={},_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.UPLOAD_IMAGE_STEP,UploadImageStep),_defineProperty(_UPLOAD_STEP_COMPONEN,UploadStep.MEDIA_UPLOAD_STEP,MediaUploadStep),_UPLOAD_STEP_COMPONEN),Upload=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"onAnimationCompleted",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function a(b){var c,e,f,g,h,i,j;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:c=d.state,e=c.response,f=c.isProcessing,g=c.fileName,h=d.props.animationDelay,f&&b===Status.SUCCEEDED&&(i=d.props.onSuccess,d.timeouts=setTimeout(function(){d.setState({isProcessing:!1,isComplete:!0},function(){return i?i(e,g):{}})},h)),f&&b===Status.FAILED&&(j=d.props.onFailure,d.timeouts=setTimeout(function(){d.setState({isProcessing:!1,isComplete:!0},function(){return j?j(e):{}})},h));case 4:case"end":return a.stop();}},a)}));return function(){return a.apply(this,arguments)}}()),_defineProperty(_assertThisInitialized(d),"asyncPost",function(a){var b=d.props.httpOptions,c=b||{},e=c.fileInputName,f=void 0===e?a.name:e,g=c.data,h=void 0===g?{}:g,i=new FormData;return i.append(f,a),Object.keys(h).forEach(function(a){return i.append(a,h[a])}),postData(d.prepareHttpOptions(b),i)}),_defineProperty(_assertThisInitialized(d),"asyncResponse",function(a,b){d.timeouts=setTimeout(function(){d.setState({response:a,isError:b===PROCESS_STATE[0],isSuccess:b===PROCESS_STATE[1]})},ANIMATION_FIX)}),_defineProperty(_assertThisInitialized(d),"prepareHttpOptions",function(a){if(!a.url)throw new Error("You must supply a URL to post image data asynchronously");return a}),_defineProperty(_assertThisInitialized(d),"handleOnClear",function(a){a.preventDefault();var b=d.props.onCancel;b&&b(),d.reset()}),_defineProperty(_assertThisInitialized(d),"reset",function(){d.dragCounter=0,clearTimeout(d.timeouts),d.setState({isComplete:!1,isError:!1,isProcessing:!1,isSuccess:!1})}),_defineProperty(_assertThisInitialized(d),"showDataImage",function(a){var b=d.state.isImage;b&&d.setState({uploadedImage:a})}),_defineProperty(_assertThisInitialized(d),"fileDropped",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function a(b){var c,e,f,g,h,i,j,k,l;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(c=d.props,e=c.httpOptions,f=c.maxSize,g=c.onStart,h=c.usDisabled,i=c.usAccept,!h){a.next=3;break}return a.abrupt("return",!1);case 3:if(b){a.next=5;break}throw new Error("Could not retrieve file");case 5:return d.setState({fileName:b.name,isDroppable:!1,isProcessing:!0}),g&&g(b),j=null,a.prev=8,a.next=11,asyncFileRead(b);case 11:j=a.sent,a.next=17;break;case 14:a.prev=14,a.t0=a["catch"](8),d.asyncResponse(a.t0,PROCESS_STATE[0]);case 17:if(j){a.next=19;break}return a.abrupt("return",!1);case 19:if(d.setState({isImage:getFileType(b,j).includes("image")}),isTypeValid(b,i,j)){a.next=24;break}return k={status:415,statusText:"Unsupported Media Type"},d.asyncResponse(k,PROCESS_STATE[0]),a.abrupt("return",!1);case 24:if(isSizeValid(b,f)){a.next=28;break}return l={status:413,statusText:"Request Entity Too Large"},d.asyncResponse(l,PROCESS_STATE[0]),a.abrupt("return",!1);case 28:if(!e){a.next=32;break}return a.next=31,d.asyncPost(b).then(function(a){return d.asyncResponse(a,"success")}).then(function(){return d.showDataImage(j),!0}).catch(function(a){return d.asyncResponse(a,PROCESS_STATE[0]),!1});case 31:return a.abrupt("return",a.sent);case 32:return d.showDataImage(j),d.asyncResponse(j,"success"),a.abrupt("return",!0);case 35:case"end":return a.stop();}},a,null,[[8,14]])}));return function(){return a.apply(this,arguments)}}()),d.dragCounter=0,d.timeouts=null,d.state={fileName:"",isComplete:!1,isError:!1,isImage:!1,isProcessing:!1,isSuccess:!1,response:null,uploadedImage:null},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"getErrorMessage",value:function getErrorMessage(a){return 413===a?this.props.csTooLargeMessage||this.props.intl.formatMessage(messages.csTooLargeMessage):415===a?this.props.csWrongTypeMessage||this.props.intl.formatMessage(messages.csWrongTypeMessage):this.props.csFailureText||this.props.intl.formatMessage(messages.csFailureText)}},{key:"onDragLeave",value:function onDragLeave(a){a.preventDefault(),this.dragCounter-=1,0===this.dragCounter&&this.setState({isDroppable:!1})}},{key:"onDragEnter",value:function onDragEnter(a){a.preventDefault(),this.dragCounter+=1;var b=this.props.usDisabled;1!==this.dragCounter||b||this.setState({isDroppable:!0})}},{key:"onDrop",value:function onDrop(a){a.preventDefault(),this.reset(),a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0]&&this.fileDropped(a.dataTransfer.files[0])}},{key:"render",value:function render(){var a=this,b=this.props,c=b.usDropMessage,d=b.usAccept,e=b.usButtonText,f=b.usDisabled,g=b.usHelpImage,h=b.usLabel,i=b.usPlaceholder,j=b.psButtonText,k=b.psProcessingText,l=b.csButtonText,m=b.csSuccessText,n=b.size,o=b.uploadStep,p=b.intl,q=this.state,r=q.response,s=q.fileName,t=q.isComplete,u=q.isDroppable,v=q.isError,w=q.isImage,x=q.isProcessing,y=q.isSuccess,z=q.uploadedImage,A=UPLOAD_STEP_COMPONENTS[o]||UploadImageStep;return/*#__PURE__*/_jsxs("div",{className:classNames({droppable:!0,"tw-droppable-sm droppable-sm":"sm"===n,"tw-droppable-md droppable-md":"md"===n||!n,"tw-droppable-lg droppable-lg":"lg"===n,"droppable-dropping":u,"droppable-processing":x,"droppable-complete":t}),onDragEnter:function onDragEnter(b){return a.onDragEnter(b)},onDragLeave:function onDragLeave(b){return a.onDragLeave(b)},onDrop:function onDrop(b){return a.onDrop(b)},onDragOver:function onDragOver(a){return a.preventDefault()},children:[!x&&!t&&/*#__PURE__*/_jsx(A,{fileDropped:function fileDropped(b){return a.fileDropped(b)},isComplete:t,usAccept:d,usButtonText:e||p.formatMessage(messages.usButtonText),usDisabled:f,usHelpImage:g,usLabel:h,usPlaceholder:i||p.formatMessage(messages.usPlaceholder)}),x&&/*#__PURE__*/_jsx(ProcessingStep,{isComplete:t,isError:v,isSuccess:y,psButtonText:j||p.formatMessage(messages.psButtonText),psProcessingText:k||p.formatMessage(messages.psProcessingText),onAnimationCompleted:function onAnimationCompleted(b){return a.onAnimationCompleted(b)},onClear:function onClear(b){return a.handleOnClear(b)}}),(y||v||t)&&/*#__PURE__*/_jsx(CompleteStep,{fileName:s,isComplete:t,isError:v,isImage:w,csButtonText:l||p.formatMessage(messages.csButtonText),csFailureText:this.getErrorMessage(null===r||void 0===r?void 0:r.status),csSuccessText:m||p.formatMessage(messages.csSuccessText),uploadedImage:z,onClear:function onClear(b){return a.handleOnClear(b)}}),!x&&/*#__PURE__*/_jsx("div",{className:"droppable-dropping-card droppable-card",children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"circle circle-sm p-t-1 text-primary",children:/*#__PURE__*/_jsx(PlusIcon,{})}),/*#__PURE__*/_jsx("h4",{className:"m-t-3",children:c||p.formatMessage(messages.usDropMessage)})]})})]})}}]),b}(Component);/*
2
2
  * This delay is required for the isError/isSuccess to be fired after isProcessing so the processIndicator, will be
3
3
  * rendered first and then updated with the right status.
4
4
  */Upload.propTypes={animationDelay:PropTypes.number,csButtonText:PropTypes.string,csFailureText:PropTypes.string,csSuccessText:PropTypes.string,csTooLargeMessage:PropTypes.string,csWrongTypeMessage:PropTypes.string,httpOptions:PropTypes.shape({url:PropTypes.string.isRequired,method:PropTypes.oneOf(["POST","PUT","PATCH"]),fileInputName:PropTypes.string,data:PropTypes.object,headers:PropTypes.object}),maxSize:PropTypes.number,onCancel:PropTypes.func,onFailure:PropTypes.func,onStart:PropTypes.func,onSuccess:PropTypes.func,psButtonText:PropTypes.string,psProcessingText:PropTypes.string,size:PropTypes.oneOf(["sm","md","lg"]),/**
@@ -1 +1 @@
1
- import{AlertCircle as AlertCircleIcon,Document as DocumentIcon}from"@transferwise/icons";import PropTypes from"prop-types";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var CompleteStep=function(a){var b=a.csButtonText,c=a.csFailureText,d=a.csSuccessText,e=a.fileName,f=a.isComplete,g=a.isError,h=a.isImage,i=a.onClear,j=a.uploadedImage;return/*#__PURE__*/_jsx("div",{className:"droppable-complete-card droppable-card","aria-hidden":!f,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"droppable-card-content d-flex flex-column align-items-center",children:g?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(AlertCircleIcon,{size:24,className:"text-danger"}),c&&/*#__PURE__*/_jsx("p",{className:"m-t-2",children:c})]}):/*#__PURE__*/_jsxs(_Fragment,{children:[h&&j?/*#__PURE__*/_jsx("img",{src:j,alt:"OK",className:"thumbnail "}):/*#__PURE__*/_jsx(DocumentIcon,{}),e&&/*#__PURE__*/_jsx("p",{className:"m-b-0",children:/*#__PURE__*/_jsx("small",{children:e})}),d&&/*#__PURE__*/_jsx("div",{className:"caption m-t-1",children:/*#__PURE__*/_jsx("span",{className:"h4",children:d})})]})}),b&&/*#__PURE__*/_jsx("button",{type:"button",className:"btn btn-default btn-sm m-t-3",onClick:function onClick(a){return i(a)},children:b})]})})};CompleteStep.propTypes={csButtonText:PropTypes.string.isRequired,csSuccessText:PropTypes.string.isRequired,csFailureText:PropTypes.string.isRequired,fileName:PropTypes.string.isRequired,isComplete:PropTypes.bool.isRequired,isError:PropTypes.bool.isRequired,isImage:PropTypes.bool.isRequired,onClear:PropTypes.func.isRequired,uploadedImage:PropTypes.string},CompleteStep.defaultProps={uploadedImage:null};export default CompleteStep;
1
+ import{AlertCircle as AlertCircleIcon,Document as DocumentIcon}from"@transferwise/icons";import PropTypes from"prop-types";import{Priority,Size}from"../../..";import Button from"../../../button";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var CompleteStep=function(a){var b=a.csButtonText,c=a.csFailureText,d=a.csSuccessText,e=a.fileName,f=a.isComplete,g=a.isError,h=a.isImage,i=a.onClear,j=a.uploadedImage;return/*#__PURE__*/_jsx("div",{className:"droppable-complete-card droppable-card","aria-hidden":!f,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx("div",{className:"droppable-card-content d-flex flex-column align-items-center",children:g?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(AlertCircleIcon,{size:24,className:"text-danger"}),c&&/*#__PURE__*/_jsx("p",{className:"m-t-2",children:c})]}):/*#__PURE__*/_jsxs(_Fragment,{children:[h&&j?/*#__PURE__*/_jsx("img",{src:j,alt:"OK",className:"thumbnail "}):/*#__PURE__*/_jsx(DocumentIcon,{}),e&&/*#__PURE__*/_jsx("p",{className:"m-b-0",children:/*#__PURE__*/_jsx("small",{children:e})}),d&&/*#__PURE__*/_jsx("div",{className:"caption m-t-1",children:/*#__PURE__*/_jsx("span",{className:"h4",children:d})})]})}),b&&/*#__PURE__*/_jsx(Button,{size:Size.SMALL,priority:Priority.SECONDARY,className:"m-t-3",onClick:function onClick(a){return i(a)},children:b})]})})};CompleteStep.propTypes={csButtonText:PropTypes.string.isRequired,csSuccessText:PropTypes.string.isRequired,csFailureText:PropTypes.string.isRequired,fileName:PropTypes.string.isRequired,isComplete:PropTypes.bool.isRequired,isError:PropTypes.bool.isRequired,isImage:PropTypes.bool.isRequired,onClear:PropTypes.func.isRequired,uploadedImage:PropTypes.string},CompleteStep.defaultProps={uploadedImage:null};export default CompleteStep;
@@ -1 +1 @@
1
- import PropTypes from"prop-types";import{Status,Size}from"../../../common";import ProcessIndicator from"../../../processIndicator";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var ProcessingStep=function(a){var b=a.isComplete,c=a.isError,d=a.isSuccess,e=a.onAnimationCompleted,f=a.onClear,g=a.psButtonText,h=a.psProcessingText,i=Status.PROCESSING;return c&&(i=Status.FAILED),d&&(i=Status.SUCCEEDED),/*#__PURE__*/_jsx("div",{className:"droppable-processing-card droppable-card","aria-hidden":b,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.Small,status:i,onAnimationCompleted:function onAnimationCompleted(a){return e(a)}}),/*#__PURE__*/_jsx("h4",{className:"m-t-3 m-b-3",children:h}),g&&/*#__PURE__*/_jsx("button",{type:"button",className:"btn btn-default btn-sm",onClick:function onClick(a){return f(a)},children:g})]})})};ProcessingStep.propTypes={isComplete:PropTypes.bool.isRequired,isError:PropTypes.bool.isRequired,isSuccess:PropTypes.bool.isRequired,onAnimationCompleted:PropTypes.func.isRequired,onClear:PropTypes.func.isRequired,psButtonText:PropTypes.string.isRequired,psProcessingText:PropTypes.string.isRequired};export default ProcessingStep;
1
+ import PropTypes from"prop-types";import Button from"../../../button";import{Status,Size}from"../../../common";import ProcessIndicator from"../../../processIndicator";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var ProcessingStep=function(a){var b=a.isComplete,c=a.isError,d=a.isSuccess,e=a.onAnimationCompleted,f=a.onClear,g=a.psButtonText,h=a.psProcessingText,i=Status.PROCESSING;return c&&(i=Status.FAILED),d&&(i=Status.SUCCEEDED),/*#__PURE__*/_jsx("div",{className:"droppable-processing-card droppable-card","aria-hidden":b,children:/*#__PURE__*/_jsxs("div",{className:"droppable-card-content",children:[/*#__PURE__*/_jsx(ProcessIndicator,{size:Size.Small,status:i,onAnimationCompleted:function onAnimationCompleted(a){return e(a)}}),/*#__PURE__*/_jsx("h4",{className:"m-t-3 m-b-3",children:h}),g&&/*#__PURE__*/_jsx(Button,{size:Size.SMALL,onClick:function onClick(a){return f(a)},children:g})]})})};ProcessingStep.propTypes={isComplete:PropTypes.bool.isRequired,isError:PropTypes.bool.isRequired,isSuccess:PropTypes.bool.isRequired,onAnimationCompleted:PropTypes.func.isRequired,onClear:PropTypes.func.isRequired,psButtonText:PropTypes.string.isRequired,psProcessingText:PropTypes.string.isRequired};export default ProcessingStep;
@@ -1 +1 @@
1
- export{postData}from"./postData";export{asyncFileRead}from"./asyncFileRead";export{isSizeValid}from"./isSizeValid";export{isTypeValid}from"./isTypeValid";export{getFileType}from"./getFileType";export{generateErrorMessage}from"./generateErrorMessage";export{getSupportedSpotMimeTypes}from"./getSupportedSpotMimeTypes";export{requestMedia}from"./requestMedia";
1
+ export{postData}from"./postData";export{asyncFileRead}from"./asyncFileRead";export{isSizeValid}from"./isSizeValid";export{isTypeValid}from"./isTypeValid";export{getFileType}from"./getFileType";export{getSupportedSpotMimeTypes}from"./getSupportedSpotMimeTypes";export{requestMedia}from"./requestMedia";
@@ -1 +1 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{useState,useEffect}from"react";import{createPortal}from"react-dom";import{jsx as _jsx}from"react/jsx-runtime";var withNextPortalWrapper=function(a){return function(b){var c=useState(!1),d=_slicedToArray(c,2),e=d[0],f=d[1];return useEffect(function(){f(!0)},[f]),e?/*#__PURE__*/createPortal(/*#__PURE__*/_jsx(a,_objectSpread({},b)),document.body):null}};export default withNextPortalWrapper;
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{useState,useEffect}from"react";import{createPortal}from"react-dom";import{jsx as _jsx}from"react/jsx-runtime";export default function withNextPortalWrapper(a){return function(b){var c=useState(!1),d=_slicedToArray(c,2),e=d[0],f=d[1];return useEffect(function(){f(!0)},[f]),e?/*#__PURE__*/createPortal(/*#__PURE__*/_jsx(a,_objectSpread({},b)),document.body):null}}
@@ -1,4 +1,4 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.set.js";import"core-js/modules/es.string.iterator.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.regexp.to-string.js";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{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=a.disabled,c=a.size,d=a.value,e=a.dayLabel,f=a.monthLabel,g=a.yearLabel,h=a.monthFormat,i=a.mode,j=a.onChange,k=a.onFocus,l=a.onBlur,m=a.placeholders,n=a.id,o=useDirection(),p=o.isRTL,q=useIntl(),r=q.locale,s=function(){return d&&isDateValid(d)?"string"==typeof d?convertToLocalMidnight(d):d:null},t=function(a){var b=INITIAL_DEFAULT_STATE;if(d&&isDateValid(d)){var c=s();b=explodeDate(c),isMonthAndYearFormat(d)&&(b.day=null)}return b[a]},u=useState(function(){return t("day")}),v=_slicedToArray(u,2),w=v[0],x=v[1],y=useState(function(){return t("month")}),z=_slicedToArray(y,2),A=z[0],B=z[1],C=useState(function(){return t("year")}),D=_slicedToArray(C,2),E=D[0],F=D[1],G=useState(s),H=_slicedToArray(G,2),I=H[0],J=H[1],K=function(a){if(!isDateValid(a))return"";switch(i){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("-");}},L=function(){var a=getMonthNames(r,h);return/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:f}),/*#__PURE__*/_jsx(Select,{name:"month",className:"form-control",disabled:b,placeholder:m.month,options:M(),size:c,selected:null===A?null:{value:A,label:a[A]},onChange:function(a){return P(a)}})]})},M=function(){var a=[],b=getMonthNames(r,h);return b.forEach(function(b,c){a.push({value:c,label:b})}),a},N=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:w,b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:A,c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:E,d=null!=a&&null!=b&&null!=c?new Date(c,b,a):null,e=isDateValid(d)?d:null;e||R(INITIAL_DEFAULT_STATE),i===DateMode.MONTH_YEAR?0<=b&&c&&(b!==A||c!==E)&&R(e):a&&0<=b&&c&&(a!==w||b!==A||c!==E)&&R(e)},O=function(a){var b=S(a.target.value,A,E),c=b.checkedDay;x(c),N(c,A,E)},P=function(a){if(!a)return B(null),void N(w,null,E);var b=a?a.value:0,c=S(w,b,E),d=c.checkedDay;B(b),w&&d!==w&&x(d),N(d,b,E)},Q=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=S(w,A,b),e=d.checkedDay;w&&e!==w&&x(e),F(c),N(e,A,c)}else F(c),N(w,A,null)},R=function(a){a!==I&&(J(a),j(K(a)||null))},S=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}},T=i===DateMode.MONTH_YEAR,U=classNames({"col-sm-8":T,"col-sm-5":!T,"pull-right":p}),V=MonthBeforeDay.has(r);return/*#__PURE__*/_jsx("div",{className:"tw-date",id:n,onFocus:function onFocus(a){return shouldPropagateOnFocus(a)?k&&k():a.stopPropagation()},onBlur:function onBlur(a){return shouldPropagateOnBlur(a)?l&&l():a.stopPropagation()},children:/*#__PURE__*/_jsxs("div",{className:"row",children:[V&&/*#__PURE__*/_jsx("div",{className:U,children:L()}),!T&&/*#__PURE__*/_jsx("div",{className:classNames("col-sm-3",{"pull-right":p}),children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(c),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:e}),/*#__PURE__*/_jsx("input",{type:"number",name:"day",className:"form-control",value:w||"",placeholder:m.day,disabled:b,onChange:function(a){return O(a)}})]})})}),!V&&/*#__PURE__*/_jsx("div",{className:U,children:L()}),/*#__PURE__*/_jsx("div",{className:"col-sm-4",children:/*#__PURE__*/_jsx("div",{className:"input-group-".concat(c),children:/*#__PURE__*/_jsxs("label",{children:[/*#__PURE__*/_jsx("span",{className:"sr-only",children:g}),/*#__PURE__*/_jsx("input",{type:"number",name:"year",className:"form-control",placeholder:m.year,value:E||"",disabled:b,onChange:function(a){return Q(a)}})]})})})]})})};// Should only propagate if the relatedTarget is not part of this DateInput component.
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.set.js";import"core-js/modules/es.string.iterator.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.regexp.to-string.js";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.
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
- 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,dayLabel:"Day",monthLabel:"Month",yearLabel:"Year",monthFormat:MonthFormat.LONG,mode:DateMode.DAY_MONTH_YEAR,placeholders:{day:"DD",month:"Month",year:"YYYY"},id:""};export default DateInput;
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;
@@ -0,0 +1 @@
1
+ import{defineMessages}from"react-intl";export default defineMessages({monthLabel:{id:"neptune.DateInput.month.label"},dayLabel:{id:"neptune.DateInput.day.label"},yearLabel:{id:"neptune.DateInput.year.label"}});