@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
@@ -0,0 +1,60 @@
1
+ import Option from '../common/Option';
2
+ import RadioButton from '../common/RadioButton';
3
+ import { RadioButtonProps } from '../common/RadioButton/RadioButton';
4
+
5
+ export interface RadioOptionProps<T extends string | number = string>
6
+ extends Required<Pick<RadioButtonProps<T>, 'id' | 'name' | 'onChange'>>,
7
+ Omit<RadioButtonProps<T>, 'readOnly' | 'id' | 'name' | 'onChange'> {
8
+ 'aria-label'?: string;
9
+ media?: React.ReactNode;
10
+ title: React.ReactNode;
11
+ content?: React.ReactNode;
12
+ complex?: boolean;
13
+ showMediaCircle?: boolean;
14
+ showMediaAtAllSizes?: boolean;
15
+ isContainerAligned?: boolean;
16
+ }
17
+
18
+ function RadioOption<T extends string | number = string>({
19
+ 'aria-label': ariaLabel,
20
+ media,
21
+ title,
22
+ content,
23
+ id,
24
+ name,
25
+ checked,
26
+ onChange,
27
+ complex,
28
+ disabled,
29
+ value,
30
+ showMediaCircle,
31
+ showMediaAtAllSizes,
32
+ isContainerAligned,
33
+ }: RadioOptionProps<T>) {
34
+ return (
35
+ <Option
36
+ aria-label={ariaLabel}
37
+ media={media}
38
+ title={title}
39
+ content={content}
40
+ name={name}
41
+ complex={complex}
42
+ disabled={disabled}
43
+ showMediaCircle={showMediaCircle}
44
+ showMediaAtAllSizes={showMediaAtAllSizes}
45
+ isContainerAligned={isContainerAligned}
46
+ button={
47
+ <RadioButton
48
+ id={id}
49
+ name={name}
50
+ checked={checked}
51
+ disabled={disabled}
52
+ value={value}
53
+ onChange={onChange}
54
+ />
55
+ }
56
+ />
57
+ );
58
+ }
59
+
60
+ export default RadioOption;
@@ -0,0 +1,2 @@
1
+ export { default } from './RadioOption';
2
+ export type { RadioOptionProps } from './RadioOption';
@@ -1,41 +0,0 @@
1
- import classNames from 'classnames';
2
- import PropTypes from 'prop-types';
3
-
4
- const RadioButton = ({ id, value, name, checked, onChange, disabled, readOnly }) => (
5
- <>
6
- <input
7
- type="radio"
8
- className="sr-only"
9
- id={id}
10
- value={value}
11
- name={name}
12
- checked={checked}
13
- disabled={disabled || readOnly}
14
- onChange={() => (!checked ? onChange(value) : null)}
15
- />
16
- <span className={classNames('tw-radio-button', { checked, disabled: disabled || readOnly })}>
17
- <span className="tw-radio-check" />
18
- </span>
19
- </>
20
- );
21
-
22
- RadioButton.propTypes = {
23
- id: PropTypes.string,
24
- name: PropTypes.string.isRequired,
25
- checked: PropTypes.bool,
26
- onChange: PropTypes.func,
27
- disabled: PropTypes.bool,
28
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
29
- readOnly: PropTypes.bool,
30
- };
31
-
32
- RadioButton.defaultProps = {
33
- checked: false,
34
- onChange: () => {},
35
- disabled: false,
36
- id: null,
37
- value: '',
38
- readOnly: false,
39
- };
40
-
41
- export default RadioButton;
@@ -1,3 +0,0 @@
1
- import Radio from './Radio';
2
-
3
- export default Radio;
@@ -1,66 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import { Component } from 'react';
3
-
4
- import Radio from '../radio';
5
-
6
- class RadioGroup extends Component {
7
- constructor(props) {
8
- super(props);
9
- this.state = {
10
- selectedValue: props.selectedValue,
11
- };
12
- }
13
-
14
- handleOnChange = (selectedValue) => {
15
- const { onChange } = this.props;
16
- this.setState({ selectedValue }, onChange && onChange(selectedValue));
17
- };
18
-
19
- render() {
20
- const { radios, name } = this.props;
21
- const { selectedValue } = this.state;
22
- return radios && radios.length > 0 ? (
23
- <div role="radiogroup">
24
- {radios.map(({ id, avatar, value, label, disabled, secondary, readOnly }, index) => (
25
- <Radio
26
- // eslint-disable-next-line react/no-array-index-key
27
- key={index}
28
- id={id}
29
- value={value}
30
- label={label}
31
- name={name}
32
- disabled={disabled}
33
- checked={selectedValue === value}
34
- secondary={secondary}
35
- readOnly={readOnly}
36
- avatar={avatar}
37
- onChange={(value_) => this.handleOnChange(value_)}
38
- />
39
- ))}
40
- </div>
41
- ) : null;
42
- }
43
- }
44
-
45
- RadioGroup.propTypes = {
46
- radios: PropTypes.arrayOf(
47
- PropTypes.shape({
48
- id: PropTypes.string,
49
- avatar: PropTypes.element,
50
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
51
- secondary: PropTypes.string,
52
- label: PropTypes.string.isRequired,
53
- disabled: PropTypes.bool,
54
- readOnly: PropTypes.bool,
55
- }),
56
- ).isRequired,
57
- onChange: PropTypes.func.isRequired,
58
- selectedValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
59
- name: PropTypes.string.isRequired,
60
- };
61
-
62
- RadioGroup.defaultProps = {
63
- selectedValue: null,
64
- };
65
-
66
- export default RadioGroup;
@@ -1 +0,0 @@
1
- export { default } from './RadioGroup';
@@ -1,81 +0,0 @@
1
- import PropTypes from 'prop-types';
2
-
3
- import Option from '../common/Option';
4
- import RadioButton from '../common/RadioButton';
5
-
6
- const RadioOption = ({
7
- 'aria-label': ariaLabel,
8
- media,
9
- title,
10
- content,
11
- id,
12
- name,
13
- checked,
14
- onChange,
15
- complex,
16
- disabled,
17
- value,
18
- showMediaCircle,
19
- showMediaAtAllSizes,
20
- isContainerAligned,
21
- }) => {
22
- const sharedProps = {
23
- 'aria-label': ariaLabel,
24
- media,
25
- title,
26
- content,
27
- name,
28
- complex,
29
- disabled,
30
- showMediaCircle,
31
- showMediaAtAllSizes,
32
- isContainerAligned,
33
- };
34
- return (
35
- <Option
36
- {...sharedProps}
37
- button={
38
- <RadioButton
39
- id={id}
40
- name={name}
41
- checked={checked}
42
- disabled={disabled}
43
- value={value}
44
- onChange={onChange}
45
- />
46
- }
47
- />
48
- );
49
- };
50
-
51
- RadioOption.propTypes = {
52
- 'aria-label': PropTypes.string,
53
- media: PropTypes.node,
54
- id: PropTypes.string.isRequired,
55
- name: PropTypes.string.isRequired,
56
- title: PropTypes.node.isRequired,
57
- content: PropTypes.node,
58
- checked: PropTypes.bool,
59
- onChange: PropTypes.func.isRequired,
60
- complex: PropTypes.bool,
61
- disabled: PropTypes.bool,
62
- value: PropTypes.string,
63
- showMediaCircle: PropTypes.bool,
64
- showMediaAtAllSizes: PropTypes.bool,
65
- isContainerAligned: PropTypes.bool,
66
- };
67
-
68
- RadioOption.defaultProps = {
69
- 'aria-label': undefined,
70
- media: null,
71
- content: null,
72
- checked: false,
73
- complex: false,
74
- disabled: false,
75
- showMediaCircle: true,
76
- showMediaAtAllSizes: false,
77
- isContainerAligned: false,
78
- value: '',
79
- };
80
-
81
- export default RadioOption;
@@ -1 +0,0 @@
1
- export { default } from './RadioOption';
File without changes