@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
package/build/index.js CHANGED
@@ -9972,54 +9972,42 @@ Provider.defaultProps = {
9972
9972
  };
9973
9973
  var Provider$1 = Provider;
9974
9974
 
9975
- const RadioButton = ({
9975
+ function RadioButton({
9976
9976
  id,
9977
- value,
9977
+ value = '',
9978
9978
  name,
9979
9979
  checked,
9980
9980
  onChange,
9981
9981
  disabled,
9982
9982
  readOnly
9983
- }) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
9984
- children: [/*#__PURE__*/jsxRuntime.jsx("input", {
9985
- type: "radio",
9986
- className: "sr-only",
9987
- id: id,
9988
- value: value,
9989
- name: name,
9990
- checked: checked,
9991
- disabled: disabled || readOnly,
9992
- onChange: () => !checked ? onChange(value) : null
9993
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
9994
- className: classNames__default.default('tw-radio-button', {
9995
- checked,
9996
- disabled: disabled || readOnly
9997
- }),
9998
- children: /*#__PURE__*/jsxRuntime.jsx("span", {
9999
- className: "tw-radio-check"
10000
- })
10001
- })]
10002
- });
10003
- RadioButton.propTypes = {
10004
- id: PropTypes__default.default.string,
10005
- name: PropTypes__default.default.string.isRequired,
10006
- checked: PropTypes__default.default.bool,
10007
- onChange: PropTypes__default.default.func,
10008
- disabled: PropTypes__default.default.bool,
10009
- value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
10010
- readOnly: PropTypes__default.default.bool
10011
- };
10012
- RadioButton.defaultProps = {
10013
- checked: false,
10014
- onChange: () => {},
10015
- disabled: false,
10016
- id: null,
10017
- value: '',
10018
- readOnly: false
10019
- };
10020
- var RadioButton$1 = RadioButton;
9983
+ }) {
9984
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
9985
+ children: [/*#__PURE__*/jsxRuntime.jsx("input", {
9986
+ type: "radio",
9987
+ className: "sr-only",
9988
+ id: id,
9989
+ value: value,
9990
+ name: name,
9991
+ checked: checked,
9992
+ disabled: disabled || readOnly,
9993
+ onChange: () => {
9994
+ if (!checked) {
9995
+ onChange?.(value);
9996
+ }
9997
+ }
9998
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
9999
+ className: classNames__default.default('tw-radio-button', {
10000
+ checked,
10001
+ disabled: disabled || readOnly
10002
+ }),
10003
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
10004
+ className: "tw-radio-check"
10005
+ })
10006
+ })]
10007
+ });
10008
+ }
10021
10009
 
10022
- const Radio = ({
10010
+ function Radio({
10023
10011
  label,
10024
10012
  id,
10025
10013
  disabled,
@@ -10027,7 +10015,7 @@ const Radio = ({
10027
10015
  avatar,
10028
10016
  secondary,
10029
10017
  ...otherProps
10030
- }) => {
10018
+ }) {
10031
10019
  const {
10032
10020
  isModern
10033
10021
  } = componentsTheming.useTheme();
@@ -10043,7 +10031,7 @@ const Radio = ({
10043
10031
  htmlFor: id,
10044
10032
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
10045
10033
  className: classNames__default.default(isModern ? 'm-r-2' : 'p-r-2', 'np-radio-button'),
10046
- children: /*#__PURE__*/jsxRuntime.jsx(RadioButton$1, {
10034
+ children: /*#__PURE__*/jsxRuntime.jsx(RadioButton, {
10047
10035
  id: id,
10048
10036
  disabled: disabled,
10049
10037
  ...otherProps
@@ -10065,100 +10053,36 @@ const Radio = ({
10065
10053
  })]
10066
10054
  })
10067
10055
  });
10068
- };
10069
- Radio.propTypes = {
10070
- avatar: PropTypes__default.default.element,
10071
- checked: PropTypes__default.default.bool,
10072
- disabled: PropTypes__default.default.bool,
10073
- id: PropTypes__default.default.string,
10074
- label: PropTypes__default.default.string.isRequired,
10075
- name: PropTypes__default.default.string.isRequired,
10076
- onChange: PropTypes__default.default.func.isRequired,
10077
- secondary: PropTypes__default.default.string,
10078
- value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
10079
- className: PropTypes__default.default.string
10080
- };
10081
- Radio.defaultProps = {
10082
- avatar: undefined,
10083
- checked: false,
10084
- disabled: false,
10085
- id: null,
10086
- secondary: null,
10087
- value: '',
10088
- className: undefined
10089
- };
10090
- var Radio$1 = Radio;
10056
+ }
10091
10057
 
10092
- class RadioGroup extends React.Component {
10093
- constructor(props) {
10094
- super(props);
10095
- this.state = {
10096
- selectedValue: props.selectedValue
10097
- };
10098
- }
10099
- handleOnChange = selectedValue => {
10100
- const {
10101
- onChange
10102
- } = this.props;
10103
- this.setState({
10104
- selectedValue
10105
- }, onChange && onChange(selectedValue));
10106
- };
10107
- render() {
10108
- const {
10109
- radios,
10110
- name
10111
- } = this.props;
10112
- const {
10113
- selectedValue
10114
- } = this.state;
10115
- return radios && radios.length > 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
10116
- role: "radiogroup",
10117
- children: radios.map(({
10118
- id,
10119
- avatar,
10120
- value,
10121
- label,
10122
- disabled,
10123
- secondary,
10124
- readOnly
10125
- }, index) => /*#__PURE__*/jsxRuntime.jsx(Radio$1
10126
- // eslint-disable-next-line react/no-array-index-key
10127
- , {
10128
- id: id,
10129
- value: value,
10130
- label: label,
10131
- name: name,
10132
- disabled: disabled,
10133
- checked: selectedValue === value,
10134
- secondary: secondary,
10135
- readOnly: readOnly,
10136
- avatar: avatar,
10137
- onChange: value_ => this.handleOnChange(value_)
10138
- }, index))
10139
- }) : null;
10140
- }
10058
+ function RadioGroup({
10059
+ name,
10060
+ radios,
10061
+ selectedValue: controlledValue,
10062
+ onChange
10063
+ }) {
10064
+ const [uncontrolledValue, setUncontrolledValue] = React.useState(controlledValue);
10065
+ return radios.length > 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
10066
+ role: "radiogroup",
10067
+ children: radios.map(({
10068
+ value = '',
10069
+ ...restProps
10070
+ }, index) => /*#__PURE__*/jsxRuntime.jsx(Radio
10071
+ // eslint-disable-next-line react/no-array-index-key
10072
+ , {
10073
+ ...restProps,
10074
+ name: name,
10075
+ value: value,
10076
+ checked: value === uncontrolledValue,
10077
+ onChange: nextValue => {
10078
+ setUncontrolledValue(nextValue);
10079
+ onChange(nextValue);
10080
+ }
10081
+ }, index))
10082
+ }) : null;
10141
10083
  }
10142
- RadioGroup.propTypes = {
10143
- radios: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
10144
- id: PropTypes__default.default.string,
10145
- avatar: PropTypes__default.default.element,
10146
- value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
10147
- secondary: PropTypes__default.default.string,
10148
- label: PropTypes__default.default.string.isRequired,
10149
- disabled: PropTypes__default.default.bool,
10150
- readOnly: PropTypes__default.default.bool
10151
- })).isRequired,
10152
- onChange: PropTypes__default.default.func.isRequired,
10153
- selectedValue: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
10154
- name: PropTypes__default.default.string.isRequired
10155
- };
10156
- RadioGroup.defaultProps = {
10157
- selectedValue: null
10158
- };
10159
- var RadioGroup$1 = RadioGroup;
10160
10084
 
10161
- const RadioOption = ({
10085
+ function RadioOption({
10162
10086
  'aria-label': ariaLabel,
10163
10087
  media,
10164
10088
  title,
@@ -10173,22 +10097,19 @@ const RadioOption = ({
10173
10097
  showMediaCircle,
10174
10098
  showMediaAtAllSizes,
10175
10099
  isContainerAligned
10176
- }) => {
10177
- const sharedProps = {
10178
- 'aria-label': ariaLabel,
10179
- media,
10180
- title,
10181
- content,
10182
- name,
10183
- complex,
10184
- disabled,
10185
- showMediaCircle,
10186
- showMediaAtAllSizes,
10187
- isContainerAligned
10188
- };
10100
+ }) {
10189
10101
  return /*#__PURE__*/jsxRuntime.jsx(Option$2, {
10190
- ...sharedProps,
10191
- button: /*#__PURE__*/jsxRuntime.jsx(RadioButton$1, {
10102
+ "aria-label": ariaLabel,
10103
+ media: media,
10104
+ title: title,
10105
+ content: content,
10106
+ name: name,
10107
+ complex: complex,
10108
+ disabled: disabled,
10109
+ showMediaCircle: showMediaCircle,
10110
+ showMediaAtAllSizes: showMediaAtAllSizes,
10111
+ isContainerAligned: isContainerAligned,
10112
+ button: /*#__PURE__*/jsxRuntime.jsx(RadioButton, {
10192
10113
  id: id,
10193
10114
  name: name,
10194
10115
  checked: checked,
@@ -10197,36 +10118,7 @@ const RadioOption = ({
10197
10118
  onChange: onChange
10198
10119
  })
10199
10120
  });
10200
- };
10201
- RadioOption.propTypes = {
10202
- 'aria-label': PropTypes__default.default.string,
10203
- media: PropTypes__default.default.node,
10204
- id: PropTypes__default.default.string.isRequired,
10205
- name: PropTypes__default.default.string.isRequired,
10206
- title: PropTypes__default.default.node.isRequired,
10207
- content: PropTypes__default.default.node,
10208
- checked: PropTypes__default.default.bool,
10209
- onChange: PropTypes__default.default.func.isRequired,
10210
- complex: PropTypes__default.default.bool,
10211
- disabled: PropTypes__default.default.bool,
10212
- value: PropTypes__default.default.string,
10213
- showMediaCircle: PropTypes__default.default.bool,
10214
- showMediaAtAllSizes: PropTypes__default.default.bool,
10215
- isContainerAligned: PropTypes__default.default.bool
10216
- };
10217
- RadioOption.defaultProps = {
10218
- 'aria-label': undefined,
10219
- media: null,
10220
- content: null,
10221
- checked: false,
10222
- complex: false,
10223
- disabled: false,
10224
- showMediaCircle: true,
10225
- showMediaAtAllSizes: false,
10226
- isContainerAligned: false,
10227
- value: ''
10228
- };
10229
- var RadioOption$1 = RadioOption;
10121
+ }
10230
10122
 
10231
10123
  const Section = ({
10232
10124
  children,
@@ -15355,9 +15247,9 @@ exports.PromoCard = PromoCard$1;
15355
15247
  exports.PromoCardGroup = PromoCard$1;
15356
15248
  exports.Provider = Provider$1;
15357
15249
  exports.RTL_LANGUAGES = RTL_LANGUAGES;
15358
- exports.Radio = Radio$1;
15359
- exports.RadioGroup = RadioGroup$1;
15360
- exports.RadioOption = RadioOption$1;
15250
+ exports.Radio = Radio;
15251
+ exports.RadioGroup = RadioGroup;
15252
+ exports.RadioOption = RadioOption;
15361
15253
  exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
15362
15254
  exports.SearchInput = SearchInput;
15363
15255
  exports.Section = Section;