@skyscanner/backpack-web 7.1.0 → 9.0.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-animate-height/package.json +4 -4
- package/bpk-component-accordion/package.json +9 -9
- package/bpk-component-aria-live/package.json +9 -9
- package/bpk-component-autosuggest/package.json +6 -6
- package/bpk-component-badge/package.json +7 -7
- package/bpk-component-banner-alert/package.json +11 -11
- package/bpk-component-barchart/package.json +10 -10
- package/bpk-component-blockquote/package.json +4 -4
- package/bpk-component-breadcrumb/package.json +7 -7
- package/bpk-component-breakpoint/package.json +6 -6
- package/bpk-component-button/package.json +4 -4
- package/bpk-component-calendar/package.json +11 -11
- package/bpk-component-card/package.json +6 -6
- package/bpk-component-checkbox/package.json +7 -7
- package/bpk-component-chip/package.json +7 -7
- package/bpk-component-close-button/package.json +6 -6
- package/bpk-component-code/package.json +4 -4
- package/bpk-component-content-container/package.json +4 -4
- package/bpk-component-datatable/package.json +6 -6
- package/bpk-component-datepicker/README.md +4 -0
- package/bpk-component-datepicker/package.json +11 -11
- package/bpk-component-datepicker/src/BpkDatepicker.js +18 -13
- package/bpk-component-datepicker/src/BpkDatepicker.module.scss +5 -0
- package/bpk-component-description-list/package.json +4 -4
- package/bpk-component-dialog/package.json +10 -10
- package/bpk-component-drawer/package.json +11 -11
- package/bpk-component-fieldset/package.json +14 -14
- package/bpk-component-flare/package.json +6 -6
- package/bpk-component-floating-notification/package.json +7 -7
- package/bpk-component-form-validation/package.json +12 -12
- package/bpk-component-graphic-promotion/package.json +6 -6
- package/bpk-component-graphic-promotion/src/BpkGraphicPromo.module.scss +54 -47
- package/bpk-component-grid/package.json +4 -4
- package/bpk-component-grid-toggle/package.json +5 -5
- package/bpk-component-horizontal-nav/package.json +8 -8
- package/bpk-component-icon/lg/account-circle.js +1 -1
- package/bpk-component-icon/lg/center-location.js +1 -1
- package/bpk-component-icon/lg/face-id.js +1 -1
- package/bpk-component-icon/lg/fingerprint.js +1 -1
- package/bpk-component-icon/lg/menu.js +1 -1
- package/bpk-component-icon/lg/search.js +1 -1
- package/bpk-component-icon/package.json +9 -9
- package/bpk-component-icon/sm/account-circle.js +1 -1
- package/bpk-component-icon/sm/center-location.js +8 -0
- package/bpk-component-icon/sm/face-id.js +8 -0
- package/bpk-component-icon/sm/fingerprint.js +8 -0
- package/bpk-component-icon/sm/menu.js +1 -1
- package/bpk-component-icon/sm/search.js +1 -1
- package/bpk-component-image/package.json +8 -8
- package/bpk-component-infinite-scroll/package.json +8 -8
- package/bpk-component-input/package.json +8 -8
- package/bpk-component-label/package.json +4 -4
- package/bpk-component-link/package.json +6 -6
- package/bpk-component-list/package.json +4 -4
- package/bpk-component-loading-button/package.json +8 -8
- package/bpk-component-map/package.json +8 -8
- package/bpk-component-mobile-scroll-container/package.json +5 -5
- package/bpk-component-modal/package.json +11 -11
- package/bpk-component-navigation-bar/package.json +10 -10
- package/bpk-component-nudger/package.json +9 -9
- package/bpk-component-overlay/package.json +6 -6
- package/bpk-component-pagination/package.json +6 -6
- package/bpk-component-panel/package.json +4 -4
- package/bpk-component-phone-input/package.json +11 -11
- package/bpk-component-popover/README.md +15 -3
- package/bpk-component-popover/package.json +10 -10
- package/bpk-component-popover/src/BpkPopoverPortal.js +2 -10
- package/bpk-component-price/package.json +5 -5
- package/bpk-component-progress/package.json +7 -7
- package/bpk-component-radio/package.json +6 -6
- package/bpk-component-rating/package.json +6 -6
- package/bpk-component-rtl-toggle/package.json +4 -4
- package/bpk-component-scrollable-calendar/package.json +8 -8
- package/bpk-component-section-list/package.json +8 -8
- package/bpk-component-select/package.json +5 -5
- package/bpk-component-skip-link/package.json +4 -4
- package/bpk-component-slider/package.json +6 -6
- package/bpk-component-spinner/package.json +5 -5
- package/bpk-component-split-input/package.json +5 -5
- package/bpk-component-star-rating/package.json +7 -7
- package/bpk-component-switch/package.json +4 -4
- package/bpk-component-table/package.json +4 -4
- package/bpk-component-text/package.json +4 -4
- package/bpk-component-textarea/package.json +6 -6
- package/bpk-component-theme-toggle/package.json +7 -7
- package/bpk-component-ticket/package.json +6 -6
- package/bpk-component-tooltip/README.md +12 -1
- package/bpk-component-tooltip/package.json +6 -6
- package/bpk-component-tooltip/src/BpkTooltip.module.scss +4 -0
- package/bpk-component-tooltip/src/BpkTooltipPortal.js +24 -21
- package/bpk-react-utils/index.js +0 -3
- package/bpk-react-utils/package.json +2 -2
- package/bpk-react-utils/src/Portal.js +1 -1
- package/bpk-scrim-utils/package.json +4 -4
- package/bpk-theming/package.json +3 -3
- package/package.json +5 -5
- package/bpk-component-navigation-stack/README.md +0 -49
- package/bpk-component-navigation-stack/index.js +0 -30
- package/bpk-component-navigation-stack/package.json +0 -33
- package/bpk-component-navigation-stack/src/BpkNavigationStack.js +0 -128
- package/bpk-component-navigation-stack/src/BpkNavigationStack.module.css +0 -18
- package/bpk-component-navigation-stack/src/BpkNavigationStack.module.scss +0 -51
- package/bpk-component-navigation-stack/src/withNavigationStackState.js +0 -104
- package/bpk-react-utils/src/Portal-v1.js +0 -310
|
@@ -16,10 +16,17 @@ import BpkText from 'bpk-component-text';
|
|
|
16
16
|
import BpkTooltip from 'bpk-component-tooltip';
|
|
17
17
|
|
|
18
18
|
const App = () => (
|
|
19
|
+
const targetRef = useRef(null);
|
|
20
|
+
const target = (
|
|
21
|
+
<div ref={targetRef} className={'my-tooltip-target'}>
|
|
22
|
+
<BpkText textStyle="lg">LHR</BpkText>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
|
|
19
26
|
<BpkTooltip
|
|
20
27
|
ariaLabel="London Heathrow"
|
|
21
28
|
id="my-tooltip"
|
|
22
|
-
target={
|
|
29
|
+
target={target}
|
|
23
30
|
>
|
|
24
31
|
London Heathrow
|
|
25
32
|
</BpkTooltip>
|
|
@@ -54,3 +61,7 @@ The label will be used on the `target` element, so any existing `aria-label` att
|
|
|
54
61
|
#### `popperModifiers`
|
|
55
62
|
|
|
56
63
|
Please refer to the [documentation](https://popper.js.org/docs/v2/modifiers/) for the underlying positioning library "Popper.js". You can achieve various behaviours such as allowing the tooltip to overflow the viewport etc.
|
|
64
|
+
|
|
65
|
+
#### target
|
|
66
|
+
|
|
67
|
+
`target` should be a DOM element with a `ref` attached to it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-tooltip",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Backpack tooltip component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@popperjs/core": "^2.11.5",
|
|
18
|
-
"bpk-mixins": "^31.
|
|
19
|
-
"bpk-react-utils": "^
|
|
18
|
+
"bpk-mixins": "^31.2.0",
|
|
19
|
+
"bpk-react-utils": "^7.0.0",
|
|
20
20
|
"prop-types": "^15.7.2"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"react": "^
|
|
23
|
+
"react": "^17.0.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@skyscanner/bpk-foundations-web": "^8.
|
|
27
|
-
"bpk-component-text": "^
|
|
26
|
+
"@skyscanner/bpk-foundations-web": "^8.3.0",
|
|
27
|
+
"bpk-component-text": "^8.0.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -22,7 +22,7 @@ import { createPopper } from '@popperjs/core';
|
|
|
22
22
|
import PropTypes from 'prop-types';
|
|
23
23
|
import React, { Component, type Node, type Element } from 'react';
|
|
24
24
|
|
|
25
|
-
import {
|
|
25
|
+
import { Portal, cssModules } from '../../bpk-react-utils';
|
|
26
26
|
|
|
27
27
|
import BpkTooltip, {
|
|
28
28
|
propTypes as tooltipPropTypes,
|
|
@@ -195,26 +195,29 @@ class BpkTooltipPortal extends Component<Props, State> {
|
|
|
195
195
|
classNames.push(portalClassName);
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
198
|
+
return (
|
|
199
|
+
<>
|
|
200
|
+
{targetWithAccessibilityProps}
|
|
201
|
+
{renderPortal && (
|
|
202
|
+
<Portal
|
|
203
|
+
target={targetWithAccessibilityProps}
|
|
204
|
+
targetRef={(targetRef) => {
|
|
205
|
+
this.targetRef = targetRef;
|
|
206
|
+
}}
|
|
207
|
+
isOpen={this.state.isOpen}
|
|
208
|
+
onOpen={this.onOpen}
|
|
209
|
+
onClose={this.closeTooltip}
|
|
210
|
+
style={portalStyle}
|
|
211
|
+
renderTarget={renderTarget}
|
|
212
|
+
className={classNames.join(' ')}
|
|
213
|
+
>
|
|
214
|
+
{/* $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'. */}
|
|
215
|
+
<BpkTooltip padded={padded} {...rest}>
|
|
216
|
+
{children}
|
|
217
|
+
</BpkTooltip>
|
|
218
|
+
</Portal>
|
|
219
|
+
)}
|
|
220
|
+
</>
|
|
218
221
|
);
|
|
219
222
|
}
|
|
220
223
|
}
|
package/bpk-react-utils/index.js
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
|
|
21
21
|
import wrapDisplayName from './src/wrapDisplayName';
|
|
22
22
|
import Portal from './src/Portal';
|
|
23
|
-
import PortalV1 from './src/Portal-v1';
|
|
24
23
|
import TransitionInitialMount from './src/TransitionInitialMount';
|
|
25
24
|
import cssModules from './src/cssModules';
|
|
26
25
|
import deprecated from './src/deprecated';
|
|
@@ -34,7 +33,6 @@ import isRTL from './src/isRTL';
|
|
|
34
33
|
|
|
35
34
|
export {
|
|
36
35
|
Portal,
|
|
37
|
-
PortalV1,
|
|
38
36
|
TransitionInitialMount,
|
|
39
37
|
cssModules,
|
|
40
38
|
deprecated,
|
|
@@ -47,7 +45,6 @@ export {
|
|
|
47
45
|
};
|
|
48
46
|
export default {
|
|
49
47
|
Portal,
|
|
50
|
-
PortalV1,
|
|
51
48
|
TransitionInitialMount,
|
|
52
49
|
cssModules,
|
|
53
50
|
deprecated,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-react-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Utilities for Backpack's React components.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"react-transition-group": "^2.5.3"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"react": "^
|
|
22
|
+
"react": "^17.0.2",
|
|
23
23
|
"react-dom": "^16.3.0 || ^17.0.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -208,7 +208,7 @@ class Portal extends Component {
|
|
|
208
208
|
this.portalElement.className = this.props.className;
|
|
209
209
|
}
|
|
210
210
|
this.setState({ isVisible: true }, () =>
|
|
211
|
-
this.props.onOpen(this.portalElement),
|
|
211
|
+
this.props.onOpen(this.portalElement, this.getTargetElement()),
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-scrim-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Higher order component that adds an overlay behind components and manages scroll states.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"a11y-focus-scope": "^1.1.3",
|
|
18
18
|
"a11y-focus-store": "^1.0.0",
|
|
19
|
-
"bpk-mixins": "^31.
|
|
20
|
-
"bpk-react-utils": "^
|
|
19
|
+
"bpk-mixins": "^31.2.0",
|
|
20
|
+
"bpk-react-utils": "^7.0.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"react": "^
|
|
23
|
+
"react": "^17.0.2"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/bpk-theming/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-theming",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Backpack theming utlities.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "c2217d61875a1f3aa2bb9ed9583c50e3f1523501",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@skyscanner/bpk-foundations-web": "^8.
|
|
17
|
+
"@skyscanner/bpk-foundations-web": "^8.3.0",
|
|
18
18
|
"prop-types": "^15.7.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"react": "^
|
|
21
|
+
"react": "^17.0.2"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@popperjs/core": "^2.11.5",
|
|
26
26
|
"@react-google-maps/api": "^2.12.0",
|
|
27
|
-
"@skyscanner/bpk-foundations-web": "^8.
|
|
28
|
-
"@skyscanner/bpk-svgs": "^14.
|
|
27
|
+
"@skyscanner/bpk-foundations-web": "^8.3.0",
|
|
28
|
+
"@skyscanner/bpk-svgs": "^14.3.4",
|
|
29
29
|
"a11y-focus-scope": "^1.1.3",
|
|
30
30
|
"a11y-focus-store": "^1.0.0",
|
|
31
|
-
"bpk-mixins": "^31.
|
|
31
|
+
"bpk-mixins": "^31.2.0",
|
|
32
32
|
"d3-path": "^2.0.0",
|
|
33
33
|
"d3-scale": "^4.0.2",
|
|
34
34
|
"date-fns": "^2.21.1",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"react-virtualized": "^9.22.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"react": "^
|
|
48
|
+
"react": "^17.0.2"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# This component is deprecated and should be considered as not supported.
|
|
2
|
-
# bpk-component-navigation-stack
|
|
3
|
-
|
|
4
|
-
> Backpack navigation stack component.
|
|
5
|
-
|
|
6
|
-
## Installation
|
|
7
|
-
|
|
8
|
-
```sh
|
|
9
|
-
npm install bpk-component-navigation-stack --save-dev
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import BpkNavigationStack from 'bpk-component-navigation-stack';
|
|
17
|
-
|
|
18
|
-
export default () => (
|
|
19
|
-
<BpkNavigationStack views={[<div />]} />
|
|
20
|
-
);
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Props
|
|
24
|
-
|
|
25
|
-
| Property | PropType | Required | Default Value |
|
|
26
|
-
| --------- | ---------------- | -------- | ------------- |
|
|
27
|
-
| views | arrayOf(element) | true | - |
|
|
28
|
-
| className | string | false | null |
|
|
29
|
-
|
|
30
|
-
## withNavigationStackState
|
|
31
|
-
|
|
32
|
-
`withNavigationStackState` returns a HOC with two instance methods, `pushView` and `popView`,
|
|
33
|
-
that can be used to push and pop views from the stack component.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
import React from 'react';
|
|
38
|
-
import BpkNavigationStack, { withNavigationStackState } from 'bpk-component-navigation-stack';
|
|
39
|
-
|
|
40
|
-
const StatefulNavigationStack = withNavigationStackState(BpkNavigationStack);
|
|
41
|
-
|
|
42
|
-
export default () => (
|
|
43
|
-
<StatefulNavigationStack initialViews={[<div />]} />
|
|
44
|
-
);
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
By default the `pushView` and `popView` callbacks are forwarded to the children, if you
|
|
48
|
-
want to disabled this behaviour pass `false` as the second argument, in this case the
|
|
49
|
-
callbacks are forwarded to the Stack component instead.
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
/* @flow strict */
|
|
20
|
-
|
|
21
|
-
import withNavigationStackState, {
|
|
22
|
-
type Props as StateProps,
|
|
23
|
-
} from './src/withNavigationStackState';
|
|
24
|
-
import BpkNavigationStack, { type Props } from './src/BpkNavigationStack';
|
|
25
|
-
|
|
26
|
-
export type BpkNavigationStackProps = Props;
|
|
27
|
-
export type StatefulBpkNavigationStackProps = StateProps;
|
|
28
|
-
|
|
29
|
-
export default BpkNavigationStack;
|
|
30
|
-
export { withNavigationStackState };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "bpk-component-navigation-stack",
|
|
3
|
-
"version": "3.2.0",
|
|
4
|
-
"description": "Backpack navigation stack component.",
|
|
5
|
-
"license": "Apache-2.0",
|
|
6
|
-
"private": true,
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git@github.com:Skyscanner/backpack.git"
|
|
10
|
-
},
|
|
11
|
-
"author": "Backpack Design System <backpack@skyscanner.net>",
|
|
12
|
-
"main": "index.js",
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
"registry": "https://registry.npmjs.org/"
|
|
15
|
-
},
|
|
16
|
-
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@skyscanner/bpk-foundations-web": "^8.0.0",
|
|
19
|
-
"bpk-mixins": "^31.1.1",
|
|
20
|
-
"bpk-react-utils": "^6.0.0",
|
|
21
|
-
"prop-types": "^15.7.2",
|
|
22
|
-
"react-transition-group": "^2.5.3"
|
|
23
|
-
},
|
|
24
|
-
"peerDependencies": {
|
|
25
|
-
"react": "^16.3.0 || ^17.0.0"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"bpk-component-button": "^6.2.7",
|
|
29
|
-
"bpk-component-icon": "^9.2.13",
|
|
30
|
-
"bpk-component-navigation-bar": "^3.1.14",
|
|
31
|
-
"bpk-component-rtl-toggle": "^3.1.12"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
/* @flow strict */
|
|
20
|
-
|
|
21
|
-
import React, { Children, type Element } from 'react';
|
|
22
|
-
import PropTypes from 'prop-types';
|
|
23
|
-
import { durationSm } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
24
|
-
import { TransitionGroup, Transition } from 'react-transition-group';
|
|
25
|
-
import debounce from 'lodash/debounce';
|
|
26
|
-
|
|
27
|
-
import { cssModules, isRTL } from '../../bpk-react-utils';
|
|
28
|
-
|
|
29
|
-
import STYLES from './BpkNavigationStack.module.scss';
|
|
30
|
-
|
|
31
|
-
const getClassName = cssModules(STYLES);
|
|
32
|
-
|
|
33
|
-
export type Views = Array<Element<any>>;
|
|
34
|
-
|
|
35
|
-
export type Props = {
|
|
36
|
-
views: Views,
|
|
37
|
-
className: ?string,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type Transitions = 'entering' | 'leaving';
|
|
41
|
-
|
|
42
|
-
type State = {
|
|
43
|
-
transition: ?Transitions,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
class BpkNavigationStack extends React.Component<Props, State> {
|
|
47
|
-
static propTypes = {
|
|
48
|
-
views: PropTypes.arrayOf(PropTypes.element).isRequired,
|
|
49
|
-
className: PropTypes.string,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
static defaultProps = {
|
|
53
|
-
className: null,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
constructor(props: Props) {
|
|
57
|
-
super(props);
|
|
58
|
-
this.state = {
|
|
59
|
-
transition: null,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
onTransitionEnter = () => this.startTransition('entering');
|
|
64
|
-
|
|
65
|
-
onTransitionExit = () => this.startTransition('leaving');
|
|
66
|
-
|
|
67
|
-
startTransition = (transition: Transitions) => {
|
|
68
|
-
this.stopTransition.cancel();
|
|
69
|
-
this.setState({ transition });
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
stopTransition = debounce(() => {
|
|
73
|
-
this.setState({ transition: null });
|
|
74
|
-
}, parseInt(durationSm, 10) + 10);
|
|
75
|
-
|
|
76
|
-
render() {
|
|
77
|
-
const { className, views, ...rest } = this.props;
|
|
78
|
-
const { transition } = this.state;
|
|
79
|
-
const lastIndex = (views || []).length - 1;
|
|
80
|
-
|
|
81
|
-
return (
|
|
82
|
-
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
|
|
83
|
-
<div
|
|
84
|
-
className={getClassName('bpk-navigation-stack', className)}
|
|
85
|
-
{...rest}
|
|
86
|
-
>
|
|
87
|
-
<TransitionGroup
|
|
88
|
-
className={getClassName(
|
|
89
|
-
'bpk-navigation-stack__view-track',
|
|
90
|
-
transition &&
|
|
91
|
-
`bpk-navigation-stack__view-track--view-${transition}`,
|
|
92
|
-
)}
|
|
93
|
-
style={{
|
|
94
|
-
transform: `translateX(${
|
|
95
|
-
lastIndex === 0 ? '0%' : `${isRTL() ? '' : '-'}${lastIndex}00%`
|
|
96
|
-
})`,
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
{Children.map(views, (view, idx) => (
|
|
100
|
-
<Transition
|
|
101
|
-
in
|
|
102
|
-
// The order of these is unlikely to change...
|
|
103
|
-
key={idx} // eslint-disable-line react/no-array-index-key
|
|
104
|
-
timeout={parseInt(durationSm, 10)}
|
|
105
|
-
unmountOnExit
|
|
106
|
-
onEnter={this.onTransitionEnter}
|
|
107
|
-
onEntered={this.stopTransition}
|
|
108
|
-
onExit={this.onTransitionExit}
|
|
109
|
-
onExited={this.stopTransition}
|
|
110
|
-
>
|
|
111
|
-
<div
|
|
112
|
-
aria-hidden={idx !== lastIndex}
|
|
113
|
-
className={getClassName(
|
|
114
|
-
'bpk-navigation-stack__view',
|
|
115
|
-
idx === lastIndex && 'bpk-navigation-stack__view--current',
|
|
116
|
-
)}
|
|
117
|
-
>
|
|
118
|
-
{view}
|
|
119
|
-
</div>
|
|
120
|
-
</Transition>
|
|
121
|
-
))}
|
|
122
|
-
</TransitionGroup>
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export default BpkNavigationStack;
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
@keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-navigation-stack{display:flex;overflow:hidden}.bpk-navigation-stack::after{content:'';min-height:inherit}.bpk-navigation-stack__view-track{display:flex;width:100%;transition:transform 200ms ease}.bpk-navigation-stack__view-track--view-entering .bpk-navigation-stack__view:nth-last-child(2){visibility:visible}.bpk-navigation-stack__view{display:flex;visibility:hidden;min-width:100%}.bpk-navigation-stack__view--current{visibility:visible}
|
|
@@ -1,51 +0,0 @@
|
|
|
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 '~bpk-mixins/index';
|
|
20
|
-
|
|
21
|
-
.bpk-navigation-stack {
|
|
22
|
-
display: flex;
|
|
23
|
-
overflow: hidden;
|
|
24
|
-
|
|
25
|
-
&::after {
|
|
26
|
-
content: '';
|
|
27
|
-
min-height: inherit;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&__view-track {
|
|
31
|
-
display: flex;
|
|
32
|
-
width: 100%;
|
|
33
|
-
transition: transform $bpk-duration-sm ease;
|
|
34
|
-
|
|
35
|
-
&--view-entering {
|
|
36
|
-
.bpk-navigation-stack__view:nth-last-child(2) {
|
|
37
|
-
visibility: visible;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&__view {
|
|
43
|
-
display: flex;
|
|
44
|
-
visibility: hidden;
|
|
45
|
-
min-width: 100%;
|
|
46
|
-
|
|
47
|
-
&--current {
|
|
48
|
-
visibility: visible;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
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
|
-
/* @flow strict */
|
|
20
|
-
|
|
21
|
-
import React, {
|
|
22
|
-
Component,
|
|
23
|
-
cloneElement,
|
|
24
|
-
type Element,
|
|
25
|
-
type ComponentType,
|
|
26
|
-
} from 'react';
|
|
27
|
-
|
|
28
|
-
import BpkNavigationStack, {
|
|
29
|
-
type Views,
|
|
30
|
-
type Props as BpkNavigationStackProps,
|
|
31
|
-
} from './BpkNavigationStack';
|
|
32
|
-
|
|
33
|
-
export type Props = {
|
|
34
|
-
...$Diff<$Exact<BpkNavigationStackProps>, { views: Views }>,
|
|
35
|
-
initialViews: Views,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type State = {
|
|
39
|
-
views: Views,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default (
|
|
43
|
-
Stack: ComponentType<any>, // TODO: Improve type
|
|
44
|
-
assignCallbacksToChildren: boolean = true,
|
|
45
|
-
) => {
|
|
46
|
-
class WithNavigationStackState extends Component<Props, State> {
|
|
47
|
-
static defaultProps = {
|
|
48
|
-
...BpkNavigationStack.defaultProps,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
constructor(props: Props) {
|
|
52
|
-
super(props);
|
|
53
|
-
|
|
54
|
-
this.state = {
|
|
55
|
-
views: this.props.initialViews,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
pushView = (view: Element<any>) => {
|
|
60
|
-
this.setState((prevState) => {
|
|
61
|
-
const views = prevState.views.slice();
|
|
62
|
-
views.push(view);
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
views,
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
popView = () => {
|
|
71
|
-
this.setState((prevState) => {
|
|
72
|
-
const views = prevState.views.slice();
|
|
73
|
-
views.pop();
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
views,
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
render() {
|
|
82
|
-
const {
|
|
83
|
-
initialViews, // unused
|
|
84
|
-
...rest
|
|
85
|
-
} = this.props;
|
|
86
|
-
|
|
87
|
-
const callbacks = {
|
|
88
|
-
pushView: this.pushView,
|
|
89
|
-
popView: this.popView,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const [views, optionalCallbacks] = assignCallbacksToChildren
|
|
93
|
-
? [this.state.views.map((view) => cloneElement(view, callbacks)), {}]
|
|
94
|
-
: [this.state.views, callbacks];
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
|
|
98
|
-
<Stack views={views} {...optionalCallbacks} {...rest} />
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return WithNavigationStackState;
|
|
104
|
-
};
|