@transferwise/components 46.1.0 → 46.2.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 (177) hide show
  1. package/README.md +3 -5
  2. package/build/index.esm.js +44 -23
  3. package/build/index.esm.js.map +1 -1
  4. package/build/index.js +44 -23
  5. package/build/index.js.map +1 -1
  6. package/build/main.css +5494 -1
  7. package/build/styles/accordion/Accordion.css +60 -1
  8. package/build/styles/actionButton/ActionButton.css +53 -1
  9. package/build/styles/avatar/Avatar.css +205 -1
  10. package/build/styles/badge/Badge.css +68 -1
  11. package/build/styles/button/Button.css +20 -1
  12. package/build/styles/card/Card.css +100 -1
  13. package/build/styles/checkboxButton/CheckboxButton.css +24 -1
  14. package/build/styles/chips/Chip.css +190 -1
  15. package/build/styles/circularButton/CircularButton.css +211 -1
  16. package/build/styles/common/Option/Option.css +100 -1
  17. package/build/styles/common/RadioButton/RadioButton.css +4 -1
  18. package/build/styles/common/bottomSheet/BottomSheet.css +53 -1
  19. package/build/styles/common/card/Card.css +49 -1
  20. package/build/styles/common/closeButton/CloseButton.css +79 -1
  21. package/build/styles/common/panel/Panel.css +73 -1
  22. package/build/styles/criticalBanner/CriticalCommsBanner.css +76 -1
  23. package/build/styles/dateInput/DateInput.css +3 -1
  24. package/build/styles/dateLookup/DateLookup.css +98 -1
  25. package/build/styles/dateLookup/dateTrigger/DateTrigger.css +68 -1
  26. package/build/styles/decision/Decision.css +93 -1
  27. package/build/styles/definitionList/DefinitionList.css +53 -1
  28. package/build/styles/dimmer/Dimmer.css +70 -1
  29. package/build/styles/drawer/Drawer.css +100 -1
  30. package/build/styles/dropFade/DropFade.css +19 -1
  31. package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -1
  32. package/build/styles/emphasis/Emphasis.css +31 -1
  33. package/build/styles/flowNavigation/FlowNavigation.css +72 -1
  34. package/build/styles/flowNavigation/animatedLabel/AnimatedLabel.css +21 -1
  35. package/build/styles/flowNavigation/backButton/BackButton.css +32 -1
  36. package/build/styles/header/Header.css +28 -1
  37. package/build/styles/image/Image.css +13 -1
  38. package/build/styles/info/Info.css +32 -1
  39. package/build/styles/inputs/Input.css +105 -1
  40. package/build/styles/inputs/InputGroup.css +62 -1
  41. package/build/styles/inputs/SelectInput.css +374 -1
  42. package/build/styles/inputs/TextArea.css +109 -1
  43. package/build/styles/instructionsList/InstructionsList.css +22 -1
  44. package/build/styles/link/Link.css +15 -1
  45. package/build/styles/listItem/ListItem.css +6 -1
  46. package/build/styles/loader/Loader.css +313 -1
  47. package/build/styles/logo/Logo.css +26 -1
  48. package/build/styles/main.css +5494 -1
  49. package/build/styles/modal/Modal.css +155 -1
  50. package/build/styles/moneyInput/MoneyInput.css +66 -1
  51. package/build/styles/navigationOption/NavigationOption.css +69 -1
  52. package/build/styles/navigationOptionsList/NavigationOptionsList.css +13 -1
  53. package/build/styles/nudge/Nudge.css +179 -1
  54. package/build/styles/overlayHeader/OverlayHeader.css +15 -1
  55. package/build/styles/phoneNumberInput/PhoneNumberInput.css +23 -1
  56. package/build/styles/popover/Popover.css +43 -1
  57. package/build/styles/progress/Progress.css +43 -1
  58. package/build/styles/progressBar/ProgressBar.css +14 -1
  59. package/build/styles/promoCard/PromoCard.css +186 -1
  60. package/build/styles/section/Section.css +10 -1
  61. package/build/styles/select/Select.css +309 -1
  62. package/build/styles/slidingPanel/SlidingPanel.css +105 -1
  63. package/build/styles/snackbar/Snackbar.css +93 -1
  64. package/build/styles/statusIcon/StatusIcon.css +78 -1
  65. package/build/styles/stepper/Stepper.css +108 -1
  66. package/build/styles/summary/Summary.css +81 -1
  67. package/build/styles/switch/Switch.css +68 -1
  68. package/build/styles/tabs/Tabs.css +121 -1
  69. package/build/styles/tile/Tile.css +55 -1
  70. package/build/styles/tooltip/Tooltip.css +50 -1
  71. package/build/styles/typeahead/Typeahead.css +183 -1
  72. package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +9 -1
  73. package/build/styles/upload/Upload.css +15 -1
  74. package/build/styles/uploadInput/UploadInput.css +71 -1
  75. package/build/styles/uploadInput/uploadButton/UploadButton.css +49 -1
  76. package/build/styles/uploadInput/uploadItem/UploadItem.css +74 -1
  77. package/build/types/accordion/Accordion.d.ts +1 -0
  78. package/build/types/accordion/Accordion.d.ts.map +1 -1
  79. package/build/types/accordion/AccordionItem/AccordionItem.d.ts +3 -0
  80. package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
  81. package/build/types/inputs/SelectInput.d.ts +6 -3
  82. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  83. package/build/types/inputs/_BottomSheet.d.ts +2 -1
  84. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  85. package/build/types/inputs/_Popover.d.ts +2 -1
  86. package/build/types/inputs/_Popover.d.ts.map +1 -1
  87. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  88. package/build/types/select/option/Option.d.ts.map +1 -1
  89. package/build/types/typeahead/util/highlight.d.ts +1 -1
  90. package/build/types/typeahead/util/highlight.d.ts.map +1 -1
  91. package/package.json +5 -11
  92. package/src/accordion/Accordion.css +60 -1
  93. package/src/accordion/Accordion.story.tsx +8 -0
  94. package/src/accordion/Accordion.tsx +2 -0
  95. package/src/accordion/AccordionItem/AccordionItem.tsx +5 -0
  96. package/src/actionButton/ActionButton.css +53 -1
  97. package/src/avatar/Avatar.css +205 -1
  98. package/src/badge/Badge.css +68 -1
  99. package/src/button/Button.css +20 -1
  100. package/src/card/Card.css +100 -1
  101. package/src/checkboxButton/CheckboxButton.css +24 -1
  102. package/src/chips/Chip.css +190 -1
  103. package/src/circularButton/CircularButton.css +211 -1
  104. package/src/common/Option/Option.css +100 -1
  105. package/src/common/RadioButton/RadioButton.css +4 -1
  106. package/src/common/bottomSheet/BottomSheet.css +53 -1
  107. package/src/common/card/Card.css +49 -1
  108. package/src/common/closeButton/CloseButton.css +79 -1
  109. package/src/common/panel/Panel.css +73 -1
  110. package/src/criticalBanner/CriticalCommsBanner.css +76 -1
  111. package/src/dateInput/DateInput.css +3 -1
  112. package/src/dateLookup/DateLookup.css +98 -1
  113. package/src/dateLookup/DateLookup.story.js +12 -8
  114. package/src/dateLookup/dateTrigger/DateTrigger.css +68 -1
  115. package/src/decision/Decision.css +93 -1
  116. package/src/definitionList/DefinitionList.css +53 -1
  117. package/src/dimmer/Dimmer.css +70 -1
  118. package/src/drawer/Drawer.css +100 -1
  119. package/src/dropFade/DropFade.css +19 -1
  120. package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -1
  121. package/src/emphasis/Emphasis.css +31 -1
  122. package/src/flowNavigation/FlowNavigation.css +72 -1
  123. package/src/flowNavigation/animatedLabel/AnimatedLabel.css +21 -1
  124. package/src/flowNavigation/backButton/BackButton.css +32 -1
  125. package/src/header/Header.css +28 -1
  126. package/src/image/Image.css +13 -1
  127. package/src/info/Info.css +32 -1
  128. package/src/inputs/Input.css +105 -1
  129. package/src/inputs/InputGroup.css +62 -1
  130. package/src/inputs/SelectInput.css +374 -1
  131. package/src/inputs/SelectInput.spec.tsx +52 -3
  132. package/src/inputs/SelectInput.story.tsx +1 -1
  133. package/src/inputs/SelectInput.tsx +30 -15
  134. package/src/inputs/TextArea.css +109 -1
  135. package/src/inputs/_BottomSheet.tsx +3 -0
  136. package/src/inputs/_Popover.tsx +3 -0
  137. package/src/instructionsList/InstructionsList.css +22 -1
  138. package/src/link/Link.css +15 -1
  139. package/src/listItem/ListItem.css +6 -1
  140. package/src/loader/Loader.css +313 -1
  141. package/src/logo/Logo.css +26 -1
  142. package/src/main.css +5494 -1
  143. package/src/modal/Modal.css +155 -1
  144. package/src/moneyInput/MoneyInput.css +66 -1
  145. package/src/moneyInput/MoneyInput.js +3 -1
  146. package/src/moneyInput/MoneyInput.spec.js +4 -1
  147. package/src/navigationOption/NavigationOption.css +69 -1
  148. package/src/navigationOptionsList/NavigationOptionsList.css +13 -1
  149. package/src/nudge/Nudge.css +179 -1
  150. package/src/overlayHeader/OverlayHeader.css +15 -1
  151. package/src/phoneNumberInput/PhoneNumberInput.css +23 -1
  152. package/src/popover/Popover.css +43 -1
  153. package/src/progress/Progress.css +43 -1
  154. package/src/progressBar/ProgressBar.css +14 -1
  155. package/src/promoCard/PromoCard.css +186 -1
  156. package/src/section/Section.css +10 -1
  157. package/src/select/Select.css +309 -1
  158. package/src/select/Select.less +1 -8
  159. package/src/select/option/Option.spec.js +3 -21
  160. package/src/select/option/Option.tsx +2 -7
  161. package/src/slidingPanel/SlidingPanel.css +105 -1
  162. package/src/snackbar/Snackbar.css +93 -1
  163. package/src/statusIcon/StatusIcon.css +78 -1
  164. package/src/stepper/Stepper.css +108 -1
  165. package/src/summary/Summary.css +81 -1
  166. package/src/switch/Switch.css +68 -1
  167. package/src/tabs/Tabs.css +121 -1
  168. package/src/tile/Tile.css +55 -1
  169. package/src/tooltip/Tooltip.css +50 -1
  170. package/src/typeahead/Typeahead.css +183 -1
  171. package/src/typeahead/typeaheadOption/TypeaheadOption.css +9 -1
  172. package/src/typeahead/typeaheadOption/TypeaheadOption.js +3 -3
  173. package/src/typeahead/util/highlight.js +1 -1
  174. package/src/upload/Upload.css +15 -1
  175. package/src/uploadInput/UploadInput.css +71 -1
  176. package/src/uploadInput/uploadButton/UploadButton.css +49 -1
  177. package/src/uploadInput/uploadItem/UploadItem.css +74 -1
package/README.md CHANGED
@@ -10,17 +10,15 @@ This is the Neptune Web React component library. It uses [Neptune CSS](https://g
10
10
 
11
11
  Neptune Components are published to npm as [@transferwise/components](https://www.npmjs.com/package/@transferwise/components).
12
12
 
13
- Install `@transferwise/components` and its peer dependencies. **Note:** currency-flags is only required if you're using the [Money Input](https://transferwise.github.io/neptune-web/components/MoneyInput) or if you're using flags on the [Select](https://transferwise.github.io/neptune-web/components/Select).
14
-
15
13
  ```
16
14
  # pnpm
17
- pnpm install @transferwise/components react react-dom prop-types currency-flags
15
+ pnpm install @transferwise/components react react-dom prop-types @wise/art
18
16
 
19
17
  # yarn
20
- yarn add @transferwise/components react react-dom prop-types currency-flags
18
+ yarn add @transferwise/components react react-dom prop-types @wise/art
21
19
 
22
20
  # npm
23
- npm install @transferwise/components react react-dom prop-types currency-flags
21
+ npm install @transferwise/components react react-dom prop-types @wise/art
24
22
  ```
25
23
 
26
24
  ```js
@@ -641,6 +641,7 @@ const AccordionItem = ({
641
641
  'aria-label': ariaLabel,
642
642
  id,
643
643
  title,
644
+ subtitle,
644
645
  content,
645
646
  onClick,
646
647
  open,
@@ -662,6 +663,7 @@ const AccordionItem = ({
662
663
  as: "button",
663
664
  media: iconElement,
664
665
  title: title,
666
+ content: subtitle,
665
667
  button: /*#__PURE__*/jsx(Chevron, {
666
668
  orientation: open ? Position.TOP : Position.BOTTOM,
667
669
  size: Size.MEDIUM
@@ -711,6 +713,7 @@ const Accordion = ({
711
713
  children: items.map((item, index) => /*#__PURE__*/jsx(AccordionItem, {
712
714
  open: itemsOpen[index],
713
715
  title: item.title,
716
+ subtitle: item.subtitle,
714
717
  content: item.content,
715
718
  icon: item.icon,
716
719
  onClick: () => handleOnClick(index)
@@ -6477,7 +6480,8 @@ function BottomSheet({
6477
6480
  initialFocusRef,
6478
6481
  padding = 'md',
6479
6482
  children,
6480
- onClose
6483
+ onClose,
6484
+ onCloseEnd
6481
6485
  }) {
6482
6486
  const {
6483
6487
  refs,
@@ -6516,6 +6520,7 @@ function BottomSheet({
6516
6520
  beforeEnter: () => {
6517
6521
  setFloatingKey(prev => prev + 1);
6518
6522
  },
6523
+ afterLeave: onCloseEnd,
6519
6524
  children: /*#__PURE__*/jsxs(FocusBoundary, {
6520
6525
  children: [/*#__PURE__*/jsx(Transition.Child, {
6521
6526
  enter: "np-bottom-sheet-v2-backdrop-container--enter",
@@ -6606,7 +6611,8 @@ function Popover({
6606
6611
  size: size$1 = 'md',
6607
6612
  padding = 'md',
6608
6613
  children,
6609
- onClose
6614
+ onClose,
6615
+ onCloseEnd
6610
6616
  }) {
6611
6617
  const {
6612
6618
  refs,
@@ -6663,6 +6669,7 @@ function Popover({
6663
6669
  beforeEnter: () => {
6664
6670
  setFloatingKey(prev => prev + 1);
6665
6671
  },
6672
+ afterLeave: onCloseEnd,
6666
6673
  children: /*#__PURE__*/jsx(FocusBoundary, {
6667
6674
  children: /*#__PURE__*/jsx(FloatingFocusManager, {
6668
6675
  context: context,
@@ -6816,6 +6823,7 @@ function SelectInputClearButton({
6816
6823
  })
6817
6824
  });
6818
6825
  }
6826
+ const noop = () => {};
6819
6827
  function SelectInput({
6820
6828
  name,
6821
6829
  placeholder,
@@ -6831,11 +6839,19 @@ function SelectInput({
6831
6839
  disabled,
6832
6840
  size = 'md',
6833
6841
  className,
6842
+ onFilterChange = noop,
6834
6843
  onChange,
6835
- onSearchChange,
6836
6844
  onClear
6837
6845
  }) {
6838
6846
  const [open, setOpen] = useState(false);
6847
+ const [filterQuery, _setFilterQuery] = useState('');
6848
+ const setFilterQuery = useEffectEvent(query => {
6849
+ _setFilterQuery(query);
6850
+ onFilterChange({
6851
+ query,
6852
+ queryNormalized: query ? searchableString(query) : null
6853
+ });
6854
+ });
6839
6855
  const triggerRef = useRef(null);
6840
6856
  const screenSm = useScreenSize(Breakpoint.SMALL);
6841
6857
  const OptionsOverlay = screenSm ? Popover : BottomSheet;
@@ -6902,6 +6918,11 @@ function SelectInput({
6902
6918
  onClose: () => {
6903
6919
  setOpen(false);
6904
6920
  },
6921
+ onCloseEnd: () => {
6922
+ if (filterQuery !== '') {
6923
+ setFilterQuery('');
6924
+ }
6925
+ },
6905
6926
  children: /*#__PURE__*/jsx(SelectInputOptions, {
6906
6927
  items: items,
6907
6928
  renderValue: renderValue,
@@ -6910,7 +6931,8 @@ function SelectInput({
6910
6931
  filterPlaceholder: filterPlaceholder,
6911
6932
  searchInputRef: searchInputRef,
6912
6933
  listboxRef: listboxRef,
6913
- onSearchChange: onSearchChange
6934
+ filterQuery: filterQuery,
6935
+ onFilterChange: setFilterQuery
6914
6936
  })
6915
6937
  })
6916
6938
  });
@@ -6981,17 +7003,17 @@ function SelectInputOptions({
6981
7003
  filterPlaceholder,
6982
7004
  searchInputRef,
6983
7005
  listboxRef,
6984
- onSearchChange
7006
+ filterQuery,
7007
+ onFilterChange
6985
7008
  }) {
6986
7009
  const intl = useIntl();
6987
7010
  const controllerRef = filterable ? searchInputRef : listboxRef;
6988
- const [query, setQuery] = useState('');
6989
7011
  const needle = useMemo(() => {
6990
7012
  if (filterable) {
6991
- return query ? searchableString(query) : null;
7013
+ return filterQuery ? searchableString(filterQuery) : null;
6992
7014
  }
6993
7015
  return undefined;
6994
- }, [filterable, query]);
7016
+ }, [filterQuery, filterable]);
6995
7017
  const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
6996
7018
  const listboxContainerRef = useRef(null);
6997
7019
  useEffect(() => {
@@ -7021,7 +7043,7 @@ function SelectInputOptions({
7021
7043
  ref: searchInputRef,
7022
7044
  shape: "rectangle",
7023
7045
  placeholder: filterPlaceholder,
7024
- value: query,
7046
+ value: filterQuery,
7025
7047
  "aria-controls": listboxId,
7026
7048
  "aria-describedby": showStatus ? statusId : undefined,
7027
7049
  onKeyDown: event => {
@@ -7032,10 +7054,7 @@ function SelectInputOptions({
7032
7054
  }
7033
7055
  },
7034
7056
  onChange: event => {
7035
- setQuery(event.currentTarget.value);
7036
- if (onSearchChange) {
7037
- onSearchChange(event.currentTarget.value);
7038
- }
7057
+ onFilterChange(event.currentTarget.value);
7039
7058
  }
7040
7059
  })
7041
7060
  }) : null, /*#__PURE__*/jsxs("section", {
@@ -7074,7 +7093,7 @@ function SelectInputOptions({
7074
7093
  },
7075
7094
  children: renderFooter({
7076
7095
  resultsEmpty,
7077
- normalizedQuery: needle
7096
+ queryNormalized: needle
7078
7097
  })
7079
7098
  })
7080
7099
  }) : null]
@@ -8086,7 +8105,11 @@ class MoneyInput extends Component {
8086
8105
  disabled: disabled,
8087
8106
  size: size,
8088
8107
  onChange: this.handleSelectChange,
8089
- onSearchChange: this.handleSearchChange,
8108
+ onFilterChange: ({
8109
+ queryNormalized
8110
+ }) => {
8111
+ this.handleSearchChange(queryNormalized ?? '');
8112
+ },
8090
8113
  ...selectProps
8091
8114
  })
8092
8115
  })]
@@ -10579,7 +10602,6 @@ var messages$2 = defineMessages({
10579
10602
  }
10580
10603
  });
10581
10604
 
10582
- // Option.tsx NEW
10583
10605
  function Option$1({
10584
10606
  label,
10585
10607
  currency = '',
@@ -10592,13 +10614,12 @@ function Option$1({
10592
10614
  const {
10593
10615
  isModern
10594
10616
  } = useTheme();
10595
- const style = classes => classes.map(className => classNames[className] || className).join(' ');
10596
- const currencyClassNames = currency ? style(['currency-flag', `currency-flag-${currency.toLowerCase()}`]) : undefined;
10597
10617
  const iconElement = icon ? /*#__PURE__*/cloneElement(icon, {
10598
10618
  size: 24,
10599
10619
  className: 'tw-icon'
10600
- }) : currency && /*#__PURE__*/jsx("i", {
10601
- className: currencyClassNames
10620
+ }) : currency && /*#__PURE__*/jsx(Flag, {
10621
+ code: currency.toLowerCase(),
10622
+ intrinsicSize: 24
10602
10623
  });
10603
10624
  const titleAndNoteElement = /*#__PURE__*/jsxs(Body, {
10604
10625
  as: "span",
@@ -12471,7 +12492,7 @@ TypeaheadInput.defaultProps = {
12471
12492
  selected: []
12472
12493
  };
12473
12494
 
12474
- function hightlight(value, query) {
12495
+ function highlight(value, query) {
12475
12496
  if (value && query) {
12476
12497
  const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());
12477
12498
  const highlightEnd = highlightStart + query.trim().length;
@@ -12511,13 +12532,13 @@ const Option = props => {
12511
12532
  tabIndex: -1,
12512
12533
  onClick: onClick,
12513
12534
  children: [/*#__PURE__*/jsx("span", {
12514
- children: hightlight(label, query)
12535
+ children: highlight(label, query)
12515
12536
  }), note && /*#__PURE__*/jsx("span", {
12516
12537
  className: "np-text-body-default m-l-1",
12517
12538
  children: note
12518
12539
  }), secondary && /*#__PURE__*/jsx("span", {
12519
12540
  className: "np-text-body-default text-ellipsis",
12520
- children: hightlight(secondary, query)
12541
+ children: highlight(secondary, query)
12521
12542
  })]
12522
12543
  })
12523
12544
  });