@skyscanner/backpack-web 37.3.2 → 37.4.1
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/bpk-component-image/src/BpkBackgroundImage.d.ts +4 -0
- package/bpk-component-image/src/BpkBackgroundImage.js +12 -0
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.d.ts +2 -1
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.js +7 -1
- package/bpk-component-tooltip/src/BpkTooltip.js +7 -6
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ export type BpkBackgroundImageProps = {
|
|
|
7
7
|
loading?: boolean;
|
|
8
8
|
src: string;
|
|
9
9
|
className?: string;
|
|
10
|
+
onError?: (() => void) | null;
|
|
10
11
|
onLoad?: (() => void) | null;
|
|
11
12
|
style?: {};
|
|
12
13
|
imageStyle?: CSSProperties;
|
|
@@ -18,12 +19,15 @@ declare class BpkBackgroundImage extends Component<BpkBackgroundImageProps> {
|
|
|
18
19
|
inView: boolean;
|
|
19
20
|
loading: boolean;
|
|
20
21
|
onLoad: null;
|
|
22
|
+
onError: null;
|
|
21
23
|
style: {};
|
|
22
24
|
imageStyle: {};
|
|
23
25
|
};
|
|
24
26
|
constructor(props: BpkBackgroundImageProps);
|
|
25
27
|
componentDidMount(): void;
|
|
26
28
|
UNSAFE_componentWillReceiveProps(newProps: BpkBackgroundImageProps): void;
|
|
29
|
+
componentDidUpdate(prevProps: BpkBackgroundImageProps): void;
|
|
30
|
+
onBackgroundImageError: () => void;
|
|
27
31
|
onBackgroundImageLoad: () => void;
|
|
28
32
|
getAspectRatio: () => number;
|
|
29
33
|
startImageLoad: () => void;
|
|
@@ -30,6 +30,7 @@ class BpkBackgroundImage extends Component {
|
|
|
30
30
|
inView: true,
|
|
31
31
|
loading: false,
|
|
32
32
|
onLoad: null,
|
|
33
|
+
onError: null,
|
|
33
34
|
style: {},
|
|
34
35
|
imageStyle: {}
|
|
35
36
|
};
|
|
@@ -47,6 +48,16 @@ class BpkBackgroundImage extends Component {
|
|
|
47
48
|
this.startImageLoad();
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
componentDidUpdate(prevProps) {
|
|
52
|
+
if (prevProps.src !== this.props.src) {
|
|
53
|
+
this.startImageLoad();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
onBackgroundImageError = () => {
|
|
57
|
+
if (this.props.onError) {
|
|
58
|
+
this.props.onError();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
50
61
|
onBackgroundImageLoad = () => {
|
|
51
62
|
if (this.props.onLoad) {
|
|
52
63
|
this.props.onLoad();
|
|
@@ -62,6 +73,7 @@ class BpkBackgroundImage extends Component {
|
|
|
62
73
|
startImageLoad = () => {
|
|
63
74
|
this.trackImg = new Image();
|
|
64
75
|
this.trackImg.src = this.props.src;
|
|
76
|
+
this.trackImg.onerror = this.onBackgroundImageError;
|
|
65
77
|
this.trackImg.onload = this.onBackgroundImageLoad;
|
|
66
78
|
};
|
|
67
79
|
render() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode, ElementType, CSSProperties } from 'react';
|
|
1
|
+
import type { ReactNode, ElementType, CSSProperties, UIEvent } from 'react';
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import type { DebouncedFunc } from 'lodash';
|
|
4
4
|
declare const computeScrollBarAwareHeight: (scrollerEl: HTMLElement | null, innerEl: HTMLElement | null) => string | null;
|
|
@@ -13,6 +13,7 @@ type Props = {
|
|
|
13
13
|
scrollerRef?: (el: HTMLElement | null) => void;
|
|
14
14
|
style?: CSSProperties;
|
|
15
15
|
showScrollbar?: boolean;
|
|
16
|
+
onScroll?: (event: UIEvent) => void;
|
|
16
17
|
};
|
|
17
18
|
type State = {
|
|
18
19
|
computedHeight: string;
|
|
@@ -109,6 +109,7 @@ class BpkMobileScrollContainer extends Component {
|
|
|
109
109
|
className,
|
|
110
110
|
innerContainerTagName = 'div',
|
|
111
111
|
leadingIndicatorClassName,
|
|
112
|
+
onScroll,
|
|
112
113
|
scrollerRef,
|
|
113
114
|
showScrollbar,
|
|
114
115
|
style,
|
|
@@ -137,7 +138,12 @@ class BpkMobileScrollContainer extends Component {
|
|
|
137
138
|
}
|
|
138
139
|
this.scrollerEl = el;
|
|
139
140
|
},
|
|
140
|
-
onScroll:
|
|
141
|
+
onScroll: event => {
|
|
142
|
+
this.setScrollIndicatorClassName();
|
|
143
|
+
if (onScroll) {
|
|
144
|
+
onScroll(event);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
141
147
|
className: scrollerClassNames,
|
|
142
148
|
children: /*#__PURE__*/_jsx(InnerContainer, {
|
|
143
149
|
"aria-label": ariaLabel,
|
|
@@ -23,8 +23,8 @@ The actual component that developers create (i.e. the default export from this p
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { cloneElement, useRef, useState, useEffect } from 'react';
|
|
26
|
-
import { arrow, FloatingArrow, FloatingPortal, offset, shift, useFloating, useHover, useInteractions, useRole } from '@floating-ui/react';
|
|
27
|
-
import { surfaceHighlightDay } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
26
|
+
import { arrow, FloatingArrow, FloatingPortal, offset, safePolygon, shift, useFloating, useFocus, useHover, useInteractions, useRole } from '@floating-ui/react';
|
|
27
|
+
import { surfaceHighlightDay, onePixelRem } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
28
28
|
import { TransitionInitialMount, cssModules } from "../../bpk-react-utils";
|
|
29
29
|
import { ARROW_ID, TOOLTIP_TYPES } from "./constants";
|
|
30
30
|
import STYLES from "./BpkTooltip.module.css";
|
|
@@ -39,12 +39,12 @@ const strokeWidth = 1;
|
|
|
39
39
|
const getArrowAlignment = placement => {
|
|
40
40
|
if (placement.includes('bottom')) {
|
|
41
41
|
return {
|
|
42
|
-
bottom:
|
|
42
|
+
bottom: `calc(100% - ${onePixelRem})`
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
if (placement.includes('top')) {
|
|
46
46
|
return {
|
|
47
|
-
top:
|
|
47
|
+
top: `calc(100% - ${onePixelRem})`
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
return undefined;
|
|
@@ -82,7 +82,8 @@ const BpkTooltip = ({
|
|
|
82
82
|
})]
|
|
83
83
|
});
|
|
84
84
|
const hover = useHover(context, {
|
|
85
|
-
mouseOnly: !hasTouchSupport() || !hideOnTouchDevices
|
|
85
|
+
mouseOnly: !hasTouchSupport() || !hideOnTouchDevices,
|
|
86
|
+
handleClose: safePolygon()
|
|
86
87
|
});
|
|
87
88
|
const role = useRole(context, {
|
|
88
89
|
role: 'tooltip'
|
|
@@ -90,7 +91,7 @@ const BpkTooltip = ({
|
|
|
90
91
|
const {
|
|
91
92
|
getFloatingProps,
|
|
92
93
|
getReferenceProps
|
|
93
|
-
} = useInteractions([hover, role]);
|
|
94
|
+
} = useInteractions([hover, role, useFocus(context)]);
|
|
94
95
|
const targetWithAccessibilityProps = /*#__PURE__*/cloneElement(target, {
|
|
95
96
|
tabIndex: '0',
|
|
96
97
|
'aria-label': ariaLabel,
|