@transferwise/components 46.14.0 → 46.15.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 (50) hide show
  1. package/build/index.esm.js +72 -180
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +74 -182
  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 +3 -0
  12. package/build/types/index.d.ts.map +1 -1
  13. package/build/types/radio/Radio.d.ts +10 -21
  14. package/build/types/radio/Radio.d.ts.map +1 -1
  15. package/build/types/radio/index.d.ts +2 -2
  16. package/build/types/radio/index.d.ts.map +1 -1
  17. package/build/types/radioGroup/RadioGroup.d.ts +10 -26
  18. package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
  19. package/build/types/radioGroup/index.d.ts +2 -1
  20. package/build/types/radioGroup/index.d.ts.map +1 -1
  21. package/build/types/radioOption/RadioOption.d.ts +15 -23
  22. package/build/types/radioOption/RadioOption.d.ts.map +1 -1
  23. package/build/types/radioOption/index.d.ts +2 -1
  24. package/build/types/radioOption/index.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/common/Option/Option.tsx +0 -1
  27. package/src/common/RadioButton/RadioButton.tsx +43 -0
  28. package/src/index.ts +3 -0
  29. package/src/radio/{Radio.story.js → Radio.story.tsx} +0 -3
  30. package/src/radio/{Radio.js → Radio.tsx} +18 -28
  31. package/src/radio/index.ts +2 -0
  32. package/src/radioGroup/RadioGroup.spec.js +24 -26
  33. package/src/radioGroup/{RadioGroup.story.js → RadioGroup.story.tsx} +0 -3
  34. package/src/radioGroup/RadioGroup.tsx +39 -0
  35. package/src/radioGroup/index.ts +2 -0
  36. package/src/radioOption/RadioOption.spec.js +4 -4
  37. package/src/radioOption/{RadioOption.story.js → RadioOption.story.tsx} +4 -4
  38. package/src/radioOption/RadioOption.tsx +60 -0
  39. package/src/radioOption/index.ts +2 -0
  40. package/src/common/RadioButton/RadioButton.js +0 -41
  41. package/src/radio/index.js +0 -3
  42. package/src/radioGroup/RadioGroup.js +0 -66
  43. package/src/radioGroup/index.js +0 -1
  44. package/src/radioOption/RadioOption.js +0 -81
  45. package/src/radioOption/index.js +0 -1
  46. /package/src/common/RadioButton/{RadioButton.spec.js → RadioButton.spec.tsx} +0 -0
  47. /package/src/common/RadioButton/__snapshots__/{RadioButton.spec.js.snap → RadioButton.spec.tsx.snap} +0 -0
  48. /package/src/common/RadioButton/{index.js → index.ts} +0 -0
  49. /package/src/radio/{Radio.rtl.spec.js → Radio.rtl.spec.tsx} +0 -0
  50. /package/src/radio/__snapshots__/{Radio.rtl.spec.js.snap → Radio.rtl.spec.tsx.snap} +0 -0
@@ -9938,54 +9938,42 @@ Provider.defaultProps = {
9938
9938
  };
9939
9939
  var Provider$1 = Provider;
9940
9940
 
9941
- const RadioButton = ({
9941
+ function RadioButton({
9942
9942
  id,
9943
- value,
9943
+ value = '',
9944
9944
  name,
9945
9945
  checked,
9946
9946
  onChange,
9947
9947
  disabled,
9948
9948
  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;
9949
+ }) {
9950
+ return /*#__PURE__*/jsxs(Fragment, {
9951
+ children: [/*#__PURE__*/jsx("input", {
9952
+ type: "radio",
9953
+ className: "sr-only",
9954
+ id: id,
9955
+ value: value,
9956
+ name: name,
9957
+ checked: checked,
9958
+ disabled: disabled || readOnly,
9959
+ onChange: () => {
9960
+ if (!checked) {
9961
+ onChange?.(value);
9962
+ }
9963
+ }
9964
+ }), /*#__PURE__*/jsx("span", {
9965
+ className: classNames('tw-radio-button', {
9966
+ checked,
9967
+ disabled: disabled || readOnly
9968
+ }),
9969
+ children: /*#__PURE__*/jsx("span", {
9970
+ className: "tw-radio-check"
9971
+ })
9972
+ })]
9973
+ });
9974
+ }
9987
9975
 
9988
- const Radio = ({
9976
+ function Radio({
9989
9977
  label,
9990
9978
  id,
9991
9979
  disabled,
@@ -9993,7 +9981,7 @@ const Radio = ({
9993
9981
  avatar,
9994
9982
  secondary,
9995
9983
  ...otherProps
9996
- }) => {
9984
+ }) {
9997
9985
  const {
9998
9986
  isModern
9999
9987
  } = useTheme();
@@ -10009,7 +9997,7 @@ const Radio = ({
10009
9997
  htmlFor: id,
10010
9998
  children: [/*#__PURE__*/jsx("span", {
10011
9999
  className: classNames(isModern ? 'm-r-2' : 'p-r-2', 'np-radio-button'),
10012
- children: /*#__PURE__*/jsx(RadioButton$1, {
10000
+ children: /*#__PURE__*/jsx(RadioButton, {
10013
10001
  id: id,
10014
10002
  disabled: disabled,
10015
10003
  ...otherProps
@@ -10031,100 +10019,36 @@ const Radio = ({
10031
10019
  })]
10032
10020
  })
10033
10021
  });
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;
10022
+ }
10057
10023
 
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
- }
10024
+ function RadioGroup({
10025
+ name,
10026
+ radios,
10027
+ selectedValue: controlledValue,
10028
+ onChange
10029
+ }) {
10030
+ const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);
10031
+ return radios.length > 0 ? /*#__PURE__*/jsx("div", {
10032
+ role: "radiogroup",
10033
+ children: radios.map(({
10034
+ value = '',
10035
+ ...restProps
10036
+ }, index) => /*#__PURE__*/jsx(Radio
10037
+ // eslint-disable-next-line react/no-array-index-key
10038
+ , {
10039
+ ...restProps,
10040
+ name: name,
10041
+ value: value,
10042
+ checked: value === uncontrolledValue,
10043
+ onChange: nextValue => {
10044
+ setUncontrolledValue(nextValue);
10045
+ onChange(nextValue);
10046
+ }
10047
+ }, index))
10048
+ }) : null;
10107
10049
  }
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
10050
 
10127
- const RadioOption = ({
10051
+ function RadioOption({
10128
10052
  'aria-label': ariaLabel,
10129
10053
  media,
10130
10054
  title,
@@ -10139,22 +10063,19 @@ const RadioOption = ({
10139
10063
  showMediaCircle,
10140
10064
  showMediaAtAllSizes,
10141
10065
  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
- };
10066
+ }) {
10155
10067
  return /*#__PURE__*/jsx(Option$2, {
10156
- ...sharedProps,
10157
- button: /*#__PURE__*/jsx(RadioButton$1, {
10068
+ "aria-label": ariaLabel,
10069
+ media: media,
10070
+ title: title,
10071
+ content: content,
10072
+ name: name,
10073
+ complex: complex,
10074
+ disabled: disabled,
10075
+ showMediaCircle: showMediaCircle,
10076
+ showMediaAtAllSizes: showMediaAtAllSizes,
10077
+ isContainerAligned: isContainerAligned,
10078
+ button: /*#__PURE__*/jsx(RadioButton, {
10158
10079
  id: id,
10159
10080
  name: name,
10160
10081
  checked: checked,
@@ -10163,36 +10084,7 @@ const RadioOption = ({
10163
10084
  onChange: onChange
10164
10085
  })
10165
10086
  });
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;
10087
+ }
10196
10088
 
10197
10089
  const Section = ({
10198
10090
  children,
@@ -15256,5 +15148,5 @@ const translations = {
15256
15148
  'zh-HK': zhHK
15257
15149
  };
15258
15150
 
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 };
15151
+ 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, 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
15152
  //# sourceMappingURL=index.esm.js.map