@transferwise/components 46.29.0 → 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/i18n/hu.json +1 -1
- package/build/index.js +4494 -4489
- package/build/index.js.map +1 -1
- package/build/index.mjs +4713 -4707
- 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/hooks/index.d.ts +0 -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 +3 -3
- 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 +61 -60
- 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/hooks/index.js +0 -1
- 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/decision/Decision.spec.js +0 -1
- package/src/dimmer/Dimmer.tsx +1 -1
- package/src/dimmer/index.ts +2 -0
- package/src/flowNavigation/FlowNavigation.spec.js +7 -22
- package/src/flowNavigation/FlowNavigation.tsx +20 -34
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +2 -2
- package/src/i18n/hu.json +1 -1
- package/src/index.ts +68 -66
- package/src/overlayHeader/OverlayHeader.js +1 -1
- package/src/provider/theme/ThemeProvider.story.tsx +21 -0
- package/src/withDisplayFormat/WithDisplayFormat.tsx +2 -2
- package/build/types/common/hooks/useClientWidth/useClientWidth.d.ts +0 -11
- package/build/types/common/hooks/useClientWidth/useClientWidth.d.ts.map +0 -1
- 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/common/hooks/useClientWidth/useClientWidth.spec.js +0 -77
- package/src/common/hooks/useClientWidth/useClientWidth.tsx +0 -47
- 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,67 @@
|
|
|
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.
|
|
58
|
-
"@storybook/
|
|
59
|
-
"@storybook/
|
|
60
|
-
"@storybook/
|
|
61
|
-
"@storybook/
|
|
62
|
-
"@storybook/
|
|
63
|
-
"@storybook/
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@testing-library/
|
|
57
|
+
"@storybook/addon-viewport": "^7.6.19",
|
|
58
|
+
"@storybook/addons": "^7.6.17",
|
|
59
|
+
"@storybook/api": "^7.6.17",
|
|
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",
|
|
69
73
|
"@transferwise/icons": "^3.7.0",
|
|
70
|
-
"@transferwise/neptune-tokens": "^8.
|
|
71
|
-
"@tsconfig/recommended": "^1.0.
|
|
72
|
-
"@types/babel__core": "^7.20.
|
|
74
|
+
"@transferwise/neptune-tokens": "^8.9.2",
|
|
75
|
+
"@tsconfig/recommended": "^1.0.6",
|
|
76
|
+
"@types/babel__core": "^7.20.5",
|
|
73
77
|
"@types/commonmark": "^0.27.9",
|
|
74
78
|
"@types/jest": "^29.5.12",
|
|
75
|
-
"@types/lodash": "4.
|
|
79
|
+
"@types/lodash": "4.17.1",
|
|
76
80
|
"@types/lodash.clamp": "^4.0.9",
|
|
77
81
|
"@types/lodash.debounce": "^4.0.9",
|
|
78
|
-
"@types/
|
|
79
|
-
"@types/
|
|
80
|
-
"@types/react": "
|
|
81
|
-
"@types/
|
|
82
|
-
"@types/
|
|
83
|
-
"@types/testing-library__jest-dom": "^5.14.5",
|
|
84
|
-
"@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",
|
|
85
87
|
"@wise/art": "^2.7.0",
|
|
86
88
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
|
|
87
|
-
"babel-plugin-formatjs": "^10.5.
|
|
89
|
+
"babel-plugin-formatjs": "^10.5.14",
|
|
88
90
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
89
91
|
"enzyme": "^3.11.0",
|
|
90
92
|
"jest": "^29.7.0",
|
|
91
93
|
"jest-environment-jsdom": "^29.7.0",
|
|
92
94
|
"jest-fetch-mock": "^3.0.3",
|
|
93
95
|
"lodash.times": "^4.3.2",
|
|
94
|
-
"react-intl": "^
|
|
95
|
-
"rollup": "^
|
|
96
|
-
"storybook": "^7.6.
|
|
96
|
+
"react-intl": "^6.6.6",
|
|
97
|
+
"rollup": "^4.17.2",
|
|
98
|
+
"storybook": "^7.6.19",
|
|
97
99
|
"@transferwise/less-config": "3.1.0",
|
|
98
|
-
"@transferwise/neptune-css": "14.
|
|
99
|
-
"@wise/components-theming": "1.
|
|
100
|
+
"@transferwise/neptune-css": "14.10.0",
|
|
101
|
+
"@wise/components-theming": "1.2.0"
|
|
100
102
|
},
|
|
101
103
|
"peerDependencies": {
|
|
102
104
|
"@transferwise/icons": "^3.7.0",
|
|
@@ -108,30 +110,29 @@
|
|
|
108
110
|
"react-intl": "^5.10.0 || ^6"
|
|
109
111
|
},
|
|
110
112
|
"dependencies": {
|
|
111
|
-
"@babel/runtime": "^7.
|
|
112
|
-
"@floating-ui/react": "^0.
|
|
113
|
-
"@formatjs/intl-locale": "^
|
|
114
|
-
"@headlessui/react": "^1.7.
|
|
115
|
-
"@popperjs/core": "^2.
|
|
116
|
-
"@radix-ui/react-id": "^1.0.
|
|
117
|
-
"@react-aria/focus": "^3.
|
|
118
|
-
"@react-aria/overlays": "^3.
|
|
119
|
-
"@react-spring/web": "~9.
|
|
120
|
-
"@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",
|
|
121
123
|
"@transferwise/neptune-validation": "^3.3.0",
|
|
122
|
-
"classnames": "^2.
|
|
124
|
+
"classnames": "^2.5.1",
|
|
123
125
|
"commonmark": "0.29.1",
|
|
124
|
-
"core-js": "^3.
|
|
126
|
+
"core-js": "^3.37.1",
|
|
125
127
|
"lodash.clamp": "^4.0.3",
|
|
126
128
|
"lodash.debounce": "^4.0.8",
|
|
127
|
-
"lodash.throttle": "^4.1.1",
|
|
128
129
|
"lodash.topairs": "^4.3.0",
|
|
129
130
|
"merge-props": "^6.0.0",
|
|
130
|
-
"prop-types": "^15.
|
|
131
|
+
"prop-types": "^15.8.1",
|
|
131
132
|
"react-popper": "^2.3.0",
|
|
132
133
|
"react-required-if": "^1.0.3",
|
|
133
|
-
"react-transition-group": "^4.4.
|
|
134
|
-
"use-sync-external-store": "^1.2.
|
|
134
|
+
"react-transition-group": "^4.4.5",
|
|
135
|
+
"use-sync-external-store": "^1.2.2"
|
|
135
136
|
},
|
|
136
137
|
"publishConfig": {
|
|
137
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
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { useClientWidth } from './useClientWidth/useClientWidth';
|
|
2
1
|
export { default as useConditionalListener } from './useConditionalListener';
|
|
3
2
|
export { default as useDirection } from './useDirection';
|
|
4
3
|
export { default as useHasIntersected } from './useHasIntersected';
|
|
@@ -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;
|
|
@@ -2,11 +2,11 @@ import '@testing-library/jest-dom';
|
|
|
2
2
|
|
|
3
3
|
import Avatar, { AvatarType } from '../avatar';
|
|
4
4
|
import { Breakpoint, Size } from '../common';
|
|
5
|
-
import { render, screen } from '../test-utils';
|
|
5
|
+
import { mockMatchMedia, render, screen } from '../test-utils';
|
|
6
6
|
|
|
7
7
|
import FlowNavigation from './FlowNavigation';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
mockMatchMedia();
|
|
10
10
|
|
|
11
11
|
jest.mock('./animatedLabel', () => {
|
|
12
12
|
return function ({ className, activeLabel }) {
|
|
@@ -24,23 +24,8 @@ jest.mock('./backButton', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
describe('FlowNavigation', () => {
|
|
27
|
-
const resetClientWidth = (width) => {
|
|
28
|
-
Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
|
|
29
|
-
configurable: true,
|
|
30
|
-
value: width,
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
27
|
beforeEach(() => {
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
afterAll(() => {
|
|
38
|
-
const originalClientWidth = Object.getOwnPropertyDescriptor(
|
|
39
|
-
HTMLElement.prototype,
|
|
40
|
-
'clientWidth',
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
Object.defineProperty(HTMLElement.prototype, 'clientWidth', originalClientWidth);
|
|
28
|
+
window.innerWidth = Breakpoint.LARGE + 1;
|
|
44
29
|
});
|
|
45
30
|
|
|
46
31
|
const props = {
|
|
@@ -117,21 +102,21 @@ describe('FlowNavigation', () => {
|
|
|
117
102
|
});
|
|
118
103
|
|
|
119
104
|
it(`renders xs-max class`, () => {
|
|
120
|
-
|
|
105
|
+
window.innerWidth = Breakpoint.SMALL - 1;
|
|
121
106
|
const { container } = render(<FlowNavigation {...props} onClose={null} />);
|
|
122
107
|
|
|
123
108
|
expect(container.querySelector('.np-flow-navigation--xs-max')).toBeInTheDocument();
|
|
124
109
|
});
|
|
125
110
|
|
|
126
111
|
it(`renders sm class`, () => {
|
|
127
|
-
|
|
112
|
+
window.innerWidth = Breakpoint.SMALL;
|
|
128
113
|
const { container } = render(<FlowNavigation {...props} onClose={null} />);
|
|
129
114
|
|
|
130
115
|
expect(container.querySelector('.np-flow-navigation--sm')).toBeInTheDocument();
|
|
131
116
|
});
|
|
132
117
|
|
|
133
118
|
it(`renders lg class`, () => {
|
|
134
|
-
|
|
119
|
+
window.innerWidth = Breakpoint.LARGE;
|
|
135
120
|
const { container } = render(<FlowNavigation {...props} onClose={null} />);
|
|
136
121
|
|
|
137
122
|
expect(container.querySelector('.np-flow-navigation--lg')).toBeInTheDocument();
|
|
@@ -139,7 +124,7 @@ describe('FlowNavigation', () => {
|
|
|
139
124
|
|
|
140
125
|
describe('on mobile', () => {
|
|
141
126
|
beforeEach(() => {
|
|
142
|
-
|
|
127
|
+
window.innerWidth = Breakpoint.SMALL - 1;
|
|
143
128
|
});
|
|
144
129
|
|
|
145
130
|
it('renders as expected', () => {
|