@transferwise/components 0.0.0-experimental-bb03a6a → 0.0.0-experimental-6d4124a

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 (72) hide show
  1. package/README.md +1 -1
  2. package/build/i18n/{cs.json → cs-CZ.json} +10 -3
  3. package/build/i18n/{de.json → de-DE.json} +10 -3
  4. package/{src/i18n/es.json → build/i18n/es-ES.json} +10 -3
  5. package/{src/i18n/fr.json → build/i18n/fr-FR.json} +10 -3
  6. package/{src/i18n/hu.json → build/i18n/hu-HU.json} +10 -3
  7. package/{src/i18n/id.json → build/i18n/id-ID.json} +10 -3
  8. package/build/i18n/{it.json → it-IT.json} +10 -3
  9. package/build/i18n/{ja.json → ja-JP.json} +10 -3
  10. package/build/i18n/{pl.json → pl-PL.json} +10 -3
  11. package/build/i18n/{pt.json → pt-BR.json} +10 -3
  12. package/{src/i18n/ro.json → build/i18n/ro-RO.json} +10 -3
  13. package/build/i18n/{ru.json → ru-RU.json} +10 -3
  14. package/build/i18n/{th.json → th-TH.json} +10 -3
  15. package/{src/i18n/tr.json → build/i18n/tr-TR.json} +10 -3
  16. package/{src/i18n/uk.json → build/i18n/uk-UA.json} +10 -3
  17. package/build/i18n/zh-CN.json +10 -3
  18. package/{src/i18n/zh.json → build/i18n/zh-HK.json} +10 -3
  19. package/build/index.esm.js +441 -169
  20. package/build/index.esm.js.map +1 -1
  21. package/build/index.js +439 -167
  22. package/build/index.js.map +1 -1
  23. package/build/types/common/locale/index.d.ts +40 -31
  24. package/build/types/common/locale/index.d.ts.map +1 -1
  25. package/build/types/dateLookup/tableLink/TableLink.d.ts +2 -16
  26. package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
  27. package/build/types/dateLookup/tableLink/index.d.ts +1 -1
  28. package/build/types/dateLookup/tableLink/index.d.ts.map +1 -1
  29. package/build/types/i18n/index.d.ts.map +1 -1
  30. package/build/types/index.d.ts +1 -1
  31. package/build/types/index.d.ts.map +1 -1
  32. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  33. package/package.json +2 -2
  34. package/src/button/Button.spec.js +12 -0
  35. package/src/button/Button.tsx +1 -1
  36. package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +8 -8
  37. package/src/common/focusBoundary/FocusBoundary.tsx +4 -4
  38. package/src/common/locale/index.spec.js +27 -37
  39. package/src/common/locale/index.ts +192 -0
  40. package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +0 -26
  41. package/src/dateLookup/tableLink/TableLink.js +70 -0
  42. package/src/i18n/{cs.json → cs-CZ.json} +10 -3
  43. package/src/i18n/{de.json → de-DE.json} +10 -3
  44. package/{build/i18n/es.json → src/i18n/es-ES.json} +10 -3
  45. package/{build/i18n/fr.json → src/i18n/fr-FR.json} +10 -3
  46. package/{build/i18n/hu.json → src/i18n/hu-HU.json} +10 -3
  47. package/{build/i18n/id.json → src/i18n/id-ID.json} +10 -3
  48. package/src/i18n/index.ts +36 -32
  49. package/src/i18n/{it.json → it-IT.json} +10 -3
  50. package/src/i18n/{ja.json → ja-JP.json} +10 -3
  51. package/src/i18n/{pl.json → pl-PL.json} +10 -3
  52. package/src/i18n/{pt.json → pt-BR.json} +10 -3
  53. package/{build/i18n/ro.json → src/i18n/ro-RO.json} +10 -3
  54. package/src/i18n/{ru.json → ru-RU.json} +10 -3
  55. package/src/i18n/{th.json → th-TH.json} +10 -3
  56. package/{build/i18n/tr.json → src/i18n/tr-TR.json} +10 -3
  57. package/{build/i18n/uk.json → src/i18n/uk-UA.json} +10 -3
  58. package/src/i18n/zh-CN.json +10 -3
  59. package/{build/i18n/zh.json → src/i18n/zh-HK.json} +10 -3
  60. package/src/index.ts +1 -1
  61. package/src/inputs/SelectInput.tsx +8 -3
  62. package/src/provider/Provider.js +1 -1
  63. package/src/provider/Provider.spec.tsx +3 -3
  64. package/src/ssr.spec.js +2 -2
  65. package/src/test-utils/index.js +1 -1
  66. package/build/i18n/zh_CN.json +0 -44
  67. package/src/common/locale/index.js +0 -130
  68. package/src/dateLookup/tableLink/TableLink.tsx +0 -74
  69. package/src/i18n/zh_CN.json +0 -44
  70. /package/build/i18n/{en.json → en-GB.json} +0 -0
  71. /package/src/dateLookup/tableLink/{index.ts → index.js} +0 -0
  72. /package/src/i18n/{en.json → en-GB.json} +0 -0
@@ -16,7 +16,7 @@ describe('Provider', () => {
16
16
  });
17
17
 
18
18
  it('does not add any elements in the DOM', async () => {
19
- const locale = 'en';
19
+ const locale = 'en-GB';
20
20
  const messages = (await import(`../i18n/${locale}.json`)) as Record<string, string>;
21
21
 
22
22
  const { container } = render(<Provider i18n={{ locale, messages }} />);
@@ -52,8 +52,8 @@ describe('Provider', () => {
52
52
  });
53
53
 
54
54
  it.each([
55
- ['ru', 'Закрыть'],
56
- ['en', 'Close'],
55
+ ['ru-RU', 'Закрыть'],
56
+ ['en-GB', 'Close'],
57
57
  ])('switching locale (%s)', async (locale, expectedMessage) => {
58
58
  expect(document.body).toBeEmptyDOMElement();
59
59
 
package/src/ssr.spec.js CHANGED
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { renderToString } from 'react-dom/server';
5
5
 
6
- import en from './i18n/en.json';
6
+ import en from './i18n/en-GB.json';
7
7
 
8
8
  import * as exposedLibraryItems from '.';
9
9
 
@@ -64,7 +64,7 @@ const excluded = new Set([
64
64
  'DEFAULT_LANG',
65
65
  'DEFAULT_LOCALE',
66
66
  'adjustLocale',
67
- 'getLangFromLocale',
67
+ 'getSupportedLangFromLocale',
68
68
  'getCountryFromLocale',
69
69
  'getDirectionFromLocale',
70
70
  'isServerSide',
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
4
4
 
5
5
  import { Provider } from '..';
6
6
  import { DEFAULT_LOCALE } from '../common/locale';
7
- import en from '../i18n/en.json';
7
+ import en from '../i18n/en-GB.json';
8
8
 
9
9
  /**
10
10
  * Custom `render` function which wraps passed elements in Provider component
@@ -1,44 +0,0 @@
1
- {
2
- "neptune.Chips.ariaLabel": "清除 {choice}",
3
- "neptune.ClearButton.ariaLabel": "清晰",
4
- "neptune.CloseButton.ariaLabel": "关闭",
5
- "neptune.DateInput.day.label": "日",
6
- "neptune.DateInput.month.label": "月",
7
- "neptune.DateInput.year.label": "年",
8
- "neptune.MoneyInput.Select.placeholder": "请选择...",
9
- "neptune.Pagination.ariaLabel": "分页导航",
10
- "neptune.PaginationLink.ariaLabel.active": "转到第 {pageNumber} 页",
11
- "neptune.PaginationLink.ariaLabel.inactive": "当前页面,第 {pageNumber} 页",
12
- "neptune.Select.searchPlaceholder": "搜索",
13
- "neptune.Summary.statusDone": "已完成",
14
- "neptune.Summary.statusNotDone": "未完成",
15
- "neptune.Summary.statusPending": "待处理",
16
- "neptune.Upload.csButtonText": "上传另一个文件?",
17
- "neptune.Upload.csFailureText": "上传失败。请重试",
18
- "neptune.Upload.csSuccessText": "上传完毕!",
19
- "neptune.Upload.csTooLargeMessage": "请提供小于 5MB 的文件",
20
- "neptune.Upload.csWrongTypeMessage": "不支持该文件类型,请试试其他文件",
21
- "neptune.Upload.psButtonText": "取消",
22
- "neptune.Upload.psProcessingText": "正在上传…",
23
- "neptune.Upload.usButtonText": "或选择文件",
24
- "neptune.Upload.usDropMessage": "拖放文件开始上传",
25
- "neptune.Upload.usPlaceholder": "拖放小于 5MB 的文件",
26
- "neptune.UploadButton.allFileTypes": "所有文件类型",
27
- "neptune.UploadButton.dropFiles": "拖放文件开始上传",
28
- "neptune.UploadButton.instructions": "{fileTypes},小于 {size}MB",
29
- "neptune.UploadButton.uploadFile": "上传文件",
30
- "neptune.UploadButton.uploadFiles": "上传文件",
31
- "neptune.UploadInput.deleteModalBody": "删除此文件会将其从我们的系统中删除",
32
- "neptune.UploadInput.deleteModalCancelButtonText": "取消",
33
- "neptune.UploadInput.deleteModalConfirmButtonText": "删除",
34
- "neptune.UploadInput.deleteModalTitle": "确定要删除此文件吗?",
35
- "neptune.UploadInput.fileIsTooLarge": "文件太大",
36
- "neptune.UploadInput.fileTypeNotSupported": "文件类型不受支持",
37
- "neptune.UploadInput.maximumFilesAlreadyUploaded": "抱歉,此上传失败,因为我们一次只能接受 {maxFilesAllowed} 个文件。",
38
- "neptune.UploadItem.deleting": "正在删除…",
39
- "neptune.UploadItem.removeFile": "删除文件 {filename}",
40
- "neptune.UploadItem.uploaded": "已上传",
41
- "neptune.UploadItem.uploadedFile": "上传的文件",
42
- "neptune.UploadItem.uploading": "正在上传…",
43
- "neptune.UploadItem.uploadingFailed": "上传失败"
44
- }
@@ -1,130 +0,0 @@
1
- import { Direction } from '..';
2
-
3
- /**
4
- * Default language
5
- *
6
- * @type {string}
7
- */
8
- export const DEFAULT_LANG = 'en';
9
-
10
- /**
11
- * Default locale
12
- *
13
- * @type {string}
14
- */
15
- export const DEFAULT_LOCALE = 'en-GB';
16
-
17
- /**
18
- * Array of languages that are written from the right to the left
19
- *
20
- * @type {string[]}
21
- */
22
- export const RTL_LANGUAGES = ['ar', 'he'];
23
-
24
- export const SUPPORTED_LANGUAGES = [
25
- DEFAULT_LANG,
26
- 'de',
27
- 'es',
28
- 'fr',
29
- 'hu',
30
- 'id',
31
- 'it',
32
- 'ja',
33
- 'pl',
34
- 'pt',
35
- 'ro',
36
- 'ru',
37
- 'th',
38
- 'tr',
39
- 'uk',
40
- 'zh',
41
- ];
42
-
43
- /**
44
- * Verifies and adjusts locale (replace `_` with `-`)
45
- * Returns null if locale is unrecognized by {Intl.Locale}
46
- *
47
- * @param {string} locale (`es`, `es_ES`, `en-GB`, `en`, `ja`, `ja-JP` etc)
48
- * @returns {string|null}
49
- */
50
- export function adjustLocale(locale) {
51
- if (!locale || locale.trim().length === 0) {
52
- return null;
53
- }
54
- try {
55
- const { baseName } = new Intl.Locale(locale.trim().replace('_', '-'));
56
- return baseName;
57
- } catch (error) {
58
- // eslint-disable-next-line no-console
59
- console.error(error);
60
- return null;
61
- }
62
- }
63
-
64
- /**
65
- * Provides corresponding lang (iso2) for provided locale
66
- * if locale is invalid or language is unsupported returns null
67
- *
68
- * @param {string} locale (`es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP` etc)
69
- * @returns {string|null}
70
- */
71
- export function getLangFromLocale(locale) {
72
- const adjustedLocale = adjustLocale(locale);
73
- if (adjustedLocale === null) {
74
- return null;
75
- }
76
- try {
77
- const { language } = new Intl.Locale(adjustedLocale);
78
-
79
- if (SUPPORTED_LANGUAGES.includes(language)) {
80
- return language;
81
- }
82
- return null;
83
- } catch (error) {
84
- // eslint-disable-next-line no-console
85
- console.error(error);
86
- return null;
87
- }
88
- }
89
-
90
- /**
91
- * Provides corresponding country code (iso2) for locales code with explicit region value (`es-ES`, `en-GB`, `ja-JP` etc.)
92
- * if the value is invalid or missing region it returns null
93
- *
94
- * @param {string} locale
95
- * @returns {string|null}
96
- */
97
- export function getCountryFromLocale(locale) {
98
- const adjustedLocale = adjustLocale(locale);
99
- if (adjustedLocale === null) {
100
- return null;
101
- }
102
- try {
103
- const { region } = new Intl.Locale(adjustedLocale);
104
- return region ?? null;
105
- } catch (error) {
106
- // eslint-disable-next-line no-console
107
- console.error(error);
108
- return null;
109
- }
110
- }
111
-
112
- /**
113
- * Provides the layout direction for a given locale.
114
- * If locale is invalid or language is unsupported returns Direction.LTR
115
- *
116
- * @param {string} locale (`es`, `es-ES`, `en-GB`, `en`, `ja`, `ja-JP` etc)
117
- * @returns {Direction} The layout direction based on the locale
118
- */
119
- export function getDirectionFromLocale(locale) {
120
- try {
121
- const adjustedLocale = adjustLocale(locale);
122
- const { language } = new Intl.Locale(adjustedLocale);
123
-
124
- return RTL_LANGUAGES.includes(language) ? Direction.RTL : Direction.LTR;
125
- } catch (error) {
126
- // eslint-disable-next-line no-console
127
- console.error(error);
128
- return Direction.LTR;
129
- }
130
- }
@@ -1,74 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- import { injectIntl, IntlShape } from 'react-intl';
3
-
4
- import messages from '../DateLookup.messages';
5
-
6
- interface TableLinkProps {
7
- item: number;
8
- type: 'day' | 'month' | 'year';
9
- title?: string;
10
- longTitle?: string;
11
- active: boolean;
12
- disabled: boolean;
13
- today: boolean;
14
- autofocus?: boolean;
15
- onClick: (item: number) => void;
16
- intl: IntlShape;
17
- }
18
-
19
- const TableLink = ({
20
- item,
21
- type,
22
- title,
23
- longTitle,
24
- active,
25
- disabled,
26
- today,
27
- autofocus,
28
- onClick,
29
- intl: { formatMessage },
30
- }: TableLinkProps) => {
31
- const buttonRef = useRef<HTMLButtonElement>(null);
32
-
33
- useEffect(() => {
34
- if (autofocus) {
35
- buttonRef.current?.focus();
36
- }
37
- }, []);
38
-
39
- const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {
40
- event.preventDefault();
41
- if (!disabled) {
42
- onClick(item);
43
- }
44
- };
45
-
46
- const calculateAriaLabel = () => {
47
- if (active) {
48
- return `${longTitle || title || ''}, ${formatMessage(messages.selected)} ${formatMessage(
49
- messages[type],
50
- )}`;
51
- }
52
- return longTitle || title;
53
- };
54
-
55
- return (
56
- <>
57
- <button
58
- ref={buttonRef}
59
- type="button"
60
- className={`tw-date-lookup-${type}-option ${active ? 'active' : ''} ${
61
- today ? 'today' : ''
62
- } np-text-body-default-bold`}
63
- disabled={disabled}
64
- aria-label={calculateAriaLabel()}
65
- aria-pressed={active}
66
- onClick={onCalendarClick}
67
- >
68
- {title || item}
69
- </button>
70
- </>
71
- );
72
- };
73
-
74
- export default injectIntl(TableLink);
@@ -1,44 +0,0 @@
1
- {
2
- "neptune.Chips.ariaLabel": "清除 {choice}",
3
- "neptune.ClearButton.ariaLabel": "清晰",
4
- "neptune.CloseButton.ariaLabel": "关闭",
5
- "neptune.DateInput.day.label": "日",
6
- "neptune.DateInput.month.label": "月",
7
- "neptune.DateInput.year.label": "年",
8
- "neptune.MoneyInput.Select.placeholder": "请选择...",
9
- "neptune.Pagination.ariaLabel": "分页导航",
10
- "neptune.PaginationLink.ariaLabel.active": "转到第 {pageNumber} 页",
11
- "neptune.PaginationLink.ariaLabel.inactive": "当前页面,第 {pageNumber} 页",
12
- "neptune.Select.searchPlaceholder": "搜索",
13
- "neptune.Summary.statusDone": "已完成",
14
- "neptune.Summary.statusNotDone": "未完成",
15
- "neptune.Summary.statusPending": "待处理",
16
- "neptune.Upload.csButtonText": "上传另一个文件?",
17
- "neptune.Upload.csFailureText": "上传失败。请重试",
18
- "neptune.Upload.csSuccessText": "上传完毕!",
19
- "neptune.Upload.csTooLargeMessage": "请提供小于 5MB 的文件",
20
- "neptune.Upload.csWrongTypeMessage": "不支持该文件类型,请试试其他文件",
21
- "neptune.Upload.psButtonText": "取消",
22
- "neptune.Upload.psProcessingText": "正在上传…",
23
- "neptune.Upload.usButtonText": "或选择文件",
24
- "neptune.Upload.usDropMessage": "拖放文件开始上传",
25
- "neptune.Upload.usPlaceholder": "拖放小于 5MB 的文件",
26
- "neptune.UploadButton.allFileTypes": "所有文件类型",
27
- "neptune.UploadButton.dropFiles": "拖放文件开始上传",
28
- "neptune.UploadButton.instructions": "{fileTypes},小于 {size}MB",
29
- "neptune.UploadButton.uploadFile": "上传文件",
30
- "neptune.UploadButton.uploadFiles": "上传文件",
31
- "neptune.UploadInput.deleteModalBody": "删除此文件会将其从我们的系统中删除",
32
- "neptune.UploadInput.deleteModalCancelButtonText": "取消",
33
- "neptune.UploadInput.deleteModalConfirmButtonText": "删除",
34
- "neptune.UploadInput.deleteModalTitle": "确定要删除此文件吗?",
35
- "neptune.UploadInput.fileIsTooLarge": "文件太大",
36
- "neptune.UploadInput.fileTypeNotSupported": "文件类型不受支持",
37
- "neptune.UploadInput.maximumFilesAlreadyUploaded": "抱歉,此上传失败,因为我们一次只能接受 {maxFilesAllowed} 个文件。",
38
- "neptune.UploadItem.deleting": "正在删除…",
39
- "neptune.UploadItem.removeFile": "删除文件 {filename}",
40
- "neptune.UploadItem.uploaded": "已上传",
41
- "neptune.UploadItem.uploadedFile": "上传的文件",
42
- "neptune.UploadItem.uploading": "正在上传…",
43
- "neptune.UploadItem.uploadingFailed": "上传失败"
44
- }
File without changes
File without changes
File without changes