@transferwise/components 0.0.0-experimental-3e282e9 → 0.0.0-experimental-c0c64e3
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.
- package/build/index.esm.js +19 -5
- package/build/index.esm.js.map +1 -1
- package/build/index.js +19 -5
- package/build/index.js.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
- package/build/types/info/Info.d.ts +6 -2
- package/build/types/info/Info.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/body/Body.story.tsx +14 -2
- package/src/dateLookup/DateLookup.js +7 -5
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +6 -0
- package/src/dateLookup/tableLink/TableLink.tsx +6 -3
- package/src/info/Info.tsx +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateLookup.d.ts","sourceRoot":"","sources":["../../../src/dateLookup/DateLookup.js"],"names":[],"mappings":";AAqBA;
|
|
1
|
+
{"version":3,"file":"DateLookup.d.ts","sourceRoot":"","sources":["../../../src/dateLookup/DateLookup.js"],"names":[],"mappings":";AAqBA;IAoBE;;;;;;aAqBC;IApCD,wBAaC;IAjBD,wCAAsB;IAEtB,yCAAuB;IAIrB;;;;;;;;;;MAUC;IA0BH,6CAMC;IAFC,uCAAyE;IAI3E,6BAGC;IAED,iBAOE;IAEF,kBAME;IAEF,oCA2CE;IAEF,wEAmBE;IAEF,+DAOE;IAEF,gCAIE;IAEF,yBAA+C;IAE/C,2BAAmD;IAEnD,0BAAiD;IAEjD,sDAME;IAEF;;;eAEE;IAEF,+CA8BE;IAEF,wBAGE;IAEF,sCA0BC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableLink.d.ts","sourceRoot":"","sources":["../../../../src/dateLookup/tableLink/TableLink.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TableLink.d.ts","sourceRoot":"","sources":["../../../../src/dateLookup/tableLink/TableLink.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAc,SAAS,EAAE,MAAM,YAAY,CAAC;AAInD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,IAAI,EAAE,SAAS,CAAC;CACjB;;;;AA8DD,wBAAqC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SizeSmall, SizeLarge } from '../common';
|
|
2
|
+
import { Position, SizeSmall, SizeLarge } from '../common';
|
|
3
3
|
export interface Props {
|
|
4
4
|
'aria-label': string;
|
|
5
5
|
/**
|
|
@@ -23,7 +23,11 @@ export interface Props {
|
|
|
23
23
|
* Title displayed inside a Popover a Modal
|
|
24
24
|
*/
|
|
25
25
|
title?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Prferred placement of the Popover, does not apply to Modal
|
|
28
|
+
*/
|
|
29
|
+
preferredPlacement?: Position;
|
|
26
30
|
}
|
|
27
|
-
declare const Info: ({ className, content, onClick, presentation, size, title, "aria-label": ariaLabel, }: Props) => import("react").JSX.Element;
|
|
31
|
+
declare const Info: ({ className, content, onClick, presentation, size, title, "aria-label": ariaLabel, preferredPlacement, }: Props) => import("react").JSX.Element;
|
|
28
32
|
export default Info;
|
|
29
33
|
//# sourceMappingURL=Info.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Info.d.ts","sourceRoot":"","sources":["../../../src/info/Info.tsx"],"names":[],"mappings":";AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"Info.d.ts","sourceRoot":"","sources":["../../../src/info/Info.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAQ,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAMjE,MAAM,WAAW,KAAK;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,kBAAkB,CAAC,EAAE,QAAQ,CAAC;CAC/B;AAED,QAAA,MAAM,IAAI,6GASP,KAAK,gCAgDP,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-c0c64e3",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"rollup": "^3.28.1",
|
|
79
79
|
"storybook": "^7.4.5",
|
|
80
80
|
"@transferwise/less-config": "3.0.6",
|
|
81
|
-
"@transferwise/neptune-css": "14.7.
|
|
81
|
+
"@transferwise/neptune-css": "14.7.1",
|
|
82
82
|
"@wise/components-theming": "0.8.4"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
package/src/body/Body.story.tsx
CHANGED
|
@@ -30,6 +30,9 @@ export const Basic = () => {
|
|
|
30
30
|
Wir bauen den internationalen <strong>Bericht der Welt auf</strong>. Wir bauen den
|
|
31
31
|
internationalen <b>Bericht der Welt auf</b>.
|
|
32
32
|
</Body>
|
|
33
|
+
<Body as="p" type={Typography.BODY_LARGE_BOLD}>
|
|
34
|
+
↑ ↓ {'<-'} {'->'}
|
|
35
|
+
</Body>
|
|
33
36
|
</div>
|
|
34
37
|
<div>
|
|
35
38
|
<Title type={Typography.TITLE_SUBSECTION}>Body Default</Title>
|
|
@@ -49,6 +52,9 @@ export const Basic = () => {
|
|
|
49
52
|
Wir bauen den internationalen <strong>Bericht der Welt auf</strong>. Wir bauen den
|
|
50
53
|
internationalen <b>Bericht der Welt auf</b>.
|
|
51
54
|
</Body>
|
|
55
|
+
<Body as="p" type={Typography.BODY_DEFAULT}>
|
|
56
|
+
↑ ↓ {'<-'} {'->'}
|
|
57
|
+
</Body>
|
|
52
58
|
</div>
|
|
53
59
|
<div>
|
|
54
60
|
<Title type={Typography.TITLE_SUBSECTION}>Body Default Bold</Title>
|
|
@@ -68,6 +74,9 @@ export const Basic = () => {
|
|
|
68
74
|
Wir bauen den internationalen <strong>Bericht der Welt auf</strong>. Wir bauen den
|
|
69
75
|
internationalen <b>Bericht der Welt auf</b>.
|
|
70
76
|
</Body>
|
|
77
|
+
<Body as="p" type={Typography.BODY_DEFAULT_BOLD}>
|
|
78
|
+
↑ ↓ {'<-'} {'->'}
|
|
79
|
+
</Body>
|
|
71
80
|
</div>
|
|
72
81
|
<div>
|
|
73
82
|
<Title type={Typography.TITLE_SUBSECTION}>Body Large</Title>
|
|
@@ -87,6 +96,9 @@ export const Basic = () => {
|
|
|
87
96
|
Wir bauen den internationalen <strong>Bericht der Welt auf</strong>. Wir bauen den
|
|
88
97
|
internationalen <b>Bericht der Welt auf</b>.
|
|
89
98
|
</Body>
|
|
99
|
+
<Body as="p" type={Typography.BODY_LARGE}>
|
|
100
|
+
↑ ↓ {'<-'} {'->'}
|
|
101
|
+
</Body>
|
|
90
102
|
</div>
|
|
91
103
|
<Title type={Typography.TITLE_SUBSECTION}>
|
|
92
104
|
Copy Example without <code>{'<Body />'}</code> component
|
|
@@ -94,12 +106,12 @@ export const Basic = () => {
|
|
|
94
106
|
<p>
|
|
95
107
|
Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo saepe repellendus
|
|
96
108
|
accusantium eveniet temporibus perspiciatis iure ut, pariatur nihil totam iusto, delectus,
|
|
97
|
-
modi possimus soluta. Et iusto odio autem debitis!
|
|
109
|
+
modi possimus soluta. Et iusto odio autem debitis! ↑ ↓ {'<-'} {'->'}
|
|
98
110
|
</p>
|
|
99
111
|
<Title type={Typography.TITLE_SUBSECTION}>Copy Example without any HTML tag</Title>
|
|
100
112
|
Lorem ipsum dolor sit amet consectetur adipisicing elit. Explicabo saepe repellendus
|
|
101
113
|
accusantium eveniet temporibus perspiciatis iure ut, pariatur nihil totam iusto, delectus,
|
|
102
|
-
modi possimus soluta. Et iusto odio autem debitis!
|
|
114
|
+
modi possimus soluta. Et iusto odio autem debitis! ↑ ↓ {'<-'} {'->'}
|
|
103
115
|
</>
|
|
104
116
|
);
|
|
105
117
|
};
|
|
@@ -28,6 +28,7 @@ class DateLookup extends PureComponent {
|
|
|
28
28
|
super(props);
|
|
29
29
|
this.state = {
|
|
30
30
|
selectedDate: getStartOfDay(props.value),
|
|
31
|
+
originalDate: null,
|
|
31
32
|
min: getStartOfDay(props.min),
|
|
32
33
|
max: getStartOfDay(props.max),
|
|
33
34
|
viewMonth: (props.value || new Date()).getMonth(),
|
|
@@ -92,7 +93,7 @@ class DateLookup extends PureComponent {
|
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
handleKeyDown = (event) => {
|
|
95
|
-
const { open } = this.state;
|
|
96
|
+
const { open, originalDate } = this.state;
|
|
96
97
|
switch (event.keyCode) {
|
|
97
98
|
case KeyCodes.LEFT:
|
|
98
99
|
if (open) {
|
|
@@ -127,19 +128,20 @@ class DateLookup extends PureComponent {
|
|
|
127
128
|
event.preventDefault();
|
|
128
129
|
break;
|
|
129
130
|
case KeyCodes.ESCAPE:
|
|
131
|
+
this.props.onChange(originalDate);
|
|
130
132
|
this.close();
|
|
131
133
|
event.preventDefault();
|
|
132
134
|
break;
|
|
133
|
-
// case KeyCodes.ENTER:
|
|
134
|
-
// this.handleSelectedDateUpdate(this.state.hoveredDate);
|
|
135
|
-
// break;
|
|
136
135
|
default:
|
|
137
136
|
break;
|
|
138
137
|
}
|
|
139
138
|
};
|
|
140
139
|
|
|
141
140
|
adjustDate = (daysToAdd, monthsToAdd, yearsToAdd) => {
|
|
142
|
-
const { selectedDate, min, max, mode } = this.state;
|
|
141
|
+
const { selectedDate, min, max, mode, originalDate } = this.state;
|
|
142
|
+
if (originalDate === null) {
|
|
143
|
+
this.setState({ originalDate: selectedDate });
|
|
144
|
+
}
|
|
143
145
|
let date;
|
|
144
146
|
if (selectedDate) {
|
|
145
147
|
date = new Date(
|
|
@@ -80,6 +80,12 @@ describe('DateLookup (keyboard events)', () => {
|
|
|
80
80
|
pressKey(KEY_CODES.DOWN);
|
|
81
81
|
onChangeCalledWith(new Date(2019, 0, 3));
|
|
82
82
|
});
|
|
83
|
+
|
|
84
|
+
it('resets to original date when escape key is pressed', () => {
|
|
85
|
+
pressKey(KEY_CODES.LEFT);
|
|
86
|
+
pressKey(KEY_CODES.ESCAPE);
|
|
87
|
+
onChangeCalledWith(date);
|
|
88
|
+
});
|
|
83
89
|
});
|
|
84
90
|
|
|
85
91
|
describe('when open and in month mode', () => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
1
2
|
import { useEffect, useRef } from 'react';
|
|
2
3
|
import { injectIntl, IntlShape } from 'react-intl';
|
|
3
4
|
|
|
@@ -59,9 +60,11 @@ const TableLink = ({
|
|
|
59
60
|
<button
|
|
60
61
|
ref={buttonRef}
|
|
61
62
|
type="button"
|
|
62
|
-
className={
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
className={classNames(
|
|
64
|
+
`tw-date-lookup-${type}-option np-text-body-default-bold`,
|
|
65
|
+
{ active: !!active },
|
|
66
|
+
{ today: !!today },
|
|
67
|
+
)}
|
|
65
68
|
disabled={disabled}
|
|
66
69
|
tabIndex={autofocus ? 0 : -1}
|
|
67
70
|
aria-label={calculateAriaLabel()}
|
package/src/info/Info.tsx
CHANGED
|
@@ -31,6 +31,10 @@ export interface Props {
|
|
|
31
31
|
* Title displayed inside a Popover a Modal
|
|
32
32
|
*/
|
|
33
33
|
title?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Prferred placement of the Popover, does not apply to Modal
|
|
36
|
+
*/
|
|
37
|
+
preferredPlacement?: Position;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
const Info = ({
|
|
@@ -41,6 +45,7 @@ const Info = ({
|
|
|
41
45
|
size = Size.SMALL,
|
|
42
46
|
title = undefined,
|
|
43
47
|
'aria-label': ariaLabel,
|
|
48
|
+
preferredPlacement = Position.BOTTOM,
|
|
44
49
|
}: Props) => {
|
|
45
50
|
const [open, setOpen] = useState(false);
|
|
46
51
|
|
|
@@ -75,7 +80,7 @@ const Info = ({
|
|
|
75
80
|
<Modal body={content} open={open} title={title} onClose={() => setOpen(false)} />
|
|
76
81
|
</>
|
|
77
82
|
) : (
|
|
78
|
-
<Popover content={content} preferredPlacement={
|
|
83
|
+
<Popover content={content} preferredPlacement={preferredPlacement} title={title}>
|
|
79
84
|
<button
|
|
80
85
|
type="button"
|
|
81
86
|
{...buttonProps}
|