@transferwise/components 46.17.2 → 46.18.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 (99) hide show
  1. package/build/index.esm.js +28 -20
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +27 -19
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +4 -0
  6. package/build/styles/instructionsList/InstructionsList.css +4 -0
  7. package/build/styles/main.css +4 -0
  8. package/build/types/accordion/Accordion.d.ts +3 -7
  9. package/build/types/accordion/Accordion.d.ts.map +1 -1
  10. package/build/types/accordion/index.d.ts +1 -0
  11. package/build/types/accordion/index.d.ts.map +1 -1
  12. package/build/types/body/Body.d.ts +1 -1
  13. package/build/types/chips/Chips.d.ts +2 -2
  14. package/build/types/chips/Chips.d.ts.map +1 -1
  15. package/build/types/dateLookup/DateLookup.d.ts +1 -0
  16. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  17. package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts +1 -1
  18. package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +1 -1
  19. package/build/types/decision/Decision.d.ts +1 -1
  20. package/build/types/decision/Decision.d.ts.map +1 -1
  21. package/build/types/flowNavigation/FlowNavigation.d.ts +1 -1
  22. package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
  23. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts +1 -1
  24. package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
  25. package/build/types/index.d.ts +2 -1
  26. package/build/types/index.d.ts.map +1 -1
  27. package/build/types/instructionsList/InstructionsList.d.ts +4 -4
  28. package/build/types/instructionsList/InstructionsList.d.ts.map +1 -1
  29. package/build/types/markdown/Markdown.d.ts +2 -2
  30. package/build/types/markdown/Markdown.d.ts.map +1 -1
  31. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -1
  32. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  33. package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts +1 -1
  34. package/build/types/phoneNumberInput/utils/excludeCountries/excludeCountries.d.ts.map +1 -1
  35. package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts +1 -1
  36. package/build/types/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.d.ts.map +1 -1
  37. package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts +1 -1
  38. package/build/types/phoneNumberInput/utils/longestMatchingPrefix/index.d.ts.map +1 -1
  39. package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts +1 -1
  40. package/build/types/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.d.ts.map +1 -1
  41. package/build/types/radioGroup/RadioGroup.d.ts +2 -1
  42. package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
  43. package/build/types/radioGroup/index.d.ts +1 -1
  44. package/build/types/radioGroup/index.d.ts.map +1 -1
  45. package/build/types/segmentedControl/SegmentedControl.d.ts +3 -3
  46. package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
  47. package/build/types/slidingPanel/SlidingPanel.d.ts.map +1 -1
  48. package/build/types/stepper/Stepper.d.ts +1 -1
  49. package/build/types/stepper/Stepper.d.ts.map +1 -1
  50. package/build/types/typeahead/Typeahead.d.ts +8 -6
  51. package/build/types/typeahead/Typeahead.d.ts.map +1 -1
  52. package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +1 -1
  53. package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts.map +1 -1
  54. package/build/types/uploadInput/UploadInput.d.ts +1 -1
  55. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  56. package/build/types/uploadInput/uploadButton/UploadButton.d.ts +1 -1
  57. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  58. package/build/types/uploadInput/uploadButton/getAllowedFileTypes.d.ts +1 -1
  59. package/build/types/uploadInput/uploadButton/getAllowedFileTypes.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/src/accordion/Accordion.tsx +6 -7
  62. package/src/accordion/index.ts +1 -0
  63. package/src/chips/Chips.story.tsx +2 -2
  64. package/src/chips/Chips.tsx +2 -2
  65. package/src/dateLookup/DateLookup.js +2 -0
  66. package/src/dateLookup/DateLookup.story.js +3 -0
  67. package/src/dateLookup/DateLookup.view.spec.js +5 -0
  68. package/src/dateLookup/dateTrigger/DateTrigger.js +1 -1
  69. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +11 -3
  70. package/src/dateLookup/getFocusableTime/getFocusableTime.tsx +1 -1
  71. package/src/decision/Decision.tsx +1 -1
  72. package/src/flowNavigation/FlowNavigation.tsx +1 -1
  73. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +6 -0
  74. package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +1 -1
  75. package/src/index.ts +2 -1
  76. package/src/instructionsList/InstructionsList.css +4 -0
  77. package/src/instructionsList/InstructionsList.less +5 -0
  78. package/src/instructionsList/InstructionsList.tsx +7 -7
  79. package/src/main.css +4 -0
  80. package/src/markdown/Markdown.tsx +3 -3
  81. package/src/moneyInput/MoneyInput.tsx +3 -3
  82. package/src/phoneNumberInput/PhoneNumberInput.tsx +1 -1
  83. package/src/phoneNumberInput/utils/excludeCountries/excludeCountries.ts +5 -2
  84. package/src/phoneNumberInput/utils/groupCountriesByPrefix/groupCountriesByPrefix.ts +1 -1
  85. package/src/phoneNumberInput/utils/longestMatchingPrefix/index.ts +1 -1
  86. package/src/phoneNumberInput/utils/sortArrayByProperty/sortArrayByProperty.ts +1 -1
  87. package/src/promoCard/PromoCardGroup.tsx +1 -1
  88. package/src/radioGroup/RadioGroup.tsx +6 -1
  89. package/src/radioGroup/index.ts +1 -1
  90. package/src/segmentedControl/SegmentedControl.tsx +3 -3
  91. package/src/slidingPanel/SlidingPanel.js +1 -0
  92. package/src/stepper/Stepper.spec.js +16 -0
  93. package/src/stepper/Stepper.tsx +2 -1
  94. package/src/typeahead/Typeahead.story.tsx +109 -0
  95. package/src/typeahead/Typeahead.tsx +18 -9
  96. package/src/typeahead/typeaheadInput/TypeaheadInput.tsx +1 -1
  97. package/src/uploadInput/UploadInput.tsx +6 -6
  98. package/src/uploadInput/uploadButton/UploadButton.tsx +5 -7
  99. package/src/uploadInput/uploadButton/getAllowedFileTypes.ts +1 -1
package/build/index.js CHANGED
@@ -1811,8 +1811,9 @@ const SlidingPanel = /*#__PURE__*/React.forwardRef(({
1811
1811
  }, reference) => {
1812
1812
  /** @type {RefObject<HTMLDivElement>} */
1813
1813
  const localReference = React.useRef(null);
1814
- return /*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
1814
+ return /*#__PURE__*/React.createElement(reactTransitionGroup.CSSTransition, {
1815
1815
  ...rest,
1816
+ key: `sliding-panel--open-${position}`,
1816
1817
  nodeRef: localReference,
1817
1818
  in: open
1818
1819
  // Wait for animation to finish before unmount.
@@ -1825,13 +1826,12 @@ const SlidingPanel = /*#__PURE__*/React.forwardRef(({
1825
1826
  'sliding-panel--fixed': slidingPanelPositionFixed
1826
1827
  }, 'sliding-panel'),
1827
1828
  appear: true,
1828
- unmountOnExit: true,
1829
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
1830
- ref: mergeRefs__default.default([reference, localReference]),
1831
- className: classNames__default.default('sliding-panel', `sliding-panel--open-${position}`, className),
1832
- children: children
1833
- })
1834
- });
1829
+ unmountOnExit: true
1830
+ }, /*#__PURE__*/jsxRuntime.jsx("div", {
1831
+ ref: mergeRefs__default.default([reference, localReference]),
1832
+ className: classNames__default.default('sliding-panel', `sliding-panel--open-${position}`, className),
1833
+ children: children
1834
+ }));
1835
1835
  });
1836
1836
  SlidingPanel.propTypes = {
1837
1837
  children: PropTypes__default.default.node,
@@ -3294,7 +3294,7 @@ const DateTrigger = ({
3294
3294
  className: "input-group-addon",
3295
3295
  children: /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
3296
3296
  className: `clear-btn clear-btn--${size}`,
3297
- "aria-label": formatMessage(dateTriggerMessages.ariaLabel),
3297
+ "aria-label": `${formatMessage(dateTriggerMessages.ariaLabel)} ${label}`,
3298
3298
  size: exports.Size.SMALL,
3299
3299
  onClick: event => {
3300
3300
  event.stopPropagation();
@@ -4272,6 +4272,7 @@ class DateLookup extends React.PureComponent {
4272
4272
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
4273
4273
  // eslint-disable-line jsx-a11y/no-static-element-interactions
4274
4274
  ref: this.element,
4275
+ id: this.props.id,
4275
4276
  "aria-labelledby": ariaLabelledBy,
4276
4277
  className: "input-group",
4277
4278
  onKeyDown: this.handleKeyDown,
@@ -4296,6 +4297,7 @@ class DateLookup extends React.PureComponent {
4296
4297
  }
4297
4298
  }
4298
4299
  DateLookup.propTypes = {
4300
+ id: PropTypes__default.default.string,
4299
4301
  value: PropTypes__default.default.instanceOf(Date),
4300
4302
  min: PropTypes__default.default.instanceOf(Date),
4301
4303
  max: PropTypes__default.default.instanceOf(Date),
@@ -5467,6 +5469,7 @@ const Stepper = ({
5467
5469
  });
5468
5470
  return /*#__PURE__*/jsxRuntime.jsx("li", {
5469
5471
  className: classNames__default.default('hidden-xs', 'tw-stepper__step', active ? 'np-text-body-default-bold tw-stepper__step--active' : 'np-text-body-default', clickable && 'tw-stepper__step--clickable', step.hoverLabel && 'tw-stepper__step--has-tooltip'),
5472
+ "aria-current": active ? 'step' : false,
5470
5473
  style: isRTL ? {
5471
5474
  right: `${index * stepPercentage * 100}%`
5472
5475
  } : {
@@ -7401,7 +7404,7 @@ const InstructionsList = ({
7401
7404
  }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
7402
7405
  children: [dontsInstructions, dosInstructions]
7403
7406
  });
7404
- return /*#__PURE__*/jsxRuntime.jsx("div", {
7407
+ return /*#__PURE__*/jsxRuntime.jsx("ul", {
7405
7408
  className: "tw-instructions",
7406
7409
  children: orderedInstructions
7407
7410
  });
@@ -7411,7 +7414,7 @@ function Instruction({
7411
7414
  type
7412
7415
  }) {
7413
7416
  const isInstructionNode = typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;
7414
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
7417
+ return /*#__PURE__*/jsxRuntime.jsxs("li", {
7415
7418
  className: "instruction",
7416
7419
  "aria-label": isInstructionNode ? item['aria-label'] : undefined,
7417
7420
  children: [type === 'do' ? /*#__PURE__*/jsxRuntime.jsx(icons.CheckCircleFill, {
@@ -7892,7 +7895,7 @@ function contains(property, query) {
7892
7895
  return property && property.toLowerCase().includes(query.toLowerCase());
7893
7896
  }
7894
7897
  function sortOptionsLabelsToFirst(options, query) {
7895
- return options.sort((first, second) => {
7898
+ return [...options].sort((first, second) => {
7896
7899
  const firstContains = contains(first.label, query);
7897
7900
  const secondContains = contains(second.label, query);
7898
7901
  if (firstContains && secondContains) {
@@ -12298,7 +12301,12 @@ class Typeahead extends React.Component {
12298
12301
  query = item.label;
12299
12302
  }
12300
12303
  this.updateSelectedValue(selected);
12301
- this.hideMenu();
12304
+ if (!item.keepFocusOnSelect) {
12305
+ this.hideMenu();
12306
+ }
12307
+ if (item.clearQueryOnSelect) {
12308
+ query = '';
12309
+ }
12302
12310
  this.setState({
12303
12311
  query
12304
12312
  });
@@ -12366,7 +12374,7 @@ class Typeahead extends React.Component {
12366
12374
  selected,
12367
12375
  errorState
12368
12376
  }, () => {
12369
- onChange(selected);
12377
+ onChange([...selected]);
12370
12378
  });
12371
12379
  };
12372
12380
  clear = event => {
@@ -12525,10 +12533,10 @@ class Typeahead extends React.Component {
12525
12533
  children: /*#__PURE__*/jsxRuntime.jsx(icons.Cross, {})
12526
12534
  })
12527
12535
  })]
12528
- }), displayAlert && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
12536
+ }), displayAlert ? /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
12529
12537
  type: alert.type,
12530
12538
  children: alert.message
12531
- }), menu]
12539
+ }) : menu]
12532
12540
  })
12533
12541
  });
12534
12542
  }
@@ -13509,7 +13517,7 @@ const UploadButton = ({
13509
13517
  if (fileTypes === '*') {
13510
13518
  return fileTypes;
13511
13519
  }
13512
- return Array.isArray(fileTypes) ? getAllowedFileTypes(fileTypes).join(', ') : getAllowedFileTypes([fileTypes]).join(', ');
13520
+ return getAllowedFileTypes(Array.isArray(fileTypes) ? fileTypes : [fileTypes]).join(', ');
13513
13521
  };
13514
13522
  function getDescription() {
13515
13523
  if (description) {
@@ -13525,7 +13533,7 @@ const UploadButton = ({
13525
13533
  function getAcceptedTypes() {
13526
13534
  const areAllFilesAllowed = getFileTypesDescription() === '*';
13527
13535
  if (areAllFilesAllowed) {
13528
- return null; //file input by default allows all files
13536
+ return {}; //file input by default allows all files
13529
13537
  }
13530
13538
  if (Array.isArray(fileTypes)) {
13531
13539
  return {
@@ -13991,7 +13999,7 @@ const UploadInput = ({
13991
13999
  }, []);
13992
14000
  React.useEffect(() => {
13993
14001
  if (onFilesChange && mounted) {
13994
- onFilesChange(uploadedFiles);
14002
+ onFilesChange([...uploadedFiles]);
13995
14003
  }
13996
14004
  }, [onFilesChange, uploadedFiles]); // eslint-disable-line react-hooks/exhaustive-deps
13997
14005
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {