@transferwise/components 46.162.2 → 46.163.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.
Files changed (92) hide show
  1. package/build/Chips/Chip/Chip.js +11 -4
  2. package/build/Chips/Chip/Chip.js.map +1 -1
  3. package/build/Chips/Chip/Chip.mjs +11 -4
  4. package/build/Chips/Chip/Chip.mjs.map +1 -1
  5. package/build/Typeahead/Typeahead.js +17 -4
  6. package/build/Typeahead/Typeahead.js.map +1 -1
  7. package/build/Typeahead/Typeahead.mjs +17 -4
  8. package/build/Typeahead/Typeahead.mjs.map +1 -1
  9. package/build/Typeahead/TypeaheadInput/TypeaheadInput.js +2 -0
  10. package/build/Typeahead/TypeaheadInput/TypeaheadInput.js.map +1 -1
  11. package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs +2 -0
  12. package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs.map +1 -1
  13. package/build/i18n/es.json +1 -0
  14. package/build/i18n/es.json.js +1 -0
  15. package/build/i18n/es.json.js.map +1 -1
  16. package/build/i18n/es.json.mjs +1 -0
  17. package/build/i18n/es.json.mjs.map +1 -1
  18. package/build/i18n/hu.json +1 -0
  19. package/build/i18n/hu.json.js +1 -0
  20. package/build/i18n/hu.json.js.map +1 -1
  21. package/build/i18n/hu.json.mjs +1 -0
  22. package/build/i18n/hu.json.mjs.map +1 -1
  23. package/build/i18n/id.json +1 -0
  24. package/build/i18n/id.json.js +1 -0
  25. package/build/i18n/id.json.js.map +1 -1
  26. package/build/i18n/id.json.mjs +1 -0
  27. package/build/i18n/id.json.mjs.map +1 -1
  28. package/build/i18n/it.json +1 -0
  29. package/build/i18n/it.json.js +1 -0
  30. package/build/i18n/it.json.js.map +1 -1
  31. package/build/i18n/it.json.mjs +1 -0
  32. package/build/i18n/it.json.mjs.map +1 -1
  33. package/build/i18n/ja.json +1 -0
  34. package/build/i18n/ja.json.js +1 -0
  35. package/build/i18n/ja.json.js.map +1 -1
  36. package/build/i18n/ja.json.mjs +1 -0
  37. package/build/i18n/ja.json.mjs.map +1 -1
  38. package/build/i18n/nl.json +1 -0
  39. package/build/i18n/nl.json.js +1 -0
  40. package/build/i18n/nl.json.js.map +1 -1
  41. package/build/i18n/nl.json.mjs +1 -0
  42. package/build/i18n/nl.json.mjs.map +1 -1
  43. package/build/i18n/pl.json +1 -0
  44. package/build/i18n/pl.json.js +1 -0
  45. package/build/i18n/pl.json.js.map +1 -1
  46. package/build/i18n/pl.json.mjs +1 -0
  47. package/build/i18n/pl.json.mjs.map +1 -1
  48. package/build/i18n/ro.json +1 -0
  49. package/build/i18n/ro.json.js +1 -0
  50. package/build/i18n/ro.json.js.map +1 -1
  51. package/build/i18n/ro.json.mjs +1 -0
  52. package/build/i18n/ro.json.mjs.map +1 -1
  53. package/build/i18n/uk.json +1 -0
  54. package/build/i18n/uk.json.js +1 -0
  55. package/build/i18n/uk.json.js.map +1 -1
  56. package/build/i18n/uk.json.mjs +1 -0
  57. package/build/i18n/uk.json.mjs.map +1 -1
  58. package/build/i18n/zh-HK.json +1 -0
  59. package/build/i18n/zh-HK.json.js +1 -0
  60. package/build/i18n/zh-HK.json.js.map +1 -1
  61. package/build/i18n/zh-HK.json.mjs +1 -0
  62. package/build/i18n/zh-HK.json.mjs.map +1 -1
  63. package/build/main.css +3 -0
  64. package/build/styles/Typeahead/Typeahead.css +3 -0
  65. package/build/styles/main.css +3 -0
  66. package/build/types/Chips/Chip/Chip.d.ts +3 -1
  67. package/build/types/Chips/Chip/Chip.d.ts.map +1 -1
  68. package/build/types/Typeahead/Typeahead.d.ts +2 -0
  69. package/build/types/Typeahead/Typeahead.d.ts.map +1 -1
  70. package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts +1 -1
  71. package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts.map +1 -1
  72. package/package.json +4 -4
  73. package/src/Chips/Chip/Chip.test.tsx +34 -0
  74. package/src/Chips/Chip/Chip.tsx +11 -3
  75. package/src/Typeahead/Typeahead.css +3 -0
  76. package/src/Typeahead/Typeahead.less +4 -0
  77. package/src/Typeahead/Typeahead.test.tsx +73 -0
  78. package/src/Typeahead/Typeahead.tsx +18 -3
  79. package/src/Typeahead/TypeaheadInput/TypeaheadInput.tsx +6 -1
  80. package/src/Typeahead/_stories/Typeahead.story.tsx +1 -0
  81. package/src/Typeahead/_stories/Typeahead.test.story.tsx +41 -0
  82. package/src/i18n/es.json +1 -0
  83. package/src/i18n/hu.json +1 -0
  84. package/src/i18n/id.json +1 -0
  85. package/src/i18n/it.json +1 -0
  86. package/src/i18n/ja.json +1 -0
  87. package/src/i18n/nl.json +1 -0
  88. package/src/i18n/pl.json +1 -0
  89. package/src/i18n/ro.json +1 -0
  90. package/src/i18n/uk.json +1 -0
  91. package/src/i18n/zh-HK.json +1 -0
  92. package/src/main.css +3 -0
@@ -35,6 +35,7 @@
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Selectează o opțiune...",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Codul țării",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Număr de telefon",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Prefix",
38
39
  "neptune.Select.searchPlaceholder": "Caută...",
39
40
  "neptune.SelectInput.noResultsFound": "Nu s-a găsit niciun rezultat",
40
41
  "neptune.StatusIcon.iconLabel.error": "Eroare:",
@@ -39,6 +39,7 @@ var ro = {
39
39
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Selectează o opțiune...",
40
40
  "neptune.PhoneNumberInput.countryCodeLabel": "Codul țării",
41
41
  "neptune.PhoneNumberInput.phoneNumberLabel": "Număr de telefon",
42
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Prefix",
42
43
  "neptune.Select.searchPlaceholder": "Caută...",
43
44
  "neptune.SelectInput.noResultsFound": "Nu s-a găsit niciun rezultat",
44
45
  "neptune.StatusIcon.iconLabel.error": "Eroare:",
@@ -1 +1 @@
1
- {"version":3,"file":"ro.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ro.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -35,6 +35,7 @@ var ro = {
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Selectează o opțiune...",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Codul țării",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Număr de telefon",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Prefix",
38
39
  "neptune.Select.searchPlaceholder": "Caută...",
39
40
  "neptune.SelectInput.noResultsFound": "Nu s-a găsit niciun rezultat",
40
41
  "neptune.StatusIcon.iconLabel.error": "Eroare:",
@@ -1 +1 @@
1
- {"version":3,"file":"ro.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ro.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -35,6 +35,7 @@
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Виберіть варіант…",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Код країни",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Номер телефону",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Префікс",
38
39
  "neptune.Select.searchPlaceholder": "Пошук…",
39
40
  "neptune.SelectInput.noResultsFound": "Нічого не знайдено",
40
41
  "neptune.StatusIcon.iconLabel.error": "Помилка:",
@@ -39,6 +39,7 @@ var uk = {
39
39
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Виберіть варіант…",
40
40
  "neptune.PhoneNumberInput.countryCodeLabel": "Код країни",
41
41
  "neptune.PhoneNumberInput.phoneNumberLabel": "Номер телефону",
42
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Префікс",
42
43
  "neptune.Select.searchPlaceholder": "Пошук…",
43
44
  "neptune.SelectInput.noResultsFound": "Нічого не знайдено",
44
45
  "neptune.StatusIcon.iconLabel.error": "Помилка:",
@@ -1 +1 @@
1
- {"version":3,"file":"uk.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"uk.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -35,6 +35,7 @@ var uk = {
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Виберіть варіант…",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Код країни",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Номер телефону",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Префікс",
38
39
  "neptune.Select.searchPlaceholder": "Пошук…",
39
40
  "neptune.SelectInput.noResultsFound": "Нічого не знайдено",
40
41
  "neptune.StatusIcon.iconLabel.error": "Помилка:",
@@ -1 +1 @@
1
- {"version":3,"file":"uk.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"uk.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -35,6 +35,7 @@
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "選擇其中一項…",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "國家/地區代碼",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "電話號碼",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "前綴",
38
39
  "neptune.Select.searchPlaceholder": "搜尋…",
39
40
  "neptune.SelectInput.noResultsFound": "找不到任何結果",
40
41
  "neptune.StatusIcon.iconLabel.error": "錯誤:",
@@ -39,6 +39,7 @@ var zhHK = {
39
39
  "neptune.PhoneNumberInput.SelectInput.placeholder": "選擇其中一項…",
40
40
  "neptune.PhoneNumberInput.countryCodeLabel": "國家/地區代碼",
41
41
  "neptune.PhoneNumberInput.phoneNumberLabel": "電話號碼",
42
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "前綴",
42
43
  "neptune.Select.searchPlaceholder": "搜尋…",
43
44
  "neptune.SelectInput.noResultsFound": "找不到任何結果",
44
45
  "neptune.StatusIcon.iconLabel.error": "錯誤:",
@@ -1 +1 @@
1
- {"version":3,"file":"zh-HK.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh-HK.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -35,6 +35,7 @@ var zhHK = {
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "選擇其中一項…",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "國家/地區代碼",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "電話號碼",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "前綴",
38
39
  "neptune.Select.searchPlaceholder": "搜尋…",
39
40
  "neptune.SelectInput.noResultsFound": "找不到任何結果",
40
41
  "neptune.StatusIcon.iconLabel.error": "錯誤:",
@@ -1 +1 @@
1
- {"version":3,"file":"zh-HK.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"zh-HK.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/build/main.css CHANGED
@@ -27578,6 +27578,9 @@ button.np-link {
27578
27578
  cursor: text;
27579
27579
  display: flex;
27580
27580
  }
27581
+ .typeahead--multiple .input-group.disabled .typeahead__input-container {
27582
+ cursor: not-allowed;
27583
+ }
27581
27584
  .typeahead--multiple .sizer {
27582
27585
  white-space: pre;
27583
27586
  position: absolute;
@@ -65,6 +65,9 @@
65
65
  cursor: text;
66
66
  display: flex;
67
67
  }
68
+ .typeahead--multiple .input-group.disabled .typeahead__input-container {
69
+ cursor: not-allowed;
70
+ }
68
71
  .typeahead--multiple .sizer {
69
72
  white-space: pre;
70
73
  position: absolute;
@@ -27578,6 +27578,9 @@ button.np-link {
27578
27578
  cursor: text;
27579
27579
  display: flex;
27580
27580
  }
27581
+ .typeahead--multiple .input-group.disabled .typeahead__input-container {
27582
+ cursor: not-allowed;
27583
+ }
27581
27584
  .typeahead--multiple .sizer {
27582
27585
  white-space: pre;
27583
27586
  position: absolute;
@@ -6,10 +6,12 @@ export type ChipProps<T extends ChipValue = ChipValue> = {
6
6
  onRemove?: () => void;
7
7
  onClick?: () => void;
8
8
  onKeyPress?: () => void;
9
+ /** @default false */
10
+ disabled?: boolean;
9
11
  closeButton?: AriaLabelProperty;
10
12
  'aria-checked'?: boolean;
11
13
  role?: string;
12
14
  } & AriaLabelProperty & CommonProps;
13
- declare const Chip: <T extends ChipValue = ChipValue>({ label, value, onRemove, onClick, onKeyPress, className, "aria-label": ariaLabel, "aria-checked": ariaChecked, role, closeButton, }: ChipProps<T>) => import("react").JSX.Element;
15
+ declare const Chip: <T extends ChipValue = ChipValue>({ label, value, onRemove, onClick, onKeyPress, disabled, className, "aria-label": ariaLabel, "aria-checked": ariaChecked, role, closeButton, }: ChipProps<T>) => import("react").JSX.Element;
14
16
  export default Chip;
15
17
  //# sourceMappingURL=Chip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../../src/Chips/Chip/Chip.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAc,MAAM,cAAc,CAAC;AAG1E,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IACvD,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,iBAAiB,GACnB,WAAW,CAAC;AAEd,QAAA,MAAM,IAAI,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,sIAW5C,SAAS,CAAC,CAAC,CAAC,gCA8Cd,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../../src/Chips/Chip/Chip.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAc,MAAM,cAAc,CAAC;AAG1E,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IACvD,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,iBAAiB,GACnB,WAAW,CAAC;AAEd,QAAA,MAAM,IAAI,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,gJAY5C,SAAS,CAAC,CAAC,CAAC,gCAmDd,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -32,6 +32,8 @@ export interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {
32
32
  chipSeparators?: readonly string[];
33
33
  /** @default true */
34
34
  clearable?: boolean;
35
+ /** @default false */
36
+ disabled?: boolean;
35
37
  footer?: ReactNode;
36
38
  /** @default [] */
37
39
  initialValue?: readonly TypeaheadOption<T>[];
@@ -1 +1 @@
1
- {"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../../src/Typeahead/Typeahead.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ement>;
13
13
  renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;
14
14
  ariaActivedescendant?: string;
15
- } & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'multiple' | 'placeholder' | 'maxHeight'>;
15
+ } & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'disabled' | 'multiple' | 'placeholder' | 'maxHeight'>;
16
16
  type TypeaheadInputState = {
17
17
  inputWidth: number;
18
18
  keyboardFocusedOptionIndex: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"TypeaheadInput.d.ts","sourceRoot":"","sources":["../../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM/D,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IACrD,SAAS,EAAE,KAAK,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACxD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IACnE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,GAA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ACvD,UAAU,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IACnE,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,IAAI,CACN,cAAc,CAAC,CAAC,CAAC,EACjB,IAAI,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,GAAG,WAAW,CACpF,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,cAAc,CAAC,CAAC,CAAE,SAAQ,SAAS,CACtD,mBAAmB,CAAC,CAAC,CAAC,EACtB,mBAAmB,CACpB;IACC,QAAQ,8CAAiC;IACzC,QAAQ,4CAA+B;gBAE3B,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAQzC,iBAAiB;IAUjB,kBAAkB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAMxD,gBAAgB,aAMd;IAEF,WAAW,GAAI,OAAO,OAAO,iCA+C3B;IAEF,MAAM;CAiCP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.162.2",
3
+ "version": "46.163.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -44,7 +44,7 @@
44
44
  "@babel/preset-env": "^7.29.7",
45
45
  "@babel/preset-react": "^7.29.7",
46
46
  "@babel/preset-typescript": "^7.29.7",
47
- "@formatjs/cli": "^6.16.23",
47
+ "@formatjs/cli": "^6.16.31",
48
48
  "@rollup/plugin-babel": "^7.1.0",
49
49
  "@rollup/plugin-json": "^6.1.0",
50
50
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -55,7 +55,7 @@
55
55
  "@storybook/addon-mcp": "^0.7.0",
56
56
  "@storybook/addon-webpack5-compiler-babel": "^4.0.1",
57
57
  "@storybook/react-webpack5": "^10.6.0",
58
- "@testing-library/dom": "^10.4.1",
58
+ "@testing-library/dom": "^10.4.2",
59
59
  "@testing-library/jest-dom": "^6.9.1",
60
60
  "@testing-library/react": "^16.3.3",
61
61
  "@testing-library/user-event": "^14.6.7",
@@ -89,7 +89,7 @@
89
89
  "lodash.times": "^4.3.2",
90
90
  "react-intl": "^7.1.14",
91
91
  "react-live": "^4.1.8",
92
- "rollup": "^4.63.1",
92
+ "rollup": "^4.63.4",
93
93
  "rollup-preserve-directives": "^1.1.3",
94
94
  "storybook": "^10.6.0",
95
95
  "storybook-addon-tag-badges": "^3.1.0",
@@ -0,0 +1,34 @@
1
+ import { render, screen, userEvent } from '../../test-utils';
2
+
3
+ import Chip from './Chip';
4
+
5
+ describe('Chip', () => {
6
+ it('calls onClick when clicked', async () => {
7
+ const onClick = jest.fn();
8
+ render(<Chip label="Accounting" onClick={onClick} />);
9
+
10
+ await userEvent.click(screen.getByRole('button', { name: 'Accounting' }));
11
+
12
+ expect(onClick).toHaveBeenCalled();
13
+ });
14
+
15
+ describe('when disabled', () => {
16
+ it('does not call onClick when clicked', async () => {
17
+ const onClick = jest.fn();
18
+ render(<Chip label="Accounting" disabled onClick={onClick} />);
19
+
20
+ await userEvent.click(screen.getByRole('button', { name: 'Accounting' }));
21
+
22
+ expect(onClick).not.toHaveBeenCalled();
23
+ });
24
+
25
+ it('marks an actionable chip as disabled and takes it out of the tab order', () => {
26
+ render(<Chip label="Accounting" disabled onClick={() => {}} />);
27
+
28
+ const chip = screen.getByRole('button', { name: 'Accounting' });
29
+ expect(chip).toHaveAttribute('aria-disabled', 'true');
30
+ expect(chip).toHaveAttribute('tabindex', '-1');
31
+ expect(chip).toHaveClass('disabled');
32
+ });
33
+ });
34
+ });
@@ -13,6 +13,8 @@ export type ChipProps<T extends ChipValue = ChipValue> = {
13
13
  onRemove?: () => void;
14
14
  onClick?: () => void;
15
15
  onKeyPress?: () => void;
16
+ /** @default false */
17
+ disabled?: boolean;
16
18
  closeButton?: AriaLabelProperty;
17
19
  'aria-checked'?: boolean;
18
20
  role?: string;
@@ -25,6 +27,7 @@ const Chip = <T extends ChipValue = ChipValue>({
25
27
  onRemove,
26
28
  onClick,
27
29
  onKeyPress,
30
+ disabled = false,
28
31
  className = undefined,
29
32
  'aria-label': ariaLabel,
30
33
  'aria-checked': ariaChecked,
@@ -32,8 +35,10 @@ const Chip = <T extends ChipValue = ChipValue>({
32
35
  closeButton,
33
36
  }: ChipProps<T>) => {
34
37
  const isActionable = onClick || onKeyPress;
38
+ const isInteractive = isActionable && !disabled;
35
39
  const defaultRole = isActionable ? 'button' : undefined;
36
- const tabIndex = isActionable ? 0 : -1;
40
+ const chipRole = role ?? defaultRole;
41
+ const tabIndex = isInteractive ? 0 : -1;
37
42
 
38
43
  const closeButtonReference = useRef<HTMLButtonElement>(null);
39
44
  const previousCloseButtonShown = useRef<boolean | undefined>(undefined);
@@ -47,19 +52,21 @@ const Chip = <T extends ChipValue = ChipValue>({
47
52
  return (
48
53
  <div
49
54
  key={value}
50
- role={role ?? defaultRole}
55
+ role={chipRole}
51
56
  tabIndex={tabIndex}
52
57
  aria-label={ariaLabel}
53
58
  aria-checked={ariaChecked}
59
+ aria-disabled={chipRole && disabled ? true : undefined}
54
60
  className={clsx(
55
61
  'np-chip',
56
62
  'd-flex',
57
63
  'align-items-center',
58
64
  'justify-content-between',
59
65
  onRemove ? 'np-chip--removable' : '',
66
+ { disabled },
60
67
  className,
61
68
  )}
62
- {...(isActionable && { onClick, onKeyPress })}
69
+ {...(isInteractive && { onClick, onKeyPress })}
63
70
  >
64
71
  <Body aria-hidden={!!onRemove} type={Typography.BODY_DEFAULT_BOLD}>
65
72
  {label}
@@ -71,6 +78,7 @@ const Chip = <T extends ChipValue = ChipValue>({
71
78
  aria-label={closeButton?.['aria-label']}
72
79
  size="sm"
73
80
  filled
81
+ isDisabled={disabled}
74
82
  onClick={onRemove}
75
83
  />
76
84
  ) : null}
@@ -65,6 +65,9 @@
65
65
  cursor: text;
66
66
  display: flex;
67
67
  }
68
+ .typeahead--multiple .input-group.disabled .typeahead__input-container {
69
+ cursor: not-allowed;
70
+ }
68
71
  .typeahead--multiple .sizer {
69
72
  white-space: pre;
70
73
  position: absolute;
@@ -77,6 +77,10 @@
77
77
  display: flex;
78
78
  }
79
79
 
80
+ .input-group.disabled .typeahead__input-container {
81
+ cursor: not-allowed;
82
+ }
83
+
80
84
  .sizer {
81
85
  white-space: pre;
82
86
  position: absolute;
@@ -256,4 +256,77 @@ describe('Typeahead', () => {
256
256
  expect.arrayContaining([{ label: 'foo' }, { label: 'bar' }]),
257
257
  );
258
258
  });
259
+
260
+ describe('when disabled', () => {
261
+ it('disables the input', () => {
262
+ render(<Typeahead id="test" name="test" options={[]} disabled onChange={() => {}} />);
263
+ expect(screen.getByRole('combobox')).toBeDisabled();
264
+ });
265
+
266
+ it('does not show the clear button when there is a value', () => {
267
+ render(
268
+ <Typeahead
269
+ id="test"
270
+ name="test"
271
+ options={[]}
272
+ initialValue={[{ label: 'Chip' }]}
273
+ disabled
274
+ onChange={() => {}}
275
+ />,
276
+ );
277
+ expect(screen.queryByRole('button', { name: /clear/i })).not.toBeInTheDocument();
278
+ });
279
+
280
+ it('keeps chips but does not let them be removed', () => {
281
+ render(
282
+ <Typeahead
283
+ id="test"
284
+ name="test"
285
+ options={[]}
286
+ multiple
287
+ initialValue={[{ label: 'Chip' }]}
288
+ disabled
289
+ onChange={() => {}}
290
+ />,
291
+ );
292
+ expect(screen.getByText('Chip').closest('.np-chip')).toHaveClass('disabled');
293
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
294
+ });
295
+
296
+ it('does not open the suggestions when the input is clicked', async () => {
297
+ render(
298
+ <Typeahead
299
+ id="test"
300
+ name="test"
301
+ options={[{ label: 'Option 1' }]}
302
+ minQueryLength={0}
303
+ disabled
304
+ onChange={() => {}}
305
+ />,
306
+ );
307
+
308
+ await userEvent.click(screen.getByRole('combobox'));
309
+
310
+ expect(screen.getByRole('combobox')).toHaveAttribute('aria-expanded', 'false');
311
+ });
312
+
313
+ it('closes the open menu when it becomes disabled', async () => {
314
+ const onChange = jest.fn();
315
+ const props = {
316
+ id: 'test',
317
+ name: 'test',
318
+ options: [],
319
+ allowNew: true,
320
+ minQueryLength: 0,
321
+ onChange,
322
+ };
323
+ const { rerender } = render(<Typeahead {...props} />);
324
+
325
+ await userEvent.type(screen.getByRole('combobox'), 'New thing');
326
+ rerender(<Typeahead {...props} disabled />);
327
+ await userEvent.click(document.body);
328
+
329
+ expect(onChange).not.toHaveBeenCalled();
330
+ });
331
+ });
259
332
  });
@@ -61,6 +61,8 @@ export interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {
61
61
  chipSeparators?: readonly string[];
62
62
  /** @default true */
63
63
  clearable?: boolean;
64
+ /** @default false */
65
+ disabled?: boolean;
64
66
  footer?: ReactNode;
65
67
  /** @default [] */
66
68
  initialValue?: readonly TypeaheadOption<T>[];
@@ -112,6 +114,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
112
114
  autoFocus: false,
113
115
  chipSeparators: [],
114
116
  clearable: true,
117
+ disabled: false,
115
118
  initialValue: [],
116
119
  inputAutoComplete: 'new-password',
117
120
  minQueryLength: DEFAULT_MIN_QUERY_LENGTH,
@@ -160,6 +163,12 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
160
163
  }
161
164
  }
162
165
 
166
+ componentDidUpdate(previousProps: TypeaheadPropsWithInputAttributes<T>) {
167
+ if (this.props.disabled && !previousProps.disabled) {
168
+ this.hideMenu();
169
+ }
170
+ }
171
+
163
172
  componentWillUnmount() {
164
173
  this.handleSearchDebounced.cancel();
165
174
  }
@@ -398,6 +407,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
398
407
  };
399
408
 
400
409
  renderChip = (option: TypeaheadOption<T>, idx: number): ReactNode => {
410
+ const { disabled } = this.props;
401
411
  const valid = this.props.validateChip?.(option);
402
412
 
403
413
  return (
@@ -408,7 +418,8 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
408
418
  'has-error': !valid,
409
419
  'np-chip--valid': valid,
410
420
  })}
411
- onRemove={() => this.removeChip(option)}
421
+ disabled={disabled}
422
+ onRemove={disabled ? undefined : () => this.removeChip(option)}
412
423
  />
413
424
  );
414
425
  };
@@ -486,6 +497,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
486
497
  addon,
487
498
  name,
488
499
  clearable,
500
+ disabled,
489
501
  allowNew,
490
502
  footer,
491
503
  showSuggestions,
@@ -501,9 +513,10 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
501
513
 
502
514
  const { errorState, query, selected, optionsShown, keyboardFocusedOptionIndex } = this.state;
503
515
 
504
- const clearButton = clearable && (query || selected.length > 0);
516
+ const clearButton = !disabled && clearable && (query || selected.length > 0);
505
517
 
506
- const dropdownOpen = optionsShown && showSuggestions && query.length >= minQueryLength;
518
+ const dropdownOpen =
519
+ !disabled && optionsShown && showSuggestions && query.length >= minQueryLength;
507
520
 
508
521
  const menu = this.renderMenu({
509
522
  footer,
@@ -556,6 +569,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
556
569
  <div
557
570
  className={clsx(`input-group input-group-${size}`, {
558
571
  'input-group--has-error': hasError,
572
+ disabled,
559
573
  })}
560
574
  >
561
575
  {addon && <span className="input-group-addon input-group-addon--search">{addon}</span>}
@@ -563,6 +577,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
563
577
  <TypeaheadInput
564
578
  {...{
565
579
  autoFocus,
580
+ disabled,
566
581
  multiple,
567
582
  dropdownOpen,
568
583
  placeholder,
@@ -23,7 +23,10 @@ export type TypeaheadInputProps<T> = {
23
23
  onPaste: React.ClipboardEventHandler<HTMLInputElement>;
24
24
  renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;
25
25
  ariaActivedescendant?: string;
26
- } & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'multiple' | 'placeholder' | 'maxHeight'>;
26
+ } & Pick<
27
+ TypeaheadProps<T>,
28
+ 'id' | 'name' | 'autoFocus' | 'disabled' | 'multiple' | 'placeholder' | 'maxHeight'
29
+ >;
27
30
 
28
31
  type TypeaheadInputState = {
29
32
  inputWidth: number;
@@ -73,6 +76,7 @@ export default class TypeaheadInput<T> extends Component<
73
76
  const {
74
77
  typeaheadId,
75
78
  autoFocus,
79
+ disabled,
76
80
  multiple,
77
81
  name,
78
82
  dropdownOpen,
@@ -98,6 +102,7 @@ export default class TypeaheadInput<T> extends Component<
98
102
  id={`input-${typeaheadId}`}
99
103
  aria-activedescendant={ariaActivedescendant}
100
104
  autoFocus={autoFocus}
105
+ disabled={disabled}
101
106
  placeholder={hasPlaceholder ? placeholder : ''}
102
107
  aria-autocomplete="list"
103
108
  aria-expanded={dropdownOpen}
@@ -36,6 +36,7 @@ const meta: Meta<typeof Typeahead> = {
36
36
  autoFocus: false,
37
37
  chipSeparators: [',', ' '],
38
38
  clearable: true,
39
+ disabled: false,
39
40
  inputAutoComplete: 'new-password',
40
41
  minQueryLength: 3,
41
42
  multiple: false,
@@ -3,6 +3,7 @@ import { Search as SearchIcon } from '@transferwise/icons';
3
3
  import { useState } from 'react';
4
4
 
5
5
  import Button from '../../Button';
6
+ import Field from '../../Field/Field';
6
7
  import Modal from '../../Modal';
7
8
  import Typeahead from '../Typeahead';
8
9
 
@@ -17,6 +18,46 @@ const meta: Meta<typeof Typeahead> = {
17
18
  };
18
19
  export default meta;
19
20
 
21
+ export const Disabled: Story = {
22
+ render: () => (
23
+ <div className="d-flex flex-column">
24
+ <Field id="typeahead-disabled-empty" label="Empty">
25
+ <Typeahead
26
+ id="typeahead-disabled-empty"
27
+ name="typeahead-disabled-empty"
28
+ disabled
29
+ placeholder="Search currencies"
30
+ addon={<SearchIcon size={24} />}
31
+ options={[]}
32
+ onChange={() => {}}
33
+ />
34
+ </Field>
35
+ <Field id="typeahead-disabled-value" label="With a value">
36
+ <Typeahead
37
+ id="typeahead-disabled-value"
38
+ name="typeahead-disabled-value"
39
+ disabled
40
+ addon={<SearchIcon size={24} />}
41
+ initialValue={[{ label: 'British pound' }]}
42
+ options={[]}
43
+ onChange={() => {}}
44
+ />
45
+ </Field>
46
+ <Field id="typeahead-disabled-chips" label="With chips">
47
+ <Typeahead
48
+ id="typeahead-disabled-chips"
49
+ name="typeahead-disabled-chips"
50
+ disabled
51
+ multiple
52
+ initialValue={[{ label: 'British pound' }, { label: 'Euro' }]}
53
+ options={[]}
54
+ onChange={() => {}}
55
+ />
56
+ </Field>
57
+ </div>
58
+ ),
59
+ };
60
+
20
61
  export const AutoFocusInModal: Story = {
21
62
  parameters: {
22
63
  docs: {
package/src/i18n/es.json CHANGED
@@ -35,6 +35,7 @@
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Selecciona una opción...",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Código de país",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Número de teléfono",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Prefijo",
38
39
  "neptune.Select.searchPlaceholder": "Buscar...",
39
40
  "neptune.SelectInput.noResultsFound": "No se han encontrado resultados",
40
41
  "neptune.StatusIcon.iconLabel.error": "Error:",
package/src/i18n/hu.json CHANGED
@@ -35,6 +35,7 @@
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Válassz ki egy lehetőséget...",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Országazonosító",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Telefonszám",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Előtag",
38
39
  "neptune.Select.searchPlaceholder": "Keresés...",
39
40
  "neptune.SelectInput.noResultsFound": "Nincs találat",
40
41
  "neptune.StatusIcon.iconLabel.error": "Hiba:",