@transferwise/components 46.0.2 → 46.0.4

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"}
@@ -15,6 +15,21 @@ declare namespace _default {
15
15
  const defaultMessage_2: string;
16
16
  export { defaultMessage_2 as defaultMessage };
17
17
  }
18
+ namespace dayPlaceholder {
19
+ const id_3: string;
20
+ export { id_3 as id };
21
+ const defaultMessage_3: string;
22
+ export { defaultMessage_3 as defaultMessage };
23
+ export const description: string;
24
+ }
25
+ namespace yearPlaceholder {
26
+ const id_4: string;
27
+ export { id_4 as id };
28
+ const defaultMessage_4: string;
29
+ export { defaultMessage_4 as defaultMessage };
30
+ const description_1: string;
31
+ export { description_1 as description };
32
+ }
18
33
  }
19
34
  export default _default;
20
35
  //# sourceMappingURL=DateInput.messages.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.0.2",
3
+ "version": "46.0.4",
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;
@@ -64,9 +64,9 @@ const DateInput = ({
64
64
  monthLabel = monthLabel || formatMessage(messages.monthLabel);
65
65
  yearLabel = yearLabel || formatMessage(messages.yearLabel);
66
66
  placeholders = {
67
- day: placeholders?.day || 'DD',
67
+ day: placeholders?.day || formatMessage(messages.dayPlaceholder),
68
68
  month: placeholders?.month || formatMessage(messages.monthLabel),
69
- year: placeholders?.year || 'YYYY',
69
+ year: placeholders?.year || formatMessage(messages.yearPlaceholder),
70
70
  };
71
71
 
72
72
  const getDateAsString = (date) => {
@@ -13,4 +13,14 @@ export default defineMessages({
13
13
  id: 'neptune.DateInput.year.label',
14
14
  defaultMessage: 'Year',
15
15
  },
16
+ dayPlaceholder: {
17
+ id: 'neptune.DateInput.day.placeholder',
18
+ defaultMessage: 'DD',
19
+ description: 'Placeholder for 2-digit day values within an input.',
20
+ },
21
+ yearPlaceholder: {
22
+ id: 'neptune.DateInput.year.placeholder',
23
+ defaultMessage: 'YYYY',
24
+ description: 'Placeholder for 4-digit year values within an input.',
25
+ },
16
26
  });
@@ -60,6 +60,16 @@ jest.mock('./DateInput.messages', () => ({
60
60
  id: 'neptune.DateInput.year.label',
61
61
  defaultMessage: 'Year',
62
62
  },
63
+ dayPlaceholder: {
64
+ id: 'neptune.DateInput.day.placeholder',
65
+ defaultMessage: 'DD',
66
+ description: 'Placeholder for 2-digit day values within an input.',
67
+ },
68
+ yearPlaceholder: {
69
+ id: 'neptune.DateInput.year.placeholder',
70
+ defaultMessage: 'YYYY',
71
+ description: 'Placeholder for 4-digit year values within an input.',
72
+ },
63
73
  }));
64
74
 
65
75
  jest.mock('react-intl');
package/src/i18n/en.json CHANGED
@@ -4,8 +4,10 @@
4
4
  "neptune.ClearButton.ariaLabel": "Clear",
5
5
  "neptune.CloseButton.ariaLabel": "Close",
6
6
  "neptune.DateInput.day.label": "Day",
7
+ "neptune.DateInput.day.placeholder": "DD",
7
8
  "neptune.DateInput.month.label": "Month",
8
9
  "neptune.DateInput.year.label": "Year",
10
+ "neptune.DateInput.year.placeholder": "YYYY",
9
11
  "neptune.DateLookup.day": "day",
10
12
  "neptune.DateLookup.goTo20YearView": "Go to 20 year view",
11
13
  "neptune.DateLookup.month": "month",
@@ -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