@transferwise/components 0.0.0-experimental-70919ee → 0.0.0-experimental-58e9ef8
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/common/preventScroll/PreventScroll.js +8 -1
- package/build/common/preventScroll/PreventScroll.js.map +1 -1
- package/build/common/preventScroll/PreventScroll.mjs +8 -1
- package/build/common/preventScroll/PreventScroll.mjs.map +1 -1
- package/build/index.js +4 -4
- package/build/inputs/SelectInput.mjs +1 -1
- package/build/inputs/_BottomSheet.js +29 -1
- package/build/inputs/_BottomSheet.js.map +1 -1
- package/build/inputs/_BottomSheet.mjs +30 -2
- package/build/inputs/_BottomSheet.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +3 -0
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +1 -1
- package/build/main.css +13 -9
- package/build/popover/Popover.mjs +1 -1
- package/build/promoCard/PromoCardContext.mjs +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.js +3 -0
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +1 -1
- package/build/slidingPanel/SlidingPanel.js +23 -20
- package/build/slidingPanel/SlidingPanel.js.map +1 -1
- package/build/slidingPanel/SlidingPanel.mjs +24 -21
- package/build/slidingPanel/SlidingPanel.mjs.map +1 -1
- package/build/styles/dimmer/Dimmer.css +1 -0
- package/build/styles/inputs/SelectInput.css +12 -9
- package/build/styles/main.css +13 -9
- package/build/types/common/preventScroll/PreventScroll.d.ts +1 -1
- package/build/types/common/preventScroll/PreventScroll.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/slidingPanel/SlidingPanel.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/common/bottomSheet/BottomSheet.test.story.tsx +94 -0
- package/src/common/bottomSheet/__snapshots__/BottomSheet.test.tsx.snap +6 -0
- package/src/common/preventScroll/PreventScroll.tsx +11 -1
- package/src/dimmer/Dimmer.css +1 -0
- package/src/dimmer/Dimmer.less +1 -0
- package/src/inputs/SelectInput.css +12 -9
- package/src/inputs/SelectInput.test.story.tsx +83 -0
- package/src/inputs/_BottomSheet.less +12 -6
- package/src/inputs/_BottomSheet.tsx +19 -5
- package/src/main.css +13 -9
- package/src/moneyInput/MoneyInput.test.story.tsx +101 -0
- package/src/slidingPanel/SlidingPanel.tsx +29 -24
package/src/main.css
CHANGED
|
@@ -2574,6 +2574,7 @@ button.np-option {
|
|
|
2574
2574
|
}
|
|
2575
2575
|
.no-scroll {
|
|
2576
2576
|
overflow: hidden;
|
|
2577
|
+
scroll-behavior: unset;
|
|
2577
2578
|
}
|
|
2578
2579
|
.dimmer {
|
|
2579
2580
|
position: fixed;
|
|
@@ -3839,35 +3840,38 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
3839
3840
|
transition-property: opacity;
|
|
3840
3841
|
transition-timing-function: ease-out;
|
|
3841
3842
|
transition-duration: 300ms;
|
|
3843
|
+
height: 100vh;
|
|
3844
|
+
min-height: -webkit-fill-available;
|
|
3842
3845
|
}
|
|
3843
3846
|
.np-bottom-sheet-v2-backdrop--closed {
|
|
3844
3847
|
opacity: 0;
|
|
3845
3848
|
}
|
|
3846
3849
|
.np-bottom-sheet-v2 {
|
|
3847
3850
|
position: fixed;
|
|
3848
|
-
inset:
|
|
3851
|
+
inset: 0;
|
|
3849
3852
|
bottom: env(keyboard-inset-height, 0px);
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
margin-top: 64px;
|
|
3855
|
-
margin-top: var(--size-64);
|
|
3853
|
+
padding-top: 64px;
|
|
3854
|
+
padding-top: var(--size-64);
|
|
3855
|
+
padding-bottom: min(env(safe-area-inset-bottom, 16px));
|
|
3856
|
+
padding-bottom: min(env(safe-area-inset-bottom, var(--size-16)));
|
|
3856
3857
|
display: flex;
|
|
3857
3858
|
flex-direction: column;
|
|
3858
3859
|
justify-content: flex-end;
|
|
3860
|
+
height: 100%;
|
|
3861
|
+
min-height: -webkit-fill-available;
|
|
3859
3862
|
}
|
|
3860
3863
|
.np-bottom-sheet-v2-content {
|
|
3861
3864
|
display: flex;
|
|
3862
3865
|
flex-direction: column;
|
|
3863
3866
|
overflow: auto;
|
|
3864
3867
|
border-top-left-radius: 32px;
|
|
3865
|
-
|
|
3868
|
+
border-top-left-radius: var(--size-32);
|
|
3866
3869
|
border-top-right-radius: 32px;
|
|
3867
|
-
|
|
3870
|
+
border-top-right-radius: var(--size-32);
|
|
3868
3871
|
background-color: #ffffff;
|
|
3869
3872
|
background-color: var(--color-background-elevated);
|
|
3870
3873
|
box-shadow: 0 0 40px rgba(69, 71, 69, 0.2);
|
|
3874
|
+
will-change: transform;
|
|
3871
3875
|
}
|
|
3872
3876
|
.np-bottom-sheet-v2-content:focus {
|
|
3873
3877
|
outline: none;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn, type Mock, userEvent, within } from 'storybook/test';
|
|
3
|
+
import { allModes } from '../../.storybook/modes';
|
|
4
|
+
import { lorem500 } from '../test-utils';
|
|
5
|
+
import { Field } from '../field/Field';
|
|
6
|
+
import Body from '../body';
|
|
7
|
+
import MoneyInput from './MoneyInput';
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'Forms/MoneyInput/tests',
|
|
11
|
+
component: MoneyInput,
|
|
12
|
+
args: {
|
|
13
|
+
amount: 1000,
|
|
14
|
+
id: 'moneyInput',
|
|
15
|
+
currencies: [
|
|
16
|
+
{
|
|
17
|
+
value: 'EUR',
|
|
18
|
+
label: 'EUR',
|
|
19
|
+
note: 'Euro',
|
|
20
|
+
currency: 'eur',
|
|
21
|
+
searchable: 'Spain, Germany, France, Austria',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: 'GBP',
|
|
25
|
+
label: 'GBP',
|
|
26
|
+
note: 'British pound',
|
|
27
|
+
currency: 'gbp',
|
|
28
|
+
searchable: 'England, Scotland, Wales',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
selectedCurrency: {
|
|
32
|
+
value: 'EUR',
|
|
33
|
+
label: 'EUR',
|
|
34
|
+
note: 'Euro',
|
|
35
|
+
currency: 'eur',
|
|
36
|
+
searchable: 'Spain, Germany, France, Austria',
|
|
37
|
+
},
|
|
38
|
+
searchPlaceholder: '',
|
|
39
|
+
onAmountChange: () => {},
|
|
40
|
+
onCurrencyChange: () => {},
|
|
41
|
+
},
|
|
42
|
+
tags: ['!autodocs'],
|
|
43
|
+
} satisfies Meta<typeof MoneyInput>;
|
|
44
|
+
export default meta;
|
|
45
|
+
|
|
46
|
+
type Story = StoryObj<typeof MoneyInput>;
|
|
47
|
+
|
|
48
|
+
const wait = async (duration = 500) =>
|
|
49
|
+
new Promise<void>((resolve) => {
|
|
50
|
+
setTimeout(resolve, duration);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* This test ensures that when the SelectInput is used within a scrollable page,
|
|
55
|
+
* opening the dropdown does not cause any unwanted scrolling or layout shifts.
|
|
56
|
+
* Expected preview should start with green bar at the top, with yellow section
|
|
57
|
+
* not in the viewport.
|
|
58
|
+
*
|
|
59
|
+
* NB: This test is disabled in Chromatic as there's no obvious way to control <html/> element of a snapshot.
|
|
60
|
+
*/
|
|
61
|
+
export const SmoothScrollReset: Story = {
|
|
62
|
+
decorators: [
|
|
63
|
+
(Story) => (
|
|
64
|
+
<>
|
|
65
|
+
<style>{`html { scroll-behavior: smooth; }`}</style>
|
|
66
|
+
<div>
|
|
67
|
+
<div
|
|
68
|
+
className="d-flex align-items-center justify-content-center"
|
|
69
|
+
style={{
|
|
70
|
+
backgroundColor: 'var(--color-bright-yellow)',
|
|
71
|
+
height: 400,
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
This block should not be in the viewport.
|
|
75
|
+
</div>
|
|
76
|
+
<div style={{ height: 10, backgroundColor: 'var(--color-bright-green)' }} />
|
|
77
|
+
<Field id="el1" label="Select currency">
|
|
78
|
+
<Story />
|
|
79
|
+
</Field>
|
|
80
|
+
<Body as="p">{lorem500}</Body>
|
|
81
|
+
</div>
|
|
82
|
+
</>
|
|
83
|
+
),
|
|
84
|
+
],
|
|
85
|
+
play: async ({ canvasElement }) => {
|
|
86
|
+
await wait(2000);
|
|
87
|
+
document.documentElement.scrollTop = 400;
|
|
88
|
+
await wait(2000);
|
|
89
|
+
const canvas = within(canvasElement);
|
|
90
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
91
|
+
await userEvent.click(triggerButton);
|
|
92
|
+
},
|
|
93
|
+
globals: {
|
|
94
|
+
viewport: { value: allModes.largeMobile.viewport, isRotated: false },
|
|
95
|
+
},
|
|
96
|
+
parameters: {
|
|
97
|
+
chromatic: {
|
|
98
|
+
disableSnapshot: true,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -3,6 +3,7 @@ import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
|
3
3
|
import { CSSTransition } from 'react-transition-group';
|
|
4
4
|
|
|
5
5
|
import { Position } from '../common';
|
|
6
|
+
import { PreventScroll } from '../common/preventScroll/PreventScroll';
|
|
6
7
|
|
|
7
8
|
export const EXIT_ANIMATION = 350;
|
|
8
9
|
|
|
@@ -33,31 +34,35 @@ const SlidingPanel = forwardRef(
|
|
|
33
34
|
useImperativeHandle(reference, () => localReference.current, []);
|
|
34
35
|
|
|
35
36
|
return (
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
data-testid={testId}
|
|
50
|
-
className={clsx(
|
|
51
|
-
'sliding-panel',
|
|
52
|
-
`sliding-panel--open-${position}`,
|
|
53
|
-
showSlidingPanelBorder && `sliding-panel--border-${position}`,
|
|
54
|
-
slidingPanelPositionFixed && 'sliding-panel--fixed',
|
|
55
|
-
className,
|
|
56
|
-
)}
|
|
37
|
+
<>
|
|
38
|
+
{open ? <PreventScroll /> : null}
|
|
39
|
+
|
|
40
|
+
<CSSTransition
|
|
41
|
+
{...rest}
|
|
42
|
+
key={`sliding-panel--open-${position}`}
|
|
43
|
+
nodeRef={localReference}
|
|
44
|
+
in={open}
|
|
45
|
+
// Wait for animation to finish before unmount.
|
|
46
|
+
timeout={{ enter: 0, exit: EXIT_ANIMATION }}
|
|
47
|
+
classNames="sliding-panel"
|
|
48
|
+
appear
|
|
49
|
+
unmountOnExit
|
|
57
50
|
>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
<div
|
|
52
|
+
ref={localReference}
|
|
53
|
+
data-testid={testId}
|
|
54
|
+
className={clsx(
|
|
55
|
+
'sliding-panel',
|
|
56
|
+
`sliding-panel--open-${position}`,
|
|
57
|
+
showSlidingPanelBorder && `sliding-panel--border-${position}`,
|
|
58
|
+
slidingPanelPositionFixed && 'sliding-panel--fixed',
|
|
59
|
+
className,
|
|
60
|
+
)}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</div>
|
|
64
|
+
</CSSTransition>
|
|
65
|
+
</>
|
|
61
66
|
);
|
|
62
67
|
},
|
|
63
68
|
);
|