@skyscanner/backpack-web 31.4.0 → 31.5.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/README.md CHANGED
@@ -31,6 +31,7 @@ To contribute please see [contributing.md](CONTRIBUTING.md).
31
31
  [`bpk-component-banner-alert`](/packages/bpk-component-banner-alert)
32
32
  [`bpk-component-barchart`](/packages/bpk-component-barchart)
33
33
  [`bpk-component-blockquote`](/packages/bpk-component-blockquote)
34
+ [`bpk-component-bottom-sheet`](/packages/bpk-component-bottom-sheet)
34
35
  [`bpk-component-breadcrumb`](/packages/bpk-component-breadcrumb)
35
36
  [`bpk-component-breakpoint`](/packages/bpk-component-breakpoint)
36
37
  [`bpk-component-button`](/packages/bpk-component-button)
@@ -0,0 +1,22 @@
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 BpkBottomSheet from './src/BpkBottomSheet';
20
+ import type { Props } from './src/BpkBottomSheet';
21
+ export type BpkBottomSheetProps = Props;
22
+ export default BpkBottomSheet;
@@ -0,0 +1,20 @@
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 BpkBottomSheet from "./src/BpkBottomSheet";
20
+ export default BpkBottomSheet;
@@ -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 type { ReactNode } from 'react';
20
+ import type { Props as BottomSheetProps } from './BpkBottomSheet';
21
+ export type Props = Partial<BottomSheetProps> & {
22
+ children: ReactNode;
23
+ closeLabel?: string;
24
+ closeOnEscPressed?: boolean;
25
+ closeOnScrimClick?: boolean;
26
+ id: string;
27
+ isOpen: boolean;
28
+ onClose: () => void;
29
+ title?: string;
30
+ /**
31
+ * Because this component uses a modal on mobile viewports, you need to let it know what
32
+ * the root element of your application is by returning its DOM node via this prop
33
+ * This is to "hide" your application from screen readers whilst the modal is open.
34
+ * The "pagewrap" element id is a convention we use internally at Skyscanner. In most cases it should "just work".
35
+ */
36
+ getApplicationElement: () => HTMLElement | null;
37
+ renderTarget?: null | HTMLElement | (() => null | HTMLElement);
38
+ };
39
+ declare const BpkBottomSheet: ({ closeLabel, closeOnEscPressed, closeOnScrimClick, id, isOpen, onClose, title, renderTarget, ...rest }: Props) => JSX.Element;
40
+ export default BpkBottomSheet;
@@ -0,0 +1,68 @@
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
+ import { useState } from "react";
19
+ import { Portal, cssModules } from "../../bpk-react-utils";
20
+ import { withScrim } from "../../bpk-scrim-utils";
21
+ import STYLES from "./BpkBottomSheet.module.css";
22
+ import BpkBottomSheetInner from "./BpkBottomSheetInner";
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ const getClassName = cssModules(STYLES);
25
+ const ScrimBpkBottomSheetInner = withScrim(BpkBottomSheetInner);
26
+ const BpkBottomSheet = ({
27
+ actionText = '',
28
+ closeLabel = '',
29
+ closeOnEscPressed = false,
30
+ closeOnScrimClick = false,
31
+ id,
32
+ isOpen,
33
+ onAction = () => null,
34
+ onClose,
35
+ renderTarget,
36
+ title = '',
37
+ wide = false,
38
+ ...rest
39
+ }) => {
40
+ const [exiting, setExitting] = useState(false);
41
+ const handleClose = () => {
42
+ setExitting(true);
43
+ setTimeout(() => {
44
+ onClose();
45
+ setExitting(false);
46
+ }, 240);
47
+ };
48
+ return /*#__PURE__*/_jsx(Portal, {
49
+ isOpen: isOpen,
50
+ onClose: handleClose,
51
+ closeOnEscPressed: closeOnEscPressed,
52
+ renderTarget: renderTarget,
53
+ children: /*#__PURE__*/_jsx(ScrimBpkBottomSheetInner, {
54
+ id: id,
55
+ onClose: handleClose,
56
+ closeOnScrimClick: closeOnScrimClick,
57
+ containerClassName: getClassName('bpk-bottom-sheet--container'),
58
+ title: title,
59
+ closeLabel: closeLabel,
60
+ actionText: actionText,
61
+ onAction: onAction,
62
+ wide: wide,
63
+ exiting: exiting,
64
+ ...rest
65
+ })
66
+ });
67
+ };
68
+ export default BpkBottomSheet;
@@ -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-bottom-sheet--container{display:flex;padding:1.5rem}@media (max-width: 32rem){.bpk-bottom-sheet--container{padding:0;overflow:hidden}}
@@ -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
+ import type { ReactNode } from 'react';
20
+ export type Props = {
21
+ children: ReactNode;
22
+ closeLabel?: string;
23
+ id: string;
24
+ onClose: () => void;
25
+ title?: string;
26
+ };
27
+ declare const BpkBottomSheetInner: ({ children, closeLabel, id, onClose, title, }: Props) => JSX.Element;
28
+ export default BpkBottomSheetInner;
@@ -0,0 +1,96 @@
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
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
20
+ import CSSTransition from 'react-transition-group/CSSTransition';
21
+
22
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
23
+ import { BpkButtonLink } from "../../bpk-component-link";
24
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
25
+ import BpkCloseButton from "../../bpk-component-close-button";
26
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
27
+ import BpkNavigationBar from "../../bpk-component-navigation-bar";
28
+ import { cssModules } from "../../bpk-react-utils";
29
+ import STYLES from "./BpkBottomSheetInner.module.css";
30
+ import { jsx as _jsx } from "react/jsx-runtime";
31
+ import { jsxs as _jsxs } from "react/jsx-runtime";
32
+ const getClassName = cssModules(STYLES);
33
+ const BpkBottomSheetInner = ({
34
+ actionText = '',
35
+ children,
36
+ closeLabel = '',
37
+ exiting,
38
+ id,
39
+ onAction = () => null,
40
+ onClose,
41
+ title = '',
42
+ wide = false
43
+ }) => {
44
+ const classNames = getClassName('bpk-bottom-sheet', wide && 'bpk-bottom-sheet--wide');
45
+ const headingId = `bpk-bottom-sheet-heading-${id}`;
46
+ return /*#__PURE__*/_jsx(CSSTransition, {
47
+ classNames: {
48
+ appear: getClassName('bpk-bottom-sheet--appear'),
49
+ appearActive: getClassName('bpk-bottom-sheet--appear-active'),
50
+ exit: getClassName('bpk-bottom-sheet--exit')
51
+ },
52
+ in: !exiting,
53
+ appear: !exiting,
54
+ out: exiting,
55
+ exit: exiting,
56
+ timeout: {
57
+ appear: 240,
58
+ exit: 240
59
+ },
60
+ children: /*#__PURE__*/_jsxs("section", {
61
+ id: id,
62
+ tabIndex: -1,
63
+ role: "dialog",
64
+ "aria-labelledby": headingId,
65
+ className: classNames,
66
+ children: [/*#__PURE__*/_jsx("header", {
67
+ className: getClassName('bpk-bottom-sheet--header'),
68
+ children: /*#__PURE__*/_jsx(BpkNavigationBar, {
69
+ id: headingId,
70
+ className: getClassName('bpk-bottom-sheet--navigation'),
71
+ title: /*#__PURE__*/_jsx("h2", {
72
+ id: headingId,
73
+ className: getClassName('bpk-bottom-sheet--heading'),
74
+ children: title
75
+ }),
76
+ leadingButton: /*#__PURE__*/_jsx(BpkCloseButton, {
77
+ className: getClassName('bpk-bottom-sheet--close-button'),
78
+ label: closeLabel,
79
+ onClick: onClose
80
+ }),
81
+ trailingButton: actionText && onAction ? /*#__PURE__*/_jsx(BpkButtonLink, {
82
+ className: getClassName('bpk-bottom-sheet--action-button'),
83
+ onClick: onAction,
84
+ children: actionText
85
+ }) : /*#__PURE__*/_jsx("div", {
86
+ className: getClassName('bpk-bottom-sheet--action-button')
87
+ })
88
+ })
89
+ }), /*#__PURE__*/_jsx("div", {
90
+ className: getClassName('bpk-bottom-sheet--content'),
91
+ children: children
92
+ })]
93
+ })
94
+ });
95
+ };
96
+ export default BpkBottomSheetInner;
@@ -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-bottom-sheet{z-index:1100;width:100%;max-width:32rem;margin:auto;transform:scale(1);transition:opacity 200ms ease-in-out,transform 200ms ease-in-out;outline:0;background-color:#fff;opacity:1;overflow:hidden;-webkit-tap-highlight-color:transparent;box-shadow:0px 12px 50px 0px rgba(37,32,31,0.25);border-radius:.5rem}@media (max-width: 32rem){.bpk-bottom-sheet{height:fit-content;max-height:90%;margin-bottom:0;border-radius:1.5rem 1.5rem 0 0;overflow-x:hidden;overflow-y:scroll;-ms-overflow-style:none;scrollbar-width:none}.bpk-bottom-sheet::-webkit-scrollbar{display:none}}.bpk-bottom-sheet--content{padding:1rem;flex:1;overflow-y:auto}@media (min-width: 32.0625rem){.bpk-bottom-sheet--wide{max-width:64rem}}@keyframes slide-up{0%{transform:translateY(100%)}100%{transform:translateY(0%)}}.bpk-bottom-sheet--appear{animation-duration:0.24s;animation-name:slide-up;animation-timing-function:ease-in-out}@media (min-width: 32.0625rem){.bpk-bottom-sheet--appear{transform:scale(0.9);opacity:0;animation:none}}@media (min-width: 32.0625rem){.bpk-bottom-sheet--appear-active{transform:scale(1);opacity:1}}.bpk-bottom-sheet--exit{animation-direction:reverse;animation-duration:0.24s;animation-name:slide-up;animation-timing-function:ease-in-out}@media (min-width: 32.0625rem){.bpk-bottom-sheet--exit{animation:none}}.bpk-bottom-sheet--header{position:sticky;top:0;z-index:899;box-shadow:0 -1px 0 0 #c2c9cd inset}.bpk-bottom-sheet--navigation{display:flex;justify-content:space-between;background-color:#fff}.bpk-bottom-sheet--heading{width:calc( 100% - ((3rem) * 2 + 0.25rem / 2));margin-right:auto;text-align:center;margin:0;font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-bottom-sheet--close-button{position:relative;left:auto;margin-right:1.5rem}html[dir='rtl'] .bpk-bottom-sheet--close-button{right:auto;margin-right:calc(-0.25rem / 2);margin-left:1.5rem}.bpk-bottom-sheet--action-button{position:relative;right:auto;width:calc(3rem - (0.25rem));margin-right:calc(0.25rem / 2);margin-left:calc(0.25rem);word-break:break-all}html[dir='rtl'] .bpk-bottom-sheet--action-button{left:auto;margin-right:calc(0.25rem);margin-left:calc(0.25rem / 2)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "31.4.0",
3
+ "version": "31.5.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",