@transferwise/components 0.0.0-experimental-50e1f17 → 0.0.0-experimental-08d336e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.esm.js +3327 -3404
- package/build/index.esm.js.map +1 -1
- package/build/index.js +3326 -3402
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/logo/Logo.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/moneyInput/MoneyInput.css +1 -1
- package/build/types/common/hooks/useLayout/useLayout.d.ts +9 -6
- package/build/types/common/hooks/useLayout/useLayout.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +1 -2
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/hooks/useLayout/useLayout.ts +21 -49
- package/src/common/responsivePanel/ResponsivePanel.spec.js +3 -1
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +1 -19
- package/src/dateLookup/dateHeader/DateHeader.spec.js +2 -0
- package/src/drawer/Drawer.rtl.spec.js +3 -1
- package/src/drawer/Drawer.spec.js +2 -0
- package/src/index.ts +1 -0
- package/src/info/Info.spec.js +7 -11
- package/src/inputs/SelectInput.tsx +0 -8
- package/src/logo/Logo.css +1 -1
- package/src/logo/Logo.js +9 -18
- package/src/logo/Logo.less +21 -2
- package/src/logo/__snapshots__/Logo.spec.js.snap +168 -72
- package/src/main.css +1 -1
- package/src/modal/Modal.rtl.spec.js +3 -1
- package/src/modal/Modal.spec.js +2 -0
- package/src/modal/Modal.tsx +2 -2
- package/src/moneyInput/MoneyInput.css +1 -1
- package/src/moneyInput/MoneyInput.js +34 -82
- package/src/moneyInput/MoneyInput.less +28 -24
- package/src/moneyInput/MoneyInput.spec.js +112 -243
- package/src/moneyInput/MoneyInput.story.tsx +1 -51
- package/src/ssr.spec.js +1 -0
- package/src/uploadInput/UploadInput.spec.tsx +3 -1
- package/src/moneyInput/MoneyInput.rtl.spec.js +0 -71
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Position } from '../common';
|
|
2
|
-
import { render, fireEvent, screen } from '../test-utils';
|
|
2
|
+
import { render, fireEvent, screen, mockMatchMedia } from '../test-utils';
|
|
3
3
|
|
|
4
4
|
import Modal from './Modal';
|
|
5
5
|
|
|
6
|
+
mockMatchMedia();
|
|
7
|
+
|
|
6
8
|
describe('Modal', () => {
|
|
7
9
|
const props = {
|
|
8
10
|
onClose: jest.fn(),
|
package/src/modal/Modal.spec.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { mount } from 'enzyme';
|
|
2
2
|
|
|
3
3
|
import { Title } from '..';
|
|
4
|
+
import { mockMatchMedia } from '../test-utils';
|
|
4
5
|
|
|
5
6
|
import Modal from './Modal';
|
|
6
7
|
|
|
7
8
|
jest.useFakeTimers();
|
|
9
|
+
mockMatchMedia();
|
|
8
10
|
jest.mock('../common');
|
|
9
11
|
|
|
10
12
|
const defaultLocale = 'en-GB';
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -52,7 +52,7 @@ const Modal = ({
|
|
|
52
52
|
}: ModalProps) => {
|
|
53
53
|
const checkSpecialClasses = (classToCheck: string) =>
|
|
54
54
|
className?.split(' ').includes(classToCheck);
|
|
55
|
-
const {
|
|
55
|
+
const { isMedium } = useLayout();
|
|
56
56
|
|
|
57
57
|
// These should be replaced with props in breaking change.
|
|
58
58
|
const isCompact = checkSpecialClasses('compact');
|
|
@@ -60,7 +60,7 @@ const Modal = ({
|
|
|
60
60
|
|
|
61
61
|
const contentReference = useRef<HTMLDivElement>(null);
|
|
62
62
|
|
|
63
|
-
return
|
|
63
|
+
return !isMedium ? (
|
|
64
64
|
<Drawer
|
|
65
65
|
open={open}
|
|
66
66
|
headerTitle={title}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.tw-money-input .tw-money-input__fixed-currency{padding-left:0!important}[dir=rtl] .tw-money-input .tw-money-input__fixed-currency{padding-left:0!important;padding-right:0!important}.tw-money-input .tw-money-input__fixed-currency.input-md .
|
|
1
|
+
.tw-money-input .tw-money-input__fixed-currency{padding-left:0!important}[dir=rtl] .tw-money-input .tw-money-input__fixed-currency{padding-left:0!important;padding-right:0!important}.tw-money-input .tw-money-input__fixed-currency.input-md .currency-flag{margin-bottom:2px}.np-theme-personal .tw-money-input .tw-money-input__fixed-currency.input-md .currency-flag{margin-bottom:1px}.tw-money-input .tw-money-input__fixed-currency.input-lg .currency-flag{margin-bottom:4px}.np-theme-personal .tw-money-input .tw-money-input__fixed-currency.input-lg .currency-flag{margin-bottom:3px}.tw-money-input .tw-money-input__fixed-currency .currency-flag{vertical-align:middle}.tw-money-input .tw-money-input__fixed-currency .np-text-title-subsection{font-weight:var(--font-weight-normal)}.tw-money-input__keyline{background-color:#86a7bd1a;background-color:var(--color-background-neutral);border:1px solid #0000001a;border:1px solid var(--color-border-neutral);height:24px;height:var(--size-24);margin-right:24px;margin-right:var(--size-24);transform:translateY(4px);width:2px}[dir=rtl] .tw-money-input__keyline{margin-left:24px;margin-left:var(--size-24);margin-right:0}.tw-money-input__fixed-currency{position:relative}.tw-money-input__fixed-currency span{color:#5d7079;color:var(--color-content-secondary)}__text{font-size:1rem;font-size:var(--font-size-16)}.input-group-sm .np-text-title-subsection,.input-group-sm .tw-money-input__text{font-size:.875rem;font-size:var(--font-size-14)}.input-group-md .np-text-title-subsection{font-size:1rem;font-size:var(--font-size-16)}.input-group-lg .tw-money-input__text{font-size:1.375rem;font-size:var(--font-size-22)}.tw-money-input .amount-currency-select-btn>.np-select>.btn{align-items:center;display:flex;max-height:50px}.tw-money-input .amount-currency-select-btn>.np-select>.btn span:not(.tw-icon){font-weight:400;font-weight:var(--font-weight-regular);min-width:2.6em}.tw-money-input .amount-currency-select-btn>.np-select>.btn .currency-flag{display:inline-block!important;margin-left:2px;margin-right:2px}.tw-money-input .amount-currency-select-btn>.np-select>.np-dropdown-toggle{padding:0 16px;padding:0 var(--padding-small);text-align:center}.np-theme-personal .tw-money-input .amount-currency-select-btn>.np-select>.np-dropdown-toggle,.np-theme-personal .tw-money-input .amount-currency-select-btn>.np-select>.np-dropdown-toggle:active,.np-theme-personal .tw-money-input .amount-currency-select-btn>.np-select>.np-dropdown-toggle:hover:not(:focus){box-shadow:none}.np-theme-personal .tw-money-input .amount-currency-select-btn>.np-select>.np-dropdown-toggle .np-text-body-large{overflow:visible;text-overflow:clip}.np-theme-personal .tw-money-input .amount-currency-select-btn>.np-select>.np-dropdown-toggle .np-text-body-large .tw-money-input__text.np-text-title-subsection{font-weight:600;font-weight:var(--font-weight-semi-bold)}.tw-money-input .amount-currency-select-btn>.np-select>.np-btn>span.tw-icon{position:static}.np-theme-personal .tw-money-input__keyline{display:none}.np-theme-personal .tw-money-input.input-group-sm .form-control{min-height:34px}.np-theme-personal .tw-money-input.input-group-md .amount-currency-select-btn .btn-md,.np-theme-personal .tw-money-input.input-group-md .form-control{min-height:53px}.np-theme-personal .tw-money-input .tw-money-input__fixed-currency .np-text-title-subsection{color:#768e9c;color:var(--color-content-tertiary);font-weight:600;font-weight:var(--font-weight-semi-bold)}.np-theme-personal .tw-money-input button{border:none}.np-theme-personal .tw-money-input .np-text-title-subsection{color:var(--color-interactive-primary)}.np-theme-personal .tw-money-input .np-select-filter:focus{outline:none}.np-theme-personal .tw-money-input .amount-currency-select-btn .currency-flag{margin-right:0;margin-top:0}.np-theme-personal .tw-money-input .amount-currency-select-btn .np-btn-md .np-text-body-large{margin-left:4px;margin-right:4px}.np-theme-personal .tw-money-input .amount-currency-select-btn .np-btn-lg .np-text-body-large{margin-left:9px;margin-right:9px}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isEmpty, isNumber, isNull } from '@transferwise/neptune-validation';
|
|
2
|
-
import { Flag } from '@wise/art';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import { Component } from 'react';
|
|
@@ -10,7 +9,7 @@ import { Key as keyValues } from '../common/key';
|
|
|
10
9
|
import keyCodes from '../common/keyCodes';
|
|
11
10
|
import { Size } from '../common/propsValues/size';
|
|
12
11
|
import { Input } from '../inputs/Input';
|
|
13
|
-
import
|
|
12
|
+
import Select from '../select';
|
|
14
13
|
import Title from '../title';
|
|
15
14
|
|
|
16
15
|
import messages from './MoneyInput.messages';
|
|
@@ -24,7 +23,7 @@ const Currency = PropTypes.shape({
|
|
|
24
23
|
note: PropTypes.string,
|
|
25
24
|
searchable: PropTypes.string,
|
|
26
25
|
});
|
|
27
|
-
|
|
26
|
+
const CUSTOM_ACTION = 'CUSTOM_ACTION';
|
|
28
27
|
const isNumberOrNull = (v) => isNumber(v) || isNull(v);
|
|
29
28
|
|
|
30
29
|
const formatAmountIfSet = (amount, currency, locale, maxLengthOverride) => {
|
|
@@ -68,7 +67,6 @@ class MoneyInput extends Component {
|
|
|
68
67
|
this.formatMessage = this.props.intl.formatMessage;
|
|
69
68
|
this.state = {
|
|
70
69
|
searchQuery: '',
|
|
71
|
-
selectedOption: this.props.selectedCurrency,
|
|
72
70
|
formattedAmount: formatAmountIfSet(
|
|
73
71
|
props.amount,
|
|
74
72
|
props.selectedCurrency.currency,
|
|
@@ -167,37 +165,14 @@ class MoneyInput extends Component {
|
|
|
167
165
|
this.amountFocused = true;
|
|
168
166
|
};
|
|
169
167
|
|
|
170
|
-
mapOption = (item) => {
|
|
171
|
-
return {
|
|
172
|
-
type: 'option',
|
|
173
|
-
value: item,
|
|
174
|
-
filterMatchers: [item.value, item.label, item.note, item.searchable],
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
|
|
178
168
|
getSelectOptions() {
|
|
179
169
|
const selectOptions = [...filterOptionsForQuery(this.props.currencies, this.state.searchQuery)];
|
|
180
170
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
formattedOptions.push({
|
|
187
|
-
type: 'group',
|
|
188
|
-
label: item.header,
|
|
189
|
-
options: [],
|
|
190
|
-
});
|
|
191
|
-
groupIndex = formattedOptions.length - 1;
|
|
192
|
-
} else {
|
|
193
|
-
if (groupIndex === null) {
|
|
194
|
-
formattedOptions.push(this.mapOption(item));
|
|
195
|
-
} else {
|
|
196
|
-
formattedOptions[groupIndex]?.options.push(this.mapOption(item));
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
return formattedOptions;
|
|
171
|
+
if (this.props.onCustomAction) {
|
|
172
|
+
selectOptions.push({ value: CUSTOM_ACTION, label: this.props.customActionLabel });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return selectOptions;
|
|
201
176
|
}
|
|
202
177
|
|
|
203
178
|
setAmount() {
|
|
@@ -226,14 +201,11 @@ class MoneyInput extends Component {
|
|
|
226
201
|
|
|
227
202
|
handleSelectChange = (value) => {
|
|
228
203
|
this.handleSearchChange('');
|
|
229
|
-
this.setState({ selectedOption: value });
|
|
230
|
-
this.props.onCurrencyChange(value);
|
|
231
|
-
};
|
|
232
204
|
|
|
233
|
-
|
|
234
|
-
this.handleSearchChange('');
|
|
235
|
-
if (this.props.onCustomAction) {
|
|
205
|
+
if (this.props.onCustomAction && value.value === CUSTOM_ACTION) {
|
|
236
206
|
this.props.onCustomAction();
|
|
207
|
+
} else {
|
|
208
|
+
this.props.onCurrencyChange(value);
|
|
237
209
|
}
|
|
238
210
|
};
|
|
239
211
|
|
|
@@ -253,25 +225,10 @@ class MoneyInput extends Component {
|
|
|
253
225
|
const { selectedCurrency, onCurrencyChange, size, addon, id, selectProps, maxLengthOverride } =
|
|
254
226
|
this.props;
|
|
255
227
|
const selectOptions = this.getSelectOptions();
|
|
256
|
-
|
|
257
|
-
const firstOptionValue = () => {
|
|
258
|
-
if (selectOptions.length !== 0) {
|
|
259
|
-
const firstOption = selectOptions[0];
|
|
260
|
-
if (firstOption.type === 'option') {
|
|
261
|
-
return firstOption.value.value;
|
|
262
|
-
}
|
|
263
|
-
if (firstOption.type === 'group' && firstOption.options.length !== 0) {
|
|
264
|
-
return firstOption.options[0].value.value;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return null;
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const firstOption = firstOptionValue();
|
|
271
|
-
|
|
272
228
|
const isFixedCurrency =
|
|
273
|
-
|
|
274
|
-
|
|
229
|
+
!this.state.searchQuery &&
|
|
230
|
+
((selectOptions.length === 1 && selectOptions[0].currency === selectedCurrency.currency) ||
|
|
231
|
+
!onCurrencyChange);
|
|
275
232
|
|
|
276
233
|
const disabled = !this.props.onAmountChange;
|
|
277
234
|
return (
|
|
@@ -348,35 +305,30 @@ class MoneyInput extends Component {
|
|
|
348
305
|
this.style('amount-currency-select-btn'),
|
|
349
306
|
)}
|
|
350
307
|
>
|
|
351
|
-
<
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
)
|
|
308
|
+
<Select
|
|
309
|
+
id={id ? `${id}-select` : undefined}
|
|
310
|
+
classNames={this.props.classNames}
|
|
311
|
+
options={selectOptions}
|
|
312
|
+
selected={{
|
|
313
|
+
...selectedCurrency,
|
|
314
|
+
label: (
|
|
315
|
+
<Title
|
|
316
|
+
as="span"
|
|
317
|
+
type={Typography.TITLE_SUBSECTION}
|
|
318
|
+
className="tw-money-input__text"
|
|
319
|
+
>
|
|
320
|
+
{selectedCurrency.label}
|
|
321
|
+
</Title>
|
|
322
|
+
),
|
|
323
|
+
note: null,
|
|
366
324
|
}}
|
|
367
|
-
renderFooter={() =>
|
|
368
|
-
this.props.onCustomAction ? (
|
|
369
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
370
|
-
<div role="button" tabIndex="0" onClick={this.handleCustomAction}>
|
|
371
|
-
{this.props.customActionLabel}
|
|
372
|
-
</div>
|
|
373
|
-
) : null
|
|
374
|
-
}
|
|
375
325
|
placeholder={this.formatMessage(messages.selectPlaceholder)}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
disabled={disabled}
|
|
326
|
+
searchPlaceholder={this.props.searchPlaceholder}
|
|
327
|
+
searchValue={this.state.searchQuery}
|
|
379
328
|
size={size}
|
|
329
|
+
required
|
|
330
|
+
dropdownWidth={Size.LARGE}
|
|
331
|
+
inverse
|
|
380
332
|
onChange={this.handleSelectChange}
|
|
381
333
|
onSearchChange={this.handleSearchChange}
|
|
382
334
|
{...selectProps}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// there's got to be a better way to do it
|
|
11
11
|
|
|
12
12
|
&.input-md {
|
|
13
|
-
.
|
|
13
|
+
.currency-flag {
|
|
14
14
|
margin-bottom: 2px;
|
|
15
15
|
|
|
16
16
|
.np-theme-personal & {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
&.input-lg {
|
|
23
|
-
.
|
|
23
|
+
.currency-flag {
|
|
24
24
|
margin-bottom: 4px;
|
|
25
25
|
|
|
26
26
|
.np-theme-personal & {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.
|
|
32
|
+
.currency-flag {
|
|
33
33
|
vertical-align: middle;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -83,8 +83,7 @@
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
.tw-money-input .amount-currency-select-btn > .np-
|
|
87
|
-
lol: 'money-input';
|
|
86
|
+
.tw-money-input .amount-currency-select-btn > .np-select > .btn {
|
|
88
87
|
display: flex;
|
|
89
88
|
align-items: center;
|
|
90
89
|
max-height: 50px;
|
|
@@ -94,35 +93,36 @@
|
|
|
94
93
|
font-weight: var(--font-weight-regular);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
.
|
|
96
|
+
.currency-flag {
|
|
98
97
|
margin-right: 2px;
|
|
99
98
|
margin-left: 2px;
|
|
100
99
|
display: inline-block !important; // override a hidden-xs in select option which has too much logic around it
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
// .np-dropdown-toggle -> .np-button-input
|
|
106
|
-
// .btn -> .np-form-control
|
|
107
|
-
// .currency-flag -> .money-input-currency-flag
|
|
108
|
-
|
|
109
|
-
.tw-money-input .amount-currency-select-btn > .np-input-group > .np-button-input {
|
|
103
|
+
.tw-money-input .amount-currency-select-btn > .np-select > .np-dropdown-toggle {
|
|
110
104
|
padding: 0 var(--padding-small);
|
|
111
105
|
text-align: center;
|
|
112
|
-
box-shadow: none;
|
|
113
106
|
|
|
114
|
-
|
|
115
|
-
&:active {
|
|
107
|
+
.np-theme-personal & {
|
|
116
108
|
box-shadow: none;
|
|
117
|
-
}
|
|
118
109
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
110
|
+
&:hover:not(:focus),
|
|
111
|
+
&:active {
|
|
112
|
+
box-shadow: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.np-text-body-large {
|
|
116
|
+
.tw-money-input__text.np-text-title-subsection {
|
|
117
|
+
font-weight: var(--font-weight-semi-bold);
|
|
118
|
+
}
|
|
119
|
+
overflow: visible;
|
|
120
|
+
text-overflow: clip;
|
|
121
|
+
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
.tw-money-input .amount-currency-select-btn > .np-
|
|
125
|
+
.tw-money-input .amount-currency-select-btn > .np-select > .np-btn > span.tw-icon {
|
|
126
126
|
position: static;
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
|
|
140
140
|
.tw-money-input.input-group-md {
|
|
141
141
|
.form-control,
|
|
142
|
-
.amount-currency-select-btn .
|
|
142
|
+
.amount-currency-select-btn .btn-md {
|
|
143
143
|
min-height: 53px;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -160,20 +160,24 @@
|
|
|
160
160
|
color: var(--color-interactive-primary);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
.np-select-filter:focus {
|
|
164
|
+
outline: none;
|
|
165
|
+
}
|
|
166
|
+
|
|
163
167
|
.amount-currency-select-btn {
|
|
164
|
-
.
|
|
168
|
+
.currency-flag {
|
|
165
169
|
margin-right: 0;
|
|
166
170
|
margin-top: 0;
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
.np-
|
|
173
|
+
.np-btn-md {
|
|
170
174
|
.np-text-body-large {
|
|
171
175
|
margin-left: 4px;
|
|
172
176
|
margin-right: 4px;
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
.np-
|
|
180
|
+
.np-btn-lg {
|
|
177
181
|
.np-text-body-large {
|
|
178
182
|
margin-left: 9px;
|
|
179
183
|
margin-right: 9px;
|