@transferwise/components 0.0.0-experimental-af01b75 → 0.0.0-experimental-0657ea4
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/ExpressiveMoneyInput/Chevron/Chevron.js +10 -2
- package/build/ExpressiveMoneyInput/Chevron/Chevron.js.map +1 -1
- package/build/ExpressiveMoneyInput/Chevron/Chevron.mjs +11 -3
- package/build/ExpressiveMoneyInput/Chevron/Chevron.mjs.map +1 -1
- package/build/common/Panel/Panel.js +13 -25
- package/build/common/Panel/Panel.js.map +1 -1
- package/build/common/Panel/Panel.mjs +10 -22
- package/build/common/Panel/Panel.mjs.map +1 -1
- package/build/common/Panel/Panel.positionUtils.js +68 -0
- package/build/common/Panel/Panel.positionUtils.js.map +1 -0
- package/build/common/Panel/Panel.positionUtils.mjs +63 -0
- package/build/common/Panel/Panel.positionUtils.mjs.map +1 -0
- package/build/common/PropsValues/position.js +0 -25
- package/build/common/PropsValues/position.js.map +1 -1
- package/build/common/PropsValues/position.mjs +1 -24
- package/build/common/PropsValues/position.mjs.map +1 -1
- package/build/main.css +12 -4
- package/build/styles/common/Panel/Panel.css +12 -4
- package/build/styles/main.css +12 -4
- package/build/types/Body/Body.d.ts +2 -2
- package/build/types/ExpressiveMoneyInput/Chevron/Chevron.d.ts.map +1 -1
- package/build/types/IconButton/IconButton.d.ts +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/Title/Title.d.ts +2 -2
- package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
- package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
- package/build/types/common/Panel/Panel.d.ts +1 -1
- package/build/types/common/Panel/Panel.d.ts.map +1 -1
- package/build/types/common/Panel/Panel.positionUtils.d.ts +7 -0
- package/build/types/common/Panel/Panel.positionUtils.d.ts.map +1 -0
- package/build/types/common/PropsValues/position.d.ts +0 -13
- package/build/types/common/PropsValues/position.d.ts.map +1 -1
- package/build/types/common/ResponsivePanel/ResponsivePanel.d.ts +1 -1
- package/package.json +2 -2
- package/src/ExpressiveMoneyInput/Chevron/Chevron.tsx +8 -3
- package/src/common/Panel/Panel.css +12 -4
- package/src/common/Panel/Panel.less +27 -9
- package/src/common/Panel/Panel.positionUtils.ts +79 -0
- package/src/common/Panel/Panel.test.tsx +40 -0
- package/src/common/Panel/Panel.tsx +13 -24
- package/src/common/Panel/_stories/Panel.rtl.test.story.tsx +110 -0
- package/src/common/PropsValues/position.ts +0 -50
- package/src/main.css +12 -4
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { withRTLDiff } from '../../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import Button from '../../../Button';
|
|
5
|
+
import { Position } from '../../PropsValues/position';
|
|
6
|
+
import Panel from '../Panel';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
component: Panel,
|
|
10
|
+
title: 'Dialogs/Panel/Tests/RTL Diff',
|
|
11
|
+
tags: ['!autodocs', '!manifest'],
|
|
12
|
+
} satisfies Meta<typeof Panel>;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof Panel>;
|
|
15
|
+
|
|
16
|
+
function PanelStory({
|
|
17
|
+
position,
|
|
18
|
+
label,
|
|
19
|
+
}: {
|
|
20
|
+
position: Parameters<typeof Panel>[0]['position'];
|
|
21
|
+
label: string;
|
|
22
|
+
}) {
|
|
23
|
+
const anchorRef = useRef<HTMLButtonElement>(null);
|
|
24
|
+
const margin =
|
|
25
|
+
position?.startsWith('bottom') || position?.startsWith('top') ? '3.5rem 0' : '2.5rem 0';
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<Button ref={anchorRef} style={{ margin }}>
|
|
30
|
+
{label}
|
|
31
|
+
</Button>
|
|
32
|
+
<Panel
|
|
33
|
+
open
|
|
34
|
+
position={position}
|
|
35
|
+
anchorRef={anchorRef}
|
|
36
|
+
arrow
|
|
37
|
+
aria-label={`Panel positioned ${label}`}
|
|
38
|
+
>
|
|
39
|
+
<div style={{ padding: '16px', maxWidth: '200px' }}>
|
|
40
|
+
Panel content positioned at <strong>{label}</strong>
|
|
41
|
+
</div>
|
|
42
|
+
</Panel>
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const Top: Story = {
|
|
48
|
+
render: () => (
|
|
49
|
+
<>
|
|
50
|
+
<PanelStory position={Position.TOP_LEFT} label="top-left" />
|
|
51
|
+
<PanelStory position={Position.TOP} label="top" />
|
|
52
|
+
<PanelStory position={Position.TOP_RIGHT} label="top-right" />
|
|
53
|
+
</>
|
|
54
|
+
),
|
|
55
|
+
...withRTLDiff({ renderAs: 'iframe', hAlign: 'center', vAlign: 'bottom' }),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const Right: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<>
|
|
61
|
+
<PanelStory position={Position.RIGHT_TOP} label="right-top" />
|
|
62
|
+
<PanelStory position={Position.RIGHT} label="right" />
|
|
63
|
+
<PanelStory position={Position.RIGHT_BOTTOM} label="right-bottom" />
|
|
64
|
+
</>
|
|
65
|
+
),
|
|
66
|
+
...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center' }),
|
|
67
|
+
};
|
|
68
|
+
export const RightFlipped: Story = {
|
|
69
|
+
render: () => (
|
|
70
|
+
<>
|
|
71
|
+
<PanelStory position={Position.RIGHT_TOP} label="right-top" />
|
|
72
|
+
<PanelStory position={Position.RIGHT} label="right" />
|
|
73
|
+
<PanelStory position={Position.RIGHT_BOTTOM} label="right-bottom" />
|
|
74
|
+
</>
|
|
75
|
+
),
|
|
76
|
+
...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center' }),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Bottom: Story = {
|
|
80
|
+
render: () => (
|
|
81
|
+
<>
|
|
82
|
+
<PanelStory position={Position.BOTTOM_LEFT} label="bottom-left" />
|
|
83
|
+
<PanelStory position={Position.BOTTOM} label="bottom" />
|
|
84
|
+
<PanelStory position={Position.BOTTOM_RIGHT} label="bottom-right" />
|
|
85
|
+
</>
|
|
86
|
+
),
|
|
87
|
+
...withRTLDiff({ renderAs: 'iframe', hAlign: 'center' }),
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const Left: Story = {
|
|
91
|
+
render: () => (
|
|
92
|
+
<>
|
|
93
|
+
<PanelStory position={Position.LEFT_TOP} label="left-top" />
|
|
94
|
+
<PanelStory position={Position.LEFT} label="left" />
|
|
95
|
+
<PanelStory position={Position.LEFT_BOTTOM} label="left-bottom" />
|
|
96
|
+
</>
|
|
97
|
+
),
|
|
98
|
+
...withRTLDiff({ renderAs: 'iframe', hAlign: 'right', vAlign: 'center' }),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const LeftFlipped: Story = {
|
|
102
|
+
render: () => (
|
|
103
|
+
<>
|
|
104
|
+
<PanelStory position={Position.LEFT_TOP} label="left-top" />
|
|
105
|
+
<PanelStory position={Position.LEFT} label="left" />
|
|
106
|
+
<PanelStory position={Position.LEFT_BOTTOM} label="left-bottom" />
|
|
107
|
+
</>
|
|
108
|
+
),
|
|
109
|
+
...withRTLDiff({ renderAs: 'iframe', hAlign: 'left', vAlign: 'center' }),
|
|
110
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Placement } from '@floating-ui/react';
|
|
2
|
-
|
|
3
1
|
export enum Position {
|
|
4
2
|
BOTTOM = 'bottom',
|
|
5
3
|
BOTTOM_LEFT = 'bottom-left',
|
|
@@ -21,51 +19,3 @@ export type PositionTop = 'top';
|
|
|
21
19
|
export type PositionRight = 'right';
|
|
22
20
|
export type PositionBottom = 'bottom';
|
|
23
21
|
export type PositionLeft = 'left';
|
|
24
|
-
|
|
25
|
-
export type PositionTopLeft = 'top-left';
|
|
26
|
-
export type PositionTopRight = 'top-right';
|
|
27
|
-
export type PositionBottomLeft = 'bottom-left';
|
|
28
|
-
export type PositionBottomRight = 'bottom-right';
|
|
29
|
-
export type PositionLeftTop = 'left-top';
|
|
30
|
-
export type PositionLeftBottom = 'left-bottom';
|
|
31
|
-
export type PositionRightTop = 'right-top';
|
|
32
|
-
export type PositionRightBottom = 'right-bottom';
|
|
33
|
-
|
|
34
|
-
/** Neptune position values that can be converted to floating-ui Placement */
|
|
35
|
-
export type FloatingPlacement =
|
|
36
|
-
| PositionTop
|
|
37
|
-
| PositionRight
|
|
38
|
-
| PositionBottom
|
|
39
|
-
| PositionLeft
|
|
40
|
-
| PositionTopLeft
|
|
41
|
-
| PositionTopRight
|
|
42
|
-
| PositionRightTop
|
|
43
|
-
| PositionRightBottom
|
|
44
|
-
| PositionBottomLeft
|
|
45
|
-
| PositionBottomRight
|
|
46
|
-
| PositionLeftTop
|
|
47
|
-
| PositionLeftBottom;
|
|
48
|
-
|
|
49
|
-
/** Maps Neptune position values to floating-ui Placement */
|
|
50
|
-
export const positionToPlacement = (position: FloatingPlacement): Placement => {
|
|
51
|
-
switch (position) {
|
|
52
|
-
case 'top-left':
|
|
53
|
-
return 'top-start';
|
|
54
|
-
case 'top-right':
|
|
55
|
-
return 'top-end';
|
|
56
|
-
case 'bottom-left':
|
|
57
|
-
return 'bottom-start';
|
|
58
|
-
case 'bottom-right':
|
|
59
|
-
return 'bottom-end';
|
|
60
|
-
case 'left-top':
|
|
61
|
-
return 'left-start';
|
|
62
|
-
case 'left-bottom':
|
|
63
|
-
return 'left-end';
|
|
64
|
-
case 'right-top':
|
|
65
|
-
return 'right-start';
|
|
66
|
-
case 'right-bottom':
|
|
67
|
-
return 'right-end';
|
|
68
|
-
default:
|
|
69
|
-
return position;
|
|
70
|
-
}
|
|
71
|
-
};
|
package/src/main.css
CHANGED
|
@@ -21875,27 +21875,35 @@ button.np-option {
|
|
|
21875
21875
|
.np-panel[data-popper-placement^="top"] > .np-panel__content {
|
|
21876
21876
|
transform: translateY(10px) scale(0.95);
|
|
21877
21877
|
}
|
|
21878
|
-
.np-panel[data-popper-placement^="top"]
|
|
21878
|
+
.np-panel[data-popper-placement^="top"] .np-panel__arrow {
|
|
21879
21879
|
inset-block-end: -6px;
|
|
21880
21880
|
}
|
|
21881
21881
|
.np-panel[data-popper-placement^="right"] > .np-panel__content {
|
|
21882
21882
|
transform: translateX(-10px) scale(0.95);
|
|
21883
21883
|
}
|
|
21884
|
-
.np-panel[data-popper-placement^="right"]
|
|
21884
|
+
.np-panel[data-popper-placement^="right"] .np-panel__arrow {
|
|
21885
21885
|
inset-inline-start: -6px;
|
|
21886
21886
|
}
|
|
21887
|
+
[dir="rtl"] .np-panel[data-popper-placement^="right"] .np-panel__arrow {
|
|
21888
|
+
inset-inline-start: unset;
|
|
21889
|
+
inset-inline-end: -6px;
|
|
21890
|
+
}
|
|
21887
21891
|
.np-panel[data-popper-placement^="bottom"] > .np-panel__content {
|
|
21888
21892
|
transform: translateY(-10px) scale(0.95);
|
|
21889
21893
|
}
|
|
21890
|
-
.np-panel[data-popper-placement^="bottom"]
|
|
21894
|
+
.np-panel[data-popper-placement^="bottom"] .np-panel__arrow {
|
|
21891
21895
|
inset-block-start: -6px;
|
|
21892
21896
|
}
|
|
21893
21897
|
.np-panel[data-popper-placement^="left"] > .np-panel__content {
|
|
21894
21898
|
transform: translateX(10px) scale(0.95);
|
|
21895
21899
|
}
|
|
21896
|
-
.np-panel[data-popper-placement^="left"]
|
|
21900
|
+
.np-panel[data-popper-placement^="left"] .np-panel__arrow {
|
|
21897
21901
|
inset-inline-end: -6px;
|
|
21898
21902
|
}
|
|
21903
|
+
[dir="rtl"] .np-panel[data-popper-placement^="left"] .np-panel__arrow {
|
|
21904
|
+
inset-inline-end: unset;
|
|
21905
|
+
inset-inline-start: -6px;
|
|
21906
|
+
}
|
|
21899
21907
|
.np-theme-personal .np-panel__content {
|
|
21900
21908
|
border-radius: 16px;
|
|
21901
21909
|
border-radius: var(--radius-medium);
|