@skyscanner/backpack-web 31.1.2 → 31.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.
Files changed (27) hide show
  1. package/bpk-component-banner-alert/src/BpkBannerAlert.js +5 -0
  2. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +3 -0
  3. package/bpk-component-calendar/src/composeCalendar.d.ts +1 -0
  4. package/bpk-component-calendar/src/composeCalendar.js +2 -0
  5. package/bpk-component-info-banner/index.d.ts +32 -0
  6. package/bpk-component-info-banner/index.js +25 -0
  7. package/bpk-component-info-banner/src/AnimateAndFade.d.ts +61 -0
  8. package/bpk-component-info-banner/src/AnimateAndFade.js +147 -0
  9. package/bpk-component-info-banner/src/BpkAnimateAndFade.module.css +18 -0
  10. package/bpk-component-info-banner/src/BpkInfoBanner.d.ts +29 -0
  11. package/bpk-component-info-banner/src/BpkInfoBanner.js +40 -0
  12. package/bpk-component-info-banner/src/BpkInfoBanner.module.css +18 -0
  13. package/bpk-component-info-banner/src/BpkInfoBannerDismissable.d.ts +30 -0
  14. package/bpk-component-info-banner/src/BpkInfoBannerDismissable.js +29 -0
  15. package/bpk-component-info-banner/src/BpkInfoBannerExpandable.d.ts +37 -0
  16. package/bpk-component-info-banner/src/BpkInfoBannerExpandable.js +35 -0
  17. package/bpk-component-info-banner/src/BpkInfoBannerInner.d.ts +58 -0
  18. package/bpk-component-info-banner/src/BpkInfoBannerInner.js +176 -0
  19. package/bpk-component-info-banner/src/common-types.d.ts +44 -0
  20. package/bpk-component-info-banner/src/common-types.js +28 -0
  21. package/bpk-component-info-banner/src/withBannerAlertState.d.ts +168 -0
  22. package/bpk-component-info-banner/src/withBannerAlertState.js +111 -0
  23. package/bpk-component-map/src/BpkPriceMarkerV2/BpkPriceMarker.js +1 -1
  24. package/bpk-component-map/src/BpkPriceMarkerV2/BpkPriceMarker.module.css +1 -1
  25. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.d.ts +1 -0
  26. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.js +10 -8
  27. package/package.json +2 -2
@@ -24,6 +24,11 @@ const defaultProps = {
24
24
  show: true,
25
25
  icon: null
26
26
  };
27
+
28
+ /**
29
+ * @deprecated use bpk-component-info-banner instead
30
+ * @returns {Component} a banner alert component
31
+ */
27
32
  const BpkBannerAlert = ({
28
33
  animateOnEnter = false,
29
34
  animateOnLeave = false,
@@ -41,6 +41,7 @@ export type Props = {
41
41
  initiallyFocusedDate?: Date | null;
42
42
  markToday?: boolean;
43
43
  markOutsideDays?: boolean;
44
+ customRowHeight?: number;
44
45
  };
45
46
  type InjectedProps = {
46
47
  onDateClick: ((date: Date) => void) | null;
@@ -105,6 +106,7 @@ declare const withCalendarState: <P extends object>(Calendar: ComponentType<P>)
105
106
  initiallyFocusedDate: null;
106
107
  markToday: boolean;
107
108
  markOutsideDays: boolean;
109
+ customRowHeight?: number;
108
110
  };
109
111
  contextType?: import("react").Context<any> | undefined;
110
112
  };
@@ -157,6 +159,7 @@ declare const _default: {
157
159
  initiallyFocusedDate: null;
158
160
  markToday: boolean;
159
161
  markOutsideDays: boolean;
162
+ customRowHeight?: number;
160
163
  };
161
164
  contextType?: import("react").Context<any> | undefined;
162
165
  };
@@ -71,6 +71,7 @@ export type Props = {
71
71
  preventKeyboardFocus?: boolean;
72
72
  selectionConfiguration?: SelectionConfiguration;
73
73
  gridClassName?: string | null;
74
+ customRowHeight?: number;
74
75
  /**
75
76
  * Key to be used to pick the desired weekDay format from the `daysOfWeek` object, for example: `nameAbbr` or `nameNarrow`.
76
77
  */
@@ -26,6 +26,7 @@ const composeCalendar = (Nav, GridHeader, Grid, CalendarDate) => {
26
26
  const BpkCalendar = ({
27
27
  changeMonthLabel = null,
28
28
  className = null,
29
+ customRowHeight,
29
30
  dateModifiers = {},
30
31
  dateProps = {},
31
32
  daysOfWeek,
@@ -116,6 +117,7 @@ const composeCalendar = (Nav, GridHeader, Grid, CalendarDate) => {
116
117
  className: gridClasses.join(' '),
117
118
  dateProps: dateProps,
118
119
  selectionConfiguration: selectionConfiguration,
120
+ customRowHeight: customRowHeight,
119
121
  ...gridProps
120
122
  })]
121
123
  });
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2022 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 BpkInfoBanner from './src/BpkInfoBanner';
20
+ import BpkInfoBannerDismissable from './src/BpkInfoBannerDismissable';
21
+ import BpkInfoBannerExpandable from './src/BpkInfoBannerExpandable';
22
+ import { ALERT_TYPES, STYLE_TYPES } from './src/common-types';
23
+ import withBannerAlertState from './src/withBannerAlertState';
24
+
25
+ export {
26
+ ALERT_TYPES,
27
+ STYLE_TYPES,
28
+ BpkInfoBannerDismissable,
29
+ BpkInfoBannerExpandable,
30
+ withBannerAlertState,
31
+ };
32
+ export default BpkInfoBanner;
@@ -0,0 +1,25 @@
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 BpkInfoBanner from "./src/BpkInfoBanner";
20
+ import BpkInfoBannerDismissable from "./src/BpkInfoBannerDismissable";
21
+ import BpkInfoBannerExpandable from "./src/BpkInfoBannerExpandable";
22
+ import { ALERT_TYPES, STYLE_TYPES } from "./src/common-types";
23
+ import withBannerAlertState from "./src/withBannerAlertState";
24
+ export { ALERT_TYPES, STYLE_TYPES, BpkInfoBannerDismissable, BpkInfoBannerExpandable, withBannerAlertState };
25
+ export default BpkInfoBanner;
@@ -0,0 +1,61 @@
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 type { ReactNode } from 'react';
21
+
22
+ type Props = {
23
+ animateOnEnter: boolean;
24
+ animateOnLeave: boolean;
25
+ children: ReactNode | string;
26
+ show: boolean;
27
+ className?: string | null;
28
+ };
29
+ type State = {
30
+ isExpanded: boolean;
31
+ visible: boolean;
32
+ initiateShow: boolean;
33
+ hideAnimationInProgress: boolean;
34
+ inDom: boolean;
35
+ };
36
+ declare class AnimateAndFade extends Component<Props, State> {
37
+ toggleImmediately: boolean;
38
+
39
+ static defaultProps: {
40
+ animateOnEnter: boolean;
41
+ animateOnLeave: boolean;
42
+ className: null;
43
+ };
44
+
45
+ constructor(props: Props);
46
+
47
+ componentDidMount(): void;
48
+
49
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
50
+
51
+ componentDidUpdate(): void;
52
+
53
+ onAnimateHeightComplete: () => void;
54
+
55
+ onFadeComplete: () => void;
56
+
57
+ toggle: () => void;
58
+
59
+ render(): JSX.Element | null;
60
+ }
61
+ export default AnimateAndFade;
@@ -0,0 +1,147 @@
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
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
21
+ import { durationSm } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
22
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
23
+ import { TransitionGroup, CSSTransition } from 'react-transition-group';
24
+ import { cssModules } from "../../bpk-react-utils";
25
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
26
+ import BpkAnimateHeight from "../../bpk-animate-height";
27
+ import STYLES from "./BpkAnimateAndFade.module.css";
28
+ import { jsx as _jsx } from "react/jsx-runtime";
29
+ import { jsxs as _jsxs } from "react/jsx-runtime";
30
+ const getClassName = cssModules(STYLES);
31
+ const ANIMATION_DURATION = parseInt(durationSm, 10);
32
+ class AnimateAndFade extends Component {
33
+ static defaultProps = {
34
+ animateOnEnter: false,
35
+ animateOnLeave: false,
36
+ className: null
37
+ };
38
+ constructor(props) {
39
+ super(props);
40
+ this.toggleImmediately = this.props.show && this.props.animateOnEnter;
41
+ const initiallyShown = this.toggleImmediately ? false : this.props.show;
42
+ this.state = {
43
+ isExpanded: initiallyShown,
44
+ visible: initiallyShown,
45
+ initiateShow: false,
46
+ hideAnimationInProgress: false,
47
+ inDom: initiallyShown
48
+ };
49
+ }
50
+ componentDidMount() {
51
+ if (this.toggleImmediately) {
52
+ this.toggle();
53
+ }
54
+ }
55
+ UNSAFE_componentWillReceiveProps(nextProps) {
56
+ if (nextProps.show === this.props.show) {
57
+ return;
58
+ }
59
+ this.toggle();
60
+ }
61
+ componentDidUpdate() {
62
+ if (this.state.initiateShow) {
63
+ // React doesn't like us calling setState from componentDidUpdate as it can lead to an infinite re-renders.
64
+ // I think it is ok here, however, as this will only happen conditionally (ie once)
65
+
66
+ this.setState({
67
+ initiateShow: false,
68
+ isExpanded: true,
69
+ visible: true
70
+ });
71
+ }
72
+ }
73
+ onAnimateHeightComplete = () => {
74
+ if (this.state.isExpanded) {
75
+ return;
76
+ }
77
+ this.setState({
78
+ inDom: false,
79
+ hideAnimationInProgress: false
80
+ });
81
+ };
82
+ onFadeComplete = () => {
83
+ if (!this.state.visible && this.state.hideAnimationInProgress) {
84
+ this.setState({
85
+ isExpanded: false
86
+ });
87
+ }
88
+ };
89
+ toggle = () => {
90
+ if (this.state.visible && this.state.isExpanded) {
91
+ this.setState({
92
+ hideAnimationInProgress: true,
93
+ visible: false
94
+ });
95
+ } else if (!this.state.visible && !this.state.isExpanded) {
96
+ this.setState({
97
+ inDom: true,
98
+ initiateShow: true
99
+ });
100
+ }
101
+ };
102
+ render() {
103
+ const {
104
+ animateOnEnter,
105
+ animateOnLeave,
106
+ children,
107
+ className
108
+ } = this.props;
109
+ const showPlaceholder = !this.state.visible && !this.state.hideAnimationInProgress;
110
+ // While the expanding animation takes place, we render the child element
111
+ // close to invisible. If we don't do this, the animate-height container
112
+ // will take on height 0, and will never expand to allow the children to fade in
113
+ return this.state.inDom ? /*#__PURE__*/_jsxs(BpkAnimateHeight, {
114
+ className: className,
115
+ onAnimationComplete: this.onAnimateHeightComplete,
116
+ duration: ANIMATION_DURATION,
117
+ height: this.state.isExpanded ? 'auto' : 0,
118
+ children: [showPlaceholder && /*#__PURE__*/_jsx("div", {
119
+ style: {
120
+ opacity: 0.35
121
+ },
122
+ children: children
123
+ }), /*#__PURE__*/_jsx(TransitionGroup, {
124
+ exit: animateOnLeave,
125
+ enter: animateOnEnter,
126
+ appear: animateOnEnter,
127
+ onTransitionEnd: this.onFadeComplete,
128
+ children: this.state.visible && /*#__PURE__*/_jsx(CSSTransition, {
129
+ classNames: {
130
+ exit: getClassName('bpk-animate-and-fade--leave'),
131
+ exitActive: getClassName('bpk-animate-and-fade--leave-active'),
132
+ enter: getClassName('bpk-animate-and-fade--enter'),
133
+ enterActive: getClassName('bpk-animate-and-fade--enter-active'),
134
+ appear: getClassName('bpk-animate-and-fade--appear'),
135
+ appearActive: getClassName('bpk-animate-and-fade--appear-active')
136
+ },
137
+ timeout: {
138
+ enter: ANIMATION_DURATION * 2,
139
+ exit: ANIMATION_DURATION * 2
140
+ },
141
+ children: children
142
+ })
143
+ })]
144
+ }) : null;
145
+ }
146
+ }
147
+ export default AnimateAndFade;
@@ -0,0 +1,18 @@
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-animate-and-fade--enter{transition:opacity 200ms ease-in-out;opacity:.01;transition-delay:200ms}.bpk-animate-and-fade--enter-active{opacity:1}.bpk-animate-and-fade--leave{transition:opacity 200ms ease-in-out;opacity:1}.bpk-animate-and-fade--leave-active{transition:opacity 200ms ease-in-out;opacity:.01}.bpk-animate-and-fade--appear{transition:opacity 200ms ease-in-out;opacity:.01;transition-delay:200ms}.bpk-animate-and-fade--appear-active{opacity:1}
@@ -0,0 +1,29 @@
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="react" />
20
+ import type { CommonProps } from './common-types';
21
+
22
+ declare const BpkInfoBanner: ({
23
+ animateOnEnter,
24
+ animateOnLeave,
25
+ icon,
26
+ show,
27
+ ...rest
28
+ }: CommonProps) => JSX.Element;
29
+ export default BpkInfoBanner;
@@ -0,0 +1,40 @@
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 BpkInfoBannerInner from "./BpkInfoBannerInner";
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ const defaultProps = {
22
+ animateOnEnter: false,
23
+ animateOnLeave: false,
24
+ show: true,
25
+ icon: null
26
+ };
27
+ const BpkInfoBanner = ({
28
+ animateOnEnter = false,
29
+ animateOnLeave = false,
30
+ icon = null,
31
+ show = true,
32
+ ...rest
33
+ }) => /*#__PURE__*/_jsx(BpkInfoBannerInner, {
34
+ animateOnEnter: animateOnEnter,
35
+ animateOnLeave: animateOnLeave,
36
+ show: show,
37
+ icon: icon,
38
+ ...rest
39
+ });
40
+ export default BpkInfoBanner;
@@ -0,0 +1,18 @@
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-info-banner{padding:0.5rem 1rem;overflow:hidden;border-radius:.5rem;margin:0;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner--style-default{background-color:#eff1f2}.bpk-info-banner--style-onContrast{background-color:#fff}.bpk-info-banner__header{display:flex;flex-direction:row;align-items:flex-start}.bpk-info-banner__header--expandable{cursor:pointer}.bpk-info-banner__icon,.bpk-info-banner__toggle{padding:0.125rem 0}.bpk-info-banner__message{padding:0.25rem 0.5rem;flex-grow:1}.bpk-info-banner__success-icon{fill:#0c838a}.bpk-info-banner__warning-icon{fill:#f55d42}.bpk-info-banner__error-icon{fill:#e70866}.bpk-info-banner__info-icon{fill:#545860}.bpk-info-banner__toggle-button{padding:0;border:0;background-color:transparent;cursor:pointer;appearance:none}.bpk-info-banner__expand-icon{fill:#545860}.bpk-info-banner__expand-icon--flipped{transform:scaleY(-1)}.bpk-info-banner__children-container{color:#161616;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner__children-container--with-action{padding:0.25rem 0 0.25rem}.bpk-info-banner__children-container--no-action{padding:0.25rem 0 0.5rem}.bpk-info-banner__expandable-action{padding-bottom:0.25rem}
@@ -0,0 +1,30 @@
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="react" />
20
+ import type { CommonProps, OnDismissHandler } from './common-types';
21
+
22
+ export type Props = CommonProps & {
23
+ dismissButtonLabel: string;
24
+ onDismiss?: OnDismissHandler;
25
+ };
26
+ declare const BpkInfoBannerDismissable: ({
27
+ onDismiss,
28
+ ...rest
29
+ }: Props) => JSX.Element;
30
+ export default BpkInfoBannerDismissable;
@@ -0,0 +1,29 @@
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 BpkInfoBannerInner, { CONFIGURATION } from "./BpkInfoBannerInner";
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ const BpkInfoBannerDismissable = ({
22
+ onDismiss = null,
23
+ ...rest
24
+ }) => /*#__PURE__*/_jsx(BpkInfoBannerInner, {
25
+ configuration: CONFIGURATION.DISMISSABLE,
26
+ onDismiss: onDismiss,
27
+ ...rest
28
+ });
29
+ export default BpkInfoBannerDismissable;
@@ -0,0 +1,37 @@
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 { ReactNode } from 'react';
20
+
21
+ import type { CommonProps, OnExpandToggleHandler } from './common-types';
22
+
23
+ export type Props = CommonProps & {
24
+ children: ReactNode;
25
+ expanded?: boolean;
26
+ toggleButtonLabel: string;
27
+ onExpandToggle?: OnExpandToggleHandler;
28
+ action?: ExpandableBannerAction;
29
+ };
30
+ declare const BpkInfoBannerExpandable: ({
31
+ action,
32
+ children,
33
+ expanded,
34
+ onExpandToggle,
35
+ ...rest
36
+ }: Props) => JSX.Element;
37
+ export default BpkInfoBannerExpandable;
@@ -0,0 +1,35 @@
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 BpkInfoBannerInner, { CONFIGURATION } from "./BpkInfoBannerInner";
20
+ import { jsx as _jsx } from "react/jsx-runtime";
21
+ const BpkInfoBannerExpandable = ({
22
+ action = null,
23
+ children,
24
+ expanded = false,
25
+ onExpandToggle = null,
26
+ ...rest
27
+ }) => /*#__PURE__*/_jsx(BpkInfoBannerInner, {
28
+ action: action,
29
+ configuration: CONFIGURATION.EXPANDABLE,
30
+ expanded: expanded,
31
+ onExpandToggle: onExpandToggle,
32
+ ...rest,
33
+ children: children
34
+ });
35
+ export default BpkInfoBannerExpandable;
@@ -0,0 +1,58 @@
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 { ReactNode } from 'react';
20
+
21
+ import type {
22
+ CommonProps,
23
+ OnDismissHandler,
24
+ OnExpandToggleHandler,
25
+ } from './common-types';
26
+
27
+ export declare const CONFIGURATION: {
28
+ readonly NONE: 'none';
29
+ readonly DISMISSABLE: 'dismissable';
30
+ readonly EXPANDABLE: 'expandable';
31
+ };
32
+ type Props = CommonProps & {
33
+ configuration?: (typeof CONFIGURATION)[keyof typeof CONFIGURATION];
34
+ children?: ReactNode | string;
35
+ expanded?: boolean;
36
+ toggleButtonLabel?: string;
37
+ onExpandToggle?: OnExpandToggleHandler;
38
+ dismissButtonLabel?: string;
39
+ onDismiss?: OnDismissHandler;
40
+ };
41
+ declare const BpkInfoBannerInner: ({
42
+ animateOnEnter,
43
+ animateOnLeave,
44
+ bannerClassName,
45
+ children,
46
+ configuration,
47
+ dismissButtonLabel,
48
+ expanded,
49
+ icon,
50
+ message,
51
+ onDismiss,
52
+ onExpandToggle,
53
+ show,
54
+ toggleButtonLabel,
55
+ type,
56
+ ...rest
57
+ }: Props) => JSX.Element;
58
+ export default BpkInfoBannerInner;
@@ -0,0 +1,176 @@
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
+ /* This is an internal component to Backpack that powers `BpkInfoBanner`,
20
+ * `BpkInfoBannerDismissable` and `BpkInfoBannerExpandable`.
21
+ */
22
+
23
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
24
+ import { durationSm } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
25
+ import { withButtonAlignment } from "../../bpk-component-icon";
26
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
27
+ import BpkLink from "../../bpk-component-link";
28
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
29
+ import BpkAnimateHeight from "../../bpk-animate-height";
30
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
31
+ import BpkCloseButton from "../../bpk-component-close-button";
32
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
33
+ import TickCircleIcon from "../../bpk-component-icon/sm/tick-circle";
34
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
35
+ import ChevronDownIcon from "../../bpk-component-icon/sm/chevron-down";
36
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
37
+ import InfoCircleIcon from "../../bpk-component-icon/sm/information-circle";
38
+ import { cssModules } from "../../bpk-react-utils";
39
+ import AnimateAndFade from "./AnimateAndFade";
40
+ import { ALERT_TYPES, STYLE_TYPES } from "./common-types";
41
+ import STYLES from "./BpkInfoBanner.module.css";
42
+ import { jsx as _jsx } from "react/jsx-runtime";
43
+ import { jsxs as _jsxs } from "react/jsx-runtime";
44
+ const getClassName = cssModules(STYLES);
45
+ const ExpandIcon = withButtonAlignment(ChevronDownIcon);
46
+ export const CONFIGURATION = {
47
+ NONE: 'none',
48
+ DISMISSABLE: 'dismissable',
49
+ EXPANDABLE: 'expandable'
50
+ };
51
+ const getIconForType = (type, CustomIcon) => {
52
+ const classMap = {
53
+ [ALERT_TYPES.SUCCESS]: getClassName('bpk-info-banner__success-icon'),
54
+ [ALERT_TYPES.WARNING]: getClassName('bpk-info-banner__warning-icon'),
55
+ [ALERT_TYPES.ERROR]: getClassName('bpk-info-banner__error-icon'),
56
+ [ALERT_TYPES.INFO]: getClassName('bpk-info-banner__info-icon')
57
+ };
58
+ const className = classMap[type];
59
+ const componentMap = {
60
+ [ALERT_TYPES.SUCCESS]: TickCircleIcon,
61
+ [ALERT_TYPES.WARNING]: InfoCircleIcon,
62
+ [ALERT_TYPES.ERROR]: InfoCircleIcon,
63
+ [ALERT_TYPES.INFO]: InfoCircleIcon
64
+ };
65
+ const Icon = CustomIcon || componentMap[type];
66
+ const AlignedIcon = withButtonAlignment(Icon);
67
+ return /*#__PURE__*/_jsx(AlignedIcon, {
68
+ className: className
69
+ });
70
+ };
71
+ const ToggleButton = props => {
72
+ const classNames = getClassName('bpk-info-banner__expand-icon', props.expanded && 'bpk-info-banner__expand-icon--flipped');
73
+ return /*#__PURE__*/_jsx("button", {
74
+ type: "button",
75
+ className: getClassName('bpk-info-banner__toggle-button'),
76
+ "aria-label": props.label,
77
+ "aria-expanded": props.expanded,
78
+ title: props.label,
79
+ children: /*#__PURE__*/_jsx(ExpandIcon, {
80
+ className: classNames
81
+ })
82
+ });
83
+ };
84
+ const BpkInfoBannerInner = ({
85
+ action = null,
86
+ animateOnEnter = false,
87
+ animateOnLeave = false,
88
+ bannerClassName,
89
+ children = null,
90
+ configuration,
91
+ dismissButtonLabel = '',
92
+ expanded = false,
93
+ icon = null,
94
+ message,
95
+ onDismiss = null,
96
+ onExpandToggle = null,
97
+ show = true,
98
+ style = STYLE_TYPES.DEFAULT,
99
+ toggleButtonLabel = '',
100
+ type = ALERT_TYPES.INFO,
101
+ ...rest
102
+ }) => {
103
+ const onBannerExpandToggle = () => {
104
+ if (onExpandToggle) {
105
+ onExpandToggle(!expanded);
106
+ }
107
+ };
108
+ const onBannerDismiss = () => {
109
+ if (onDismiss) {
110
+ onDismiss();
111
+ }
112
+ };
113
+ const isExpandable = configuration === CONFIGURATION.EXPANDABLE;
114
+ const dismissable = configuration === CONFIGURATION.DISMISSABLE;
115
+ const showChildren = isExpandable && expanded;
116
+ const sectionClassNames = getClassName('bpk-info-banner', `bpk-info-banner--${type}`, `bpk-info-banner--style-${style}`, bannerClassName && bannerClassName);
117
+ const headerClassNames = getClassName('bpk-info-banner__header', isExpandable && 'bpk-info-banner__header--expandable');
118
+ const childrenContainerClassName = action && isExpandable ? getClassName('bpk-info-banner__children-container--with-action') : getClassName('bpk-info-banner__children-container--no-action');
119
+
120
+ /* eslint-disable
121
+ jsx-a11y/no-static-element-interactions,
122
+ jsx-a11y/click-events-have-key-events,
123
+ */
124
+ // Disabling 'click-events-have-key-events and interactive-supports-focus' because header element is not focusable.
125
+ // ToggleButton is focusable and works for this.
126
+ return /*#__PURE__*/_jsx(AnimateAndFade, {
127
+ animateOnEnter: animateOnEnter,
128
+ animateOnLeave: dismissable || animateOnLeave,
129
+ show: show,
130
+ ...rest,
131
+ children: /*#__PURE__*/_jsxs("section", {
132
+ className: sectionClassNames,
133
+ role: "alert",
134
+ children: [/*#__PURE__*/_jsxs("div", {
135
+ role: isExpandable ? 'button' : undefined,
136
+ className: headerClassNames,
137
+ onClick: onBannerExpandToggle,
138
+ children: [/*#__PURE__*/_jsx("span", {
139
+ className: getClassName('bpk-info-banner__icon'),
140
+ children: getIconForType(type, icon)
141
+ }), /*#__PURE__*/_jsx("span", {
142
+ className: getClassName('bpk-info-banner__message'),
143
+ children: message
144
+ }), isExpandable && /*#__PURE__*/_jsx("span", {
145
+ className: getClassName('bpk-info-banner__toggle'),
146
+ children: /*#__PURE__*/_jsx(ToggleButton, {
147
+ expanded: expanded,
148
+ label: toggleButtonLabel
149
+ })
150
+ }), dismissable && /*#__PURE__*/_jsx("span", {
151
+ className: getClassName('bpk-info-banner__toggle'),
152
+ children: /*#__PURE__*/_jsx(BpkCloseButton, {
153
+ className: getClassName('bpk-info-banner__toggle-button'),
154
+ onClick: onBannerDismiss,
155
+ "aria-label": dismissButtonLabel,
156
+ label: dismissButtonLabel
157
+ })
158
+ })]
159
+ }), /*#__PURE__*/_jsxs(BpkAnimateHeight, {
160
+ duration: parseInt(durationSm, 10),
161
+ height: showChildren ? 'auto' : 0,
162
+ children: [/*#__PURE__*/_jsx("div", {
163
+ className: childrenContainerClassName,
164
+ children: children
165
+ }), isExpandable && action && /*#__PURE__*/_jsx(BpkLink, {
166
+ className: getClassName('bpk-info-banner__expandable-action'),
167
+ onClick: action.callback,
168
+ children: action.title
169
+ })]
170
+ })]
171
+ })
172
+ });
173
+ /* eslint-enable */
174
+ };
175
+
176
+ export default BpkInfoBannerInner;
@@ -0,0 +1,44 @@
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 { FunctionComponent, ReactNode } from 'react';
20
+
21
+ export declare const ALERT_TYPES: {
22
+ readonly PRIMARY: 'primary';
23
+ readonly SUCCESS: 'success';
24
+ readonly WARN: 'warn';
25
+ readonly ERROR: 'error';
26
+ readonly NEUTRAL: 'neutral';
27
+ };
28
+ export type AlertTypeValue = (typeof ALERT_TYPES)[keyof typeof ALERT_TYPES];
29
+ export type CommonProps = {
30
+ type: AlertTypeValue;
31
+ message: ReactNode | string;
32
+ animateOnEnter?: boolean;
33
+ animateOnLeave?: boolean;
34
+ show?: boolean;
35
+ bannerClassName?: string | null;
36
+ icon?: FunctionComponent<any> | null;
37
+ [rest: string]: any;
38
+ };
39
+ export type OnExpandToggleHandler =
40
+ | ((expanded: boolean) => void)
41
+ | null
42
+ | undefined;
43
+ export type OnDismissHandler = (() => void) | null | undefined;
44
+ export type OnHideHandler = (() => void) | null | undefined;
@@ -0,0 +1,28 @@
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
+ export const ALERT_TYPES = {
20
+ SUCCESS: 'success',
21
+ WARNING: 'warning',
22
+ ERROR: 'error',
23
+ INFO: 'info'
24
+ };
25
+ export const STYLE_TYPES = {
26
+ DEFAULT: 'default',
27
+ ON_CONTRAST: 'onContrast'
28
+ };
@@ -0,0 +1,168 @@
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="node" />
20
+ import type { ComponentType } from 'react';
21
+ export type WithBannerAlertStateProps = {
22
+ onHide?: () => void;
23
+ hideAfter?: number;
24
+ };
25
+ declare const withBannerAlertState: <
26
+ P extends Partial<
27
+ import('./common-types').CommonProps & {
28
+ dismissButtonLabel: string;
29
+ onDismiss?: import('./common-types').OnDismissHandler;
30
+ } & {
31
+ children: import('react').ReactNode;
32
+ expanded?: boolean | undefined;
33
+ toggleButtonLabel: string;
34
+ onExpandToggle?: import('./common-types').OnExpandToggleHandler;
35
+ }
36
+ >,
37
+ >(
38
+ WrappedComponent: ComponentType<P>,
39
+ ) => {
40
+ new (props: P & WithBannerAlertStateProps): {
41
+ hideIntervalId?: NodeJS.Timeout | null | undefined;
42
+ componentDidMount(): void;
43
+ componentWillUnmount(): void;
44
+ onExpandToggle: () => void;
45
+ onDismiss: () => void;
46
+ onHide: () => void;
47
+ render(): JSX.Element;
48
+ context: any;
49
+ setState<
50
+ K extends keyof {
51
+ expanded?: boolean | undefined;
52
+ show?: boolean | undefined;
53
+ },
54
+ >(
55
+ state:
56
+ | {
57
+ expanded?: boolean | undefined;
58
+ show?: boolean | undefined;
59
+ }
60
+ | ((
61
+ prevState: Readonly<{
62
+ expanded?: boolean | undefined;
63
+ show?: boolean | undefined;
64
+ }>,
65
+ props: Readonly<P & WithBannerAlertStateProps>,
66
+ ) =>
67
+ | {
68
+ expanded?: boolean | undefined;
69
+ show?: boolean | undefined;
70
+ }
71
+ | Pick<
72
+ {
73
+ expanded?: boolean | undefined;
74
+ show?: boolean | undefined;
75
+ },
76
+ K
77
+ >
78
+ | null)
79
+ | Pick<
80
+ {
81
+ expanded?: boolean | undefined;
82
+ show?: boolean | undefined;
83
+ },
84
+ K
85
+ >
86
+ | null,
87
+ callback?: (() => void) | undefined,
88
+ ): void;
89
+ forceUpdate(callback?: (() => void) | undefined): void;
90
+ readonly props: Readonly<P & WithBannerAlertStateProps> &
91
+ Readonly<{
92
+ children?: import('react').ReactNode;
93
+ }>;
94
+ state: Readonly<{
95
+ expanded?: boolean | undefined;
96
+ show?: boolean | undefined;
97
+ }>;
98
+ refs: {
99
+ [key: string]: import('react').ReactInstance;
100
+ };
101
+ shouldComponentUpdate?(
102
+ nextProps: Readonly<P & WithBannerAlertStateProps>,
103
+ nextState: Readonly<{
104
+ expanded?: boolean | undefined;
105
+ show?: boolean | undefined;
106
+ }>,
107
+ nextContext: any,
108
+ ): boolean;
109
+ componentDidCatch?(
110
+ error: Error,
111
+ errorInfo: import('react').ErrorInfo,
112
+ ): void;
113
+ getSnapshotBeforeUpdate?(
114
+ prevProps: Readonly<P & WithBannerAlertStateProps>,
115
+ prevState: Readonly<{
116
+ expanded?: boolean | undefined;
117
+ show?: boolean | undefined;
118
+ }>,
119
+ ): any;
120
+ componentDidUpdate?(
121
+ prevProps: Readonly<P & WithBannerAlertStateProps>,
122
+ prevState: Readonly<{
123
+ expanded?: boolean | undefined;
124
+ show?: boolean | undefined;
125
+ }>,
126
+ snapshot?: any,
127
+ ): void;
128
+ componentWillMount?(): void;
129
+ UNSAFE_componentWillMount?(): void;
130
+ componentWillReceiveProps?(
131
+ nextProps: Readonly<P & WithBannerAlertStateProps>,
132
+ nextContext: any,
133
+ ): void;
134
+ UNSAFE_componentWillReceiveProps?(
135
+ nextProps: Readonly<P & WithBannerAlertStateProps>,
136
+ nextContext: any,
137
+ ): void;
138
+ componentWillUpdate?(
139
+ nextProps: Readonly<P & WithBannerAlertStateProps>,
140
+ nextState: Readonly<{
141
+ expanded?: boolean | undefined;
142
+ show?: boolean | undefined;
143
+ }>,
144
+ nextContext: any,
145
+ ): void;
146
+ UNSAFE_componentWillUpdate?(
147
+ nextProps: Readonly<P & WithBannerAlertStateProps>,
148
+ nextState: Readonly<{
149
+ expanded?: boolean | undefined;
150
+ show?: boolean | undefined;
151
+ }>,
152
+ nextContext: any,
153
+ ): void;
154
+ };
155
+ displayName: string;
156
+ defaultProps: {
157
+ onDismiss: null;
158
+ onExpandToggle: null;
159
+ onHide: null;
160
+ expanded: boolean;
161
+ show: boolean;
162
+ hideAfter: null;
163
+ animateOnLeave: boolean;
164
+ children: null;
165
+ };
166
+ contextType?: import('react').Context<any> | undefined;
167
+ };
168
+ export default withBannerAlertState;
@@ -0,0 +1,111 @@
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 { wrapDisplayName } from "../../bpk-react-utils";
21
+ import BpkInfoBannerExpandable from "./BpkInfoBannerExpandable";
22
+ import { jsx as _jsx } from "react/jsx-runtime";
23
+ const withBannerAlertState = WrappedComponent => {
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
+ constructor(props) {
36
+ super(props);
37
+ this.state = {
38
+ expanded: props.expanded,
39
+ show: true
40
+ };
41
+ this.hideIntervalId = null;
42
+ }
43
+ componentDidMount() {
44
+ const {
45
+ hideAfter
46
+ } = this.props;
47
+ if (WrappedComponent !== BpkInfoBannerExpandable && hideAfter && hideAfter > 0) {
48
+ this.hideIntervalId = setTimeout(() => {
49
+ this.onHide();
50
+ }, hideAfter * 1000);
51
+ }
52
+ }
53
+ componentWillUnmount() {
54
+ if (this.hideIntervalId) {
55
+ clearTimeout(this.hideIntervalId);
56
+ }
57
+ }
58
+ onExpandToggle = () => {
59
+ this.setState(prevState => {
60
+ const expanded = !prevState.expanded;
61
+ if (this.props.onExpandToggle) {
62
+ this.props.onExpandToggle(expanded);
63
+ }
64
+ return {
65
+ expanded
66
+ };
67
+ });
68
+ };
69
+ onDismiss = () => {
70
+ this.setState({
71
+ show: false
72
+ });
73
+ if (this.props.onDismiss) {
74
+ this.props.onDismiss();
75
+ }
76
+ };
77
+ onHide = () => {
78
+ this.setState({
79
+ show: false
80
+ });
81
+ if (this.props.onHide) {
82
+ this.props.onHide();
83
+ }
84
+ };
85
+ render() {
86
+ const {
87
+ animateOnLeave,
88
+ children,
89
+ expanded,
90
+ hideAfter,
91
+ onDismiss,
92
+ onExpandToggle,
93
+ onHide,
94
+ show,
95
+ ...rest
96
+ } = this.props;
97
+ return /*#__PURE__*/_jsx(WrappedComponent, {
98
+ expanded: this.state.expanded,
99
+ onExpandToggle: this.onExpandToggle,
100
+ onDismiss: this.onDismiss,
101
+ show: this.state.show,
102
+ animateOnLeave: hideAfter && hideAfter > 0 || animateOnLeave,
103
+ ...rest,
104
+ children: children
105
+ });
106
+ }
107
+ }
108
+ component.displayName = wrapDisplayName(WrappedComponent, 'withBannerAlertState');
109
+ return component;
110
+ };
111
+ export default withBannerAlertState;
@@ -54,7 +54,7 @@ export const BpkPriceMarkerV2 = props => {
54
54
  children: /*#__PURE__*/_jsxs("div", {
55
55
  className: classNames,
56
56
  children: [icon, /*#__PURE__*/_jsx(BpkText, {
57
- textStyle: TEXT_STYLES.label2,
57
+ textStyle: TEXT_STYLES.label3,
58
58
  children: label
59
59
  })]
60
60
  })
@@ -15,4 +15,4 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-price-marker{display:flex;height:1.5rem;padding:0 0.5rem;justify-content:center;align-items:center;border-radius:.5rem;gap:0.5rem}.bpk-price-marker--dynamic{cursor:pointer}.bpk-price-marker-unselected{background-color:#fff;color:#161616}.bpk-price-marker-unselected--icon{fill:#161616}.bpk-price-marker-previous_selected{background-color:#cfe4ff;color:#161616}.bpk-price-marker-previous_selected--icon{fill:#161616}.bpk-price-marker-selected{background-color:#05203c;color:#fff}.bpk-price-marker-selected--icon{fill:#fff}.bpk-price-marker__wrapper{position:relative;display:flex;padding:0;flex-direction:column;align-items:center;border:none;background:none}
18
+ @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-price-marker{display:flex;height:1.5rem;padding:0 0.5rem;justify-content:center;align-items:center;border-radius:.5rem;box-shadow:0px 1px 3px 0px rgba(37,32,31,0.3);gap:0.5rem}.bpk-price-marker--dynamic{cursor:pointer}.bpk-price-marker-unselected{background-color:#fff;color:#161616}.bpk-price-marker-unselected--icon{fill:#161616}.bpk-price-marker-previous_selected{background-color:#cfe4ff;color:#161616}.bpk-price-marker-previous_selected--icon{fill:#161616}.bpk-price-marker-selected{background-color:#05203c;color:#fff}.bpk-price-marker-selected--icon{fill:#fff}.bpk-price-marker__wrapper{position:relative;display:flex;padding:0;flex-direction:column;align-items:center;border:none;background:none}
@@ -29,6 +29,7 @@ type Props = Partial<BpkCalendarGridProps> & {
29
29
  focusedDate?: Date | null;
30
30
  selectionConfiguration?: SelectionConfiguration;
31
31
  className?: string | null;
32
+ customRowHeight?: number;
32
33
  };
33
34
  declare const BpkScrollableCalendarGridList: (props: Props) => JSX.Element;
34
35
  export default BpkScrollableCalendarGridList;
@@ -29,20 +29,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
29
29
  const getClassName = cssModules(STYLES);
30
30
 
31
31
  // These constants are here to facilitate calculating the height
32
- // Row and month item heights are defined in rem to support text scaling
33
- const ROW_HEIGHT = 2.75;
34
32
  // This is the additional height of each grid without any rows.
35
33
  const BASE_MONTH_ITEM_HEIGHT = 8.125;
36
34
  const COLUMN_COUNT = 7;
37
35
  // Most browsers have by default 16px root font size
38
36
  const DEFAULT_ROOT_FONT_SIZE = 16;
39
- // Most calendar grids have 5 rows. Calculate height in px as this is what react-window expects.
40
- const ESTIMATED_MONTH_ITEM_HEIGHT = (BASE_MONTH_ITEM_HEIGHT + 5 * ROW_HEIGHT) * DEFAULT_ROOT_FONT_SIZE;
41
37
  // Minimum month item width (useful for server-side rendering. This value will be overridden with an accurate width after mounting)
42
38
  const ESTIMATED_MONTH_ITEM_WIDTH = BASE_MONTH_ITEM_HEIGHT * 7 * DEFAULT_ROOT_FONT_SIZE;
43
39
  const BpkScrollableCalendarGridList = props => {
44
40
  const {
45
41
  className = null,
42
+ customRowHeight = 2.75,
46
43
  focusedDate = null,
47
44
  minDate,
48
45
  selectionConfiguration,
@@ -52,13 +49,18 @@ const BpkScrollableCalendarGridList = props => {
52
49
  const startDate = startOfDay(startOfMonth(minDate));
53
50
  const endDate = startOfDay(startOfMonth(rest.maxDate));
54
51
  const monthsCount = DateUtils.differenceInCalendarMonths(endDate, startDate);
52
+
53
+ // Row and month item heights are defined in rem to support text scaling
54
+ const rowHeight = customRowHeight;
55
+ // Most calendar grids have 5 rows. Calculate height in px as this is what react-window expects.
56
+ const estimatedMonthItemHeight = (BASE_MONTH_ITEM_HEIGHT + 5 * rowHeight) * DEFAULT_ROOT_FONT_SIZE;
55
57
  const getInitialRootFontSize = () => parseFloat(getComputedStyle(document.documentElement).fontSize) || DEFAULT_ROOT_FONT_SIZE;
56
58
 
57
59
  // The `react-window` API requires the height in pixels to be specified
58
60
  // To be able to scale text size, we use rem and then we get the root font size so that we can calculate the final value in px
59
61
  const [rootFontSize, setRootFontSize] = useState(getInitialRootFontSize);
60
62
  const months = useMemo(() => getMonthsArray(startDate, monthsCount), [minDate, monthsCount]);
61
- const monthItemHeights = useMemo(() => getMonthItemHeights(months, rest.weekStartsOn, COLUMN_COUNT, ROW_HEIGHT * rootFontSize, BASE_MONTH_ITEM_HEIGHT * rootFontSize), [rootFontSize, months, rest.weekStartsOn]);
63
+ const monthItemHeights = useMemo(() => getMonthItemHeights(months, rest.weekStartsOn, COLUMN_COUNT, rowHeight * rootFontSize, BASE_MONTH_ITEM_HEIGHT * rootFontSize), [rootFontSize, months, rest.weekStartsOn]);
62
64
  useEffect(() => {
63
65
  // this is required by the react-window library in order to re-render the list whenever an item's size changes
64
66
  if (listRef.current) {
@@ -66,7 +68,7 @@ const BpkScrollableCalendarGridList = props => {
66
68
  }
67
69
  }, [monthItemHeights]);
68
70
  const getHtmlElement = () => typeof document !== 'undefined' ? document.querySelector('html') : {};
69
- const getItemSize = index => monthItemHeights[index] || ESTIMATED_MONTH_ITEM_HEIGHT;
71
+ const getItemSize = index => monthItemHeights[index] || estimatedMonthItemHeight;
70
72
  const rowRenderer = ({
71
73
  index,
72
74
  style
@@ -103,7 +105,7 @@ const BpkScrollableCalendarGridList = props => {
103
105
  className: getClassName('bpk-scrollable-calendar-grid-list', className),
104
106
  children: /*#__PURE__*/_jsx(AutoSizer, {
105
107
  onResize: onResize,
106
- defaultHeight: ESTIMATED_MONTH_ITEM_HEIGHT,
108
+ defaultHeight: estimatedMonthItemHeight,
107
109
  defaultWidth: ESTIMATED_MONTH_ITEM_WIDTH,
108
110
  children: ({
109
111
  height,
@@ -114,7 +116,7 @@ const BpkScrollableCalendarGridList = props => {
114
116
  } : {},
115
117
  width: width,
116
118
  height: height,
117
- estimatedItemSize: ESTIMATED_MONTH_ITEM_HEIGHT,
119
+ estimatedItemSize: estimatedMonthItemHeight,
118
120
  itemSize: getItemSize,
119
121
  itemCount: months.length,
120
122
  overscanCount: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "31.1.2",
3
+ "version": "31.3.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@popperjs/core": "^2.11.5",
26
26
  "@react-google-maps/api": "^2.12.0",
27
- "@skyscanner/bpk-foundations-web": "^17.4.0",
27
+ "@skyscanner/bpk-foundations-web": "^17.5.3",
28
28
  "@skyscanner/bpk-svgs": "^19.0.0",
29
29
  "a11y-focus-scope": "^1.1.3",
30
30
  "a11y-focus-store": "^1.0.0",