@transferwise/components 46.14.0 → 46.16.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 (63) hide show
  1. package/build/index.esm.js +97 -196
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +100 -199
  4. package/build/index.js.map +1 -1
  5. package/build/types/actionButton/ActionButton.d.ts +1 -1
  6. package/build/types/common/Option/Option.d.ts.map +1 -1
  7. package/build/types/common/RadioButton/RadioButton.d.ts +10 -34
  8. package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
  9. package/build/types/common/RadioButton/index.d.ts +1 -1
  10. package/build/types/common/RadioButton/index.d.ts.map +1 -1
  11. package/build/types/index.d.ts +4 -0
  12. package/build/types/index.d.ts.map +1 -1
  13. package/build/types/instructionsList/InstructionsList.d.ts +4 -2
  14. package/build/types/instructionsList/InstructionsList.d.ts.map +1 -1
  15. package/build/types/instructionsList/index.d.ts +2 -2
  16. package/build/types/instructionsList/index.d.ts.map +1 -1
  17. package/build/types/moneyInput/MoneyInput.d.ts +1 -0
  18. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  19. package/build/types/radio/Radio.d.ts +10 -21
  20. package/build/types/radio/Radio.d.ts.map +1 -1
  21. package/build/types/radio/index.d.ts +2 -2
  22. package/build/types/radio/index.d.ts.map +1 -1
  23. package/build/types/radioGroup/RadioGroup.d.ts +10 -26
  24. package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
  25. package/build/types/radioGroup/index.d.ts +2 -1
  26. package/build/types/radioGroup/index.d.ts.map +1 -1
  27. package/build/types/radioOption/RadioOption.d.ts +15 -23
  28. package/build/types/radioOption/RadioOption.d.ts.map +1 -1
  29. package/build/types/radioOption/index.d.ts +2 -1
  30. package/build/types/radioOption/index.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/src/common/Option/Option.tsx +0 -1
  33. package/src/common/RadioButton/RadioButton.tsx +43 -0
  34. package/src/index.ts +4 -0
  35. package/src/instructionsList/InstructionsList.spec.tsx +14 -0
  36. package/src/instructionsList/{InstructionList.story.tsx → InstructionsList.story.tsx} +14 -2
  37. package/src/instructionsList/InstructionsList.tsx +31 -17
  38. package/src/instructionsList/index.ts +3 -0
  39. package/src/moneyInput/MoneyInput.rtl.spec.tsx +12 -0
  40. package/src/moneyInput/MoneyInput.tsx +12 -2
  41. package/src/radio/{Radio.story.js → Radio.story.tsx} +0 -3
  42. package/src/radio/{Radio.js → Radio.tsx} +18 -28
  43. package/src/radio/index.ts +2 -0
  44. package/src/radioGroup/RadioGroup.spec.js +24 -26
  45. package/src/radioGroup/{RadioGroup.story.js → RadioGroup.story.tsx} +0 -3
  46. package/src/radioGroup/RadioGroup.tsx +39 -0
  47. package/src/radioGroup/index.ts +2 -0
  48. package/src/radioOption/RadioOption.spec.js +4 -4
  49. package/src/radioOption/{RadioOption.story.js → RadioOption.story.tsx} +4 -4
  50. package/src/radioOption/RadioOption.tsx +60 -0
  51. package/src/radioOption/index.ts +2 -0
  52. package/src/common/RadioButton/RadioButton.js +0 -41
  53. package/src/instructionsList/index.js +0 -3
  54. package/src/radio/index.js +0 -3
  55. package/src/radioGroup/RadioGroup.js +0 -66
  56. package/src/radioGroup/index.js +0 -1
  57. package/src/radioOption/RadioOption.js +0 -81
  58. package/src/radioOption/index.js +0 -1
  59. /package/src/common/RadioButton/{RadioButton.spec.js → RadioButton.spec.tsx} +0 -0
  60. /package/src/common/RadioButton/__snapshots__/{RadioButton.spec.js.snap → RadioButton.spec.tsx.snap} +0 -0
  61. /package/src/common/RadioButton/{index.js → index.ts} +0 -0
  62. /package/src/radio/{Radio.rtl.spec.js → Radio.rtl.spec.tsx} +0 -0
  63. /package/src/radio/__snapshots__/{Radio.rtl.spec.js.snap → Radio.rtl.spec.tsx.snap} +0 -0
@@ -7382,23 +7382,31 @@ const InputWithDisplayFormat = props => /*#__PURE__*/jsx(WithDisplayFormat, {
7382
7382
 
7383
7383
  const InstructionsList = ({
7384
7384
  dos,
7385
- donts
7385
+ donts,
7386
+ sort = 'dosFirst'
7386
7387
  }) => {
7387
- return /*#__PURE__*/jsxs("div", {
7388
+ const dosInstructions = dos?.map((doThis, index) =>
7389
+ /*#__PURE__*/
7390
+ // eslint-disable-next-line react/no-array-index-key
7391
+ jsx(Instruction, {
7392
+ item: doThis,
7393
+ type: "do"
7394
+ }, index)) ?? null;
7395
+ const dontsInstructions = donts?.map((dont, index) =>
7396
+ /*#__PURE__*/
7397
+ // eslint-disable-next-line react/no-array-index-key
7398
+ jsx(Instruction, {
7399
+ item: dont,
7400
+ type: "dont"
7401
+ }, index)) ?? null;
7402
+ const orderedInstructions = sort === 'dosFirst' ? /*#__PURE__*/jsxs(Fragment, {
7403
+ children: [dosInstructions, dontsInstructions]
7404
+ }) : /*#__PURE__*/jsxs(Fragment, {
7405
+ children: [dontsInstructions, dosInstructions]
7406
+ });
7407
+ return /*#__PURE__*/jsx("div", {
7388
7408
  className: "tw-instructions",
7389
- children: [dos && dos.map((doThis, index) =>
7390
- /*#__PURE__*/
7391
- // eslint-disable-next-line react/no-array-index-key
7392
- jsx(Instruction, {
7393
- item: doThis,
7394
- type: "do"
7395
- }, index)), donts && donts.map((dont, index) =>
7396
- /*#__PURE__*/
7397
- // eslint-disable-next-line react/no-array-index-key
7398
- jsx(Instruction, {
7399
- item: dont,
7400
- type: "dont"
7401
- }, index))]
7409
+ children: orderedInstructions
7402
7410
  });
7403
7411
  };
7404
7412
  function Instruction({
@@ -7422,7 +7430,6 @@ function Instruction({
7422
7430
  })]
7423
7431
  });
7424
7432
  }
7425
- var InstructionsList$1 = InstructionsList;
7426
7433
 
7427
7434
  const Loader = ({
7428
7435
  small = false,
@@ -7757,6 +7764,7 @@ class MoneyInput extends Component {
7757
7764
  size,
7758
7765
  addon,
7759
7766
  id,
7767
+ 'aria-labelledby': ariaLabelledBy,
7760
7768
  selectProps,
7761
7769
  maxLengthOverride
7762
7770
  } = this.props;
@@ -7780,6 +7788,7 @@ class MoneyInput extends Component {
7780
7788
  const isFixedCurrency = !this.state.searchQuery && hasSingleCurrency() || !onCurrencyChange;
7781
7789
  const disabled = !this.props.onAmountChange;
7782
7790
  return /*#__PURE__*/jsxs("div", {
7791
+ "aria-labelledby": ariaLabelledBy,
7783
7792
  className: classNames(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
7784
7793
  children: [/*#__PURE__*/jsx(Input, {
7785
7794
  id: id,
@@ -9938,54 +9947,42 @@ Provider.defaultProps = {
9938
9947
  };
9939
9948
  var Provider$1 = Provider;
9940
9949
 
9941
- const RadioButton = ({
9950
+ function RadioButton({
9942
9951
  id,
9943
- value,
9952
+ value = '',
9944
9953
  name,
9945
9954
  checked,
9946
9955
  onChange,
9947
9956
  disabled,
9948
9957
  readOnly
9949
- }) => /*#__PURE__*/jsxs(Fragment, {
9950
- children: [/*#__PURE__*/jsx("input", {
9951
- type: "radio",
9952
- className: "sr-only",
9953
- id: id,
9954
- value: value,
9955
- name: name,
9956
- checked: checked,
9957
- disabled: disabled || readOnly,
9958
- onChange: () => !checked ? onChange(value) : null
9959
- }), /*#__PURE__*/jsx("span", {
9960
- className: classNames('tw-radio-button', {
9961
- checked,
9962
- disabled: disabled || readOnly
9963
- }),
9964
- children: /*#__PURE__*/jsx("span", {
9965
- className: "tw-radio-check"
9966
- })
9967
- })]
9968
- });
9969
- RadioButton.propTypes = {
9970
- id: PropTypes.string,
9971
- name: PropTypes.string.isRequired,
9972
- checked: PropTypes.bool,
9973
- onChange: PropTypes.func,
9974
- disabled: PropTypes.bool,
9975
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
9976
- readOnly: PropTypes.bool
9977
- };
9978
- RadioButton.defaultProps = {
9979
- checked: false,
9980
- onChange: () => {},
9981
- disabled: false,
9982
- id: null,
9983
- value: '',
9984
- readOnly: false
9985
- };
9986
- var RadioButton$1 = RadioButton;
9958
+ }) {
9959
+ return /*#__PURE__*/jsxs(Fragment, {
9960
+ children: [/*#__PURE__*/jsx("input", {
9961
+ type: "radio",
9962
+ className: "sr-only",
9963
+ id: id,
9964
+ value: value,
9965
+ name: name,
9966
+ checked: checked,
9967
+ disabled: disabled || readOnly,
9968
+ onChange: () => {
9969
+ if (!checked) {
9970
+ onChange?.(value);
9971
+ }
9972
+ }
9973
+ }), /*#__PURE__*/jsx("span", {
9974
+ className: classNames('tw-radio-button', {
9975
+ checked,
9976
+ disabled: disabled || readOnly
9977
+ }),
9978
+ children: /*#__PURE__*/jsx("span", {
9979
+ className: "tw-radio-check"
9980
+ })
9981
+ })]
9982
+ });
9983
+ }
9987
9984
 
9988
- const Radio = ({
9985
+ function Radio({
9989
9986
  label,
9990
9987
  id,
9991
9988
  disabled,
@@ -9993,7 +9990,7 @@ const Radio = ({
9993
9990
  avatar,
9994
9991
  secondary,
9995
9992
  ...otherProps
9996
- }) => {
9993
+ }) {
9997
9994
  const {
9998
9995
  isModern
9999
9996
  } = useTheme();
@@ -10009,7 +10006,7 @@ const Radio = ({
10009
10006
  htmlFor: id,
10010
10007
  children: [/*#__PURE__*/jsx("span", {
10011
10008
  className: classNames(isModern ? 'm-r-2' : 'p-r-2', 'np-radio-button'),
10012
- children: /*#__PURE__*/jsx(RadioButton$1, {
10009
+ children: /*#__PURE__*/jsx(RadioButton, {
10013
10010
  id: id,
10014
10011
  disabled: disabled,
10015
10012
  ...otherProps
@@ -10031,100 +10028,36 @@ const Radio = ({
10031
10028
  })]
10032
10029
  })
10033
10030
  });
10034
- };
10035
- Radio.propTypes = {
10036
- avatar: PropTypes.element,
10037
- checked: PropTypes.bool,
10038
- disabled: PropTypes.bool,
10039
- id: PropTypes.string,
10040
- label: PropTypes.string.isRequired,
10041
- name: PropTypes.string.isRequired,
10042
- onChange: PropTypes.func.isRequired,
10043
- secondary: PropTypes.string,
10044
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
10045
- className: PropTypes.string
10046
- };
10047
- Radio.defaultProps = {
10048
- avatar: undefined,
10049
- checked: false,
10050
- disabled: false,
10051
- id: null,
10052
- secondary: null,
10053
- value: '',
10054
- className: undefined
10055
- };
10056
- var Radio$1 = Radio;
10031
+ }
10057
10032
 
10058
- class RadioGroup extends Component {
10059
- constructor(props) {
10060
- super(props);
10061
- this.state = {
10062
- selectedValue: props.selectedValue
10063
- };
10064
- }
10065
- handleOnChange = selectedValue => {
10066
- const {
10067
- onChange
10068
- } = this.props;
10069
- this.setState({
10070
- selectedValue
10071
- }, onChange && onChange(selectedValue));
10072
- };
10073
- render() {
10074
- const {
10075
- radios,
10076
- name
10077
- } = this.props;
10078
- const {
10079
- selectedValue
10080
- } = this.state;
10081
- return radios && radios.length > 0 ? /*#__PURE__*/jsx("div", {
10082
- role: "radiogroup",
10083
- children: radios.map(({
10084
- id,
10085
- avatar,
10086
- value,
10087
- label,
10088
- disabled,
10089
- secondary,
10090
- readOnly
10091
- }, index) => /*#__PURE__*/jsx(Radio$1
10092
- // eslint-disable-next-line react/no-array-index-key
10093
- , {
10094
- id: id,
10095
- value: value,
10096
- label: label,
10097
- name: name,
10098
- disabled: disabled,
10099
- checked: selectedValue === value,
10100
- secondary: secondary,
10101
- readOnly: readOnly,
10102
- avatar: avatar,
10103
- onChange: value_ => this.handleOnChange(value_)
10104
- }, index))
10105
- }) : null;
10106
- }
10033
+ function RadioGroup({
10034
+ name,
10035
+ radios,
10036
+ selectedValue: controlledValue,
10037
+ onChange
10038
+ }) {
10039
+ const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);
10040
+ return radios.length > 0 ? /*#__PURE__*/jsx("div", {
10041
+ role: "radiogroup",
10042
+ children: radios.map(({
10043
+ value = '',
10044
+ ...restProps
10045
+ }, index) => /*#__PURE__*/jsx(Radio
10046
+ // eslint-disable-next-line react/no-array-index-key
10047
+ , {
10048
+ ...restProps,
10049
+ name: name,
10050
+ value: value,
10051
+ checked: value === uncontrolledValue,
10052
+ onChange: nextValue => {
10053
+ setUncontrolledValue(nextValue);
10054
+ onChange(nextValue);
10055
+ }
10056
+ }, index))
10057
+ }) : null;
10107
10058
  }
10108
- RadioGroup.propTypes = {
10109
- radios: PropTypes.arrayOf(PropTypes.shape({
10110
- id: PropTypes.string,
10111
- avatar: PropTypes.element,
10112
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
10113
- secondary: PropTypes.string,
10114
- label: PropTypes.string.isRequired,
10115
- disabled: PropTypes.bool,
10116
- readOnly: PropTypes.bool
10117
- })).isRequired,
10118
- onChange: PropTypes.func.isRequired,
10119
- selectedValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
10120
- name: PropTypes.string.isRequired
10121
- };
10122
- RadioGroup.defaultProps = {
10123
- selectedValue: null
10124
- };
10125
- var RadioGroup$1 = RadioGroup;
10126
10059
 
10127
- const RadioOption = ({
10060
+ function RadioOption({
10128
10061
  'aria-label': ariaLabel,
10129
10062
  media,
10130
10063
  title,
@@ -10139,22 +10072,19 @@ const RadioOption = ({
10139
10072
  showMediaCircle,
10140
10073
  showMediaAtAllSizes,
10141
10074
  isContainerAligned
10142
- }) => {
10143
- const sharedProps = {
10144
- 'aria-label': ariaLabel,
10145
- media,
10146
- title,
10147
- content,
10148
- name,
10149
- complex,
10150
- disabled,
10151
- showMediaCircle,
10152
- showMediaAtAllSizes,
10153
- isContainerAligned
10154
- };
10075
+ }) {
10155
10076
  return /*#__PURE__*/jsx(Option$2, {
10156
- ...sharedProps,
10157
- button: /*#__PURE__*/jsx(RadioButton$1, {
10077
+ "aria-label": ariaLabel,
10078
+ media: media,
10079
+ title: title,
10080
+ content: content,
10081
+ name: name,
10082
+ complex: complex,
10083
+ disabled: disabled,
10084
+ showMediaCircle: showMediaCircle,
10085
+ showMediaAtAllSizes: showMediaAtAllSizes,
10086
+ isContainerAligned: isContainerAligned,
10087
+ button: /*#__PURE__*/jsx(RadioButton, {
10158
10088
  id: id,
10159
10089
  name: name,
10160
10090
  checked: checked,
@@ -10163,36 +10093,7 @@ const RadioOption = ({
10163
10093
  onChange: onChange
10164
10094
  })
10165
10095
  });
10166
- };
10167
- RadioOption.propTypes = {
10168
- 'aria-label': PropTypes.string,
10169
- media: PropTypes.node,
10170
- id: PropTypes.string.isRequired,
10171
- name: PropTypes.string.isRequired,
10172
- title: PropTypes.node.isRequired,
10173
- content: PropTypes.node,
10174
- checked: PropTypes.bool,
10175
- onChange: PropTypes.func.isRequired,
10176
- complex: PropTypes.bool,
10177
- disabled: PropTypes.bool,
10178
- value: PropTypes.string,
10179
- showMediaCircle: PropTypes.bool,
10180
- showMediaAtAllSizes: PropTypes.bool,
10181
- isContainerAligned: PropTypes.bool
10182
- };
10183
- RadioOption.defaultProps = {
10184
- 'aria-label': undefined,
10185
- media: null,
10186
- content: null,
10187
- checked: false,
10188
- complex: false,
10189
- disabled: false,
10190
- showMediaCircle: true,
10191
- showMediaAtAllSizes: false,
10192
- isContainerAligned: false,
10193
- value: ''
10194
- };
10195
- var RadioOption$1 = RadioOption;
10096
+ }
10196
10097
 
10197
10098
  const Section = ({
10198
10099
  children,
@@ -15256,5 +15157,5 @@ const translations = {
15256
15157
  'zh-HK': zhHK
15257
15158
  };
15258
15159
 
15259
- export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15160
+ export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15260
15161
  //# sourceMappingURL=index.esm.js.map