@transferwise/components 46.23.0 → 46.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/i18n/es.json +2 -2
- package/build/i18n/hu.json +2 -2
- package/build/i18n/zh-HK.json +2 -2
- package/build/index.js +103 -80
- package/build/index.js.map +1 -1
- package/build/{index.esm.js → index.mjs} +102 -78
- package/build/index.mjs.map +1 -0
- package/build/mocks.js +33 -27
- package/build/mocks.js.map +1 -1
- package/build/mocks.mjs +40 -0
- package/build/mocks.mjs.map +1 -0
- package/build/types/common/dateUtils/getFormatForLocale/getFormatForLocale.d.ts +3 -0
- package/build/types/common/dateUtils/getFormatForLocale/getFormatForLocale.d.ts.map +1 -0
- package/build/types/common/dateUtils/index.d.ts +7 -6
- package/build/types/common/dateUtils/index.d.ts.map +1 -1
- package/build/types/common/hooks/useMedia.d.ts.map +1 -1
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/emphasis/Emphasis.d.ts +1 -1
- package/build/types/emphasis/Emphasis.d.ts.map +1 -1
- package/build/types/emphasis/EmphasisHtmlTransformer.d.ts +1 -1
- package/build/types/emphasis/EmphasisHtmlTransformer.d.ts.map +1 -1
- package/build/types/emphasis/index.d.ts +1 -0
- package/build/types/emphasis/index.d.ts.map +1 -1
- package/build/types/i18n/index.d.ts.map +1 -1
- package/build/types/index.d.ts +5 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/loader/Loader.d.ts +3 -3
- package/build/types/loader/Loader.d.ts.map +1 -1
- package/build/types/loader/index.d.ts +2 -2
- package/build/types/loader/index.d.ts.map +1 -1
- package/build/types/money/Money.d.ts +8 -11
- package/build/types/money/Money.d.ts.map +1 -1
- package/build/types/money/index.d.ts +2 -1
- package/build/types/money/index.d.ts.map +1 -1
- package/build/types/navigationOptionsList/NavigationOptionsList.d.ts +7 -10
- package/build/types/navigationOptionsList/NavigationOptionsList.d.ts.map +1 -1
- package/build/types/navigationOptionsList/index.d.ts +2 -1
- package/build/types/navigationOptionsList/index.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/build/types/slidingPanel/SlidingPanel.d.ts.map +1 -1
- package/package.json +20 -5
- package/src/avatar/{Avatar.spec.js → Avatar.spec.tsx} +6 -13
- package/src/common/dateUtils/getFormatForLocale/getFormatForLocale.ts +2 -0
- package/src/common/dateUtils/index.ts +7 -6
- package/src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.ts +1 -1
- package/src/common/hooks/useMedia.ts +2 -1
- package/src/dateInput/DateInput.spec.js +29 -9
- package/src/dateInput/DateInput.story.tsx +0 -3
- package/src/dateInput/DateInput.tsx +90 -48
- package/src/emphasis/{Emphasis.spec.js → Emphasis.spec.tsx} +2 -1
- package/src/emphasis/Emphasis.tsx +1 -1
- package/src/emphasis/{EmphasisHtmlTransformer.spec.js → EmphasisHtmlTransformer.spec.tsx} +0 -12
- package/src/emphasis/EmphasisHtmlTransformer.ts +1 -1
- package/src/emphasis/index.ts +1 -0
- package/src/i18n/es.json +2 -2
- package/src/i18n/hu.json +2 -2
- package/src/i18n/index.ts +1 -0
- package/src/i18n/zh-HK.json +2 -2
- package/src/index.ts +5 -0
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.js +3 -2
- package/src/inputs/SelectInput.tsx +5 -3
- package/src/loader/Loader.tsx +3 -3
- package/src/loader/index.ts +2 -0
- package/src/money/{Money.spec.js → Money.spec.tsx} +1 -1
- package/src/money/{Money.js → Money.tsx} +6 -7
- package/src/money/index.ts +2 -0
- package/src/navigationOptionsList/NavigationOptionsList.tsx +20 -0
- package/src/navigationOptionsList/index.ts +2 -0
- package/src/radio/Radio.story.tsx +3 -4
- package/src/segmentedControl/SegmentedControl.tsx +1 -0
- package/src/slidingPanel/SlidingPanel.tsx +4 -4
- package/src/switch/Switch.story.tsx +4 -1
- package/build/index.esm.js.map +0 -1
- package/build/mocks.d.ts +0 -9
- package/build/mocks.d.ts.map +0 -1
- package/build/mocks.esm.js +0 -34
- package/build/mocks.esm.js.map +0 -1
- package/build/types/common/dateUtils/getDayNames/index.d.ts +0 -2
- package/build/types/common/dateUtils/getDayNames/index.d.ts.map +0 -1
- package/build/types/common/dateUtils/getMonthNames/index.d.ts +0 -2
- package/build/types/common/dateUtils/getMonthNames/index.d.ts.map +0 -1
- package/build/types/common/dateUtils/isDateValid/index.d.ts +0 -2
- package/build/types/common/dateUtils/isDateValid/index.d.ts.map +0 -1
- package/build/types/common/dateUtils/isWithinRange/index.d.ts +0 -2
- package/build/types/common/dateUtils/isWithinRange/index.d.ts.map +0 -1
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts +0 -2
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts.map +0 -1
- package/src/common/dateUtils/getDayNames/index.ts +0 -1
- package/src/common/dateUtils/getMonthNames/index.ts +0 -1
- package/src/common/dateUtils/isDateValid/index.ts +0 -1
- package/src/common/dateUtils/isWithinRange/index.ts +0 -1
- package/src/common/dateUtils/moveToWithinRange/index.ts +0 -1
- package/src/loader/index.js +0 -3
- package/src/money/index.js +0 -1
- package/src/navigationOptionsList/NavigationOptionsList.js +0 -20
- package/src/navigationOptionsList/index.js +0 -1
- /package/src/loader/{Loader.spec.js → Loader.spec.tsx} +0 -0
- /package/src/navigationOptionsList/{NavigationOptionsList.spec.js → NavigationOptionsList.spec.tsx} +0 -0
- /package/src/navigationOptionsList/{NavigationOptionsList.story.js → NavigationOptionsList.story.tsx} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { shallow, mount } from 'enzyme';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
|
|
4
|
-
import { DateInput
|
|
4
|
+
import { DateInput } from '..';
|
|
5
5
|
import { mockMatchMedia, mockResizeObserver } from '../test-utils';
|
|
6
6
|
|
|
7
7
|
const LOCALES = {
|
|
8
8
|
jp: 'ja-JP',
|
|
9
|
+
us: 'en-US',
|
|
9
10
|
};
|
|
10
11
|
const DEFAULT_LOCALE = 'en-GB';
|
|
11
12
|
const FEBRUARY_INDEX = 1;
|
|
@@ -182,24 +183,43 @@ describe('Date Input Component', () => {
|
|
|
182
183
|
});
|
|
183
184
|
|
|
184
185
|
describe('when locale is provided', () => {
|
|
185
|
-
it('shows day before month if locale
|
|
186
|
+
it('shows day before month if locale is GB', () => {
|
|
187
|
+
useIntl.mockReturnValue({
|
|
188
|
+
locale: DEFAULT_LOCALE,
|
|
189
|
+
formatMessage: (message) => message.defaultMessage,
|
|
190
|
+
});
|
|
191
|
+
|
|
186
192
|
component = shallow(<DateInput {...props} />);
|
|
187
193
|
|
|
188
|
-
|
|
189
|
-
expect(
|
|
190
|
-
expect(
|
|
194
|
+
expect(component.find('span').at(0).text()).toBe('Day');
|
|
195
|
+
expect(component.find('span').at(1).text()).toBe('Month');
|
|
196
|
+
expect(component.find('span').at(2).text()).toBe('Year');
|
|
191
197
|
});
|
|
192
198
|
|
|
193
|
-
it('shows
|
|
199
|
+
it('shows month before day if locale is US', () => {
|
|
200
|
+
useIntl.mockReturnValue({
|
|
201
|
+
locale: LOCALES.us,
|
|
202
|
+
formatMessage: (message) => message.defaultMessage,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
component = shallow(<DateInput {...props} />);
|
|
206
|
+
|
|
207
|
+
expect(component.find('span').at(0).text()).toBe('Month');
|
|
208
|
+
expect(component.find('span').at(1).text()).toBe('Day');
|
|
209
|
+
expect(component.find('span').at(2).text()).toBe('Year');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('shows year, month, day if locale is JP', () => {
|
|
194
213
|
useIntl.mockReturnValue({
|
|
195
214
|
locale: LOCALES.jp,
|
|
196
215
|
formatMessage: (message) => message.defaultMessage,
|
|
197
216
|
});
|
|
217
|
+
|
|
198
218
|
component = shallow(<DateInput {...props} />);
|
|
199
219
|
|
|
200
|
-
|
|
201
|
-
expect(
|
|
202
|
-
expect(
|
|
220
|
+
expect(component.find('span').at(0).text()).toBe('Year');
|
|
221
|
+
expect(component.find('span').at(1).text()).toBe('Month');
|
|
222
|
+
expect(component.find('span').at(2).text()).toBe('Day');
|
|
203
223
|
});
|
|
204
224
|
});
|
|
205
225
|
|
|
@@ -4,13 +4,11 @@ import { useIntl } from 'react-intl';
|
|
|
4
4
|
|
|
5
5
|
import { Input, SelectInput, SelectInputProps, SelectInputOptionContent } from '..';
|
|
6
6
|
import { Size, DateMode, MonthFormat, SizeSmall, SizeMedium, SizeLarge } from '../common';
|
|
7
|
-
import { getMonthNames, isDateValid, isMonthAndYearFormat } from '../common/dateUtils';
|
|
7
|
+
import { getMonthNames, isDateValid, isMonthAndYearFormat, MDY, YMD } from '../common/dateUtils';
|
|
8
8
|
|
|
9
9
|
import messages from './DateInput.messages';
|
|
10
10
|
import { convertToLocalMidnight } from './utils';
|
|
11
11
|
|
|
12
|
-
const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
|
|
13
|
-
|
|
14
12
|
export interface DateInputProps {
|
|
15
13
|
'aria-label'?: string;
|
|
16
14
|
'aria-labelledby'?: string;
|
|
@@ -243,7 +241,59 @@ const DateInput = ({
|
|
|
243
241
|
'col-sm-5': !monthYearOnly,
|
|
244
242
|
});
|
|
245
243
|
|
|
246
|
-
const
|
|
244
|
+
const getMonth = () => {
|
|
245
|
+
return <div className={monthWidth}>{getSelectElement()}</div>;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const getDay = () => {
|
|
249
|
+
return (
|
|
250
|
+
<div className="col-sm-3">
|
|
251
|
+
<label>
|
|
252
|
+
<span className="sr-only">{dayLabel}</span>
|
|
253
|
+
<div className={`input-group input-group-${size}`}>
|
|
254
|
+
<Input
|
|
255
|
+
type="text"
|
|
256
|
+
inputMode="numeric"
|
|
257
|
+
pattern="[0-9]*"
|
|
258
|
+
name="day"
|
|
259
|
+
autoComplete={dayAutoComplete}
|
|
260
|
+
value={day || ''}
|
|
261
|
+
placeholder={placeholders?.day}
|
|
262
|
+
disabled={disabled}
|
|
263
|
+
min={1}
|
|
264
|
+
onChange={(event) => handleDayChange(event)}
|
|
265
|
+
/>
|
|
266
|
+
</div>
|
|
267
|
+
</label>
|
|
268
|
+
</div>
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const getYear = () => {
|
|
273
|
+
return (
|
|
274
|
+
<div className="col-sm-4">
|
|
275
|
+
<label>
|
|
276
|
+
<span className="sr-only">{yearLabel}</span>
|
|
277
|
+
<div className={`input-group input-group-${size}`}>
|
|
278
|
+
<Input
|
|
279
|
+
type="text"
|
|
280
|
+
inputMode="numeric"
|
|
281
|
+
pattern="[0-9]*"
|
|
282
|
+
name="year"
|
|
283
|
+
autoComplete={yearAutoComplete}
|
|
284
|
+
placeholder={placeholders?.year}
|
|
285
|
+
value={year || ''}
|
|
286
|
+
disabled={disabled}
|
|
287
|
+
min={1}
|
|
288
|
+
onChange={(event) => handleYearChange(event)}
|
|
289
|
+
/>
|
|
290
|
+
</div>
|
|
291
|
+
</label>
|
|
292
|
+
</div>
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
const monthBeforeDay = MDY.has(locale);
|
|
296
|
+
const yearFirst = YMD.has(locale);
|
|
247
297
|
|
|
248
298
|
return (
|
|
249
299
|
<div
|
|
@@ -260,50 +310,42 @@ const DateInput = ({
|
|
|
260
310
|
}
|
|
261
311
|
>
|
|
262
312
|
<div className="row">
|
|
263
|
-
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
value={year || ''}
|
|
300
|
-
disabled={disabled}
|
|
301
|
-
min={1}
|
|
302
|
-
onChange={(event) => handleYearChange(event)}
|
|
303
|
-
/>
|
|
304
|
-
</div>
|
|
305
|
-
</label>
|
|
306
|
-
</div>
|
|
313
|
+
{(() => {
|
|
314
|
+
if (monthYearOnly) {
|
|
315
|
+
return (
|
|
316
|
+
<>
|
|
317
|
+
{!yearFirst && getMonth()}
|
|
318
|
+
{getYear()}
|
|
319
|
+
{yearFirst && getMonth()}
|
|
320
|
+
</>
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
if (monthBeforeDay) {
|
|
324
|
+
return (
|
|
325
|
+
<>
|
|
326
|
+
{getMonth()}
|
|
327
|
+
{getDay()}
|
|
328
|
+
{getYear()}
|
|
329
|
+
</>
|
|
330
|
+
);
|
|
331
|
+
} else if (yearFirst) {
|
|
332
|
+
return (
|
|
333
|
+
<>
|
|
334
|
+
{getYear()}
|
|
335
|
+
{getMonth()}
|
|
336
|
+
{getDay()}
|
|
337
|
+
</>
|
|
338
|
+
);
|
|
339
|
+
} else {
|
|
340
|
+
return (
|
|
341
|
+
<>
|
|
342
|
+
{getDay()}
|
|
343
|
+
{getMonth()}
|
|
344
|
+
{getYear()}
|
|
345
|
+
</>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
})()}
|
|
307
349
|
</div>
|
|
308
350
|
</div>
|
|
309
351
|
);
|
|
@@ -12,10 +12,11 @@ describe('Emphasis', () => {
|
|
|
12
12
|
${'<negative>negative</negative>'} | ${'em.emphasis.emphasis--negative'}
|
|
13
13
|
${'<warning>warning</warning>'} | ${'em.emphasis.emphasis--warning'}
|
|
14
14
|
`('$text renders as expected with selectoe $selector', ({ text, selector }) => {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
15
16
|
const { container } = render(<Emphasis text={text} />);
|
|
16
17
|
|
|
17
18
|
expect(container.querySelector(selector)).toBeInTheDocument();
|
|
18
|
-
expect(container
|
|
19
|
+
expect(container?.firstElementChild?.tagName).toBe('SPAN');
|
|
19
20
|
});
|
|
20
21
|
});
|
|
21
22
|
|
|
@@ -5,7 +5,7 @@ import EmphasisHtmlTransformer from './EmphasisHtmlTransformer';
|
|
|
5
5
|
const SUPPORTED_TAGS = ['important', 'positive', 'negative', 'warning'];
|
|
6
6
|
const emphasisHtmlTransformer = new EmphasisHtmlTransformer(SUPPORTED_TAGS);
|
|
7
7
|
|
|
8
|
-
type EmphasisProps = {
|
|
8
|
+
export type EmphasisProps = {
|
|
9
9
|
text?: string;
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -33,16 +33,4 @@ describe('creates safe, enphasised html', () => {
|
|
|
33
33
|
expect(emphasisHtmlTransformer.transform('hello\nworld')).toStrictEqual('hello<br />world');
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
describe('returns null when no input provided', () => {
|
|
38
|
-
it('input is null', () => {
|
|
39
|
-
const emphasisHtmlTransformer = new EmphasisHtmlTransformer();
|
|
40
|
-
expect(emphasisHtmlTransformer.transform(null)).toBeNull();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('input is undefined', () => {
|
|
44
|
-
const emphasisHtmlTransformer = new EmphasisHtmlTransformer();
|
|
45
|
-
expect(emphasisHtmlTransformer.transform(undefined)).toBeNull();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
36
|
});
|
package/src/emphasis/index.ts
CHANGED
package/src/i18n/es.json
CHANGED
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"neptune.Upload.csButtonText": "¿Quieres subir otro archivo?",
|
|
30
30
|
"neptune.Upload.csFailureText": "La carga del archivo ha fallado. Por favor, inténtalo de nuevo",
|
|
31
31
|
"neptune.Upload.csSuccessText": "¡Se ha subido el archivo!",
|
|
32
|
-
"neptune.Upload.csTooLargeMessage": "
|
|
32
|
+
"neptune.Upload.csTooLargeMessage": "Proporciona un archivo menor de {maxSize} MB",
|
|
33
33
|
"neptune.Upload.csWrongTypeMessage": "Tipo de archivo no aceptado. Por favor, inténtalo de nuevo con un archivo diferente",
|
|
34
34
|
"neptune.Upload.psButtonText": "Cancela",
|
|
35
35
|
"neptune.Upload.psProcessingText": "Subiendo...",
|
|
36
36
|
"neptune.Upload.usButtonText": "O selecciona un archivo",
|
|
37
37
|
"neptune.Upload.usDropMessage": "Arrastra un archivo para subirlo",
|
|
38
|
-
"neptune.Upload.usPlaceholder": "Arrastra y suelta un archivo
|
|
38
|
+
"neptune.Upload.usPlaceholder": "Arrastra y suelta un archivo de menos de {maxSize} MB",
|
|
39
39
|
"neptune.UploadButton.allFileTypes": "Todos los tipos de archivos",
|
|
40
40
|
"neptune.UploadButton.dropFiles": "Arrastra un archivo para subirlo",
|
|
41
41
|
"neptune.UploadButton.instructions": "{fileTypes}, menor que {size}MB",
|
package/src/i18n/hu.json
CHANGED
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"neptune.Upload.csButtonText": "Másik fájl feltöltése?",
|
|
30
30
|
"neptune.Upload.csFailureText": "Feltöltés sikertelen. Kérünk, próbáld újra",
|
|
31
31
|
"neptune.Upload.csSuccessText": "Feltöltés sikeres",
|
|
32
|
-
"neptune.Upload.csTooLargeMessage": "Kérünk,
|
|
32
|
+
"neptune.Upload.csTooLargeMessage": "Kérünk, olyan fájlt küldj el, amely kisebb mint {maxSize}MB",
|
|
33
33
|
"neptune.Upload.csWrongTypeMessage": "Nem támogatott fájltípus. Kérünk, próbáld újra másik fájllal",
|
|
34
34
|
"neptune.Upload.psButtonText": "Mégsem",
|
|
35
35
|
"neptune.Upload.psProcessingText": "Feltöltés...",
|
|
36
36
|
"neptune.Upload.usButtonText": "Vagy válaszd ki a fájlt",
|
|
37
37
|
"neptune.Upload.usDropMessage": "Húzd ide a fájlokat a feltöltéshez",
|
|
38
|
-
"neptune.Upload.usPlaceholder": "Húzz ide egy {maxSize} MB
|
|
38
|
+
"neptune.Upload.usPlaceholder": "Húzz ide egy legfeljebb {maxSize} MB méretű fájlt",
|
|
39
39
|
"neptune.UploadButton.allFileTypes": "Összes fájltípus",
|
|
40
40
|
"neptune.UploadButton.dropFiles": "Húzd a fájlokat ide a feltöltéshez",
|
|
41
41
|
"neptune.UploadButton.instructions": "{fileTypes}, legfeljebb {size}MB",
|
package/src/i18n/index.ts
CHANGED
package/src/i18n/zh-HK.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"neptune.ClearButton.ariaLabel": "清除",
|
|
5
5
|
"neptune.CloseButton.ariaLabel": "關閉",
|
|
6
6
|
"neptune.DateInput.day.label": "日",
|
|
7
|
-
"neptune.DateInput.day.placeholder": "
|
|
7
|
+
"neptune.DateInput.day.placeholder": "日",
|
|
8
8
|
"neptune.DateInput.month.label": "月",
|
|
9
9
|
"neptune.DateInput.year.label": "年",
|
|
10
|
-
"neptune.DateInput.year.placeholder": "
|
|
10
|
+
"neptune.DateInput.year.placeholder": "年",
|
|
11
11
|
"neptune.DateLookup.day": "日",
|
|
12
12
|
"neptune.DateLookup.goTo20YearView": "切換至20年視圖",
|
|
13
13
|
"neptune.DateLookup.month": "月",
|
package/src/index.ts
CHANGED
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
* Types
|
|
3
3
|
*/
|
|
4
4
|
export type { AccordionProps, AccordionItem } from './accordion';
|
|
5
|
+
export type { AvatarProps } from './avatar';
|
|
5
6
|
export type { ActionOptionProps } from './actionOption';
|
|
6
7
|
export type { BadgeProps } from './badge';
|
|
7
8
|
export type { CircularButtonProps } from './circularButton';
|
|
8
9
|
export type { DecisionProps } from './decision/Decision';
|
|
10
|
+
export type { EmphasisProps } from './emphasis';
|
|
9
11
|
export type { InfoProps } from './info';
|
|
10
12
|
export type { SummaryProps } from './summary';
|
|
11
13
|
export type { InputProps } from './inputs/Input';
|
|
12
14
|
export type { DateInputProps } from './dateInput';
|
|
13
15
|
export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
|
|
14
16
|
export type { InputGroupProps } from './inputs/InputGroup';
|
|
17
|
+
export type { LoaderProps } from './loader';
|
|
18
|
+
export type { NavigationOptionListProps } from './navigationOptionsList';
|
|
15
19
|
export type { SearchInputProps } from './inputs/SearchInput';
|
|
16
20
|
export type {
|
|
17
21
|
SelectInputGroupItem,
|
|
@@ -41,6 +45,7 @@ export type { TooltipProps } from './tooltip';
|
|
|
41
45
|
export type { UploadedFile, UploadError, UploadResponse } from './uploadInput/types';
|
|
42
46
|
export type { MarkdownProps } from './markdown';
|
|
43
47
|
export type { ModalProps } from './modal';
|
|
48
|
+
export type { MoneyProps } from './money';
|
|
44
49
|
export type {
|
|
45
50
|
CurrencyHeaderItem,
|
|
46
51
|
CurrencyItem,
|
|
@@ -34,14 +34,15 @@ const Template = (args) => {
|
|
|
34
34
|
const placeholder = args.pattern;
|
|
35
35
|
const displayPattern = args.pattern;
|
|
36
36
|
const label = args.label;
|
|
37
|
+
const id = label.replaceAll(' ', '-').toLowerCase();
|
|
37
38
|
|
|
38
39
|
return (
|
|
39
40
|
<>
|
|
40
|
-
<label id="template" htmlFor=
|
|
41
|
+
<label id="template" htmlFor={id}>
|
|
41
42
|
{label}
|
|
42
43
|
</label>
|
|
43
44
|
<InputWithDisplayFormat
|
|
44
|
-
id=
|
|
45
|
+
id={id}
|
|
45
46
|
placeholder={placeholder}
|
|
46
47
|
displayPattern={displayPattern}
|
|
47
48
|
className="form-control"
|
|
@@ -5,7 +5,6 @@ import classNames from 'classnames';
|
|
|
5
5
|
import mergeProps from 'merge-props';
|
|
6
6
|
import { createContext, forwardRef, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
7
|
import { useIntl } from 'react-intl';
|
|
8
|
-
import mergeRefs from 'react-merge-refs';
|
|
9
8
|
|
|
10
9
|
import { useEffectEvent } from '../common/hooks/useEffectEvent';
|
|
11
10
|
import { useScreenSize } from '../common/hooks/useScreenSize';
|
|
@@ -251,7 +250,7 @@ export function SelectInput<T = string, M extends boolean = false>({
|
|
|
251
250
|
});
|
|
252
251
|
});
|
|
253
252
|
|
|
254
|
-
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
253
|
+
const triggerRef = useRef<HTMLButtonElement | null>(null);
|
|
255
254
|
|
|
256
255
|
const screenSm = useScreenSize(Breakpoint.SMALL);
|
|
257
256
|
const OptionsOverlay = screenSm ? Popover : BottomSheet;
|
|
@@ -290,7 +289,10 @@ export function SelectInput<T = string, M extends boolean = false>({
|
|
|
290
289
|
<SelectInputTriggerButtonPropsContext.Provider
|
|
291
290
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
292
291
|
value={{
|
|
293
|
-
ref:
|
|
292
|
+
ref: (node) => {
|
|
293
|
+
ref(node);
|
|
294
|
+
triggerRef.current = node;
|
|
295
|
+
},
|
|
294
296
|
id,
|
|
295
297
|
...mergeProps(
|
|
296
298
|
{
|
package/src/loader/Loader.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTheme } from '@wise/components-theming';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { Size, SizeExtraSmall, SizeSmall, SizeMedium, SizeLarge, SizeExtraLarge } from '../common';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ type DeprecatedSize = SizeExtraSmall | SizeLarge | SizeExtraLarge;
|
|
|
9
9
|
|
|
10
10
|
type SizeType = SizeSmall | SizeMedium;
|
|
11
11
|
|
|
12
|
-
type
|
|
12
|
+
export type LoaderProps = {
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated use `size` instead
|
|
15
15
|
*/
|
|
@@ -37,7 +37,7 @@ const Loader = ({
|
|
|
37
37
|
displayInstantly = false,
|
|
38
38
|
classNames = {},
|
|
39
39
|
...restProps
|
|
40
|
-
}:
|
|
40
|
+
}: LoaderProps) => {
|
|
41
41
|
const { theme } = useTheme();
|
|
42
42
|
const [hasDebounced, setHasDebounced] = useState(displayInstantly);
|
|
43
43
|
|
|
@@ -11,7 +11,7 @@ describe('Money', () => {
|
|
|
11
11
|
it('formats the string with amount, currency & the passed in locale', () => {
|
|
12
12
|
const { container } = render(<Money amount={4.98} currency="GBP" />, {
|
|
13
13
|
locale: 'fr',
|
|
14
|
-
messages:
|
|
14
|
+
messages: undefined,
|
|
15
15
|
});
|
|
16
16
|
expect(container).toHaveTextContent('4,98 GBP');
|
|
17
17
|
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { formatMoney } from '@transferwise/formatting';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import { useIntl } from 'react-intl';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
export interface MoneyProps {
|
|
5
|
+
amount: number;
|
|
6
|
+
currency: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Money = ({ amount, currency }: MoneyProps) => {
|
|
6
10
|
const { locale } = useIntl();
|
|
7
11
|
return <>{formatMoney(amount, currency, locale)}</>;
|
|
8
12
|
};
|
|
9
13
|
|
|
10
|
-
Money.propTypes = {
|
|
11
|
-
amount: PropTypes.number.isRequired,
|
|
12
|
-
currency: PropTypes.string.isRequired,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
14
|
export default Money;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Children } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface NavigationOptionListProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const NavigationOptionList = ({ children }: NavigationOptionListProps) => {
|
|
9
|
+
return (
|
|
10
|
+
<ul className="np-navigation-options-list">
|
|
11
|
+
{Children.map(children, (child) => (
|
|
12
|
+
<li key={child?.toString()} className="np-navigation-options-list__item">
|
|
13
|
+
{child}
|
|
14
|
+
</li>
|
|
15
|
+
))}
|
|
16
|
+
</ul>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default NavigationOptionList;
|
|
@@ -44,7 +44,7 @@ export const Basic = () => {
|
|
|
44
44
|
<Radio
|
|
45
45
|
label={label}
|
|
46
46
|
name="name"
|
|
47
|
-
id="
|
|
47
|
+
id="id1"
|
|
48
48
|
checked={checked}
|
|
49
49
|
disabled={disabled}
|
|
50
50
|
secondary={secondary}
|
|
@@ -61,7 +61,7 @@ export const Basic = () => {
|
|
|
61
61
|
<div className={`form-group ${hasError ? 'has-error' : ''}`}>
|
|
62
62
|
<Checkbox
|
|
63
63
|
label={label}
|
|
64
|
-
id="
|
|
64
|
+
id="id2"
|
|
65
65
|
checked={checked}
|
|
66
66
|
disabled={disabled}
|
|
67
67
|
secondary={secondary}
|
|
@@ -71,10 +71,9 @@ export const Basic = () => {
|
|
|
71
71
|
<div className={`form-group ${hasError ? 'has-error' : ''}`}>
|
|
72
72
|
<Checkbox
|
|
73
73
|
label={label}
|
|
74
|
-
id="
|
|
74
|
+
id="id3"
|
|
75
75
|
checked={checked}
|
|
76
76
|
disabled={disabled}
|
|
77
|
-
// secondary={secondary}
|
|
78
77
|
onChange={() => setChecked(!checked)}
|
|
79
78
|
/>
|
|
80
79
|
</div>
|
|
@@ -101,6 +101,7 @@ const SegmentedControl = ({
|
|
|
101
101
|
className={classNames('segmented-control__segments', {
|
|
102
102
|
'segmented-control__segments--no-animate': !animate,
|
|
103
103
|
})}
|
|
104
|
+
role={mode !== 'input' ? 'tablist' : undefined}
|
|
104
105
|
>
|
|
105
106
|
{segmentsWithRefs.map((segment) =>
|
|
106
107
|
mode === 'input' ? (
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { forwardRef, useRef } from 'react';
|
|
3
|
-
import mergeRefs from 'react-merge-refs';
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
4
3
|
import { CSSTransition } from 'react-transition-group';
|
|
5
4
|
|
|
6
5
|
import { Position } from '../common';
|
|
@@ -28,7 +27,8 @@ const SlidingPanel = forwardRef(
|
|
|
28
27
|
}: Omit<SlidingPanelProps, 'ref'>,
|
|
29
28
|
reference: React.ForwardedRef<HTMLDivElement>,
|
|
30
29
|
) => {
|
|
31
|
-
const localReference = useRef<HTMLDivElement>(null);
|
|
30
|
+
const localReference = useRef<HTMLDivElement>(null as never);
|
|
31
|
+
useImperativeHandle(reference, () => localReference.current, []);
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<CSSTransition
|
|
@@ -43,7 +43,7 @@ const SlidingPanel = forwardRef(
|
|
|
43
43
|
unmountOnExit
|
|
44
44
|
>
|
|
45
45
|
<div
|
|
46
|
-
ref={
|
|
46
|
+
ref={localReference}
|
|
47
47
|
className={classNames(
|
|
48
48
|
'sliding-panel',
|
|
49
49
|
`sliding-panel--open-${position}`,
|
|
@@ -39,6 +39,9 @@ export const Disabled = () => {
|
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
41
|
<div className="d-flex flex-column">
|
|
42
|
+
<label id="labelID" htmlFor="switchId">
|
|
43
|
+
A switch with a label
|
|
44
|
+
</label>
|
|
42
45
|
<Switch
|
|
43
46
|
checked={checked}
|
|
44
47
|
disabled
|
|
@@ -53,7 +56,7 @@ export const Disabled = () => {
|
|
|
53
56
|
disabled
|
|
54
57
|
className="a-class-name"
|
|
55
58
|
aria-labelledby="labelID"
|
|
56
|
-
id="
|
|
59
|
+
id="switchId1"
|
|
57
60
|
onClick={() => setCheck(!checked)}
|
|
58
61
|
/>
|
|
59
62
|
</div>
|