@transferwise/components 46.29.1 → 46.29.2
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.js +4722 -4672
- package/build/index.js.map +1 -1
- package/build/index.mjs +3484 -3434
- package/build/index.mjs.map +1 -1
- package/build/mocks.js.map +1 -1
- package/build/mocks.mjs.map +1 -1
- package/build/types/common/DOMOperations/DOMOperations.d.ts +10 -2
- package/build/types/common/DOMOperations/DOMOperations.d.ts.map +1 -1
- package/build/types/common/DOMOperations/index.d.ts +1 -3
- package/build/types/common/DOMOperations/index.d.ts.map +1 -1
- package/build/types/common/bottomSheet/BottomSheet.d.ts +2 -2
- package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
- package/build/types/common/bottomSheet/index.d.ts +2 -1
- package/build/types/common/bottomSheet/index.d.ts.map +1 -1
- package/build/types/common/closeButton/CloseButton.messages.d.ts +7 -7
- package/build/types/common/closeButton/CloseButton.messages.d.ts.map +1 -1
- package/build/types/common/closeButton/index.d.ts +0 -1
- package/build/types/common/closeButton/index.d.ts.map +1 -1
- package/build/types/common/deviceDetection/deviceDetection.d.ts +1 -1
- package/build/types/common/deviceDetection/deviceDetection.d.ts.map +1 -1
- package/build/types/common/deviceDetection/index.d.ts +1 -1
- package/build/types/common/deviceDetection/index.d.ts.map +1 -1
- package/build/types/common/domHelpers/documentIosClick.d.ts +7 -2
- package/build/types/common/domHelpers/documentIosClick.d.ts.map +1 -1
- package/build/types/common/domHelpers/index.d.ts +1 -6
- package/build/types/common/domHelpers/index.d.ts.map +1 -1
- package/build/types/common/flowHeader/index.d.ts +2 -0
- package/build/types/common/flowHeader/index.d.ts.map +1 -0
- package/build/types/common/focusBoundary/index.d.ts +1 -1
- package/build/types/common/focusBoundary/index.d.ts.map +1 -1
- package/build/types/common/historyNavigator/historyNavigator.d.ts +8 -8
- package/build/types/common/historyNavigator/historyNavigator.d.ts.map +1 -1
- package/build/types/common/historyNavigator/index.d.ts +1 -1
- package/build/types/common/historyNavigator/index.d.ts.map +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/index.d.ts +1 -1
- package/build/types/common/panel/index.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +1 -1
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/dimmer/index.d.ts +2 -1
- package/build/types/dimmer/index.d.ts.map +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/index.d.ts +42 -41
- package/build/types/index.d.ts.map +1 -1
- package/package.json +56 -57
- package/src/common/DOMOperations/index.ts +1 -0
- package/src/common/bottomSheet/BottomSheet.tsx +6 -3
- package/src/common/bottomSheet/index.ts +2 -0
- package/src/common/closeButton/{CloseButton.spec.js → CloseButton.spec.tsx} +1 -0
- package/src/common/closeButton/index.ts +0 -1
- package/src/common/deviceDetection/{deviceDetection.spec.js → deviceDetection.spec.ts} +1 -1
- package/src/common/deviceDetection/deviceDetection.ts +7 -0
- package/src/common/domHelpers/{documentIosClick.spec.js → documentIosClick.spec.ts} +7 -13
- package/src/common/domHelpers/{documentIosClick.js → documentIosClick.ts} +23 -0
- package/src/common/domHelpers/index.ts +4 -23
- package/src/common/flowHeader/{FlowHeader.spec.js → FlowHeader.spec.tsx} +2 -1
- package/src/common/flowHeader/index.ts +1 -0
- package/src/common/historyNavigator/{historyNavigator.js → historyNavigator.ts} +9 -5
- package/src/common/panel/{Panel.spec.js → Panel.spec.tsx} +14 -9
- package/src/common/panel/Panel.tsx +3 -3
- package/src/common/responsivePanel/ResponsivePanel.tsx +1 -1
- package/src/dimmer/Dimmer.tsx +1 -1
- package/src/dimmer/index.ts +2 -0
- package/src/flowNavigation/FlowNavigation.tsx +1 -2
- package/src/index.ts +68 -66
- package/src/overlayHeader/OverlayHeader.js +1 -1
- package/src/withDisplayFormat/WithDisplayFormat.tsx +2 -2
- package/src/common/DOMOperations/index.js +0 -3
- package/src/common/bottomSheet/index.js +0 -1
- package/src/common/deviceDetection/deviceDetection.js +0 -7
- package/src/dimmer/index.js +0 -1
- /package/src/common/DOMOperations/{DOMOperations.spec.js → DOMOperations.spec.tsx} +0 -0
- /package/src/common/DOMOperations/{DOMOperations.js → DOMOperations.ts} +0 -0
- /package/src/common/closeButton/{CloseButton.messages.js → CloseButton.messages.ts} +0 -0
- /package/src/common/closeButton/__snapshots__/{CloseButton.spec.js.snap → CloseButton.spec.tsx.snap} +0 -0
- /package/src/common/deviceDetection/{index.js → index.ts} +0 -0
- /package/src/common/flowHeader/__snapshots__/{FlowHeader.spec.js.snap → FlowHeader.spec.tsx.snap} +0 -0
- /package/src/common/focusBoundary/{index.js → index.ts} +0 -0
- /package/src/common/historyNavigator/{historyNavigator.spec.js → historyNavigator.spec.ts} +0 -0
- /package/src/common/historyNavigator/{index.js → index.ts} +0 -0
- /package/src/common/panel/__snapshots__/{Panel.spec.js.snap → Panel.spec.tsx.snap} +0 -0
- /package/src/common/panel/{index.js → index.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.29.
|
|
3
|
+
"version": "46.29.2",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -38,65 +38,64 @@
|
|
|
38
38
|
"!**/*.tsbuildinfo"
|
|
39
39
|
],
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@babel/core": "^7.
|
|
42
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
43
|
-
"@babel/preset-env": "^7.
|
|
44
|
-
"@babel/preset-react": "^7.
|
|
45
|
-
"@babel/preset-typescript": "^7.
|
|
46
|
-
"@formatjs/cli": "^
|
|
47
|
-
"@rollup/plugin-babel": "^6.0.
|
|
48
|
-
"@rollup/plugin-json": "^6.
|
|
49
|
-
"@rollup/plugin-node-resolve": "^15.2.
|
|
50
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
41
|
+
"@babel/core": "^7.24.5",
|
|
42
|
+
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
43
|
+
"@babel/preset-env": "^7.24.5",
|
|
44
|
+
"@babel/preset-react": "^7.24.1",
|
|
45
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
46
|
+
"@formatjs/cli": "^6.2.10",
|
|
47
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
48
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
49
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
50
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
51
51
|
"@rollup/plugin-url": "^8.0.2",
|
|
52
|
-
"@storybook/addon-a11y": "^7.6.
|
|
53
|
-
"@storybook/addon-actions": "^7.6.
|
|
54
|
-
"@storybook/addon-essentials": "^7.6.
|
|
55
|
-
"@storybook/addon-interactions": "^7.6.
|
|
52
|
+
"@storybook/addon-a11y": "^7.6.19",
|
|
53
|
+
"@storybook/addon-actions": "^7.6.19",
|
|
54
|
+
"@storybook/addon-essentials": "^7.6.19",
|
|
55
|
+
"@storybook/addon-interactions": "^7.6.19",
|
|
56
56
|
"@storybook/addon-knobs": "^7.0.2",
|
|
57
|
-
"@storybook/addon-viewport": "^7.6.
|
|
57
|
+
"@storybook/addon-viewport": "^7.6.19",
|
|
58
58
|
"@storybook/addons": "^7.6.17",
|
|
59
59
|
"@storybook/api": "^7.6.17",
|
|
60
|
-
"@storybook/components": "^7.6.
|
|
61
|
-
"@storybook/core-events": "^7.6.
|
|
62
|
-
"@storybook/manager-api": "^7.6.
|
|
63
|
-
"@storybook/react": "^7.6.
|
|
64
|
-
"@storybook/react-webpack5": "^7.6.
|
|
65
|
-
"@storybook/test": "^7.6.
|
|
66
|
-
"@storybook/theming": "^7.6.
|
|
67
|
-
"@storybook/types": "^7.6.
|
|
68
|
-
"@testing-library/dom": "^7.
|
|
69
|
-
"@testing-library/jest-dom": "^5.
|
|
70
|
-
"@testing-library/react": "^12.
|
|
71
|
-
"@testing-library/react-hooks": "^8.0.
|
|
72
|
-
"@testing-library/user-event": "^13.
|
|
60
|
+
"@storybook/components": "^7.6.19",
|
|
61
|
+
"@storybook/core-events": "^7.6.19",
|
|
62
|
+
"@storybook/manager-api": "^7.6.19",
|
|
63
|
+
"@storybook/react": "^7.6.19",
|
|
64
|
+
"@storybook/react-webpack5": "^7.6.19",
|
|
65
|
+
"@storybook/test": "^7.6.19",
|
|
66
|
+
"@storybook/theming": "^7.6.19",
|
|
67
|
+
"@storybook/types": "^7.6.19",
|
|
68
|
+
"@testing-library/dom": "^7.31.2",
|
|
69
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
70
|
+
"@testing-library/react": "^12.1.5",
|
|
71
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
72
|
+
"@testing-library/user-event": "^13.5.0",
|
|
73
73
|
"@transferwise/icons": "^3.7.0",
|
|
74
74
|
"@transferwise/neptune-tokens": "^8.9.2",
|
|
75
|
-
"@tsconfig/recommended": "^1.0.
|
|
76
|
-
"@types/babel__core": "^7.20.
|
|
75
|
+
"@tsconfig/recommended": "^1.0.6",
|
|
76
|
+
"@types/babel__core": "^7.20.5",
|
|
77
77
|
"@types/commonmark": "^0.27.9",
|
|
78
78
|
"@types/jest": "^29.5.12",
|
|
79
|
-
"@types/lodash": "4.
|
|
79
|
+
"@types/lodash": "4.17.1",
|
|
80
80
|
"@types/lodash.clamp": "^4.0.9",
|
|
81
81
|
"@types/lodash.debounce": "^4.0.9",
|
|
82
|
-
"@types/
|
|
83
|
-
"@types/react": "^17.0.
|
|
84
|
-
"@types/react-
|
|
85
|
-
"@types/
|
|
86
|
-
"@types/
|
|
87
|
-
"@types/use-sync-external-store": "^0.0.4",
|
|
82
|
+
"@types/react": "^17.0.80",
|
|
83
|
+
"@types/react-dom": "^17.0.25",
|
|
84
|
+
"@types/react-transition-group": "4.4.10",
|
|
85
|
+
"@types/testing-library__jest-dom": "^5.14.9",
|
|
86
|
+
"@types/use-sync-external-store": "^0.0.6",
|
|
88
87
|
"@wise/art": "^2.7.0",
|
|
89
88
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
|
|
90
|
-
"babel-plugin-formatjs": "^10.5.
|
|
89
|
+
"babel-plugin-formatjs": "^10.5.14",
|
|
91
90
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
92
91
|
"enzyme": "^3.11.0",
|
|
93
92
|
"jest": "^29.7.0",
|
|
94
93
|
"jest-environment-jsdom": "^29.7.0",
|
|
95
94
|
"jest-fetch-mock": "^3.0.3",
|
|
96
95
|
"lodash.times": "^4.3.2",
|
|
97
|
-
"react-intl": "^
|
|
98
|
-
"rollup": "^
|
|
99
|
-
"storybook": "^7.6.
|
|
96
|
+
"react-intl": "^6.6.6",
|
|
97
|
+
"rollup": "^4.17.2",
|
|
98
|
+
"storybook": "^7.6.19",
|
|
100
99
|
"@transferwise/less-config": "3.1.0",
|
|
101
100
|
"@transferwise/neptune-css": "14.10.0",
|
|
102
101
|
"@wise/components-theming": "1.2.0"
|
|
@@ -111,29 +110,29 @@
|
|
|
111
110
|
"react-intl": "^5.10.0 || ^6"
|
|
112
111
|
},
|
|
113
112
|
"dependencies": {
|
|
114
|
-
"@babel/runtime": "^7.
|
|
115
|
-
"@floating-ui/react": "^0.
|
|
116
|
-
"@formatjs/intl-locale": "^
|
|
117
|
-
"@headlessui/react": "^1.7.
|
|
118
|
-
"@popperjs/core": "^2.
|
|
119
|
-
"@radix-ui/react-id": "^1.0.
|
|
120
|
-
"@react-aria/focus": "^3.
|
|
121
|
-
"@react-aria/overlays": "^3.
|
|
122
|
-
"@react-spring/web": "~9.
|
|
123
|
-
"@transferwise/formatting": "^2.
|
|
113
|
+
"@babel/runtime": "^7.24.5",
|
|
114
|
+
"@floating-ui/react": "^0.26.15",
|
|
115
|
+
"@formatjs/intl-locale": "^3.4.5",
|
|
116
|
+
"@headlessui/react": "^1.7.19",
|
|
117
|
+
"@popperjs/core": "^2.11.8",
|
|
118
|
+
"@radix-ui/react-id": "^1.0.1",
|
|
119
|
+
"@react-aria/focus": "^3.17.0",
|
|
120
|
+
"@react-aria/overlays": "^3.22.0",
|
|
121
|
+
"@react-spring/web": "~9.7.3",
|
|
122
|
+
"@transferwise/formatting": "^2.13.0",
|
|
124
123
|
"@transferwise/neptune-validation": "^3.3.0",
|
|
125
|
-
"classnames": "^2.
|
|
124
|
+
"classnames": "^2.5.1",
|
|
126
125
|
"commonmark": "0.29.1",
|
|
127
|
-
"core-js": "^3.
|
|
126
|
+
"core-js": "^3.37.1",
|
|
128
127
|
"lodash.clamp": "^4.0.3",
|
|
129
128
|
"lodash.debounce": "^4.0.8",
|
|
130
129
|
"lodash.topairs": "^4.3.0",
|
|
131
130
|
"merge-props": "^6.0.0",
|
|
132
|
-
"prop-types": "^15.
|
|
131
|
+
"prop-types": "^15.8.1",
|
|
133
132
|
"react-popper": "^2.3.0",
|
|
134
133
|
"react-required-if": "^1.0.3",
|
|
135
|
-
"react-transition-group": "^4.4.
|
|
136
|
-
"use-sync-external-store": "^1.2.
|
|
134
|
+
"react-transition-group": "^4.4.5",
|
|
135
|
+
"use-sync-external-store": "^1.2.2"
|
|
137
136
|
},
|
|
138
137
|
"publishConfig": {
|
|
139
138
|
"access": "public"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { addNoScrollClass, removeNoScrollClass } from './DOMOperations';
|
|
@@ -25,8 +25,11 @@ const CONTENT_SCROLL_THRESHOLD = 1;
|
|
|
25
25
|
|
|
26
26
|
const MOVE_OFFSET_THRESHOLD = 50;
|
|
27
27
|
|
|
28
|
-
type
|
|
29
|
-
{
|
|
28
|
+
export type BottomSheetProps = PropsWithChildren<
|
|
29
|
+
{
|
|
30
|
+
onClose?: (event: Event | SyntheticEvent) => void;
|
|
31
|
+
open: boolean;
|
|
32
|
+
} & CommonProps
|
|
30
33
|
>;
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -35,7 +38,7 @@ type Props = PropsWithChildren<
|
|
|
35
38
|
* Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet
|
|
36
39
|
*
|
|
37
40
|
*/
|
|
38
|
-
const BottomSheet = (props:
|
|
41
|
+
const BottomSheet = (props: BottomSheetProps): ReactElement => {
|
|
39
42
|
const bottomSheetReference = useRef<HTMLDivElement>(null);
|
|
40
43
|
const topBarReference = useRef<HTMLDivElement>(null);
|
|
41
44
|
const contentReference = useRef<HTMLDivElement>(null);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function isIosDevice() {
|
|
2
|
+
const sampleTouchDevices = ['iphone', 'ipad', 'ipod'];
|
|
3
|
+
const matchString = sampleTouchDevices.map((device: string) => `(${device})`).join('|');
|
|
4
|
+
const regex = new RegExp(matchString, 'gi');
|
|
5
|
+
|
|
6
|
+
return typeof navigator !== 'undefined' && !!regex.test(navigator.userAgent);
|
|
7
|
+
}
|
|
@@ -8,19 +8,13 @@ import {
|
|
|
8
8
|
jest.mock('../deviceDetection');
|
|
9
9
|
|
|
10
10
|
describe('Document ios click', () => {
|
|
11
|
-
let add;
|
|
12
|
-
let remove;
|
|
11
|
+
let add: jest.SpyInstance;
|
|
12
|
+
let remove: jest.SpyInstance;
|
|
13
13
|
|
|
14
14
|
beforeEach(() => {
|
|
15
|
-
isIosDevice.mockReturnValue(false);
|
|
16
|
-
global.document =
|
|
17
|
-
|
|
18
|
-
classList: {
|
|
19
|
-
add: jest.fn(),
|
|
20
|
-
remove: jest.fn(),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
15
|
+
(isIosDevice as jest.Mock).mockReturnValue(false);
|
|
16
|
+
global.document.documentElement.classList.add = jest.fn();
|
|
17
|
+
global.document.documentElement.classList.remove = jest.fn();
|
|
24
18
|
|
|
25
19
|
add = jest.spyOn(global.document.documentElement.classList, 'add');
|
|
26
20
|
remove = jest.spyOn(global.document.documentElement.classList, 'remove');
|
|
@@ -37,13 +31,13 @@ describe('Document ios click', () => {
|
|
|
37
31
|
});
|
|
38
32
|
|
|
39
33
|
it('does add ios click to document if it is ios device', () => {
|
|
40
|
-
isIosDevice.mockReturnValue(true);
|
|
34
|
+
(isIosDevice as jest.Mock).mockReturnValue(true);
|
|
41
35
|
addClickClassToDocumentOnIos();
|
|
42
36
|
expect(add).toHaveBeenCalledWith('ios-click');
|
|
43
37
|
});
|
|
44
38
|
|
|
45
39
|
it('does remove ios click from document if it is ios device', () => {
|
|
46
|
-
isIosDevice.mockReturnValue(true);
|
|
40
|
+
(isIosDevice as jest.Mock).mockReturnValue(true);
|
|
47
41
|
removeClickClassFromDocumentOnIos();
|
|
48
42
|
expect(remove).toHaveBeenCalledWith('ios-click');
|
|
49
43
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
|
2
|
+
|
|
1
3
|
import { isIosDevice } from '../deviceDetection';
|
|
2
4
|
|
|
3
5
|
/*
|
|
@@ -17,3 +19,24 @@ export function removeClickClassFromDocumentOnIos() {
|
|
|
17
19
|
document.documentElement.classList.remove('ios-click');
|
|
18
20
|
}
|
|
19
21
|
}
|
|
22
|
+
|
|
23
|
+
export function isServerSide(): boolean {
|
|
24
|
+
return typeof window === 'undefined';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isBrowser(): boolean {
|
|
28
|
+
return !isServerSide();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function stopPropagation(event: SyntheticEvent) {
|
|
32
|
+
event.stopPropagation();
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
if (event.nativeEvent && event.nativeEvent.stopImmediatePropagation) {
|
|
35
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getSimpleRandomId(prefix: string): string {
|
|
40
|
+
const random = Math.ceil(Math.random() * 999999);
|
|
41
|
+
return `${prefix}${random}`;
|
|
42
|
+
}
|
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import { SyntheticEvent } from 'react';
|
|
2
|
-
|
|
3
|
-
export function isServerSide(): boolean {
|
|
4
|
-
return typeof window === 'undefined';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function isBrowser(): boolean {
|
|
8
|
-
return !isServerSide();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function stopPropagation(event: SyntheticEvent) {
|
|
12
|
-
event.stopPropagation();
|
|
13
|
-
event.preventDefault();
|
|
14
|
-
if (event.nativeEvent && event.nativeEvent.stopImmediatePropagation) {
|
|
15
|
-
event.nativeEvent.stopImmediatePropagation();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getSimpleRandomId(prefix: string): string {
|
|
20
|
-
const random = Math.ceil(Math.random() * 999999);
|
|
21
|
-
return `${prefix}${random}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
1
|
export {
|
|
25
2
|
addClickClassToDocumentOnIos,
|
|
3
|
+
getSimpleRandomId,
|
|
4
|
+
isBrowser,
|
|
5
|
+
isServerSide,
|
|
26
6
|
removeClickClassFromDocumentOnIos,
|
|
7
|
+
stopPropagation,
|
|
27
8
|
} from './documentIosClick';
|
|
@@ -4,6 +4,7 @@ import { render } from '@testing-library/react';
|
|
|
4
4
|
import { Layout } from '../propsValues/layouts';
|
|
5
5
|
|
|
6
6
|
import FlowHeader from './FlowHeader';
|
|
7
|
+
import type { FlowHeaderProps } from './FlowHeader';
|
|
7
8
|
|
|
8
9
|
describe('FlowHeader', () => {
|
|
9
10
|
const props = {
|
|
@@ -11,7 +12,7 @@ describe('FlowHeader', () => {
|
|
|
11
12
|
rightContent: 'rightContent',
|
|
12
13
|
bottomContent: 'bottomContent',
|
|
13
14
|
className: 'className',
|
|
14
|
-
};
|
|
15
|
+
} satisfies FlowHeaderProps;
|
|
15
16
|
it('renders as expected', () => {
|
|
16
17
|
expect(render(<FlowHeader {...props} />).container).toMatchSnapshot();
|
|
17
18
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './FlowHeader';
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
class HistoryNavigator {
|
|
2
|
-
|
|
2
|
+
history: (string | number)[];
|
|
3
|
+
currIndex: number;
|
|
4
|
+
historyLimit: number | undefined;
|
|
5
|
+
|
|
6
|
+
constructor(history?: (string | number)[], historyLimit?: number) {
|
|
3
7
|
this.history = history && history.length > 0 ? history : [''];
|
|
4
8
|
this.currIndex = this.history.length - 1;
|
|
5
9
|
this.historyLimit = historyLimit;
|
|
6
10
|
}
|
|
7
11
|
|
|
8
|
-
reset = (newHistory
|
|
9
|
-
this.history = newHistory;
|
|
10
|
-
this.currIndex =
|
|
12
|
+
reset = (newHistory?: (string | number)[], historyLimit = 20) => {
|
|
13
|
+
this.history = newHistory && newHistory.length > 0 ? newHistory : [''];
|
|
14
|
+
this.currIndex = this.history.length - 1;
|
|
11
15
|
this.historyLimit = historyLimit;
|
|
12
16
|
};
|
|
13
17
|
|
|
14
|
-
add = (element) => {
|
|
18
|
+
add = (element: string | number) => {
|
|
15
19
|
if (!this.historyLimit || this.history.length <= this.historyLimit) {
|
|
16
20
|
this.history.push(element);
|
|
17
21
|
// Always keep the current Index to the latest change
|
|
@@ -4,6 +4,11 @@ import { Position } from '..';
|
|
|
4
4
|
import { render } from '../../test-utils';
|
|
5
5
|
|
|
6
6
|
import Panel from './Panel';
|
|
7
|
+
import type { PanelProps } from './Panel';
|
|
8
|
+
|
|
9
|
+
const mockAnchorRef: React.RefObject<HTMLAnchorElement> = {
|
|
10
|
+
current: document.createElement('a'),
|
|
11
|
+
};
|
|
7
12
|
|
|
8
13
|
describe('Panel', () => {
|
|
9
14
|
const props = {
|
|
@@ -11,9 +16,9 @@ describe('Panel', () => {
|
|
|
11
16
|
children: <div>children</div>,
|
|
12
17
|
open: true,
|
|
13
18
|
position: Position.TOP,
|
|
14
|
-
anchorRef:
|
|
19
|
+
anchorRef: mockAnchorRef,
|
|
15
20
|
onClose: jest.fn(),
|
|
16
|
-
};
|
|
21
|
+
} satisfies PanelProps;
|
|
17
22
|
|
|
18
23
|
it('renders', () => {
|
|
19
24
|
const { container } = render(<Panel {...props} />);
|
|
@@ -31,7 +36,7 @@ describe('Panel', () => {
|
|
|
31
36
|
expect(getArrow()).toBeInTheDocument();
|
|
32
37
|
});
|
|
33
38
|
|
|
34
|
-
it('opens/closes Panel based on open',
|
|
39
|
+
it('opens/closes Panel based on open', () => {
|
|
35
40
|
const { rerender } = render(<Panel {...props} open={false} />);
|
|
36
41
|
|
|
37
42
|
expect(getPanel()).not.toBeInTheDocument();
|
|
@@ -41,9 +46,9 @@ describe('Panel', () => {
|
|
|
41
46
|
expect(getPanel()).toBeInTheDocument();
|
|
42
47
|
});
|
|
43
48
|
|
|
44
|
-
it('does not set width for content as width of an anchor (by default)',
|
|
45
|
-
const anchorReference = createRef();
|
|
46
|
-
const panelReference = createRef();
|
|
49
|
+
it('does not set width for content as width of an anchor (by default)', () => {
|
|
50
|
+
const anchorReference = createRef<HTMLDivElement>();
|
|
51
|
+
const panelReference = createRef<HTMLDivElement>();
|
|
47
52
|
|
|
48
53
|
render(
|
|
49
54
|
<>
|
|
@@ -61,9 +66,9 @@ describe('Panel', () => {
|
|
|
61
66
|
expect(panelReference.current).toHaveStyle({ width: undefined });
|
|
62
67
|
});
|
|
63
68
|
|
|
64
|
-
it('sets same width for content as width of an anchor (anchorWidth={true})',
|
|
65
|
-
const anchorReference = createRef();
|
|
66
|
-
const panelReference = createRef();
|
|
69
|
+
it('sets same width for content as width of an anchor (anchorWidth={true})', () => {
|
|
70
|
+
const anchorReference = createRef<HTMLDivElement>();
|
|
71
|
+
const panelReference = createRef<HTMLDivElement>();
|
|
67
72
|
|
|
68
73
|
render(
|
|
69
74
|
<>
|
|
@@ -26,7 +26,7 @@ const fallbackPlacements = {
|
|
|
26
26
|
[Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export type
|
|
29
|
+
export type PanelProps = PropsWithChildren<{
|
|
30
30
|
arrow?: boolean;
|
|
31
31
|
flip?: boolean;
|
|
32
32
|
altAxis?: boolean;
|
|
@@ -38,7 +38,7 @@ export type Props = PropsWithChildren<{
|
|
|
38
38
|
}> &
|
|
39
39
|
HTMLAttributes<HTMLDivElement>;
|
|
40
40
|
|
|
41
|
-
const Panel = forwardRef<HTMLDivElement,
|
|
41
|
+
const Panel = forwardRef<HTMLDivElement, PanelProps>(
|
|
42
42
|
(
|
|
43
43
|
{
|
|
44
44
|
arrow = false,
|
|
@@ -51,7 +51,7 @@ const Panel = forwardRef<HTMLDivElement, Props>(
|
|
|
51
51
|
anchorRef,
|
|
52
52
|
anchorWidth = false,
|
|
53
53
|
...rest
|
|
54
|
-
}:
|
|
54
|
+
}: PanelProps,
|
|
55
55
|
reference,
|
|
56
56
|
) => {
|
|
57
57
|
const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);
|
|
@@ -6,7 +6,7 @@ import { Position } from '..';
|
|
|
6
6
|
import BottomSheet from '../bottomSheet';
|
|
7
7
|
import { useLayout } from '../hooks';
|
|
8
8
|
import Panel from '../panel';
|
|
9
|
-
import {
|
|
9
|
+
import { PanelProps } from '../panel/Panel';
|
|
10
10
|
|
|
11
11
|
const ResponsivePanel = forwardRef<HTMLDivElement, PanelProps>(
|
|
12
12
|
(
|
package/src/dimmer/Dimmer.tsx
CHANGED
|
@@ -29,7 +29,7 @@ export const EXIT_ANIMATION = 350;
|
|
|
29
29
|
|
|
30
30
|
const dimmerManager = new DimmerManager();
|
|
31
31
|
|
|
32
|
-
type DimmerProps = CommonProps & {
|
|
32
|
+
export type DimmerProps = CommonProps & {
|
|
33
33
|
children?: ReactNode;
|
|
34
34
|
disableClickToClose?: boolean;
|
|
35
35
|
contentPosition?: PositionTop | PositionCenter | PositionBottom;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { useRef } from 'react';
|
|
3
2
|
import { useIntl } from 'react-intl';
|
|
4
3
|
|
|
5
4
|
import { Breakpoint, Layout } from '../common';
|
|
@@ -8,10 +7,10 @@ import FlowHeader from '../common/flowHeader/FlowHeader';
|
|
|
8
7
|
import Logo from '../logo';
|
|
9
8
|
import Stepper, { type Step } from '../stepper/Stepper';
|
|
10
9
|
|
|
10
|
+
import { useScreenSize } from '../common/hooks/useScreenSize';
|
|
11
11
|
import messages from './FlowNavigation.messages';
|
|
12
12
|
import AnimatedLabel from './animatedLabel';
|
|
13
13
|
import BackButton from './backButton';
|
|
14
|
-
import { useScreenSize } from '../common/hooks/useScreenSize';
|
|
15
14
|
|
|
16
15
|
export interface FlowNavigationProps {
|
|
17
16
|
activeStep?: number;
|