@skyscanner/backpack-web 25.1.0 → 25.3.0
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-badge/src/BpkBadge.js +4 -4
- package/bpk-component-breakpoint/index.d.ts +21 -0
- package/bpk-component-breakpoint/src/BpkBreakpoint.d.ts +39 -0
- package/bpk-component-breakpoint/src/BpkBreakpoint.js +18 -24
- package/bpk-component-button/src/BpkButtonV2/BpkButton.js +7 -7
- package/bpk-component-calendar/index.d.ts +4 -1
- package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +15 -7
- package/bpk-component-calendar/src/BpkCalendarContainer.js +4 -2
- package/bpk-component-calendar/src/BpkCalendarDate.d.ts +12 -12
- package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +4 -4
- package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +1 -1
- package/bpk-component-calendar/src/Week.d.ts +9 -9
- package/bpk-component-calendar/src/Week.js +2 -2
- package/bpk-component-card/src/BpkCardWrapper.module.css +1 -1
- package/bpk-component-card/src/BpkDividedCard.js +3 -3
- package/bpk-component-chip/src/BpkDismissibleChip.js +3 -3
- package/bpk-component-chip/src/BpkSelectableChip.js +7 -7
- package/bpk-component-datepicker/index.d.ts +23 -0
- package/bpk-component-datepicker/src/BpkDatepicker.d.ts +533 -0
- package/bpk-component-datepicker/src/BpkDatepicker.js +9 -46
- package/bpk-component-datepicker/src/themeAttributes.js +1 -0
- package/bpk-component-image/index.d.ts +27 -0
- package/bpk-component-image/src/BpkBackgroundImage.d.ts +50 -0
- package/bpk-component-image/src/BpkBackgroundImage.js +4 -16
- package/bpk-component-image/src/BpkImage.d.ts +48 -0
- package/bpk-component-image/src/BpkImage.js +10 -36
- package/bpk-component-image/src/BpkImageBorderRadiusStyles.d.ts +23 -0
- package/bpk-component-image/src/BpkImageBorderRadiusStyles.js +3 -1
- package/bpk-component-image/src/withLazyLoading.d.ts +73 -0
- package/bpk-component-image/src/withLazyLoading.js +18 -28
- package/bpk-component-image/src/withLoadingBehavior.d.ts +57 -0
- package/bpk-component-image/src/withLoadingBehavior.js +3 -2
- package/bpk-component-input/index.d.ts +2 -16
- package/bpk-component-input/src/BpkClearButton.d.ts +5 -9
- package/bpk-component-input/src/BpkInput.d.ts +16 -21
- package/bpk-component-input/src/common-types.d.ts +3 -6
- package/bpk-component-input/src/common-types.js +0 -1
- package/bpk-component-input/src/withOpenEvents.d.ts +56 -97
- package/bpk-component-input/src/withOpenEvents.js +0 -1
- package/bpk-component-modal/src/BpkModal.js +13 -13
- package/bpk-component-modal/src/BpkModalInner.js +10 -10
- package/bpk-component-radio/src/BpkRadio.module.css +1 -1
- package/bpk-component-scrollable-calendar/index.d.ts +25 -0
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendar.d.ts +596 -0
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarDate.d.ts +32 -0
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarDate.js +21 -28
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.d.ts +29 -0
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.js +8 -7
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.d.ts +56 -0
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.js +8 -15
- package/bpk-component-scrollable-calendar/src/utils.d.ts +21 -0
- package/bpk-component-scrollable-calendar/src/utils.js +1 -1
- package/bpk-component-scrollable-calendar/test-utils.d.ts +52 -0
- package/bpk-component-scrollable-calendar/test-utils.js +2 -2
- package/bpk-component-text/src/BpkText.js +4 -4
- package/bpk-scrim-utils/src/withScrim.js +33 -31
- package/package.json +4 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkImage from './src/BpkImage';
|
|
20
|
+
import BpkBackgroundImage from './src/BpkBackgroundImage';
|
|
21
|
+
import type { BpkBackgroundImageProps } from './src/BpkBackgroundImage';
|
|
22
|
+
import withLazyLoading from './src/withLazyLoading';
|
|
23
|
+
import withLoadingBehavior from './src/withLoadingBehavior';
|
|
24
|
+
import BORDER_RADIUS_STYLES from './src/BpkImageBorderRadiusStyles';
|
|
25
|
+
export type { BpkBackgroundImageProps };
|
|
26
|
+
export default BpkImage;
|
|
27
|
+
export { BpkBackgroundImage, withLazyLoading, withLoadingBehavior, BORDER_RADIUS_STYLES, };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { Component, CSSProperties } from 'react';
|
|
20
|
+
import type { ReactNode } from 'react';
|
|
21
|
+
export type BpkBackgroundImageProps = {
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
aspectRatio: number;
|
|
24
|
+
inView?: boolean;
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
src: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
onLoad?: (() => void) | null;
|
|
29
|
+
style?: {};
|
|
30
|
+
imageStyle?: CSSProperties;
|
|
31
|
+
};
|
|
32
|
+
declare class BpkBackgroundImage extends Component<BpkBackgroundImageProps> {
|
|
33
|
+
trackImg?: HTMLImageElement | null;
|
|
34
|
+
static defaultProps: {
|
|
35
|
+
className: string;
|
|
36
|
+
inView: boolean;
|
|
37
|
+
loading: boolean;
|
|
38
|
+
onLoad: null;
|
|
39
|
+
style: {};
|
|
40
|
+
imageStyle: {};
|
|
41
|
+
};
|
|
42
|
+
constructor(props: BpkBackgroundImageProps);
|
|
43
|
+
componentDidMount(): void;
|
|
44
|
+
UNSAFE_componentWillReceiveProps(newProps: BpkBackgroundImageProps): void;
|
|
45
|
+
onBackgroundImageLoad: () => void;
|
|
46
|
+
getAspectRatio: () => number;
|
|
47
|
+
startImageLoad: () => void;
|
|
48
|
+
render(): JSX.Element;
|
|
49
|
+
}
|
|
50
|
+
export default BpkBackgroundImage;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
8
|
var _CSSTransition = _interopRequireDefault(require("react-transition-group/CSSTransition"));
|
|
10
9
|
var _base = require("@skyscanner/bpk-foundations-web/tokens/base.es6");
|
|
11
10
|
var _bpkReactUtils = require("../../bpk-react-utils");
|
|
@@ -33,14 +32,14 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
33
32
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
33
|
* See the License for the specific language governing permissions and
|
|
35
34
|
* limitations under the License.
|
|
36
|
-
*/
|
|
35
|
+
*/ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
36
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
37
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
37
38
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkBackgroundImageModule.default);
|
|
38
39
|
class BpkBackgroundImage extends _react.Component {
|
|
39
40
|
constructor(props) {
|
|
40
41
|
super(props);
|
|
41
42
|
_defineProperty(this, "trackImg", void 0);
|
|
42
|
-
_defineProperty(this, "startImageLoad", void 0);
|
|
43
|
-
_defineProperty(this, "onBackgroundImageLoad", void 0);
|
|
44
43
|
_defineProperty(this, "onBackgroundImageLoad", () => {
|
|
45
44
|
if (this.props.onLoad) {
|
|
46
45
|
this.props.onLoad();
|
|
@@ -127,19 +126,8 @@ class BpkBackgroundImage extends _react.Component {
|
|
|
127
126
|
});
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
|
-
_defineProperty(BpkBackgroundImage, "propTypes", {
|
|
131
|
-
aspectRatio: _propTypes.default.number.isRequired,
|
|
132
|
-
src: _propTypes.default.string.isRequired,
|
|
133
|
-
className: _propTypes.default.string,
|
|
134
|
-
inView: _propTypes.default.bool,
|
|
135
|
-
loading: _propTypes.default.bool,
|
|
136
|
-
onLoad: _propTypes.default.func,
|
|
137
|
-
style: _propTypes.default.object,
|
|
138
|
-
// eslint-disable-line react/forbid-prop-types
|
|
139
|
-
imageStyle: _propTypes.default.object // eslint-disable-line react/forbid-prop-types
|
|
140
|
-
});
|
|
141
129
|
_defineProperty(BpkBackgroundImage, "defaultProps", {
|
|
142
|
-
className:
|
|
130
|
+
className: '',
|
|
143
131
|
inView: true,
|
|
144
132
|
loading: false,
|
|
145
133
|
onLoad: null,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { Component } from 'react';
|
|
20
|
+
import BORDER_RADIUS_STYLES from './BpkImageBorderRadiusStyles';
|
|
21
|
+
type BpkImageProps = {
|
|
22
|
+
altText: string;
|
|
23
|
+
src: string;
|
|
24
|
+
aspectRatio: number;
|
|
25
|
+
inView?: boolean;
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
borderRadiusStyle?: typeof BORDER_RADIUS_STYLES[keyof typeof BORDER_RADIUS_STYLES];
|
|
28
|
+
className?: string;
|
|
29
|
+
onLoad?: (() => void) | null;
|
|
30
|
+
style?: {};
|
|
31
|
+
suppressHydrationWarning?: boolean;
|
|
32
|
+
[rest: string]: any;
|
|
33
|
+
};
|
|
34
|
+
declare class BpkImage extends Component<BpkImageProps> {
|
|
35
|
+
placeholder?: HTMLElement | null;
|
|
36
|
+
static defaultProps: {
|
|
37
|
+
borderRadiusStyle: "none";
|
|
38
|
+
inView: boolean;
|
|
39
|
+
loading: boolean;
|
|
40
|
+
onLoad: null;
|
|
41
|
+
style: {};
|
|
42
|
+
suppressHydrationWarning: boolean;
|
|
43
|
+
};
|
|
44
|
+
onImageLoad: () => void;
|
|
45
|
+
getAspectRatio: () => number;
|
|
46
|
+
render(): JSX.Element;
|
|
47
|
+
}
|
|
48
|
+
export default BpkImage;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
8
|
var _CSSTransition = _interopRequireDefault(require("react-transition-group/CSSTransition"));
|
|
10
9
|
var _base = require("@skyscanner/bpk-foundations-web/tokens/base.es6");
|
|
11
10
|
var _bpkReactUtils = require("../../bpk-react-utils");
|
|
@@ -38,7 +37,9 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
38
37
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
38
|
* See the License for the specific language governing permissions and
|
|
40
39
|
* limitations under the License.
|
|
41
|
-
*/
|
|
40
|
+
*/ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
41
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
42
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
42
43
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkImageModule.default);
|
|
43
44
|
class Image extends _react.Component {
|
|
44
45
|
constructor(props) {
|
|
@@ -68,30 +69,20 @@ class Image extends _react.Component {
|
|
|
68
69
|
if (hidden) {
|
|
69
70
|
imgClassNames.push(getClassName('bpk-image__img--hidden'));
|
|
70
71
|
}
|
|
71
|
-
return (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
onLoad: onImageLoad,
|
|
78
|
-
ref: this.setImgRef
|
|
79
|
-
}, rest))
|
|
80
|
-
);
|
|
72
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", _objectSpread({
|
|
73
|
+
className: imgClassNames.join(' '),
|
|
74
|
+
alt: altText,
|
|
75
|
+
onLoad: onImageLoad,
|
|
76
|
+
ref: this.setImgRef
|
|
77
|
+
}, rest));
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
|
-
_defineProperty(Image, "propTypes", {
|
|
84
|
-
altText: _propTypes.default.string.isRequired,
|
|
85
|
-
hidden: _propTypes.default.bool,
|
|
86
|
-
onImageLoad: _propTypes.default.func.isRequired
|
|
87
|
-
});
|
|
88
80
|
_defineProperty(Image, "defaultProps", {
|
|
89
81
|
hidden: false
|
|
90
82
|
});
|
|
91
83
|
class BpkImage extends _react.Component {
|
|
92
84
|
constructor(...args) {
|
|
93
85
|
super(...args);
|
|
94
|
-
_defineProperty(this, "onImageLoad", void 0);
|
|
95
86
|
_defineProperty(this, "placeholder", void 0);
|
|
96
87
|
_defineProperty(this, "onImageLoad", () => {
|
|
97
88
|
if (this.props.onLoad) {
|
|
@@ -143,10 +134,7 @@ class BpkImage extends _react.Component {
|
|
|
143
134
|
},
|
|
144
135
|
className: classNames.join(' '),
|
|
145
136
|
suppressHydrationWarning: this.props.suppressHydrationWarning,
|
|
146
|
-
children: [inView &&
|
|
147
|
-
/*#__PURE__*/
|
|
148
|
-
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
|
|
149
|
-
(0, _jsxRuntime.jsx)(Image, _objectSpread({
|
|
137
|
+
children: [inView && /*#__PURE__*/(0, _jsxRuntime.jsx)(Image, _objectSpread({
|
|
150
138
|
hidden: loading,
|
|
151
139
|
altText: altText,
|
|
152
140
|
onImageLoad: this.onImageLoad
|
|
@@ -170,22 +158,8 @@ class BpkImage extends _react.Component {
|
|
|
170
158
|
});
|
|
171
159
|
}
|
|
172
160
|
}
|
|
173
|
-
_defineProperty(BpkImage, "propTypes", {
|
|
174
|
-
altText: _propTypes.default.string.isRequired,
|
|
175
|
-
src: _propTypes.default.string.isRequired,
|
|
176
|
-
aspectRatio: _propTypes.default.number.isRequired,
|
|
177
|
-
borderRadiusStyle: _propTypes.default.oneOf(Object.keys(_BpkImageBorderRadiusStyles.default)),
|
|
178
|
-
className: _propTypes.default.string,
|
|
179
|
-
inView: _propTypes.default.bool,
|
|
180
|
-
loading: _propTypes.default.bool,
|
|
181
|
-
onLoad: _propTypes.default.func,
|
|
182
|
-
style: _propTypes.default.object,
|
|
183
|
-
// eslint-disable-line react/forbid-prop-types
|
|
184
|
-
suppressHydrationWarning: _propTypes.default.bool
|
|
185
|
-
});
|
|
186
161
|
_defineProperty(BpkImage, "defaultProps", {
|
|
187
162
|
borderRadiusStyle: _BpkImageBorderRadiusStyles.default.none,
|
|
188
|
-
className: null,
|
|
189
163
|
inView: true,
|
|
190
164
|
loading: false,
|
|
191
165
|
onLoad: null,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
declare const BORDER_RADIUS_STYLES: {
|
|
20
|
+
readonly none: "none";
|
|
21
|
+
readonly sm: "sm";
|
|
22
|
+
};
|
|
23
|
+
export default BORDER_RADIUS_STYLES;
|
|
@@ -20,7 +20,9 @@ exports.default = void 0;
|
|
|
20
20
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
21
|
* See the License for the specific language governing permissions and
|
|
22
22
|
* limitations under the License.
|
|
23
|
-
*/
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const BORDER_RADIUS_STYLES = {
|
|
24
26
|
none: 'none',
|
|
25
27
|
sm: 'sm'
|
|
26
28
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/// <reference types="lodash" />
|
|
20
|
+
import type { ComponentType } from 'react';
|
|
21
|
+
type WithLazyLoadingProps = {
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: {};
|
|
24
|
+
[rest: string]: any;
|
|
25
|
+
};
|
|
26
|
+
type WithLazyLoadingState = {
|
|
27
|
+
inView: boolean;
|
|
28
|
+
};
|
|
29
|
+
export default function withLazyLoading<P extends object>(WrappedComponent: ComponentType<P>, documentRef?: Document | null): {
|
|
30
|
+
new (props: Omit<P, 'inView'> & WithLazyLoadingProps): {
|
|
31
|
+
element?: HTMLElement | null | undefined;
|
|
32
|
+
placeholderReference?: string | undefined;
|
|
33
|
+
componentDidMount(): void;
|
|
34
|
+
componentWillUnmount(): void;
|
|
35
|
+
setInView: () => void;
|
|
36
|
+
getPassiveArgs(): {
|
|
37
|
+
capture: boolean;
|
|
38
|
+
passive?: boolean;
|
|
39
|
+
};
|
|
40
|
+
removeEventListeners: () => void;
|
|
41
|
+
checkInView: import("lodash").DebouncedFunc<() => void>;
|
|
42
|
+
supportsPassiveEvents: () => boolean;
|
|
43
|
+
isInViewPort: () => boolean;
|
|
44
|
+
render(): JSX.Element;
|
|
45
|
+
context: any;
|
|
46
|
+
setState<K extends "inView">(state: WithLazyLoadingState | ((prevState: Readonly<WithLazyLoadingState>, props: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>) => WithLazyLoadingState | Pick<WithLazyLoadingState, K> | null) | Pick<WithLazyLoadingState, K> | null, callback?: (() => void) | undefined): void;
|
|
47
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
48
|
+
readonly props: Readonly<Omit<P, "inView"> & WithLazyLoadingProps> & Readonly<{
|
|
49
|
+
children?: import("react").ReactNode;
|
|
50
|
+
}>;
|
|
51
|
+
state: Readonly<WithLazyLoadingState>;
|
|
52
|
+
refs: {
|
|
53
|
+
[key: string]: import("react").ReactInstance;
|
|
54
|
+
};
|
|
55
|
+
shouldComponentUpdate?(nextProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, nextState: Readonly<WithLazyLoadingState>, nextContext: any): boolean;
|
|
56
|
+
componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
|
|
57
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, prevState: Readonly<WithLazyLoadingState>): any;
|
|
58
|
+
componentDidUpdate?(prevProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, prevState: Readonly<WithLazyLoadingState>, snapshot?: any): void;
|
|
59
|
+
componentWillMount?(): void;
|
|
60
|
+
UNSAFE_componentWillMount?(): void;
|
|
61
|
+
componentWillReceiveProps?(nextProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, nextContext: any): void;
|
|
62
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, nextContext: any): void;
|
|
63
|
+
componentWillUpdate?(nextProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, nextState: Readonly<WithLazyLoadingState>, nextContext: any): void;
|
|
64
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<P, "inView"> & WithLazyLoadingProps>, nextState: Readonly<WithLazyLoadingState>, nextContext: any): void;
|
|
65
|
+
};
|
|
66
|
+
displayName: string;
|
|
67
|
+
defaultProps: {
|
|
68
|
+
style: {};
|
|
69
|
+
className: string;
|
|
70
|
+
};
|
|
71
|
+
contextType?: import("react").Context<any> | undefined;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = withLazyLoading;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
8
|
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
10
9
|
var _bpkReactUtils = require("../../bpk-react-utils");
|
|
11
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -36,16 +35,10 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
36
35
|
*/
|
|
37
36
|
function withLazyLoading(WrappedComponent, documentRef) {
|
|
38
37
|
class WithLazyLoading extends _react.Component {
|
|
39
|
-
constructor() {
|
|
40
|
-
super();
|
|
41
|
-
_defineProperty(this, "checkInView", void 0);
|
|
38
|
+
constructor(props) {
|
|
39
|
+
super(props);
|
|
42
40
|
_defineProperty(this, "element", void 0);
|
|
43
|
-
_defineProperty(this, "isInViewPort", void 0);
|
|
44
41
|
_defineProperty(this, "placeholderReference", void 0);
|
|
45
|
-
_defineProperty(this, "removeEventListeners", void 0);
|
|
46
|
-
_defineProperty(this, "setInView", void 0);
|
|
47
|
-
_defineProperty(this, "state", void 0);
|
|
48
|
-
_defineProperty(this, "supportsPassiveEvents", void 0);
|
|
49
42
|
_defineProperty(this, "setInView", () => {
|
|
50
43
|
this.setState(() => ({
|
|
51
44
|
inView: true
|
|
@@ -53,10 +46,10 @@ function withLazyLoading(WrappedComponent, documentRef) {
|
|
|
53
46
|
this.removeEventListeners();
|
|
54
47
|
});
|
|
55
48
|
_defineProperty(this, "removeEventListeners", () => {
|
|
56
|
-
documentRef
|
|
57
|
-
documentRef
|
|
58
|
-
documentRef
|
|
59
|
-
documentRef
|
|
49
|
+
documentRef?.removeEventListener('scroll', this.checkInView, _objectSpread({}, this.getPassiveArgs()));
|
|
50
|
+
documentRef?.removeEventListener('resize', this.checkInView);
|
|
51
|
+
documentRef?.removeEventListener('orientationchange', this.checkInView);
|
|
52
|
+
documentRef?.removeEventListener('fullscreenchange', this.checkInView);
|
|
60
53
|
});
|
|
61
54
|
_defineProperty(this, "checkInView", (0, _throttle.default)(() => {
|
|
62
55
|
if (this.isInViewPort()) {
|
|
@@ -74,8 +67,9 @@ function withLazyLoading(WrappedComponent, documentRef) {
|
|
|
74
67
|
return supportsPassiveOption;
|
|
75
68
|
}
|
|
76
69
|
});
|
|
77
|
-
|
|
78
|
-
window.
|
|
70
|
+
const noop = function () {};
|
|
71
|
+
window.addEventListener('test', noop, opts);
|
|
72
|
+
window.removeEventListener('test', noop, opts);
|
|
79
73
|
} catch (e) {
|
|
80
74
|
return false;
|
|
81
75
|
}
|
|
@@ -84,8 +78,8 @@ function withLazyLoading(WrappedComponent, documentRef) {
|
|
|
84
78
|
_defineProperty(this, "isInViewPort", () => {
|
|
85
79
|
if (!this.element) return false;
|
|
86
80
|
const rect = this.element.getBoundingClientRect();
|
|
87
|
-
const viewPortHeight = Math.max(window.innerHeight, documentRef.documentElement.clientHeight);
|
|
88
|
-
const viewPortWidth = Math.max(window.innerWidth, documentRef.documentElement.clientWidth);
|
|
81
|
+
const viewPortHeight = documentRef ? Math.max(window.innerHeight, documentRef.documentElement.clientHeight) : -1;
|
|
82
|
+
const viewPortWidth = documentRef ? Math.max(window.innerWidth, documentRef.documentElement.clientWidth) : -1;
|
|
89
83
|
return rect.bottom >= 0 && rect.right >= 0 && rect.top < viewPortHeight && rect.left < viewPortWidth;
|
|
90
84
|
});
|
|
91
85
|
this.state = {
|
|
@@ -93,10 +87,10 @@ function withLazyLoading(WrappedComponent, documentRef) {
|
|
|
93
87
|
};
|
|
94
88
|
}
|
|
95
89
|
componentDidMount() {
|
|
96
|
-
documentRef
|
|
97
|
-
documentRef
|
|
98
|
-
documentRef
|
|
99
|
-
documentRef
|
|
90
|
+
documentRef?.addEventListener('scroll', this.checkInView, _objectSpread({}, this.getPassiveArgs()));
|
|
91
|
+
documentRef?.addEventListener('resize', this.checkInView);
|
|
92
|
+
documentRef?.addEventListener('orientationchange', this.checkInView);
|
|
93
|
+
documentRef?.addEventListener('fullscreenchange', this.checkInView);
|
|
100
94
|
// call checkInView immediately incase the
|
|
101
95
|
// component is already in view prior to scrolling
|
|
102
96
|
this.checkInView();
|
|
@@ -132,14 +126,10 @@ function withLazyLoading(WrappedComponent, documentRef) {
|
|
|
132
126
|
});
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
|
-
_defineProperty(WithLazyLoading, "
|
|
136
|
-
style: _propTypes.default.object,
|
|
137
|
-
// eslint-disable-line react/forbid-prop-types
|
|
138
|
-
className: _propTypes.default.string
|
|
139
|
-
});
|
|
129
|
+
_defineProperty(WithLazyLoading, "displayName", void 0);
|
|
140
130
|
_defineProperty(WithLazyLoading, "defaultProps", {
|
|
141
|
-
style:
|
|
142
|
-
className:
|
|
131
|
+
style: {},
|
|
132
|
+
className: ''
|
|
143
133
|
});
|
|
144
134
|
WithLazyLoading.displayName = (0, _bpkReactUtils.wrapDisplayName)(WrappedComponent, 'withLazyLoading');
|
|
145
135
|
return WithLazyLoading;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { ComponentType } from 'react';
|
|
20
|
+
type InjectedProps = {
|
|
21
|
+
onLoad: () => void;
|
|
22
|
+
loading: boolean;
|
|
23
|
+
};
|
|
24
|
+
type State = {
|
|
25
|
+
loading: boolean;
|
|
26
|
+
};
|
|
27
|
+
export default function withLoadingBehavior<P extends object>(WrappedComponent: ComponentType<P>): {
|
|
28
|
+
new (props: Omit<P, keyof InjectedProps>): {
|
|
29
|
+
onLoad: () => void;
|
|
30
|
+
render(): JSX.Element;
|
|
31
|
+
context: any;
|
|
32
|
+
setState<K extends "loading">(state: State | ((prevState: Readonly<State>, props: Readonly<Omit<P, keyof InjectedProps>>) => State | Pick<State, K> | null) | Pick<State, K> | null, callback?: (() => void) | undefined): void;
|
|
33
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
34
|
+
readonly props: Readonly<Omit<P, keyof InjectedProps>> & Readonly<{
|
|
35
|
+
children?: import("react").ReactNode;
|
|
36
|
+
}>;
|
|
37
|
+
state: Readonly<State>;
|
|
38
|
+
refs: {
|
|
39
|
+
[key: string]: import("react").ReactInstance;
|
|
40
|
+
};
|
|
41
|
+
componentDidMount?(): void;
|
|
42
|
+
shouldComponentUpdate?(nextProps: Readonly<Omit<P, keyof InjectedProps>>, nextState: Readonly<State>, nextContext: any): boolean;
|
|
43
|
+
componentWillUnmount?(): void;
|
|
44
|
+
componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
|
|
45
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<Omit<P, keyof InjectedProps>>, prevState: Readonly<State>): any;
|
|
46
|
+
componentDidUpdate?(prevProps: Readonly<Omit<P, keyof InjectedProps>>, prevState: Readonly<State>, snapshot?: any): void;
|
|
47
|
+
componentWillMount?(): void;
|
|
48
|
+
UNSAFE_componentWillMount?(): void;
|
|
49
|
+
componentWillReceiveProps?(nextProps: Readonly<Omit<P, keyof InjectedProps>>, nextContext: any): void;
|
|
50
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Omit<P, keyof InjectedProps>>, nextContext: any): void;
|
|
51
|
+
componentWillUpdate?(nextProps: Readonly<Omit<P, keyof InjectedProps>>, nextState: Readonly<State>, nextContext: any): void;
|
|
52
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<P, keyof InjectedProps>>, nextState: Readonly<State>, nextContext: any): void;
|
|
53
|
+
};
|
|
54
|
+
displayName: string;
|
|
55
|
+
contextType?: import("react").Context<any> | undefined;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -30,8 +30,8 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
30
30
|
*/
|
|
31
31
|
function withLoadingBehavior(WrappedComponent) {
|
|
32
32
|
class WithLoadingBehavior extends _react.Component {
|
|
33
|
-
constructor() {
|
|
34
|
-
super();
|
|
33
|
+
constructor(props) {
|
|
34
|
+
super(props);
|
|
35
35
|
_defineProperty(this, "onLoad", () => {
|
|
36
36
|
this.setState(() => ({
|
|
37
37
|
loading: false
|
|
@@ -48,6 +48,7 @@ function withLoadingBehavior(WrappedComponent) {
|
|
|
48
48
|
}, this.props));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
_defineProperty(WithLoadingBehavior, "displayName", void 0);
|
|
51
52
|
WithLoadingBehavior.displayName = (0, _bpkReactUtils.wrapDisplayName)(WrappedComponent, 'withLoadingBehavior');
|
|
52
53
|
return WithLoadingBehavior;
|
|
53
54
|
}
|
|
@@ -18,22 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
import BpkInput from './src/BpkInput';
|
|
20
20
|
import withOpenEvents from './src/withOpenEvents';
|
|
21
|
-
import {
|
|
22
|
-
propTypes,
|
|
23
|
-
defaultProps,
|
|
24
|
-
CLEAR_BUTTON_MODES,
|
|
25
|
-
INPUT_TYPES,
|
|
26
|
-
type Props,
|
|
27
|
-
} from './src/common-types';
|
|
21
|
+
import { propTypes, defaultProps, CLEAR_BUTTON_MODES, INPUT_TYPES, type Props } from './src/common-types';
|
|
28
22
|
import themeAttributes from './src/themeAttributes';
|
|
29
|
-
|
|
30
23
|
export default BpkInput;
|
|
31
24
|
export type BpkInputProps = Props;
|
|
32
|
-
export {
|
|
33
|
-
propTypes,
|
|
34
|
-
defaultProps,
|
|
35
|
-
withOpenEvents,
|
|
36
|
-
INPUT_TYPES,
|
|
37
|
-
CLEAR_BUTTON_MODES,
|
|
38
|
-
themeAttributes,
|
|
39
|
-
};
|
|
25
|
+
export { propTypes, defaultProps, withOpenEvents, INPUT_TYPES, CLEAR_BUTTON_MODES, themeAttributes, };
|
|
@@ -16,13 +16,9 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
label,
|
|
25
|
-
onClick,
|
|
26
|
-
...rest
|
|
27
|
-
}: Props) => JSX.Element;
|
|
19
|
+
import type { ComponentProps } from 'react';
|
|
20
|
+
interface Props extends ComponentProps<'button'> {
|
|
21
|
+
label: string;
|
|
22
|
+
}
|
|
23
|
+
declare const BpkClearButton: ({ className, label, onClick, ...rest }: Props) => JSX.Element;
|
|
28
24
|
export default BpkClearButton;
|
|
@@ -17,30 +17,25 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { Component } from 'react';
|
|
20
|
-
|
|
21
20
|
import type { Props } from './common-types';
|
|
22
|
-
|
|
23
21
|
type State = {
|
|
24
|
-
|
|
22
|
+
persistClearButton: boolean;
|
|
25
23
|
};
|
|
26
24
|
declare class BpkInput extends Component<Props, State> {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
constructor(props: Props);
|
|
43
|
-
|
|
44
|
-
render(): JSX.Element;
|
|
25
|
+
static defaultProps: {
|
|
26
|
+
type: "text";
|
|
27
|
+
valid: null;
|
|
28
|
+
large: boolean;
|
|
29
|
+
docked: boolean;
|
|
30
|
+
dockedFirst: boolean;
|
|
31
|
+
dockedMiddle: boolean;
|
|
32
|
+
dockedLast: boolean;
|
|
33
|
+
inputRef: null;
|
|
34
|
+
clearButtonMode: "never";
|
|
35
|
+
clearButtonLabel: null;
|
|
36
|
+
onClear: null;
|
|
37
|
+
};
|
|
38
|
+
constructor(props: Props);
|
|
39
|
+
render(): JSX.Element;
|
|
45
40
|
}
|
|
46
41
|
export default BpkInput;
|