@transferwise/components 0.0.0-experimental-3ab6847 → 0.0.0-experimental-0e85724
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/ListItem/ListItem.js +2 -0
- package/build/ListItem/ListItem.js.map +1 -1
- package/build/ListItem/ListItem.mjs +2 -0
- package/build/ListItem/ListItem.mjs.map +1 -1
- package/build/Snackbar/Snackbar.js +101 -98
- package/build/Snackbar/Snackbar.js.map +1 -1
- package/build/Snackbar/Snackbar.mjs +102 -99
- package/build/Snackbar/Snackbar.mjs.map +1 -1
- package/build/i18n/de.json +1 -0
- package/build/i18n/de.json.js +1 -0
- package/build/i18n/de.json.js.map +1 -1
- package/build/i18n/de.json.mjs +1 -0
- package/build/i18n/de.json.mjs.map +1 -1
- package/build/i18n/fr.json +1 -0
- package/build/i18n/fr.json.js +1 -0
- package/build/i18n/fr.json.js.map +1 -1
- package/build/i18n/fr.json.mjs +1 -0
- package/build/i18n/fr.json.mjs.map +1 -1
- package/build/i18n/th.json +1 -0
- package/build/i18n/th.json.js +1 -0
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +1 -0
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/main.css +5 -0
- package/build/styles/ListItem/ListItem.css +5 -0
- package/build/styles/main.css +5 -0
- package/build/types/ListItem/ListItem.d.ts +6 -1
- package/build/types/ListItem/ListItem.d.ts.map +1 -1
- package/build/types/Snackbar/Snackbar.d.ts +15 -1
- package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ListItem/ListItem.css +5 -0
- package/src/ListItem/ListItem.less +4 -0
- package/src/ListItem/ListItem.test.tsx +17 -0
- package/src/ListItem/ListItem.tsx +7 -0
- package/src/ListItem/_stories/ListItem.layout.test.story.tsx +23 -0
- package/src/ListItem/_stories/ListItem.story.tsx +8 -0
- package/src/Snackbar/Snackbar.tsx +88 -90
- package/src/i18n/de.json +1 -0
- package/src/i18n/fr.json +1 -0
- package/src/i18n/th.json +1 -0
- package/src/main.css +5 -0
|
@@ -60,6 +60,7 @@ export default {
|
|
|
60
60
|
disabled: false,
|
|
61
61
|
disabledPromptMessage: undefined,
|
|
62
62
|
spotlight: undefined,
|
|
63
|
+
paddingY: undefined,
|
|
63
64
|
inverted: false,
|
|
64
65
|
valueColumnWidth: undefined,
|
|
65
66
|
},
|
|
@@ -73,6 +74,13 @@ export default {
|
|
|
73
74
|
inactive: 'inactive',
|
|
74
75
|
},
|
|
75
76
|
},
|
|
77
|
+
paddingY: {
|
|
78
|
+
control: 'radio',
|
|
79
|
+
options: ['unset (undefined)', 12, 24],
|
|
80
|
+
mapping: {
|
|
81
|
+
'unset (undefined)': undefined,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
76
84
|
},
|
|
77
85
|
} satisfies Meta<ListItemProps>;
|
|
78
86
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component, createRef } from 'react';
|
|
2
2
|
import { CSSTransition } from 'react-transition-group';
|
|
3
3
|
|
|
4
4
|
import Button from '../Button';
|
|
5
5
|
import Body from '../Body';
|
|
6
6
|
import type { ThemeDark, ThemeLight } from '../common';
|
|
7
|
+
import { DirectionContext } from '../Provider/Direction';
|
|
7
8
|
import withNextPortal from '../WithNextPortal/WithNextPortal';
|
|
8
9
|
|
|
9
10
|
const CSS_TRANSITION_DURATION = 400;
|
|
@@ -24,105 +25,102 @@ interface SnackbarState extends Pick<SnackbarProps, 'action' | 'text' | 'theme'>
|
|
|
24
25
|
visible: boolean;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/** The props of the last committed render, as `this.props` was in the class component. */
|
|
32
|
-
const committedProps = useRef(props);
|
|
33
|
-
|
|
34
|
-
const [state, setState] = useState<SnackbarState>({
|
|
35
|
-
visible: false,
|
|
36
|
-
text: '',
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
useEffect(
|
|
40
|
-
() => () => {
|
|
41
|
-
window.clearTimeout(leaveTimeout.current);
|
|
42
|
-
window.clearTimeout(transitionTimeout.current);
|
|
43
|
-
},
|
|
44
|
-
[],
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// Runs after every render to mirror the componentDidUpdate lifecycle this component previously
|
|
48
|
-
// relied on, including the shouldComponentUpdate guard that ignored every update without text.
|
|
49
|
-
// Both rules below are disabled on purpose: the dependency-less effect and its synchronous state
|
|
50
|
-
// updates are what keep this conversion behaviour-identical to the class component.
|
|
51
|
-
/* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const previousProps = committedProps.current;
|
|
54
|
-
committedProps.current = props;
|
|
55
|
-
|
|
56
|
-
const { action, text, timeout, timestamp } = props;
|
|
57
|
-
|
|
58
|
-
// shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the
|
|
59
|
-
// updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is
|
|
60
|
-
// given text again. Preserved here deliberately to keep this refactor behaviour-identical.
|
|
61
|
-
const updateWhileTextIsPresent = (update: () => void) => {
|
|
62
|
-
if (committedProps.current.text) {
|
|
63
|
-
update();
|
|
64
|
-
}
|
|
65
|
-
};
|
|
28
|
+
export class Snackbar extends Component<SnackbarProps, SnackbarState> {
|
|
29
|
+
bodyRef = createRef<HTMLSpanElement>();
|
|
30
|
+
timeout = 0;
|
|
31
|
+
transitionTimeout = 0;
|
|
66
32
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
33
|
+
constructor(props: SnackbarProps) {
|
|
34
|
+
super(props);
|
|
35
|
+
this.state = {
|
|
36
|
+
visible: false,
|
|
37
|
+
text: '',
|
|
71
38
|
};
|
|
39
|
+
}
|
|
72
40
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
41
|
+
componentWillUnmount() {
|
|
42
|
+
window.clearTimeout(this.timeout);
|
|
43
|
+
window.clearTimeout(this.transitionTimeout);
|
|
44
|
+
}
|
|
77
45
|
|
|
78
|
-
|
|
79
|
-
|
|
46
|
+
shouldComponentUpdate(nextProps: SnackbarProps, nextState: SnackbarState) {
|
|
47
|
+
if (!nextProps.text) {
|
|
48
|
+
return false;
|
|
80
49
|
}
|
|
50
|
+
if (
|
|
51
|
+
nextProps.timestamp === this.props.timestamp &&
|
|
52
|
+
nextState.visible === this.state.visible &&
|
|
53
|
+
nextState.text === this.state.text
|
|
54
|
+
) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setLeaveTimeout = () => {
|
|
62
|
+
const { timeout } = this.props;
|
|
63
|
+
|
|
64
|
+
this.timeout = window.setTimeout(() => {
|
|
65
|
+
this.setState({ visible: false });
|
|
66
|
+
}, timeout);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
componentDidUpdate(previousProps: SnackbarProps) {
|
|
70
|
+
const { action, text, timestamp } = this.props;
|
|
81
71
|
|
|
82
72
|
if (!previousProps.text) {
|
|
83
|
-
|
|
73
|
+
this.setState({ visible: true, action, text }, () => {
|
|
74
|
+
this.setLeaveTimeout();
|
|
75
|
+
});
|
|
84
76
|
} else if (previousProps.timestamp !== timestamp) {
|
|
85
|
-
window.clearTimeout(
|
|
86
|
-
|
|
87
|
-
if (state.visible) {
|
|
88
|
-
setState(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
window.clearTimeout(this.timeout);
|
|
78
|
+
|
|
79
|
+
if (this.state.visible) {
|
|
80
|
+
this.setState({ visible: false }, () => {
|
|
81
|
+
this.transitionTimeout = window.setTimeout(() => {
|
|
82
|
+
this.setState({ visible: true, action, text });
|
|
83
|
+
this.setLeaveTimeout();
|
|
84
|
+
}, CSS_TRANSITION_DURATION);
|
|
85
|
+
});
|
|
92
86
|
} else {
|
|
93
|
-
|
|
87
|
+
this.setState({ visible: true, action, text });
|
|
88
|
+
this.setLeaveTimeout();
|
|
94
89
|
}
|
|
95
90
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
render() {
|
|
94
|
+
const { action, text, visible } = this.state;
|
|
95
|
+
const { timeout } = this.props;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div className="snackbar" aria-live="assertive" role="alert">
|
|
99
|
+
<CSSTransition
|
|
100
|
+
nodeRef={this.bodyRef}
|
|
101
|
+
in={visible}
|
|
102
|
+
classNames="snackbar__text-container"
|
|
103
|
+
timeout={{
|
|
104
|
+
appear: 0,
|
|
105
|
+
enter: timeout,
|
|
106
|
+
exit: CSS_TRANSITION_DURATION,
|
|
107
|
+
}}
|
|
108
|
+
unmountOnExit
|
|
109
|
+
>
|
|
110
|
+
<Body ref={this.bodyRef} as="span" className="snackbar__text">
|
|
111
|
+
{text}
|
|
112
|
+
{action ? (
|
|
113
|
+
<Button className="snackbar__text__action" v2 size="sm" onClick={action.onClick}>
|
|
114
|
+
{action.label}
|
|
115
|
+
</Button>
|
|
116
|
+
) : null}
|
|
117
|
+
</Body>
|
|
118
|
+
</CSSTransition>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Snackbar.contextType = DirectionContext;
|
|
127
125
|
|
|
128
126
|
export default withNextPortal(Snackbar);
|
package/src/i18n/de.json
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "Wähle eine Option...",
|
|
36
36
|
"neptune.PhoneNumberInput.countryCodeLabel": "Ländercode",
|
|
37
37
|
"neptune.PhoneNumberInput.phoneNumberLabel": "Telefonnummer",
|
|
38
|
+
"neptune.PhoneNumberInput.phoneNumberPrefix": "Vorwahl",
|
|
38
39
|
"neptune.Select.searchPlaceholder": "Wird gesucht...",
|
|
39
40
|
"neptune.SelectInput.noResultsFound": "Keine Ergebnisse gefunden",
|
|
40
41
|
"neptune.StatusIcon.iconLabel.error": "Fehler:",
|
package/src/i18n/fr.json
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "Sélectionnez une option…",
|
|
36
36
|
"neptune.PhoneNumberInput.countryCodeLabel": "Code pays",
|
|
37
37
|
"neptune.PhoneNumberInput.phoneNumberLabel": "Numéro de téléphone",
|
|
38
|
+
"neptune.PhoneNumberInput.phoneNumberPrefix": "Indicatif",
|
|
38
39
|
"neptune.Select.searchPlaceholder": "Recherche...",
|
|
39
40
|
"neptune.SelectInput.noResultsFound": "Aucun résultat trouvé",
|
|
40
41
|
"neptune.StatusIcon.iconLabel.error": "Erreur :",
|
package/src/i18n/th.json
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "เลือกตัวเลือก...",
|
|
36
36
|
"neptune.PhoneNumberInput.countryCodeLabel": "รหัสประเทศ",
|
|
37
37
|
"neptune.PhoneNumberInput.phoneNumberLabel": "หมายเลขโทรศัพท์",
|
|
38
|
+
"neptune.PhoneNumberInput.phoneNumberPrefix": "คำนำหน้า",
|
|
38
39
|
"neptune.Select.searchPlaceholder": "ค้นหา...",
|
|
39
40
|
"neptune.SelectInput.noResultsFound": "ไม่พบผลลัพธ์",
|
|
40
41
|
"neptune.StatusIcon.iconLabel.error": "ข้อผิดพลาด:",
|
package/src/main.css
CHANGED
|
@@ -23806,6 +23806,11 @@ button.np-option {
|
|
|
23806
23806
|
padding-inline: 0;
|
|
23807
23807
|
container-type: inline-size;
|
|
23808
23808
|
}
|
|
23809
|
+
.wds-list-item-paddingY-24 {
|
|
23810
|
+
padding-block: 24px;
|
|
23811
|
+
padding-block: var(--size-24);
|
|
23812
|
+
padding-inline: 0;
|
|
23813
|
+
}
|
|
23809
23814
|
.wds-list-item + .wds-list-item-spotlight,
|
|
23810
23815
|
.wds-list-item-spotlight + .wds-list-item {
|
|
23811
23816
|
margin-block-start: 16px;
|