@skyscanner/backpack-web 34.6.0 → 34.7.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 (30) hide show
  1. package/bpk-component-aria-live/src/BpkAriaLive.module.css +1 -1
  2. package/bpk-component-barchart/src/BpkChartDataTable.module.css +1 -1
  3. package/bpk-component-calendar/src/BpkCalendarGrid.module.css +1 -1
  4. package/bpk-component-calendar/src/BpkCalendarNav.module.css +1 -1
  5. package/bpk-component-carousel/index.d.ts +2 -0
  6. package/bpk-component-carousel/index.js +20 -0
  7. package/bpk-component-carousel/src/BpkCarousel.d.ts +4 -0
  8. package/bpk-component-carousel/src/BpkCarousel.js +62 -0
  9. package/bpk-component-carousel/src/BpkCarousel.module.css +18 -0
  10. package/bpk-component-carousel/src/BpkCarouselContainer.d.ts +10 -0
  11. package/bpk-component-carousel/src/BpkCarouselContainer.js +92 -0
  12. package/bpk-component-carousel/src/BpkCarouselContainer.module.css +18 -0
  13. package/bpk-component-carousel/src/BpkCarouselImage.d.ts +7 -0
  14. package/bpk-component-carousel/src/BpkCarouselImage.js +34 -0
  15. package/bpk-component-carousel/src/BpkCarouselImage.module.css +18 -0
  16. package/bpk-component-carousel/src/types.d.ts +11 -0
  17. package/bpk-component-carousel/src/types.js +1 -0
  18. package/bpk-component-carousel/src/utils.d.ts +4 -0
  19. package/bpk-component-carousel/src/utils.js +68 -0
  20. package/bpk-component-drawer/src/BpkDrawerContent.module.css +1 -1
  21. package/bpk-component-icon/src/withDescription.module.css +1 -1
  22. package/bpk-component-page-indicator/src/BpkPageIndicator.js +56 -42
  23. package/bpk-component-pagination/src/BpkPaginationNudger.module.css +1 -1
  24. package/bpk-component-popover/src/BpkPopover.js +2 -4
  25. package/bpk-component-popover/src/BpkPopover.module.css +1 -1
  26. package/bpk-component-theme-toggle/src/BpkThemeToggle.module.css +1 -1
  27. package/bpk-mixins/_utils.scss +1 -0
  28. package/bpk-stylesheets/base.css +1 -1
  29. package/package.json +1 -1
  30. package/unstable__bpk-mixins/_utils.scss +1 -0
@@ -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
- .bpk-aria-live--invisible{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-aria-live--invisible{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
@@ -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
- .bpk-chart-data-table{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}.bpk-chart-data-table thead,.bpk-chart-data-table tbody{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-chart-data-table{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.bpk-chart-data-table thead,.bpk-chart-data-table tbody{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
@@ -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
- .bpk-calendar-grid{border-collapse:separate;border-spacing:0}.bpk-calendar-grid--animating{z-index:1;transition:transform .2s ease-in-out}.bpk-calendar-grid__caption{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-calendar-grid{border-collapse:separate;border-spacing:0}.bpk-calendar-grid--animating{z-index:1;transition:transform .2s ease-in-out}.bpk-calendar-grid__caption{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
@@ -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
- .bpk-calendar-nav{display:table}.bpk-calendar-nav__month{display:table-cell;text-align:center}.bpk-calendar-nav__nudger{display:table-cell;padding:0 .5rem;text-align:center;vertical-align:middle;box-sizing:border-box}.bpk-calendar-nav__button{width:100%;height:2.25rem;padding:.375rem 0;border:none;background:none;cursor:pointer;appearance:none;color:#161616;color:var(--bpk-calendar-nudger-icon-color, rgb(22, 22, 22))}.bpk-no-touch-support .bpk-calendar-nav__button:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-calendar-nudger-icon-hover-color, rgb(22, 22, 22))}:global(.bpk-no-touch-support) .bpk-calendar-nav__button:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-calendar-nudger-icon-hover-color, rgb(22, 22, 22))}.bpk-calendar-nav__button:active{color:#161616;color:var(--bpk-calendar-nudger-icon-active-color, rgb(22, 22, 22))}html[dir=rtl] .bpk-calendar-nav__button .bpk-calendar-nav__icon{transform:scaleX(-1)}.bpk-calendar-nav__button:disabled{cursor:not-allowed}.bpk-calendar-nav__text--hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-calendar-nav{display:table}.bpk-calendar-nav__month{display:table-cell;text-align:center}.bpk-calendar-nav__nudger{display:table-cell;padding:0 .5rem;text-align:center;vertical-align:middle;box-sizing:border-box}.bpk-calendar-nav__button{width:100%;height:2.25rem;padding:.375rem 0;border:none;background:none;cursor:pointer;appearance:none;color:#161616;color:var(--bpk-calendar-nudger-icon-color, rgb(22, 22, 22))}.bpk-no-touch-support .bpk-calendar-nav__button:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-calendar-nudger-icon-hover-color, rgb(22, 22, 22))}:global(.bpk-no-touch-support) .bpk-calendar-nav__button:hover:not(:active):not(:disabled){color:#161616;color:var(--bpk-calendar-nudger-icon-hover-color, rgb(22, 22, 22))}.bpk-calendar-nav__button:active{color:#161616;color:var(--bpk-calendar-nudger-icon-active-color, rgb(22, 22, 22))}html[dir=rtl] .bpk-calendar-nav__button .bpk-calendar-nav__icon{transform:scaleX(-1)}.bpk-calendar-nav__button:disabled{cursor:not-allowed}.bpk-calendar-nav__text--hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
@@ -0,0 +1,2 @@
1
+ import BpkCarousel from "./src/BpkCarousel";
2
+ export default BpkCarousel;
@@ -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 BpkCarousel from "./src/BpkCarousel";
20
+ export default BpkCarousel;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { Props } from './types';
3
+ declare const BpkCarousel: ({ bottom, images, initialImageIndex, onImageChanged, }: Props) => JSX.Element;
4
+ export default BpkCarousel;
@@ -0,0 +1,62 @@
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 { useRef, useState } from 'react';
20
+
21
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
22
+ import BpkPageIndicator, { VARIANT } from "../../bpk-component-page-indicator";
23
+ import { cssModules } from "../../bpk-react-utils";
24
+ import BpkCarouselContainer from "./BpkCarouselContainer";
25
+ import { useScrollToInitialImage } from "./utils";
26
+ import STYLES from "./BpkCarousel.module.css";
27
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
28
+ const getClassName = cssModules(STYLES);
29
+ const BpkCarousel = ({
30
+ bottom,
31
+ images,
32
+ initialImageIndex = 0,
33
+ onImageChanged = null
34
+ }) => {
35
+ const [shownImageIndex, updateShownImageIndex] = useState(initialImageIndex);
36
+ const imagesRef = useRef([]);
37
+ useScrollToInitialImage(initialImageIndex, imagesRef);
38
+ return /*#__PURE__*/_jsxs("div", {
39
+ className: getClassName('bpk-carousel'),
40
+ children: [/*#__PURE__*/_jsx(BpkCarouselContainer, {
41
+ images: images,
42
+ onVisible: updateShownImageIndex,
43
+ imagesRef: imagesRef,
44
+ onImageChanged: onImageChanged
45
+ }), /*#__PURE__*/_jsx("div", {
46
+ className: getClassName('bpk-carousel__page-indicator-over-image'),
47
+ style: bottom ? {
48
+ bottom
49
+ } : undefined,
50
+ "data-testid": "carousel-page-indicator-container",
51
+ children: /*#__PURE__*/_jsx(BpkPageIndicator, {
52
+ currentIndex: shownImageIndex,
53
+ totalIndicators: images.length,
54
+ variant: VARIANT.overImage,
55
+ indicatorLabel: "Go to slide",
56
+ prevNavLabel: "Previous slide",
57
+ nextNavLabel: "Next slide"
58
+ })
59
+ })]
60
+ });
61
+ };
62
+ export default BpkCarousel;
@@ -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
+ .bpk-carousel{position:relative}.bpk-carousel__page-indicator-over-image{position:absolute;right:0;bottom:.25rem;left:0;display:flex;margin:auto 1rem;justify-content:center;overflow:clip}
@@ -0,0 +1,10 @@
1
+ import type { MutableRefObject, ReactNode } from 'react';
2
+ import type { OnImageChangedHandler } from './types';
3
+ type Props = {
4
+ images: ReactNode[];
5
+ onVisible: (visibleIndex: number) => void;
6
+ imagesRef: MutableRefObject<Array<HTMLElement | null>>;
7
+ onImageChanged: OnImageChangedHandler;
8
+ };
9
+ declare const BpkScrollContainer: import("react").MemoExoticComponent<({ images, imagesRef, onImageChanged, onVisible }: Props) => JSX.Element>;
10
+ export default BpkScrollContainer;
@@ -0,0 +1,92 @@
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 { memo, useState } from 'react';
20
+ import { cssModules } from "../../bpk-react-utils";
21
+ import BpkCarouselImage from "./BpkCarouselImage";
22
+ import { useIntersectionObserver } from "./utils";
23
+ import STYLES from "./BpkCarouselContainer.module.css";
24
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
26
+ const BpkScrollContainer = /*#__PURE__*/memo(({
27
+ images,
28
+ imagesRef,
29
+ onImageChanged,
30
+ onVisible
31
+ }) => {
32
+ const [root, setRoot] = useState(null);
33
+ const observeImageChange = useIntersectionObserver(onVisible, {
34
+ root,
35
+ threshold: 0.5
36
+ }, onImageChanged);
37
+ const observeCycleScroll = useIntersectionObserver(index => {
38
+ const imageElement = imagesRef.current && imagesRef.current[index];
39
+ if (imageElement) {
40
+ imageElement.scrollIntoView({
41
+ block: 'nearest',
42
+ inline: 'start'
43
+ });
44
+ }
45
+ }, {
46
+ root,
47
+ threshold: 1
48
+ });
49
+ if (images.length === 1) {
50
+ return /*#__PURE__*/_jsx("div", {
51
+ className: getClassName('bpk-carousel-container'),
52
+ role: "list",
53
+ "data-testid": "image-gallery-scroll-container",
54
+ children: /*#__PURE__*/_jsx(BpkCarouselImage, {
55
+ image: images[0],
56
+ index: 0
57
+ })
58
+ });
59
+ }
60
+ return /*#__PURE__*/_jsxs("div", {
61
+ className: getClassName('bpk-carousel-container'),
62
+ ref: setRoot,
63
+ "data-testid": "image-gallery-scroll-container",
64
+ role: "list",
65
+ children: [/*#__PURE__*/_jsx(BpkCarouselImage, {
66
+ image: images[images.length - 1],
67
+ index: images.length - 1,
68
+ ref: el => {
69
+ observeCycleScroll(el);
70
+ observeImageChange(el);
71
+ }
72
+ }), images.map((image, index) => /*#__PURE__*/_jsx(BpkCarouselImage
73
+ // eslint-disable-next-line react/no-array-index-key
74
+ , {
75
+ image: image,
76
+ index: index,
77
+ ref: el => {
78
+ // eslint-disable-next-line no-param-reassign
79
+ imagesRef.current[index] = el;
80
+ observeImageChange(el);
81
+ }
82
+ }, index)), /*#__PURE__*/_jsx(BpkCarouselImage, {
83
+ image: images[0],
84
+ index: 0,
85
+ ref: el => {
86
+ observeCycleScroll(el);
87
+ observeImageChange(el);
88
+ }
89
+ })]
90
+ });
91
+ });
92
+ export default BpkScrollContainer;
@@ -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
+ .bpk-carousel-container{display:grid;width:100%;height:100%;grid:1fr/auto-flow 100%;overflow-x:auto;overflow-y:hidden;backface-visibility:hidden;overscroll-behavior:contain;scroll-snap-type:x mandatory;scrollbar-width:none;user-select:none}.bpk-carousel-container::-webkit-scrollbar{display:none}
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from "react";
2
+ type ImageProps = {
3
+ image: ReactNode;
4
+ index: number;
5
+ };
6
+ declare const BpkCarouselImage: import("react").ForwardRefExoticComponent<ImageProps & import("react").RefAttributes<HTMLDivElement>>;
7
+ export default BpkCarouselImage;
@@ -0,0 +1,34 @@
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 { forwardRef } from "react";
20
+ import { cssModules } from "../../bpk-react-utils";
21
+ import STYLES from "./BpkCarouselImage.module.css";
22
+ import { jsx as _jsx } from "react/jsx-runtime";
23
+ const getClassName = cssModules(STYLES);
24
+ const BpkCarouselImage = /*#__PURE__*/forwardRef(({
25
+ image,
26
+ index
27
+ }, ref) => /*#__PURE__*/_jsx("div", {
28
+ className: getClassName('bpk-carousel-image'),
29
+ "data-index": index,
30
+ ref: ref,
31
+ role: "listitem",
32
+ children: image
33
+ }, index));
34
+ export default BpkCarouselImage;
@@ -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
+ .bpk-carousel-image{display:inline-flex;width:100%;min-width:0;height:100%;min-height:0;justify-content:center;scroll-snap-align:start;scroll-snap-stop:always;isolation:isolate}.bpk-carousel-image img{max-width:100%;max-height:100%;object-fit:initial}
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ export type OnImageChangedHandler = ((shownImageIndex: number) => void) | null | undefined;
3
+ export type Props = {
4
+ images: ReactNode[];
5
+ initialImageIndex?: number;
6
+ onImageChanged?: OnImageChangedHandler;
7
+ /**
8
+ * This prop is used to let the consumer adjust the spacing between the page indicator and the bottom of the image when variant is VARIANT.overImage
9
+ */
10
+ bottom?: number;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MutableRefObject } from 'react';
2
+ import type { OnImageChangedHandler } from './types';
3
+ export declare function useScrollToInitialImage(initialImageIndex: number, imagesRef: MutableRefObject<Array<HTMLElement | null>>): void;
4
+ export declare function useIntersectionObserver(onIntersecting: (index: number) => void, { root, threshold }: IntersectionObserverInit, onImageChanged?: OnImageChangedHandler): (element: HTMLElement | null) => void;
@@ -0,0 +1,68 @@
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 { useEffect, useMemo, useRef } from 'react';
20
+ export function useScrollToInitialImage(initialImageIndex, imagesRef) {
21
+ useEffect(() => {
22
+ const element = imagesRef.current[initialImageIndex];
23
+ if (element) {
24
+ element.scrollIntoView({
25
+ block: 'nearest',
26
+ inline: 'start'
27
+ });
28
+ }
29
+ }, [initialImageIndex, imagesRef]);
30
+ }
31
+ export function useIntersectionObserver(onIntersecting, {
32
+ root,
33
+ threshold
34
+ }, onImageChanged) {
35
+ const callbackRef = useRef(onIntersecting);
36
+ useEffect(() => {
37
+ callbackRef.current = onIntersecting;
38
+ });
39
+ const observe = useMemo(() => {
40
+ if (!root) return () => {};
41
+ const observer = new IntersectionObserver(entries => {
42
+ const shownEntry = entries.find(entry => entry.isIntersecting);
43
+ if (!shownEntry) {
44
+ return;
45
+ }
46
+ const {
47
+ index
48
+ } = shownEntry.target.dataset;
49
+ if (index) {
50
+ const currentIndex = parseInt(index, 10);
51
+ callbackRef.current(currentIndex);
52
+ if (onImageChanged) {
53
+ onImageChanged(currentIndex);
54
+ }
55
+ }
56
+ }, {
57
+ root,
58
+ threshold
59
+ });
60
+ const observeElement = element => {
61
+ if (element && observer) {
62
+ observer.observe(element);
63
+ }
64
+ };
65
+ return observeElement;
66
+ }, [onImageChanged, root, threshold]);
67
+ return observe;
68
+ }
@@ -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
- .bpk-drawer{position:fixed;right:0;display:flex;z-index:1100;width:90%;max-width:25rem;height:100%;flex-direction:column;transform:translate(100%);transition:transform 200ms ease;outline:0;background:#fff;overflow-y:scroll;box-shadow:0px 12px 50px 0px rgba(37,32,31,.25)}html[dir=rtl] .bpk-drawer{right:auto;left:0;transform:translate(-100%)}@media(max-width: 32rem){.bpk-drawer{width:100%;max-width:100%}}.bpk-drawer--entering,.bpk-drawer--entered{transform:translate(0)}html[dir=rtl] .bpk-drawer--entering,html[dir=rtl] .bpk-drawer--entered{transform:translate(0)}.bpk-drawer--exiting{transition:transform 50ms ease}.bpk-drawer--exiting,.bpk-drawer--exited{transform:translate(100%)}html[dir=rtl] .bpk-drawer--exiting,html[dir=rtl] .bpk-drawer--exited{transform:translate(-100%)}.bpk-drawer__header{display:flex;min-height:3rem;padding:1rem;justify-content:space-between;align-items:center;flex:0 0;box-shadow:0 -1px 0 0 #c1c7cf inset}.bpk-drawer__heading{margin:0;font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-drawer__heading--visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}.bpk-drawer__close-button{float:right}html[dir=rtl] .bpk-drawer__close-button{float:left}.bpk-drawer__content{height:100%;padding:1rem;flex:1 1 100%;overflow-y:auto}
18
+ .bpk-drawer{position:fixed;right:0;display:flex;z-index:1100;width:90%;max-width:25rem;height:100%;flex-direction:column;transform:translate(100%);transition:transform 200ms ease;outline:0;background:#fff;overflow-y:scroll;box-shadow:0px 12px 50px 0px rgba(37,32,31,.25)}html[dir=rtl] .bpk-drawer{right:auto;left:0;transform:translate(-100%)}@media(max-width: 32rem){.bpk-drawer{width:100%;max-width:100%}}.bpk-drawer--entering,.bpk-drawer--entered{transform:translate(0)}html[dir=rtl] .bpk-drawer--entering,html[dir=rtl] .bpk-drawer--entered{transform:translate(0)}.bpk-drawer--exiting{transition:transform 50ms ease}.bpk-drawer--exiting,.bpk-drawer--exited{transform:translate(100%)}html[dir=rtl] .bpk-drawer--exiting,html[dir=rtl] .bpk-drawer--exited{transform:translate(-100%)}.bpk-drawer__header{display:flex;min-height:3rem;padding:1rem;justify-content:space-between;align-items:center;flex:0 0;box-shadow:0 -1px 0 0 #c1c7cf inset}.bpk-drawer__heading{margin:0;font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-drawer__heading--visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.bpk-drawer__close-button{float:right}html[dir=rtl] .bpk-drawer__close-button{float:left}.bpk-drawer__content{height:100%;padding:1rem;flex:1 1 100%;overflow-y:auto}
@@ -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
- .bpk-icon-description{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-icon-description{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
@@ -36,50 +36,64 @@ const BpkPageIndicator = ({
36
36
  showNav,
37
37
  totalIndicators,
38
38
  variant
39
- }) =>
40
- /*#__PURE__*/
41
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
42
- _jsx("div", {
43
- className: className,
44
- children: /*#__PURE__*/_jsxs("div", {
45
- className: getClassName('bpk-page-indicator', showNav && 'bpk-page-indicator__showNav'),
46
- children: [showNav && /*#__PURE__*/_jsx(NavButton, {
47
- currentIndex: currentIndex,
48
- onClick: onClick,
49
- disabled: currentIndex === 0,
50
- direction: DIRECTIONS.PREV,
51
- ariaLabel: prevNavLabel
52
- }), /*#__PURE__*/_jsx("div", {
53
- className: getClassName('bpk-page-indicator__container'),
54
- children: /*#__PURE__*/_jsx("div", {
55
- className: getClassName('bpk-page-indicator__indicators-container'),
56
- style: currentIndex > START_SCROLL_INDEX ? {
57
- '--scroll-index': totalIndicators > DISPLAYED_TOTAL ? Math.min(currentIndex - START_SCROLL_INDEX, totalIndicators - DISPLAYED_TOTAL) : 0
58
- } : undefined,
59
- children: [...Array(totalIndicators)].map((val, index) => /*#__PURE__*/_jsx("button", {
60
- type: "button",
61
- onClick: e => {
62
- onClick(e, index, DIRECTIONS.INDICATORS);
63
- },
64
- className: getClassName('bpk-page-indicator__indicator', `bpk-page-indicator__indicator--${variant}`, index === currentIndex && `bpk-page-indicator__indicator--active-${variant}`),
65
- "aria-label": `${indicatorLabel} ${index + 1}`,
66
- "aria-current": currentIndex === index ? 'true' : 'false'
67
- // eslint-disable-next-line react/no-array-index-key
68
- }, `indicator-${index}`))
39
+ }) => {
40
+ /**
41
+ * This validation is used to avoid an a11y issue when onClick isn't available.
42
+ * In this case, we can set aria-hidden = true to let screen reader skip reading page indicator dots.
43
+ * and render the dot as div rather than button to align with aria-hidden = true.
44
+ */
45
+ const isInteractive = !!onClick;
46
+ return (
47
+ /*#__PURE__*/
48
+ // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
49
+ _jsx("div", {
50
+ className: className,
51
+ "aria-hidden": isInteractive ? 'false' : 'true',
52
+ "data-testid": "indicator-container",
53
+ children: /*#__PURE__*/_jsxs("div", {
54
+ className: getClassName('bpk-page-indicator', showNav && 'bpk-page-indicator__showNav'),
55
+ children: [showNav && /*#__PURE__*/_jsx(NavButton, {
56
+ currentIndex: currentIndex,
57
+ onClick: onClick,
58
+ disabled: currentIndex === 0,
59
+ direction: DIRECTIONS.PREV,
60
+ ariaLabel: prevNavLabel
61
+ }), /*#__PURE__*/_jsx("div", {
62
+ className: getClassName('bpk-page-indicator__container'),
63
+ children: /*#__PURE__*/_jsx("div", {
64
+ className: getClassName('bpk-page-indicator__indicators-container'),
65
+ style: currentIndex > START_SCROLL_INDEX ? {
66
+ '--scroll-index': totalIndicators > DISPLAYED_TOTAL ? Math.min(currentIndex - START_SCROLL_INDEX, totalIndicators - DISPLAYED_TOTAL) : 0
67
+ } : undefined,
68
+ children: [...Array(totalIndicators)].map((val, index) => isInteractive ? /*#__PURE__*/_jsx("button", {
69
+ type: "button",
70
+ onClick: e => {
71
+ onClick(e, index, DIRECTIONS.INDICATORS);
72
+ },
73
+ className: getClassName('bpk-page-indicator__indicator', `bpk-page-indicator__indicator--${variant}`, index === currentIndex && `bpk-page-indicator__indicator--active-${variant}`),
74
+ "aria-label": `${indicatorLabel} ${index + 1}`,
75
+ "aria-current": currentIndex === index ? 'true' : 'false'
76
+ // eslint-disable-next-line react/no-array-index-key
77
+ }, `indicator-${index}`) : /*#__PURE__*/_jsx("div", {
78
+ className: getClassName('bpk-page-indicator__indicator', `bpk-page-indicator__indicator--${variant}`, index === currentIndex && `bpk-page-indicator__indicator--active-${variant}`)
79
+ // eslint-disable-next-line react/no-array-index-key
80
+ }, `indicator-${index}`))
81
+ })
82
+ }), showNav && /*#__PURE__*/_jsx(NavButton, {
83
+ currentIndex: currentIndex,
84
+ onClick: onClick,
85
+ disabled: currentIndex === totalIndicators - 1,
86
+ ariaLabel: nextNavLabel,
87
+ direction: DIRECTIONS.NEXT
88
+ })]
69
89
  })
70
- }), showNav && /*#__PURE__*/_jsx(NavButton, {
71
- currentIndex: currentIndex,
72
- onClick: onClick,
73
- disabled: currentIndex === totalIndicators - 1,
74
- ariaLabel: nextNavLabel,
75
- direction: DIRECTIONS.NEXT
76
- })]
77
- })
78
- });
90
+ })
91
+ );
92
+ };
79
93
  BpkPageIndicator.propTypes = {
80
- indicatorLabel: PropTypes.string.isRequired,
81
- prevNavLabel: PropTypes.string.isRequired,
82
- nextNavLabel: PropTypes.string.isRequired,
94
+ indicatorLabel: PropTypes.string,
95
+ prevNavLabel: PropTypes.string,
96
+ nextNavLabel: PropTypes.string,
83
97
  currentIndex: PropTypes.number.isRequired,
84
98
  totalIndicators: PropTypes.number.isRequired,
85
99
  variant: PropTypes.oneOf(Object.keys(VARIANT)),
@@ -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
- .bpk-pagination-nudger{display:flex;width:2.25rem;height:2.25rem;justify-content:center;align-content:center}.bpk-pagination-nudger__text--hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-pagination-nudger{display:flex;width:2.25rem;height:2.25rem;justify-content:center;align-content:center}.bpk-pagination-nudger__text--hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { useState, useEffect, useRef, cloneElement, isValidElement } from 'react';
20
- import { useFloating, autoUpdate, offset, useClick, useDismiss, useInteractions, FloatingFocusManager, arrow, FloatingArrow, flip, shift } from '@floating-ui/react';
20
+ import { useFloating, autoUpdate, offset, useClick, useDismiss, useInteractions, FloatingFocusManager, arrow, FloatingArrow, shift } from '@floating-ui/react';
21
21
  import { surfaceHighlightDay } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
22
22
 
23
23
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
@@ -80,9 +80,7 @@ const BpkPopover = ({
80
80
  open: isOpenState,
81
81
  onOpenChange: setIsOpenState,
82
82
  placement,
83
- middleware: [showArrow && offset(17), flip({
84
- crossAxis: true
85
- }), shift(), showArrow && arrow({
83
+ middleware: [showArrow && offset(17), shift(), showArrow && arrow({
86
84
  element: arrowRef
87
85
  })],
88
86
  whileElementsMounted: autoUpdate
@@ -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
- .bpk-popover--container{z-index:900}.bpk-popover{transition:opacity 200ms ease-in-out;outline:0;background-color:#fff;opacity:1;border-radius:.5rem;box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}@media(min-width: 32.0625rem){.bpk-popover{max-width:32rem;transition:opacity 50ms ease-in-out}}.bpk-popover--appear{opacity:0}.bpk-popover--appear-active{opacity:1}.bpk-popover__arrow{width:1.5rem;height:1.5rem;fill:#fff}.bpk-popover__arrow[data-hide]{visibility:hidden}.bpk-popover__body--padded{padding:1rem}.bpk-popover__body--padded:not(:last-of-type){padding-bottom:0}.bpk-popover__header{display:flex;padding:1rem 1rem 0;justify-content:space-between}.bpk-popover__header~.bpk-popover__body--padded{padding-top:.5rem}.bpk-popover__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}.bpk-popover__footer{padding:.5rem 1rem;text-align:right}html[dir=rtl] .bpk-popover__footer{text-align:left}.bpk-popover__action{padding:0 1rem 1rem 1rem}
18
+ .bpk-popover--container{z-index:900}.bpk-popover{transition:opacity 200ms ease-in-out;outline:0;background-color:#fff;opacity:1;border-radius:.5rem;box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}@media(min-width: 32.0625rem){.bpk-popover{max-width:32rem;transition:opacity 50ms ease-in-out}}.bpk-popover--appear{opacity:0}.bpk-popover--appear-active{opacity:1}.bpk-popover__arrow{width:1.5rem;height:1.5rem;fill:#fff}.bpk-popover__arrow[data-hide]{visibility:hidden}.bpk-popover__body--padded{padding:1rem}.bpk-popover__body--padded:not(:last-of-type){padding-bottom:0}.bpk-popover__header{display:flex;padding:1rem 1rem 0;justify-content:space-between}.bpk-popover__header~.bpk-popover__body--padded{padding-top:.5rem}.bpk-popover__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.bpk-popover__footer{padding:.5rem 1rem;text-align:right}html[dir=rtl] .bpk-popover__footer{text-align:left}.bpk-popover__action{padding:0 1rem 1rem 1rem}
@@ -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
- .bpk-theme-toggle__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-theme-toggle__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
@@ -63,6 +63,7 @@
63
63
  margin: -1px; /* stylelint-disable-line unit-disallowed-list */
64
64
  padding: 0;
65
65
  border: 0;
66
+ white-space: nowrap;
66
67
  overflow: hidden;
67
68
  clip: rect(0 0 0 0);
68
69
  }
@@ -16,4 +16,4 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  *
19
- *//*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}template,[hidden]{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:bold}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}html{font-size:100%;box-sizing:border-box}*{box-sizing:inherit}*::before,*::after{box-sizing:inherit}body{color:#161616;font-family:"Skyscanner Relative",-apple-system,BlinkMacSystemFont,"Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:1rem;line-height:1.3rem}body.scaffold-font-size{font-size:13px}body.enable-font-smoothing{-webkit-font-smoothing:antialiased}:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.hidden,.hide{display:none !important}.visuallyhidden,.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0)}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus,.visually-hidden.focusable:active,.visually-hidden.focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.invisible{visibility:hidden}.clearfix::before,.clearfix::after{content:"";display:table}.clearfix::after{clear:both}
19
+ *//*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}template,[hidden]{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:bold}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}html{font-size:100%;box-sizing:border-box}*{box-sizing:inherit}*::before,*::after{box-sizing:inherit}body{color:#161616;font-family:"Skyscanner Relative",-apple-system,BlinkMacSystemFont,"Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;font-size:1rem;line-height:1.3rem}body.scaffold-font-size{font-size:13px}body.enable-font-smoothing{-webkit-font-smoothing:antialiased}:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.hidden,.hide{display:none !important}.visuallyhidden,.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus,.visually-hidden.focusable:active,.visually-hidden.focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.invisible{visibility:hidden}.clearfix::before,.clearfix::after{content:"";display:table}.clearfix::after{clear:both}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "34.6.0",
3
+ "version": "34.7.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,6 +64,7 @@
64
64
  margin: -1px; /* stylelint-disable-line unit-disallowed-list */
65
65
  padding: 0;
66
66
  border: 0;
67
+ white-space: nowrap;
67
68
  overflow: hidden;
68
69
  clip: rect(0 0 0 0);
69
70
  }