@skyscanner/backpack-web 42.25.0 → 42.26.0-dev-v27635015998.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/README.md +58 -58
- package/bpk-component-accordion/src/BpkAccordionItem.d.ts +1 -1
- package/bpk-component-accordion/src/withAccordionItemState.d.ts +2 -7
- package/bpk-component-accordion/src/withAccordionItemState.js +4 -6
- package/bpk-component-accordion/src/withSingleItemAccordionState.d.ts +1 -1
- package/bpk-component-aria-live/src/BpkAriaLive.d.ts +1 -1
- package/bpk-component-aria-live/src/BpkAriaLive.story-helpers.d.ts +2 -2
- package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.d.ts +4 -4
- package/bpk-component-badge/src/BpkBadge.module.css +1 -1
- package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +4 -7
- package/bpk-component-banner-alert/src/AnimateAndFade.js +14 -10
- package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +0 -10
- package/bpk-component-banner-alert/src/withBannerAlertState.js +3 -13
- package/bpk-component-barchart/src/BpkBarchart.js +24 -41
- package/bpk-component-barchart/src/BpkBarchartBar.js +7 -16
- package/bpk-component-barchart/src/BpkBarchartBars.js +6 -14
- package/bpk-component-barchart/src/BpkChartAxis.js +5 -12
- package/bpk-component-barchart/src/BpkChartDataTable.js +1 -4
- package/bpk-component-barchart/src/BpkChartGridLines.js +3 -8
- package/bpk-component-calendar/index.d.ts +2 -2
- package/bpk-component-calendar/index.js +2 -2
- package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +3 -28
- package/bpk-component-calendar/src/BpkCalendarContainer.js +47 -34
- package/bpk-component-calendar/src/BpkCalendarDate.d.ts +0 -1
- package/bpk-component-calendar/src/BpkCalendarDate.js +32 -31
- package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +13 -14
- package/bpk-component-calendar/src/BpkCalendarGrid.js +28 -37
- package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +0 -4
- package/bpk-component-calendar/src/BpkCalendarGridHeader.js +2 -6
- package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +0 -5
- package/bpk-component-calendar/src/BpkCalendarGridTransition.js +0 -5
- package/bpk-component-calendar/src/BpkCalendarWeek.d.ts +0 -1
- package/bpk-component-calendar/src/BpkCalendarWeek.js +19 -27
- package/bpk-component-calendar/src/custom-proptypes.d.ts +1 -1
- package/bpk-component-card-list/src/BpkCardList.js +0 -3
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.js +1 -3
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListRowRailContainer.js +1 -14
- package/bpk-component-card-list/src/BpkCardListRowRail/utils.d.ts +1 -2
- package/bpk-component-card-list/src/BpkCardListRowRail/utils.js +0 -21
- package/bpk-component-card-list/src/common-types.d.ts +4 -7
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.d.ts +1 -1
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.d.ts +1 -1
- package/bpk-component-datepicker/src/BpkDatepicker.d.ts +6 -192
- package/bpk-component-datepicker/src/BpkDatepicker.js +46 -53
- package/bpk-component-dialog/src/BpkDialogInner.d.ts +0 -7
- package/bpk-component-drawer/src/BpkDrawerContent.d.ts +2 -2
- package/bpk-component-drawer/src/BpkDrawerContent.js +13 -1
- package/bpk-component-fieldset/src/BpkFieldset.d.ts +1 -1
- package/bpk-component-floating-notification/src/BpkFloatingNotification.js +4 -1
- package/bpk-component-grid-toggle/src/BpkGridToggle.js +9 -7
- package/bpk-component-image/src/BpkBackgroundImage.d.ts +1 -9
- package/bpk-component-image/src/BpkBackgroundImage.js +18 -18
- package/bpk-component-image/src/BpkImage.d.ts +1 -8
- package/bpk-component-image/src/BpkImage.js +10 -18
- package/bpk-component-image/src/withLazyLoading.d.ts +0 -4
- package/bpk-component-image/src/withLazyLoading.js +2 -6
- package/bpk-component-infinite-scroll/src/withInfiniteScroll.js +6 -8
- package/bpk-component-info-banner/src/AnimateAndFade.d.ts +4 -7
- package/bpk-component-info-banner/src/AnimateAndFade.js +14 -10
- package/bpk-component-info-banner/src/withBannerAlertState.d.ts +0 -10
- package/bpk-component-info-banner/src/withBannerAlertState.js +3 -13
- package/bpk-component-input/index.d.ts +2 -2
- package/bpk-component-input/index.js +2 -2
- package/bpk-component-input/src/BpkInput.d.ts +0 -13
- package/bpk-component-input/src/BpkInput.js +13 -12
- package/bpk-component-input/src/common-types.d.ts +0 -32
- package/bpk-component-input/src/common-types.js +1 -56
- package/bpk-component-input/src/withOpenEvents.d.ts +1 -12
- package/bpk-component-input/src/withOpenEvents.js +2 -14
- package/bpk-component-layout/src/BpkProvider.d.ts +3 -3
- package/bpk-component-layout/src/BpkProvider.js +59 -3
- package/bpk-component-map/src/BpkBasicMapMarker.d.ts +1 -8
- package/bpk-component-map/src/BpkBasicMapMarker.js +0 -6
- package/bpk-component-map/src/BpkIconMarker.js +4 -10
- package/bpk-component-map/src/BpkIconMarkerBackground.js +3 -8
- package/bpk-component-map/src/BpkMap.js +14 -30
- package/bpk-component-map/src/withGoogleMapsScript.js +4 -8
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.d.ts +0 -1
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.js +1 -5
- package/bpk-component-modal/index.d.ts +1 -2
- package/bpk-component-modal/index.js +1 -3
- package/bpk-component-navigation-bar/src/BpkNavigationBar.d.ts +2 -2
- package/bpk-component-phone-input/src/BpkPhoneInput.js +6 -14
- package/bpk-component-progress/src/BpkProgress.d.ts +0 -8
- package/bpk-component-progress/src/BpkProgress.js +10 -16
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendar.d.ts +0 -14
- package/bpk-component-section-list/src/BpkSectionListItem.js +4 -10
- package/bpk-component-section-list/src/BpkSectionListSection.js +1 -4
- package/bpk-component-segmented-control/src/BpkSegmentedControl.d.ts +1 -1
- package/bpk-component-select/src/BpkSelect.d.ts +1 -1
- package/bpk-component-slider/src/BpkSlider.js +1 -1
- package/bpk-component-spinner/src/SpinnerLayout.story-helpers.d.ts +1 -7
- package/bpk-component-spinner/src/SpinnerLayout.story-helpers.js +0 -4
- package/bpk-component-split-input/src/BpkInputField.d.ts +2 -6
- package/bpk-component-split-input/src/BpkInputField.js +2 -6
- package/bpk-component-split-input/src/BpkSplitInput.d.ts +0 -6
- package/bpk-component-split-input/src/BpkSplitInput.js +7 -13
- package/bpk-component-star-rating/src/withInteractiveStarRatingState.d.ts +0 -3
- package/bpk-component-star-rating/src/withInteractiveStarRatingState.js +0 -3
- package/bpk-component-ticket/src/BpkTicket.js +6 -14
- package/bpk-mixins/_badges.scss +3 -3
- package/bpk-react-utils/index.d.ts +3 -1
- package/bpk-react-utils/src/BpkDialogWrapper/BpkDialogWrapper.js +1 -0
- package/bpk-react-utils/src/Portal.d.ts +10 -22
- package/bpk-react-utils/src/Portal.js +22 -19
- package/bpk-react-utils/src/TransitionInitialMount.d.ts +4 -2
- package/bpk-react-utils/src/TransitionInitialMount.js +23 -14
- package/bpk-scrim-utils/index.d.ts +0 -7
- package/bpk-scrim-utils/src/withScrim.d.ts +0 -7
- package/bpk-scrim-utils/src/withScrim.js +10 -15
- package/bpk-stylesheets/base.css +1 -1
- package/bpk-stylesheets/primitives.css +2 -0
- package/bpk-stylesheets/theme-backpack-dark.css +3 -2
- package/bpk-stylesheets/theme-backpack-light.css +5 -4
- package/package.json +5 -3
- package/bpk-component-modal/src/legacy-prop-types.js +0 -74
|
@@ -35,7 +35,10 @@ class BpkGridToggle extends Component {
|
|
|
35
35
|
document.addEventListener('keydown', this.handleKeyDown);
|
|
36
36
|
}
|
|
37
37
|
componentWillUnmount() {
|
|
38
|
-
|
|
38
|
+
const {
|
|
39
|
+
targetContainer = 'body'
|
|
40
|
+
} = this.props;
|
|
41
|
+
document.querySelector(targetContainer).classList.remove(GRID_CLASS_NAME);
|
|
39
42
|
document.removeEventListener('keydown', this.handleKeyDown);
|
|
40
43
|
}
|
|
41
44
|
handleKeyDown = e => {
|
|
@@ -44,15 +47,18 @@ class BpkGridToggle extends Component {
|
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
toggleGrid = e => {
|
|
50
|
+
const {
|
|
51
|
+
targetContainer = 'body'
|
|
52
|
+
} = this.props;
|
|
47
53
|
e.preventDefault();
|
|
48
|
-
document.querySelector(
|
|
54
|
+
document.querySelector(targetContainer).classList.toggle(GRID_CLASS_NAME);
|
|
49
55
|
this.setState(state => ({
|
|
50
56
|
gridEnabled: !state.gridEnabled
|
|
51
57
|
}));
|
|
52
58
|
};
|
|
53
59
|
render() {
|
|
54
60
|
const {
|
|
55
|
-
className
|
|
61
|
+
className = null
|
|
56
62
|
} = this.props;
|
|
57
63
|
const {
|
|
58
64
|
gridEnabled
|
|
@@ -73,8 +79,4 @@ BpkGridToggle.propTypes = {
|
|
|
73
79
|
targetContainer: PropTypes.string,
|
|
74
80
|
className: PropTypes.string
|
|
75
81
|
};
|
|
76
|
-
BpkGridToggle.defaultProps = {
|
|
77
|
-
targetContainer: 'body',
|
|
78
|
-
className: null
|
|
79
|
-
};
|
|
80
82
|
export default BpkGridToggle;
|
|
@@ -14,21 +14,13 @@ export type BpkBackgroundImageProps = {
|
|
|
14
14
|
};
|
|
15
15
|
declare class BpkBackgroundImage extends Component<BpkBackgroundImageProps> {
|
|
16
16
|
trackImg?: HTMLImageElement | null;
|
|
17
|
-
static defaultProps: {
|
|
18
|
-
className: string;
|
|
19
|
-
inView: boolean;
|
|
20
|
-
loading: boolean;
|
|
21
|
-
onLoad: null;
|
|
22
|
-
onError: null;
|
|
23
|
-
style: {};
|
|
24
|
-
imageStyle: {};
|
|
25
|
-
};
|
|
26
17
|
constructor(props: BpkBackgroundImageProps);
|
|
27
18
|
componentDidMount(): void;
|
|
28
19
|
componentDidUpdate(prevProps: BpkBackgroundImageProps): void;
|
|
29
20
|
onBackgroundImageError: () => void;
|
|
30
21
|
onBackgroundImageLoad: () => void;
|
|
31
22
|
getAspectRatio: () => number;
|
|
23
|
+
spinnerNodeRef: import("react").RefObject<HTMLDivElement>;
|
|
32
24
|
startImageLoad: () => void;
|
|
33
25
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
34
26
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { Component } from 'react';
|
|
19
|
+
import { Component, createRef } from 'react';
|
|
20
20
|
import CSSTransition from 'react-transition-group/CSSTransition';
|
|
21
21
|
import { animations } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
22
22
|
import { BpkSpinner } from "../../bpk-component-spinner";
|
|
@@ -25,30 +25,27 @@ import STYLES from "./BpkBackgroundImage.module.css";
|
|
|
25
25
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
26
|
const getClassName = cssModules(STYLES);
|
|
27
27
|
class BpkBackgroundImage extends Component {
|
|
28
|
-
static defaultProps = {
|
|
29
|
-
className: '',
|
|
30
|
-
inView: true,
|
|
31
|
-
loading: false,
|
|
32
|
-
onLoad: null,
|
|
33
|
-
onError: null,
|
|
34
|
-
style: {},
|
|
35
|
-
imageStyle: {}
|
|
36
|
-
};
|
|
37
28
|
constructor(props) {
|
|
38
29
|
super(props);
|
|
39
30
|
this.trackImg = null;
|
|
40
31
|
}
|
|
41
32
|
componentDidMount() {
|
|
42
|
-
|
|
33
|
+
const {
|
|
34
|
+
inView = true
|
|
35
|
+
} = this.props;
|
|
36
|
+
if (inView) {
|
|
43
37
|
this.startImageLoad();
|
|
44
38
|
}
|
|
45
39
|
}
|
|
46
40
|
componentDidUpdate(prevProps) {
|
|
47
41
|
const {
|
|
48
|
-
inView,
|
|
42
|
+
inView = true,
|
|
49
43
|
src
|
|
50
44
|
} = this.props;
|
|
51
|
-
|
|
45
|
+
const {
|
|
46
|
+
inView: prevInView = true
|
|
47
|
+
} = prevProps;
|
|
48
|
+
if (prevProps.src !== src || inView && !prevInView) {
|
|
52
49
|
this.startImageLoad();
|
|
53
50
|
}
|
|
54
51
|
}
|
|
@@ -69,6 +66,7 @@ class BpkBackgroundImage extends Component {
|
|
|
69
66
|
}
|
|
70
67
|
return 1;
|
|
71
68
|
};
|
|
69
|
+
spinnerNodeRef = /*#__PURE__*/createRef();
|
|
72
70
|
startImageLoad = () => {
|
|
73
71
|
this.trackImg = new Image();
|
|
74
72
|
this.trackImg.src = this.props.src;
|
|
@@ -78,12 +76,12 @@ class BpkBackgroundImage extends Component {
|
|
|
78
76
|
render() {
|
|
79
77
|
const {
|
|
80
78
|
children,
|
|
81
|
-
className,
|
|
82
|
-
imageStyle,
|
|
83
|
-
inView,
|
|
84
|
-
loading,
|
|
79
|
+
className = '',
|
|
80
|
+
imageStyle = {},
|
|
81
|
+
inView = true,
|
|
82
|
+
loading = false,
|
|
85
83
|
src,
|
|
86
|
-
style
|
|
84
|
+
style = {}
|
|
87
85
|
} = this.props;
|
|
88
86
|
const calculatedAspectRatio = this.getAspectRatio();
|
|
89
87
|
const aspectRatioPc = `${100 / calculatedAspectRatio}%`;
|
|
@@ -110,12 +108,14 @@ class BpkBackgroundImage extends Component {
|
|
|
110
108
|
},
|
|
111
109
|
className: imageClassNames.join(' ')
|
|
112
110
|
}), loading && /*#__PURE__*/_jsx(CSSTransition, {
|
|
111
|
+
nodeRef: this.spinnerNodeRef,
|
|
113
112
|
classNames: {
|
|
114
113
|
exit: getClassName('bpk-background-image__spinner--shown'),
|
|
115
114
|
exitActive: getClassName('bpk-background-image__spinner--hidden')
|
|
116
115
|
},
|
|
117
116
|
timeout: parseInt(animations.durationBase, 10),
|
|
118
117
|
children: /*#__PURE__*/_jsx("div", {
|
|
118
|
+
ref: this.spinnerNodeRef,
|
|
119
119
|
className: getClassName('bpk-background-image__spinner'),
|
|
120
120
|
children: /*#__PURE__*/_jsx(BpkSpinner, {})
|
|
121
121
|
})
|
|
@@ -18,16 +18,9 @@ type BpkImageProps = {
|
|
|
18
18
|
};
|
|
19
19
|
declare class BpkImage extends Component<BpkImageProps> {
|
|
20
20
|
placeholder?: HTMLElement | null;
|
|
21
|
-
static defaultProps: {
|
|
22
|
-
borderRadiusStyle: "none";
|
|
23
|
-
inView: boolean;
|
|
24
|
-
loading: boolean;
|
|
25
|
-
onLoad: null;
|
|
26
|
-
style: {};
|
|
27
|
-
suppressHydrationWarning: boolean;
|
|
28
|
-
};
|
|
29
21
|
onImageLoad: () => void;
|
|
30
22
|
getAspectRatio: () => number;
|
|
23
|
+
spinnerNodeRef: import("react").RefObject<HTMLDivElement>;
|
|
31
24
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
32
25
|
}
|
|
33
26
|
export default BpkImage;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { Component } from 'react';
|
|
19
|
+
import { Component, createRef } from 'react';
|
|
20
20
|
import CSSTransition from 'react-transition-group/CSSTransition';
|
|
21
21
|
import { animations } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
22
22
|
import { BpkSpinner } from "../../bpk-component-spinner";
|
|
@@ -26,9 +26,6 @@ import STYLES from "./BpkImage.module.css";
|
|
|
26
26
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
27
|
const getClassName = cssModules(STYLES);
|
|
28
28
|
class Image extends Component {
|
|
29
|
-
static defaultProps = {
|
|
30
|
-
hidden: false
|
|
31
|
-
};
|
|
32
29
|
constructor(props) {
|
|
33
30
|
super(props);
|
|
34
31
|
this.img = null;
|
|
@@ -46,7 +43,7 @@ class Image extends Component {
|
|
|
46
43
|
render() {
|
|
47
44
|
const {
|
|
48
45
|
altText,
|
|
49
|
-
hidden,
|
|
46
|
+
hidden = false,
|
|
50
47
|
onImageLoad,
|
|
51
48
|
...rest
|
|
52
49
|
} = this.props;
|
|
@@ -64,14 +61,6 @@ class Image extends Component {
|
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
class BpkImage extends Component {
|
|
67
|
-
static defaultProps = {
|
|
68
|
-
borderRadiusStyle: BORDER_RADIUS_STYLES.none,
|
|
69
|
-
inView: true,
|
|
70
|
-
loading: false,
|
|
71
|
-
onLoad: null,
|
|
72
|
-
style: {},
|
|
73
|
-
suppressHydrationWarning: false
|
|
74
|
-
};
|
|
75
64
|
onImageLoad = () => {
|
|
76
65
|
if (this.props.onLoad) {
|
|
77
66
|
this.props.onLoad();
|
|
@@ -83,16 +72,17 @@ class BpkImage extends Component {
|
|
|
83
72
|
}
|
|
84
73
|
return 1;
|
|
85
74
|
};
|
|
75
|
+
spinnerNodeRef = /*#__PURE__*/createRef();
|
|
86
76
|
render() {
|
|
87
77
|
const {
|
|
88
78
|
altText,
|
|
89
79
|
aspectRatio,
|
|
90
|
-
borderRadiusStyle,
|
|
80
|
+
borderRadiusStyle = BORDER_RADIUS_STYLES.none,
|
|
91
81
|
className,
|
|
92
|
-
inView,
|
|
93
|
-
loading,
|
|
82
|
+
inView = true,
|
|
83
|
+
loading = false,
|
|
94
84
|
onLoad,
|
|
95
|
-
style,
|
|
85
|
+
style = {},
|
|
96
86
|
...rest
|
|
97
87
|
} = this.props;
|
|
98
88
|
const classNames = [getClassName('bpk-image')];
|
|
@@ -120,19 +110,21 @@ class BpkImage extends Component {
|
|
|
120
110
|
paddingBottom: aspectRatioPercentage
|
|
121
111
|
},
|
|
122
112
|
className: classNames.join(' '),
|
|
123
|
-
suppressHydrationWarning: this.props.suppressHydrationWarning,
|
|
113
|
+
suppressHydrationWarning: !!this.props.suppressHydrationWarning,
|
|
124
114
|
children: [inView && /*#__PURE__*/_jsx(Image, {
|
|
125
115
|
hidden: loading,
|
|
126
116
|
altText: altText,
|
|
127
117
|
onImageLoad: this.onImageLoad,
|
|
128
118
|
...rest
|
|
129
119
|
}), loading && /*#__PURE__*/_jsx(CSSTransition, {
|
|
120
|
+
nodeRef: this.spinnerNodeRef,
|
|
130
121
|
classNames: {
|
|
131
122
|
exit: getClassName('bpk-image__spinner--shown'),
|
|
132
123
|
exitActive: getClassName('bpk-image__spinner--hidden')
|
|
133
124
|
},
|
|
134
125
|
timeout: parseInt(animations.durationBase, 10),
|
|
135
126
|
children: /*#__PURE__*/_jsx("div", {
|
|
127
|
+
ref: this.spinnerNodeRef,
|
|
136
128
|
className: getClassName('bpk-image__spinner'),
|
|
137
129
|
children: /*#__PURE__*/_jsx(BpkSpinner, {})
|
|
138
130
|
})
|
|
@@ -43,10 +43,6 @@ export default function withLazyLoading<P extends object>(WrappedComponent: Comp
|
|
|
43
43
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, nextState: Readonly<WithLazyLoadingState>, nextContext: any): void;
|
|
44
44
|
};
|
|
45
45
|
displayName: string;
|
|
46
|
-
defaultProps: {
|
|
47
|
-
style: {};
|
|
48
|
-
className: string;
|
|
49
|
-
};
|
|
50
46
|
contextType?: import("react").Context<any> | undefined;
|
|
51
47
|
};
|
|
52
48
|
export {};
|
|
@@ -22,10 +22,6 @@ import { wrapDisplayName } from "../../bpk-react-utils";
|
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
export default function withLazyLoading(WrappedComponent, documentRef) {
|
|
24
24
|
class WithLazyLoading extends Component {
|
|
25
|
-
static defaultProps = {
|
|
26
|
-
style: {},
|
|
27
|
-
className: ''
|
|
28
|
-
};
|
|
29
25
|
constructor(props) {
|
|
30
26
|
super(props);
|
|
31
27
|
this.state = {
|
|
@@ -102,8 +98,8 @@ export default function withLazyLoading(WrappedComponent, documentRef) {
|
|
|
102
98
|
};
|
|
103
99
|
render() {
|
|
104
100
|
const {
|
|
105
|
-
className,
|
|
106
|
-
style,
|
|
101
|
+
className = '',
|
|
102
|
+
style = {},
|
|
107
103
|
...rest
|
|
108
104
|
} = this.props;
|
|
109
105
|
return /*#__PURE__*/_jsx("div", {
|
|
@@ -49,9 +49,6 @@ const withInfiniteScroll = ComponentToExtend => class WithInfiniteScroll extends
|
|
|
49
49
|
static propTypes = {
|
|
50
50
|
...propTypes
|
|
51
51
|
};
|
|
52
|
-
static defaultProps = {
|
|
53
|
-
...defaultProps
|
|
54
|
-
};
|
|
55
52
|
constructor(props) {
|
|
56
53
|
super(props);
|
|
57
54
|
this.state = {
|
|
@@ -73,7 +70,7 @@ const withInfiniteScroll = ComponentToExtend => class WithInfiniteScroll extends
|
|
|
73
70
|
componentDidMount() {
|
|
74
71
|
this.props.dataSource.onDataChange(this.updateData);
|
|
75
72
|
this.fetchItems({
|
|
76
|
-
elementsPerScroll: this.props.initiallyLoadedElements
|
|
73
|
+
elementsPerScroll: this.props.initiallyLoadedElements ?? defaultProps.initiallyLoadedElements
|
|
77
74
|
}).then(newState => {
|
|
78
75
|
this.setState(newState);
|
|
79
76
|
});
|
|
@@ -87,7 +84,7 @@ const withInfiniteScroll = ComponentToExtend => class WithInfiniteScroll extends
|
|
|
87
84
|
this.props.dataSource.onDataChange(this.updateData);
|
|
88
85
|
this.fetchItems({
|
|
89
86
|
index: 0,
|
|
90
|
-
elementsPerScroll: this.props.elementsPerScroll,
|
|
87
|
+
elementsPerScroll: this.props.elementsPerScroll ?? defaultProps.elementsPerScroll,
|
|
91
88
|
elementsToRender: []
|
|
92
89
|
}).then(newState => this.setStateAfterDsUpdate(newState));
|
|
93
90
|
}
|
|
@@ -118,14 +115,15 @@ const withInfiniteScroll = ComponentToExtend => class WithInfiniteScroll extends
|
|
|
118
115
|
const {
|
|
119
116
|
index
|
|
120
117
|
} = this.state;
|
|
118
|
+
const elementsPerScroll = this.props.elementsPerScroll ?? defaultProps.elementsPerScroll;
|
|
121
119
|
// This means updateData was called before any data was loaded, e.g.
|
|
122
120
|
// An ArrayDataSource initialized empty and then changed latter on via `updateData`
|
|
123
121
|
// In this case we want to load new data and not just replace the old one.
|
|
124
122
|
// "See More After" should also be computed again in this case.
|
|
125
|
-
const isFirstLoad = index <
|
|
123
|
+
const isFirstLoad = index < elementsPerScroll;
|
|
126
124
|
this.fetchItems({
|
|
127
125
|
index: 0,
|
|
128
|
-
elementsPerScroll: isFirstLoad ?
|
|
126
|
+
elementsPerScroll: isFirstLoad ? elementsPerScroll : index,
|
|
129
127
|
elementsToRender: [],
|
|
130
128
|
computeShowSeeMore: isFirstLoad
|
|
131
129
|
}).then(newState => this.setStateAfterDsUpdate(newState));
|
|
@@ -142,7 +140,7 @@ const withInfiniteScroll = ComponentToExtend => class WithInfiniteScroll extends
|
|
|
142
140
|
index
|
|
143
141
|
} = extend({
|
|
144
142
|
index: this.state.index,
|
|
145
|
-
elementsPerScroll: this.props.elementsPerScroll,
|
|
143
|
+
elementsPerScroll: this.props.elementsPerScroll ?? defaultProps.elementsPerScroll,
|
|
146
144
|
elementsToRender: this.state.elementsToRender,
|
|
147
145
|
computeShowSeeMore: true
|
|
148
146
|
}, config);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ReactNode, RefObject } from 'react';
|
|
3
3
|
type Props = {
|
|
4
|
-
animateOnEnter
|
|
5
|
-
animateOnLeave
|
|
4
|
+
animateOnEnter?: boolean;
|
|
5
|
+
animateOnLeave?: boolean;
|
|
6
6
|
children: ReactNode | string;
|
|
7
7
|
show: boolean;
|
|
8
8
|
className?: string | undefined;
|
|
@@ -16,15 +16,12 @@ type State = {
|
|
|
16
16
|
};
|
|
17
17
|
declare class AnimateAndFade extends Component<Props, State> {
|
|
18
18
|
toggleImmediately: boolean;
|
|
19
|
-
static defaultProps: {
|
|
20
|
-
animateOnEnter: boolean;
|
|
21
|
-
animateOnLeave: boolean;
|
|
22
|
-
};
|
|
23
19
|
constructor(props: Props);
|
|
24
20
|
componentDidMount(): void;
|
|
25
21
|
componentDidUpdate(prevProps: Props): void;
|
|
26
22
|
onAnimateHeightComplete: () => void;
|
|
27
23
|
onFadeComplete: () => void;
|
|
24
|
+
nodeRef: RefObject<HTMLElement>;
|
|
28
25
|
toggle: () => void;
|
|
29
26
|
render(): import("react/jsx-runtime").JSX.Element | null;
|
|
30
27
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { Component } from 'react';
|
|
19
|
+
import { Component, cloneElement, createRef, isValidElement } from 'react';
|
|
20
20
|
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
|
21
21
|
import { durationSm } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
22
22
|
import BpkAnimateHeight from "../../bpk-animate-height";
|
|
@@ -26,14 +26,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
26
26
|
const getClassName = cssModules(STYLES);
|
|
27
27
|
const ANIMATION_DURATION = parseInt(durationSm, 10);
|
|
28
28
|
class AnimateAndFade extends Component {
|
|
29
|
-
static defaultProps = {
|
|
30
|
-
animateOnEnter: false,
|
|
31
|
-
animateOnLeave: false
|
|
32
|
-
};
|
|
33
29
|
constructor(props) {
|
|
34
30
|
super(props);
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const {
|
|
32
|
+
animateOnEnter = false,
|
|
33
|
+
show
|
|
34
|
+
} = props;
|
|
35
|
+
this.toggleImmediately = show && animateOnEnter;
|
|
36
|
+
const initiallyShown = this.toggleImmediately ? false : show;
|
|
37
37
|
this.state = {
|
|
38
38
|
isExpanded: initiallyShown,
|
|
39
39
|
visible: initiallyShown,
|
|
@@ -78,6 +78,7 @@ class AnimateAndFade extends Component {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
+
nodeRef = /*#__PURE__*/createRef();
|
|
81
82
|
toggle = () => {
|
|
82
83
|
if (this.state.visible && this.state.isExpanded) {
|
|
83
84
|
this.setState({
|
|
@@ -93,8 +94,8 @@ class AnimateAndFade extends Component {
|
|
|
93
94
|
};
|
|
94
95
|
render() {
|
|
95
96
|
const {
|
|
96
|
-
animateOnEnter,
|
|
97
|
-
animateOnLeave,
|
|
97
|
+
animateOnEnter = false,
|
|
98
|
+
animateOnLeave = false,
|
|
98
99
|
children,
|
|
99
100
|
className
|
|
100
101
|
} = this.props;
|
|
@@ -119,6 +120,7 @@ class AnimateAndFade extends Component {
|
|
|
119
120
|
appear: animateOnEnter,
|
|
120
121
|
onTransitionEnd: this.onFadeComplete,
|
|
121
122
|
children: this.state.visible && /*#__PURE__*/_jsx(CSSTransition, {
|
|
123
|
+
nodeRef: this.nodeRef,
|
|
122
124
|
classNames: {
|
|
123
125
|
exit: getClassName('bpk-animate-and-fade--leave'),
|
|
124
126
|
exitActive: getClassName('bpk-animate-and-fade--leave-active'),
|
|
@@ -131,7 +133,9 @@ class AnimateAndFade extends Component {
|
|
|
131
133
|
enter: ANIMATION_DURATION * 2,
|
|
132
134
|
exit: ANIMATION_DURATION * 2
|
|
133
135
|
},
|
|
134
|
-
children: children
|
|
136
|
+
children: /*#__PURE__*/isValidElement(children) ? /*#__PURE__*/cloneElement(children, {
|
|
137
|
+
ref: this.nodeRef
|
|
138
|
+
}) : children
|
|
135
139
|
})
|
|
136
140
|
})]
|
|
137
141
|
})
|
|
@@ -71,16 +71,6 @@ declare const withBannerAlertState: <P extends BpkInfoBannerProps>(WrappedCompon
|
|
|
71
71
|
}>, nextContext: any): void;
|
|
72
72
|
};
|
|
73
73
|
displayName: string;
|
|
74
|
-
defaultProps: {
|
|
75
|
-
onDismiss: null;
|
|
76
|
-
onExpandToggle: null;
|
|
77
|
-
onHide: null;
|
|
78
|
-
expanded: boolean;
|
|
79
|
-
show: boolean;
|
|
80
|
-
hideAfter: null;
|
|
81
|
-
animateOnLeave: boolean;
|
|
82
|
-
children: null;
|
|
83
|
-
};
|
|
84
74
|
contextType?: import("react").Context<any> | undefined;
|
|
85
75
|
};
|
|
86
76
|
export default withBannerAlertState;
|
|
@@ -22,20 +22,10 @@ import BpkInfoBannerExpandable from "./BpkInfoBannerExpandable";
|
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
const withBannerAlertState = WrappedComponent => {
|
|
24
24
|
class component extends Component {
|
|
25
|
-
static defaultProps = {
|
|
26
|
-
onDismiss: null,
|
|
27
|
-
onExpandToggle: null,
|
|
28
|
-
onHide: null,
|
|
29
|
-
expanded: false,
|
|
30
|
-
show: true,
|
|
31
|
-
hideAfter: null,
|
|
32
|
-
animateOnLeave: false,
|
|
33
|
-
children: null
|
|
34
|
-
};
|
|
35
25
|
constructor(props) {
|
|
36
26
|
super(props);
|
|
37
27
|
this.state = {
|
|
38
|
-
expanded: props.expanded,
|
|
28
|
+
expanded: props.expanded ?? false,
|
|
39
29
|
show: true
|
|
40
30
|
};
|
|
41
31
|
this.hideIntervalId = null;
|
|
@@ -84,8 +74,8 @@ const withBannerAlertState = WrappedComponent => {
|
|
|
84
74
|
};
|
|
85
75
|
render() {
|
|
86
76
|
const {
|
|
87
|
-
animateOnLeave,
|
|
88
|
-
children,
|
|
77
|
+
animateOnLeave = false,
|
|
78
|
+
children = null,
|
|
89
79
|
expanded,
|
|
90
80
|
hideAfter,
|
|
91
81
|
onDismiss,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BpkInput from './src/BpkInput';
|
|
2
|
-
import {
|
|
2
|
+
import { CLEAR_BUTTON_MODES, INPUT_TYPES, type Props } from './src/common-types';
|
|
3
3
|
import themeAttributes from './src/themeAttributes';
|
|
4
4
|
import withOpenEvents from './src/withOpenEvents';
|
|
5
5
|
export default BpkInput;
|
|
6
6
|
export type BpkInputProps = Props;
|
|
7
|
-
export {
|
|
7
|
+
export { withOpenEvents, INPUT_TYPES, CLEAR_BUTTON_MODES, themeAttributes };
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import BpkInput from "./src/BpkInput";
|
|
20
|
-
import {
|
|
20
|
+
import { CLEAR_BUTTON_MODES, INPUT_TYPES } from "./src/common-types";
|
|
21
21
|
import themeAttributes from "./src/themeAttributes";
|
|
22
22
|
import withOpenEvents from "./src/withOpenEvents";
|
|
23
23
|
export default BpkInput;
|
|
24
|
-
export {
|
|
24
|
+
export { withOpenEvents, INPUT_TYPES, CLEAR_BUTTON_MODES, themeAttributes };
|
|
@@ -4,19 +4,6 @@ type State = {
|
|
|
4
4
|
persistClearButton: boolean;
|
|
5
5
|
};
|
|
6
6
|
declare class BpkInput extends Component<Props, State> {
|
|
7
|
-
static defaultProps: {
|
|
8
|
-
type: "text";
|
|
9
|
-
valid: null;
|
|
10
|
-
large: boolean;
|
|
11
|
-
docked: boolean;
|
|
12
|
-
dockedFirst: boolean;
|
|
13
|
-
dockedMiddle: boolean;
|
|
14
|
-
dockedLast: boolean;
|
|
15
|
-
inputRef: null;
|
|
16
|
-
clearButtonMode: "never";
|
|
17
|
-
clearButtonLabel: null;
|
|
18
|
-
onClear: null;
|
|
19
|
-
};
|
|
20
7
|
constructor(props: Props);
|
|
21
8
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
22
9
|
}
|
|
@@ -20,13 +20,12 @@ import { Component } from 'react';
|
|
|
20
20
|
import { withButtonAlignment } from "../../bpk-component-icon";
|
|
21
21
|
import ClearIcon from "../../bpk-component-icon/sm/close-circle";
|
|
22
22
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
23
|
-
import { CLEAR_BUTTON_MODES,
|
|
23
|
+
import { CLEAR_BUTTON_MODES, INPUT_TYPES } from "./common-types";
|
|
24
24
|
import STYLES from "./BpkInput.module.css";
|
|
25
25
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
26
|
const getClassName = cssModules(STYLES);
|
|
27
27
|
const ClearButtonIcon = withButtonAlignment(ClearIcon);
|
|
28
28
|
class BpkInput extends Component {
|
|
29
|
-
static defaultProps = defaultProps;
|
|
30
29
|
constructor(props) {
|
|
31
30
|
super(props);
|
|
32
31
|
this.state = {
|
|
@@ -39,17 +38,18 @@ class BpkInput extends Component {
|
|
|
39
38
|
const clearButtonClassNames = [getClassName('bpk-input__clear-button')];
|
|
40
39
|
const {
|
|
41
40
|
className,
|
|
42
|
-
clearButtonLabel,
|
|
43
|
-
clearButtonMode,
|
|
44
|
-
docked,
|
|
45
|
-
dockedFirst,
|
|
46
|
-
dockedLast,
|
|
47
|
-
dockedMiddle,
|
|
48
|
-
inputRef,
|
|
49
|
-
large,
|
|
41
|
+
clearButtonLabel = null,
|
|
42
|
+
clearButtonMode = CLEAR_BUTTON_MODES.never,
|
|
43
|
+
docked = false,
|
|
44
|
+
dockedFirst = false,
|
|
45
|
+
dockedLast = false,
|
|
46
|
+
dockedMiddle = false,
|
|
47
|
+
inputRef = null,
|
|
48
|
+
large = false,
|
|
50
49
|
name,
|
|
51
|
-
onClear,
|
|
52
|
-
|
|
50
|
+
onClear = null,
|
|
51
|
+
type = INPUT_TYPES.text,
|
|
52
|
+
valid = null,
|
|
53
53
|
value,
|
|
54
54
|
...rest
|
|
55
55
|
} = this.props;
|
|
@@ -105,6 +105,7 @@ class BpkInput extends Component {
|
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
"aria-invalid": isInvalid,
|
|
108
|
+
type: type,
|
|
108
109
|
value: value,
|
|
109
110
|
name: name,
|
|
110
111
|
...getDataComponentAttribute('Input'),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import type { ComponentProps, SyntheticEvent } from 'react';
|
|
3
2
|
export declare const CLEAR_BUTTON_MODES: {
|
|
4
3
|
readonly never: "never";
|
|
@@ -50,35 +49,4 @@ export type PropsWithClearButtonMode = BaseProps & {
|
|
|
50
49
|
onClear: (e?: SyntheticEvent<HTMLButtonElement>) => void;
|
|
51
50
|
};
|
|
52
51
|
export type Props = PropsWithoutClearButonMode | PropsWithClearButtonMode;
|
|
53
|
-
export declare const clearablePropType: (props: any, propName: string, componentName: string) => Error | null;
|
|
54
|
-
export declare const propTypes: {
|
|
55
|
-
id: PropTypes.Validator<string>;
|
|
56
|
-
name: PropTypes.Validator<string>;
|
|
57
|
-
value: PropTypes.Validator<string>;
|
|
58
|
-
type: PropTypes.Requireable<"number" | "text" | "tel" | "email" | "password">;
|
|
59
|
-
className: PropTypes.Requireable<string>;
|
|
60
|
-
valid: PropTypes.Requireable<boolean>;
|
|
61
|
-
large: PropTypes.Requireable<boolean>;
|
|
62
|
-
docked: PropTypes.Requireable<boolean>;
|
|
63
|
-
dockedFirst: PropTypes.Requireable<boolean>;
|
|
64
|
-
dockedMiddle: PropTypes.Requireable<boolean>;
|
|
65
|
-
dockedLast: PropTypes.Requireable<boolean>;
|
|
66
|
-
inputRef: PropTypes.Requireable<(...args: any[]) => any>;
|
|
67
|
-
clearButtonMode: PropTypes.Requireable<string>;
|
|
68
|
-
clearButtonLabel: (props: any, propName: string, componentName: string) => Error | null;
|
|
69
|
-
onClear: (props: any, propName: string, componentName: string) => Error | null;
|
|
70
|
-
};
|
|
71
|
-
export declare const defaultProps: {
|
|
72
|
-
type: "text";
|
|
73
|
-
valid: null;
|
|
74
|
-
large: boolean;
|
|
75
|
-
docked: boolean;
|
|
76
|
-
dockedFirst: boolean;
|
|
77
|
-
dockedMiddle: boolean;
|
|
78
|
-
dockedLast: boolean;
|
|
79
|
-
inputRef: null;
|
|
80
|
-
clearButtonMode: "never";
|
|
81
|
-
clearButtonLabel: null;
|
|
82
|
-
onClear: null;
|
|
83
|
-
};
|
|
84
52
|
export {};
|