@transferwise/components 46.0.1 → 46.0.3

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.
@@ -1,17 +1,14 @@
1
- import * as React from 'react';
2
-
3
- export type ChevronOrientation = "top" | "bottom" | "left" | "right";
4
-
5
- export type ChevronSize = "xs" | "sm" | "md";
6
-
7
- export interface ChevronProps {
8
- orientation?: ChevronOrientation;
9
- size?: ChevronSize;
10
- disabled?: boolean;
11
- className?: string;
12
- }
13
-
14
- declare const Chevron: React.FC<ChevronProps>;
15
-
16
- export default Chevron;
17
-
1
+ /// <reference types="react" />
2
+ import { PositionTop, PositionBottom, PositionRight, PositionLeft, SizeExtraSmall, SizeSmall, SizeMedium } from '../common';
3
+ export interface ChevronProps {
4
+ orientation?: PositionTop | PositionBottom | PositionLeft | PositionRight;
5
+ size?: SizeExtraSmall | SizeSmall | SizeMedium;
6
+ disabled?: boolean;
7
+ className?: string;
8
+ }
9
+ export interface ExtraSmallChevronProps {
10
+ className?: string;
11
+ }
12
+ declare const Chevron: ({ orientation, size, disabled, className, }: ChevronProps) => import("react").JSX.Element;
13
+ export default Chevron;
14
+ //# sourceMappingURL=Chevron.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chevron.d.ts","sourceRoot":"","sources":["../../../src/chevron/Chevron.js"],"names":[],"mappings":";AAmCA;;;;;gCAeC"}
1
+ {"version":3,"file":"Chevron.d.ts","sourceRoot":"","sources":["../../../src/chevron/Chevron.tsx"],"names":[],"mappings":";AAIA,OAAO,EAGL,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,SAAS,EACT,UAAU,EACX,MAAM,WAAW,CAAC;AAQnB,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,WAAW,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,CAAC;IAC1E,IAAI,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmBD,QAAA,MAAM,OAAO,gDAKV,YAAY,gCAed,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- export { default } from "./Chevron";
1
+ export { default } from './Chevron';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chevron/index.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chevron/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.0.1",
3
+ "version": "46.0.3",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -46,7 +46,7 @@ const Avatar: React.FC<AvatarProps> = ({
46
46
  backgroundColor = null,
47
47
  backgroundColorSeed = null,
48
48
  children = null,
49
- className = null,
49
+ className,
50
50
  outlined = false,
51
51
  size: sizeFromProps = 48,
52
52
  theme = Theme.LIGHT,
@@ -3,8 +3,6 @@ import { render, screen, userEvent } from '../test-utils';
3
3
 
4
4
  import Card from '.';
5
5
 
6
- jest.mock('../chevron');
7
-
8
6
  describe('Card', () => {
9
7
  const defaultProps = {
10
8
  title: 'A Card',
@@ -103,14 +101,14 @@ describe('Card', () => {
103
101
  it('renders a chevron', () => {
104
102
  renderCard({ children: 'mock children' });
105
103
 
106
- expect(screen.getByTestId('mock-chevron')).toHaveAttribute('orientation', Position.BOTTOM);
104
+ expect(screen.getByTestId('chevron-up-icon')).toHaveClass(Position.BOTTOM);
107
105
  });
108
106
 
109
107
  describe('when expanded', () => {
110
108
  it('flips chevron', () => {
111
109
  renderCard({ children: 'mock children', isExpanded: true });
112
110
 
113
- expect(screen.getByTestId('mock-chevron')).toHaveAttribute('orientation', Position.TOP);
111
+ expect(screen.getByTestId('chevron-up-icon')).toHaveClass(Position.TOP);
114
112
  });
115
113
 
116
114
  it('renders children', () => {
@@ -5,20 +5,6 @@ import Chevron from './Chevron';
5
5
  export default {
6
6
  component: Chevron,
7
7
  title: 'Other/Chevron',
8
- argTypes: {
9
- orientation: {
10
- type: {
11
- name: 'enum',
12
- value: ['top', 'bottom', 'left', 'right'],
13
- },
14
- },
15
- size: {
16
- type: {
17
- name: 'enum',
18
- value: ['xs', 'sm', 'md'],
19
- },
20
- },
21
- },
22
8
  tags: ['autodocs'],
23
9
  } satisfies Meta<typeof Chevron>;
24
10
 
@@ -29,4 +15,11 @@ export const Basic: Story = {
29
15
  orientation: 'top',
30
16
  size: 'md',
31
17
  },
18
+ render: (args) => {
19
+ return (
20
+ <span>
21
+ <Chevron {...args} />
22
+ </span>
23
+ );
24
+ },
32
25
  };
@@ -0,0 +1,73 @@
1
+ import { ChevronUp } from '@transferwise/icons';
2
+ import { IconSize } from '@transferwise/icons/lib/types';
3
+ import classNames from 'classnames';
4
+
5
+ import {
6
+ Size,
7
+ Position,
8
+ PositionTop,
9
+ PositionBottom,
10
+ PositionRight,
11
+ PositionLeft,
12
+ SizeExtraSmall,
13
+ SizeSmall,
14
+ SizeMedium,
15
+ } from '../common';
16
+
17
+ const CONTAINER_SIZE = {
18
+ [Size.EXTRA_SMALL]: 10,
19
+ [Size.SMALL]: 16,
20
+ [Size.MEDIUM]: 24,
21
+ };
22
+
23
+ export interface ChevronProps {
24
+ orientation?: PositionTop | PositionBottom | PositionLeft | PositionRight;
25
+ size?: SizeExtraSmall | SizeSmall | SizeMedium;
26
+ disabled?: boolean;
27
+ className?: string;
28
+ }
29
+
30
+ export interface ExtraSmallChevronProps {
31
+ className?: string;
32
+ }
33
+
34
+ const ExtraSmallChevron = ({ className }: ExtraSmallChevronProps) => {
35
+ return (
36
+ <span
37
+ className={classNames('tw-icon', 'tw-icon-chevron', className)}
38
+ role="presentation"
39
+ aria-hidden
40
+ >
41
+ <svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor" focusable="false">
42
+ <path
43
+ fillRule="evenodd"
44
+ d="M4.9995 2.0865L0.0635004 6.7645L1.2745 7.9125L4.9995 4.3835L8.7245 7.9135L9.9355 6.7645L4.9995 2.0865Z"
45
+ />
46
+ </svg>
47
+ </span>
48
+ );
49
+ };
50
+
51
+ const Chevron = ({
52
+ orientation = Position.BOTTOM,
53
+ size = Size.SMALL,
54
+ disabled = false,
55
+ className,
56
+ }: ChevronProps) => {
57
+ const classNameValue = classNames(
58
+ 'tw-chevron',
59
+ { 'chevron-color': !disabled },
60
+ `${orientation}`.toLowerCase(),
61
+ className,
62
+ );
63
+
64
+ if (size === Size.EXTRA_SMALL) {
65
+ return <ExtraSmallChevron className={classNameValue} />;
66
+ }
67
+
68
+ const sizeValue = CONTAINER_SIZE[size] as IconSize;
69
+
70
+ return <ChevronUp className={classNameValue} size={sizeValue} />;
71
+ };
72
+
73
+ export default Chevron;
@@ -361,7 +361,7 @@ class MoneyInput extends Component {
361
361
  renderValue={(currency, withinTrigger) => {
362
362
  return (
363
363
  <SelectInputOptionContent
364
- title={currency.label}
364
+ title={withinTrigger ? currency.currency.toUpperCase() : currency.label}
365
365
  note={withinTrigger ? undefined : currency.note}
366
366
  icon={<Flag code={currency.currency} intrinsicSize={24} />}
367
367
  />
@@ -3,8 +3,6 @@ import { within, userEvent } from '@storybook/testing-library';
3
3
  import { Lock } from '@transferwise/icons';
4
4
  import React from 'react';
5
5
 
6
- import Drawer from '../drawer';
7
-
8
6
  import MoneyInput from '.';
9
7
 
10
8
  export default {
@@ -82,6 +80,17 @@ const exampleCurrency = {
82
80
  },
83
81
  } as const;
84
82
 
83
+ const exampleBalanceCurrency = {
84
+ eur: {
85
+ ...exampleCurrency.eur,
86
+ label: '123.45 EUR',
87
+ },
88
+ gbp: {
89
+ ...exampleCurrency.gbp,
90
+ label: '12.34 GBP',
91
+ },
92
+ } as const;
93
+
85
94
  export const SingleCurrency: Story = {
86
95
  args: {
87
96
  currencies: [],
@@ -117,6 +126,20 @@ export const MultipleCurrencies: Story = {
117
126
  },
118
127
  };
119
128
 
129
+ export const BalanceCurrencies: Story = {
130
+ args: {
131
+ currencies: [
132
+ {
133
+ header: 'Balance currencies',
134
+ },
135
+ exampleBalanceCurrency.eur,
136
+ exampleBalanceCurrency.gbp,
137
+ ],
138
+ selectedCurrency: exampleBalanceCurrency.eur,
139
+ searchPlaceholder: 'Type a currency / country',
140
+ },
141
+ };
142
+
120
143
  export const OpenedInput: Story = {
121
144
  ...MultipleCurrencies,
122
145
  play: ({ canvasElement }) => {
@@ -1,67 +0,0 @@
1
- import { ChevronUp } from '@transferwise/icons';
2
- import classNames from 'classnames';
3
- import PropTypes from 'prop-types';
4
-
5
- import { Size, Position } from '../common';
6
-
7
- const CONTAINER_SIZE = {
8
- [Size.EXTRA_SMALL]: 10,
9
- [Size.SMALL]: 16,
10
- [Size.MEDIUM]: 24,
11
- };
12
-
13
- const ExtraSmallChevron = ({ className }) => (
14
- <span
15
- className={classNames('tw-icon', 'tw-icon-chevron', className)}
16
- role="presentation"
17
- aria-hidden
18
- >
19
- <svg width="10" height="10" viewBox="0 0 10 10" fill="currentColor" focusable="false">
20
- <path
21
- fillRule="evenodd"
22
- d="M4.9995 2.0865L0.0635004 6.7645L1.2745 7.9125L4.9995 4.3835L8.7245 7.9135L9.9355 6.7645L4.9995 2.0865Z"
23
- />
24
- </svg>
25
- </span>
26
- );
27
-
28
- ExtraSmallChevron.propTypes = {
29
- className: PropTypes.string,
30
- };
31
-
32
- ExtraSmallChevron.defaultProps = {
33
- className: null,
34
- };
35
-
36
- const Chevron = ({ orientation, size, disabled, className }) => {
37
- const classNameValue = classNames(
38
- 'tw-chevron',
39
- { 'chevron-color': !disabled },
40
- `${[orientation]}`.toLowerCase(),
41
- className,
42
- );
43
-
44
- const sizeValue = CONTAINER_SIZE[size];
45
-
46
- if (size === Size.EXTRA_SMALL) {
47
- return <ExtraSmallChevron className={classNameValue} />;
48
- }
49
-
50
- return <ChevronUp className={classNameValue} size={sizeValue} />;
51
- };
52
-
53
- Chevron.propTypes = {
54
- orientation: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
55
- size: PropTypes.oneOf(['xs', 'sm', 'md']),
56
- disabled: PropTypes.bool,
57
- className: PropTypes.string,
58
- };
59
-
60
- Chevron.defaultProps = {
61
- orientation: Position.BOTTOM,
62
- size: Size.SMALL,
63
- disabled: false,
64
- className: null,
65
- };
66
-
67
- export default Chevron;
@@ -1,7 +0,0 @@
1
- export default function (props) {
2
- return (
3
- <span data-testid="mock-chevron" {...props}>
4
- Mock Chevron
5
- </span>
6
- );
7
- }
File without changes