@skyscanner/backpack-web 42.12.0 → 42.13.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 (21) hide show
  1. package/bpk-component-comparison-table/index.d.ts +4 -1
  2. package/bpk-component-comparison-table/index.js +3 -1
  3. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTable.d.ts +17 -0
  4. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTable.js +41 -0
  5. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTable.module.css +18 -0
  6. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableColumnHeader.d.ts +8 -0
  7. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableColumnHeader.js +66 -0
  8. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableColumnHeaderPlaceholder.d.ts +7 -0
  9. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableColumnHeaderPlaceholder.js +49 -0
  10. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableContent.d.ts +3 -0
  11. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableContent.js +94 -0
  12. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableHeader.d.ts +3 -0
  13. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableHeader.js +42 -0
  14. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableHeaderRow.d.ts +9 -0
  15. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableHeaderRow.js +52 -0
  16. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableRoot.d.ts +3 -0
  17. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableRoot.js +38 -0
  18. package/bpk-component-comparison-table/src/BpkComparisonTable/common-types.d.ts +73 -0
  19. package/bpk-component-comparison-table/src/BpkComparisonTable/common-types.js +1 -0
  20. package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTray.module.css +1 -1
  21. package/package.json +1 -1
@@ -1,3 +1,6 @@
1
+ import BpkComparisonTable from './src/BpkComparisonTable/BpkComparisonTable';
1
2
  import BpkComparisonTray from './src/BpkComparisonTray/BpkComparisonTray';
2
3
  export type { BpkComparisonItem, BpkComparisonTrayRootProps, BpkComparisonTrayItemProps, BpkComparisonTrayNamespace, } from './src/BpkComparisonTray/common-types';
3
- export default BpkComparisonTray;
4
+ export type { BpkCompareRow, BpkCompareColumn, BpkComparisonTableRootProps, BpkComparisonTableStrings, BpkComparisonTableNamespace, } from './src/BpkComparisonTable/common-types';
5
+ export { BpkComparisonTray };
6
+ export default BpkComparisonTable;
@@ -16,5 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
+ import BpkComparisonTable from "./src/BpkComparisonTable/BpkComparisonTable";
19
20
  import BpkComparisonTray from "./src/BpkComparisonTray/BpkComparisonTray";
20
- export default BpkComparisonTray;
21
+ export { BpkComparisonTray };
22
+ export default BpkComparisonTable;
@@ -0,0 +1,17 @@
1
+ import type { BpkComparisonTableNamespace } from './common-types';
2
+ /**
3
+ * BpkComparisonTable — side-by-side comparison modal.
4
+ *
5
+ * @example
6
+ * <BpkComparisonTable.Root isOpen={isOpen} onClose={() => setIsOpen(false)}>
7
+ * <BpkComparisonTable.Header title="Compare cars" strings={strings} />
8
+ * <BpkComparisonTable.Content
9
+ * columns={columns}
10
+ * onRemove={(itemId) => handleRemove(itemId)}
11
+ * onAddMoreClick={() => setIsOpen(false)}
12
+ * strings={strings}
13
+ * />
14
+ * </BpkComparisonTable.Root>
15
+ */
16
+ declare const BpkComparisonTable: BpkComparisonTableNamespace;
17
+ export default BpkComparisonTable;
@@ -0,0 +1,41 @@
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 BpkComparisonTableContent from "./BpkComparisonTableContent";
20
+ import BpkComparisonTableHeader from "./BpkComparisonTableHeader";
21
+ import BpkComparisonTableRoot from "./BpkComparisonTableRoot";
22
+ /**
23
+ * BpkComparisonTable — side-by-side comparison modal.
24
+ *
25
+ * @example
26
+ * <BpkComparisonTable.Root isOpen={isOpen} onClose={() => setIsOpen(false)}>
27
+ * <BpkComparisonTable.Header title="Compare cars" strings={strings} />
28
+ * <BpkComparisonTable.Content
29
+ * columns={columns}
30
+ * onRemove={(itemId) => handleRemove(itemId)}
31
+ * onAddMoreClick={() => setIsOpen(false)}
32
+ * strings={strings}
33
+ * />
34
+ * </BpkComparisonTable.Root>
35
+ */
36
+ const BpkComparisonTable = {
37
+ Root: BpkComparisonTableRoot,
38
+ Header: BpkComparisonTableHeader,
39
+ Content: BpkComparisonTableContent
40
+ };
41
+ export default BpkComparisonTable;
@@ -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-comparison-table__scroll-container{flex:1;overflow:auto;min-block-size:0;overscroll-behavior:contain}.bpk-comparison-table__scroll-container tbody{transform:translateY(var(--bpk-rows-offset, 0))}.bpk-comparison-table__scroll-container td:not(:last-child){border-inline-end:1px solid #c1c7cf}.bpk-comparison-table__scroll-container th:not(:last-child)::after{position:absolute;content:"";background-color:#c1c7cf;inline-size:1px;inset-block-end:0;inset-block-start:1rem;inset-inline-end:0}.bpk-comparison-table__scroll-container table{border-collapse:separate;border-spacing:0;min-inline-size:33.75rem}.bpk-comparison-table__scroll-container th{position:sticky;z-index:1;padding:0;background-color:#fff;vertical-align:top;inset-block-start:0}.bpk-comparison-table__header-content{display:flex;padding:1rem;flex-direction:column}.bpk-comparison-table__header-image-wrapper{position:relative;opacity:var(--bpk-image-opacity, 1);margin-block-end:1rem}.bpk-comparison-table__header-image-area{display:flex;justify-content:center;align-items:center;border-radius:.25rem;background-color:#e0e4e9;overflow:hidden;block-size:5.1875rem}.bpk-comparison-table__header-image-area img{max-block-size:100%;max-inline-size:100%;object-fit:contain}.bpk-comparison-table__header-id-section{margin-block-start:calc(6.1875rem*(var(--bpk-image-opacity, 1) - 1))}.bpk-comparison-table__best-tag{position:absolute;z-index:1;transform:translateY(-50%);inset-block-start:0}.bpk-comparison-table__remove-button{opacity:var(--bpk-image-opacity, 1);overflow:clip;margin-block-start:calc(.5rem*var(--bpk-image-opacity, 1));max-block-size:calc(5rem*var(--bpk-image-opacity, 1));overflow-clip-margin:.25rem}.bpk-comparison-table__placeholder-cell{background-color:#fff}
@@ -0,0 +1,8 @@
1
+ import type { BpkCompareColumn } from './common-types';
2
+ type BpkComparisonTableColumnHeaderProps = Pick<BpkCompareColumn, 'imageSrc' | 'imageAlt' | 'headerContent' | 'itemId' | 'bestTag' | 'removeA11yLabel'> & {
3
+ removeLabel: string;
4
+ bestTagLabel: string;
5
+ onRemove: (itemId: string) => void;
6
+ };
7
+ declare const BpkComparisonTableColumnHeader: ({ bestTag, bestTagLabel, headerContent, imageAlt, imageSrc, itemId, onRemove, removeA11yLabel, removeLabel, }: BpkComparisonTableColumnHeaderProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default BpkComparisonTableColumnHeader;
@@ -0,0 +1,66 @@
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 BpkBadge, { BADGE_TYPES } from "../../../bpk-component-badge";
20
+ import BpkButton, { BUTTON_TYPES, SIZE_TYPES } from "../../../bpk-component-button";
21
+ import { cssModules } from "../../../bpk-react-utils";
22
+ import STYLES from "./BpkComparisonTable.module.css";
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ const getClassName = cssModules(STYLES);
25
+ const BpkComparisonTableColumnHeader = ({
26
+ bestTag = false,
27
+ bestTagLabel,
28
+ headerContent,
29
+ imageAlt = '',
30
+ imageSrc,
31
+ itemId,
32
+ onRemove,
33
+ removeA11yLabel,
34
+ removeLabel
35
+ }) => /*#__PURE__*/_jsxs("div", {
36
+ className: getClassName('bpk-comparison-table__header-content'),
37
+ children: [/*#__PURE__*/_jsxs("div", {
38
+ className: getClassName('bpk-comparison-table__header-image-wrapper'),
39
+ children: [/*#__PURE__*/_jsx("div", {
40
+ className: getClassName('bpk-comparison-table__header-image-area'),
41
+ children: imageSrc && /*#__PURE__*/_jsx("img", {
42
+ src: imageSrc,
43
+ alt: imageAlt
44
+ })
45
+ }), bestTag && /*#__PURE__*/_jsx("span", {
46
+ className: getClassName('bpk-comparison-table__best-tag'),
47
+ children: /*#__PURE__*/_jsx(BpkBadge, {
48
+ type: BADGE_TYPES.brand,
49
+ children: bestTagLabel
50
+ })
51
+ })]
52
+ }), /*#__PURE__*/_jsx("div", {
53
+ className: getClassName('bpk-comparison-table__header-id-section'),
54
+ children: headerContent
55
+ }), /*#__PURE__*/_jsx("div", {
56
+ className: getClassName('bpk-comparison-table__remove-button'),
57
+ children: /*#__PURE__*/_jsx(BpkButton, {
58
+ type: BUTTON_TYPES.link,
59
+ size: SIZE_TYPES.small,
60
+ onClick: () => onRemove(itemId),
61
+ "aria-label": removeA11yLabel,
62
+ children: removeLabel
63
+ })
64
+ })]
65
+ });
66
+ export default BpkComparisonTableColumnHeader;
@@ -0,0 +1,7 @@
1
+ type BpkComparisonTableColumnHeaderPlaceholderProps = {
2
+ addMoreDescription: string;
3
+ addMoreLinkText: string;
4
+ onAddMoreClick: () => void;
5
+ };
6
+ declare const BpkComparisonTableColumnHeaderPlaceholder: ({ addMoreDescription, addMoreLinkText, onAddMoreClick, }: BpkComparisonTableColumnHeaderPlaceholderProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default BpkComparisonTableColumnHeaderPlaceholder;
@@ -0,0 +1,49 @@
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 BpkButton, { BUTTON_TYPES, SIZE_TYPES } from "../../../bpk-component-button";
20
+ import { BpkFlex, BpkSpacing } from "../../../bpk-component-layout";
21
+ import BpkText, { TEXT_COLORS, TEXT_STYLES } from "../../../bpk-component-text";
22
+ import { cssModules } from "../../../bpk-react-utils";
23
+ import STYLES from "./BpkComparisonTable.module.css";
24
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
26
+ const BpkComparisonTableColumnHeaderPlaceholder = ({
27
+ addMoreDescription,
28
+ addMoreLinkText,
29
+ onAddMoreClick
30
+ }) => /*#__PURE__*/_jsxs(BpkFlex, {
31
+ direction: "column",
32
+ align: "center",
33
+ gap: BpkSpacing.MD,
34
+ paddingTop: BpkSpacing.LG,
35
+ paddingInline: BpkSpacing.XL,
36
+ children: [/*#__PURE__*/_jsx(BpkText, {
37
+ textAlign: "center",
38
+ tagName: "p",
39
+ textStyle: TEXT_STYLES.bodyDefault,
40
+ color: TEXT_COLORS.textSecondary,
41
+ children: addMoreDescription
42
+ }), /*#__PURE__*/_jsx(BpkButton, {
43
+ type: BUTTON_TYPES.link,
44
+ size: SIZE_TYPES.small,
45
+ onClick: onAddMoreClick,
46
+ children: addMoreLinkText
47
+ })]
48
+ });
49
+ export default BpkComparisonTableColumnHeaderPlaceholder;
@@ -0,0 +1,3 @@
1
+ import type { BpkComparisonTableContentProps } from './common-types';
2
+ declare const BpkComparisonTableContent: ({ columns, onAddMoreClick, onRemove, strings, }: BpkComparisonTableContentProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default BpkComparisonTableContent;
@@ -0,0 +1,94 @@
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 { useEffect, useRef } from 'react';
20
+ import { BpkTable, BpkTableBody, BpkTableCell, BpkTableRow, TABLE_BODY_TYPES } from "../../../bpk-component-table";
21
+ import { cssModules } from "../../../bpk-react-utils";
22
+ import BpkComparisonTableHeaderRow from "./BpkComparisonTableHeaderRow";
23
+ import STYLES from "./BpkComparisonTable.module.css";
24
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
+ const getClassName = cssModules(STYLES);
26
+ const MAX_COLUMNS = 3;
27
+
28
+ // Matches the image area height (5.1875rem × 16px). Opacity goes from 1 → 0 as the user scrolls 0 → 83 px, giving a smooth parallax fade.
29
+ const IMAGE_FADE_THRESHOLD_PX = 83;
30
+ const BpkComparisonTableContent = ({
31
+ columns,
32
+ onAddMoreClick,
33
+ onRemove,
34
+ strings
35
+ }) => {
36
+ const scrollContainerRef = useRef(null);
37
+
38
+ // Pad with nulls so the table always renders exactly MAX_COLUMNS slots.
39
+ const displayColumns = [...columns, null, null, null].slice(0, MAX_COLUMNS);
40
+ const rowIds = columns[0]?.rows.map(row => row.rowId) ?? [];
41
+
42
+ // Dev-mode guard: warn if not all columns share the same rowId sequence.
43
+ if (process.env.NODE_ENV !== 'production' && columns.length > 1) {
44
+ const rowIdsByColumn = columns.map(column => column.rows.map(row => row.rowId).join(','));
45
+ const allMatch = rowIdsByColumn.every(ids => ids === rowIdsByColumn[0]);
46
+ if (!allMatch) {
47
+ // eslint-disable-next-line no-console
48
+ console.warn('[BpkComparisonTable] Not all columns share the same rowId sequence. Rows may misalign.');
49
+ }
50
+ }
51
+
52
+ // Pre-index cells by itemId → rowId for O(1) lookup during render.
53
+ const cellsByItemAndRow = new Map(columns.map(column => [column.itemId, new Map(column.rows.map(row => [row.rowId, row.cell]))]));
54
+ useEffect(() => {
55
+ const container = scrollContainerRef.current;
56
+ if (!container) return undefined;
57
+ const handleScroll = () => {
58
+ const {
59
+ scrollTop
60
+ } = container;
61
+ // During the animation phase, push tbody down by the scroll amount so rows appear locked in place.
62
+ // Once the fade-out completes the offset is fixed at the threshold and normal scrolling resumes.
63
+ container.style.setProperty('--bpk-rows-offset', `${Math.min(scrollTop, IMAGE_FADE_THRESHOLD_PX)}px`);
64
+ container.style.setProperty('--bpk-image-opacity', `${1 - Math.min(scrollTop / IMAGE_FADE_THRESHOLD_PX, 1)}`);
65
+ };
66
+ container.addEventListener('scroll', handleScroll, {
67
+ passive: true
68
+ });
69
+ return () => container.removeEventListener('scroll', handleScroll);
70
+ }, []);
71
+ return /*#__PURE__*/_jsx("div", {
72
+ ref: scrollContainerRef,
73
+ className: getClassName('bpk-comparison-table__scroll-container'),
74
+ children: /*#__PURE__*/_jsxs(BpkTable, {
75
+ children: [/*#__PURE__*/_jsx(BpkComparisonTableHeaderRow, {
76
+ displayColumns: displayColumns,
77
+ onRemove: onRemove,
78
+ onAddMoreClick: onAddMoreClick,
79
+ strings: strings
80
+ }), /*#__PURE__*/_jsx(BpkTableBody, {
81
+ type: TABLE_BODY_TYPES.striped,
82
+ children: rowIds.map(rowId => /*#__PURE__*/_jsx(BpkTableRow, {
83
+ children: displayColumns.map((column, index) => /*#__PURE__*/_jsx(BpkTableCell, {
84
+ // Placeholder need a distinct background colour not available via BpkTableCell props
85
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
86
+ className: column ? undefined : getClassName('bpk-comparison-table__placeholder-cell'),
87
+ children: column ? cellsByItemAndRow.get(column.itemId)?.get(rowId) ?? null : null
88
+ }, column ? `${rowId}-${column.itemId}` : `${rowId}-placeholder-${index}`))
89
+ }, rowId))
90
+ })]
91
+ })
92
+ });
93
+ };
94
+ export default BpkComparisonTableContent;
@@ -0,0 +1,3 @@
1
+ import type { BpkComparisonTableHeaderProps } from './common-types';
2
+ declare const BpkComparisonTableHeader: ({ children, strings, title }: BpkComparisonTableHeaderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default BpkComparisonTableHeader;
@@ -0,0 +1,42 @@
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 { BpkBox, BpkSpacing } from "../../../bpk-component-layout";
20
+ import { BpkModalV3 } from "../../../bpk-component-modal";
21
+ import BpkVisuallyHidden from "../../../bpk-component-visually-hidden";
22
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
23
+ const BpkComparisonTableHeader = ({
24
+ children,
25
+ strings,
26
+ title
27
+ }) => /*#__PURE__*/_jsxs(_Fragment, {
28
+ children: [/*#__PURE__*/_jsxs(BpkModalV3.Header, {
29
+ children: [/*#__PURE__*/_jsx(BpkModalV3.Title, {
30
+ children: title ?? /*#__PURE__*/_jsx(BpkVisuallyHidden, {
31
+ children: strings.accessibleLabel
32
+ })
33
+ }), /*#__PURE__*/_jsx(BpkModalV3.CloseTrigger, {
34
+ label: strings.closeLabel
35
+ })]
36
+ }), children && /*#__PURE__*/_jsx(BpkBox, {
37
+ paddingBottom: BpkSpacing.MD,
38
+ paddingInline: BpkSpacing.Base,
39
+ children: children
40
+ })]
41
+ });
42
+ export default BpkComparisonTableHeader;
@@ -0,0 +1,9 @@
1
+ import type { BpkComparisonTableStrings, BpkCompareColumn } from './common-types';
2
+ type BpkComparisonTableHeaderRowProps = {
3
+ displayColumns: Array<BpkCompareColumn | null>;
4
+ onRemove: (itemId: string) => void;
5
+ onAddMoreClick: () => void;
6
+ strings: BpkComparisonTableStrings;
7
+ };
8
+ declare const BpkComparisonTableHeaderRow: ({ displayColumns, onAddMoreClick, onRemove, strings, }: BpkComparisonTableHeaderRowProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default BpkComparisonTableHeaderRow;
@@ -0,0 +1,52 @@
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 { BpkTableHead, BpkTableHeadCell, BpkTableRow } from "../../../bpk-component-table";
20
+ import BpkComparisonTableColumnHeader from "./BpkComparisonTableColumnHeader";
21
+ import BpkComparisonTableColumnHeaderPlaceholder from "./BpkComparisonTableColumnHeaderPlaceholder";
22
+ import { jsx as _jsx } from "react/jsx-runtime";
23
+ const BpkComparisonTableHeaderRow = ({
24
+ displayColumns,
25
+ onAddMoreClick,
26
+ onRemove,
27
+ strings
28
+ }) => {
29
+ const {
30
+ addMoreDescription,
31
+ addMoreLinkText,
32
+ bestTagLabel,
33
+ removeLabel
34
+ } = strings;
35
+ return /*#__PURE__*/_jsx(BpkTableHead, {
36
+ children: /*#__PURE__*/_jsx(BpkTableRow, {
37
+ children: displayColumns.map((column, index) => /*#__PURE__*/_jsx(BpkTableHeadCell, {
38
+ children: column ? /*#__PURE__*/_jsx(BpkComparisonTableColumnHeader, {
39
+ ...column,
40
+ removeLabel: removeLabel,
41
+ onRemove: onRemove,
42
+ bestTagLabel: bestTagLabel
43
+ }) : /*#__PURE__*/_jsx(BpkComparisonTableColumnHeaderPlaceholder, {
44
+ addMoreDescription: addMoreDescription,
45
+ addMoreLinkText: addMoreLinkText,
46
+ onAddMoreClick: onAddMoreClick
47
+ })
48
+ }, column ? column.itemId : `placeholder-${index}`))
49
+ })
50
+ });
51
+ };
52
+ export default BpkComparisonTableHeaderRow;
@@ -0,0 +1,3 @@
1
+ import type { BpkComparisonTableRootProps } from './common-types';
2
+ declare const BpkComparisonTableRoot: ({ children, isOpen, onClose }: BpkComparisonTableRootProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default BpkComparisonTableRoot;
@@ -0,0 +1,38 @@
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 { BpkModalV3 } from "../../../bpk-component-modal";
20
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21
+ const BpkComparisonTableRoot = ({
22
+ children,
23
+ isOpen,
24
+ onClose
25
+ }) => /*#__PURE__*/_jsx(BpkModalV3.Root, {
26
+ open: isOpen,
27
+ onOpenChange: details => {
28
+ if (!details.open) {
29
+ onClose();
30
+ }
31
+ },
32
+ children: /*#__PURE__*/_jsxs(BpkModalV3.Portal, {
33
+ children: [/*#__PURE__*/_jsx(BpkModalV3.Scrim, {}), /*#__PURE__*/_jsx(BpkModalV3.Content, {
34
+ children: children
35
+ })]
36
+ })
37
+ });
38
+ export default BpkComparisonTableRoot;
@@ -0,0 +1,73 @@
1
+ import type { ReactNode } from 'react';
2
+ /** A single row entry within a comparison column. */
3
+ export type BpkCompareRow = {
4
+ /** Stable unique identifier used to align rows across columns. */
5
+ rowId: string;
6
+ /** Cell content — consumer-controlled ReactNode. */
7
+ cell: ReactNode;
8
+ };
9
+ /** Data for one filled comparison column. */
10
+ export type BpkCompareColumn = {
11
+ /** Stable unique identifier used for removal callbacks. */
12
+ itemId: string;
13
+ /** When true, renders a BpkBadge type=brand overlaying the top-left of the image area. */
14
+ bestTag?: boolean;
15
+ /** Image src for the header image area. */
16
+ imageSrc?: string;
17
+ /** Alt text for the header image. */
18
+ imageAlt?: string;
19
+ /** Consumer-owned slot rendered below the image area (name, description, price, CTA...). */
20
+ headerContent: ReactNode;
21
+ /** Row data — must match rowId sequences across all columns. */
22
+ rows: BpkCompareRow[];
23
+ /** Accessible label for the Remove button (e.g. "Remove rentalcars.com deal"). */
24
+ removeA11yLabel: string;
25
+ };
26
+ /** All strings required by BpkComparisonTable. */
27
+ export type BpkComparisonTableStrings = {
28
+ /** Accessible dialog name, used via BpkVisuallyHidden when no visible title is provided. */
29
+ accessibleLabel: string;
30
+ /** Accessible label for the modal close button. */
31
+ closeLabel: string;
32
+ /** Visible label for the Remove button in each column header. */
33
+ removeLabel: string;
34
+ /** Text inside the BpkBadge when bestTag=true (e.g. "Best"). */
35
+ bestTagLabel: string;
36
+ /** Description text inside the placeholder column. */
37
+ addMoreDescription: string;
38
+ /** Link text inside the placeholder column. */
39
+ addMoreLinkText: string;
40
+ };
41
+ /** Props for BpkComparisonTable.Root — modal shell only. */
42
+ export type BpkComparisonTableRootProps = {
43
+ /** Controls whether the modal is open. */
44
+ isOpen: boolean;
45
+ /** Called when the modal close trigger is activated or Escape is pressed. */
46
+ onClose: () => void;
47
+ /** BpkComparisonTable.Header and BpkComparisonTable.Content. */
48
+ children: ReactNode;
49
+ };
50
+ /** Props for BpkComparisonTable.Header — modal header + optional AiBlurb slot. */
51
+ export type BpkComparisonTableHeaderProps = {
52
+ /** Optional modal title rendered via BpkModalV3.Title. */
53
+ title?: string;
54
+ strings: BpkComparisonTableStrings;
55
+ /** Optional slot for AI blurb or any content below the title/close row. */
56
+ children?: ReactNode;
57
+ };
58
+ /** Props for BpkComparisonTable.Content — modal body with the comparison table. */
59
+ export type BpkComparisonTableContentProps = {
60
+ /** 1–3 filled columns. Component pads to 3 with placeholder cells automatically. */
61
+ columns: BpkCompareColumn[];
62
+ /** Called when a Remove button is clicked, with the column's itemId. */
63
+ onRemove: (itemId: string) => void;
64
+ /** Called when the Add more link in a placeholder column is clicked. */
65
+ onAddMoreClick: () => void;
66
+ strings: BpkComparisonTableStrings;
67
+ };
68
+ /** Namespace type covering all BpkComparisonTable subcomponents. */
69
+ export type BpkComparisonTableNamespace = {
70
+ Root: (props: BpkComparisonTableRootProps) => ReactNode;
71
+ Header: (props: BpkComparisonTableHeaderProps) => ReactNode;
72
+ Content: (props: BpkComparisonTableContentProps) => ReactNode;
73
+ };
@@ -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-comparison-tray{width:22.1875rem;max-width:100%}@media(max-width: 32rem){.bpk-comparison-tray{width:auto;min-width:0;flex:1}}.bpk-comparison-tray__item{position:relative;width:3.875rem;height:1.75rem;flex-shrink:0}.bpk-comparison-tray__item-image-container{width:100%;height:100%;background-color:#eff3f8;overflow:hidden;border-radius:.25rem}.bpk-comparison-tray__item-image-container img{object-fit:cover}.bpk-comparison-tray__item-close{position:relative;position:absolute;top:0;right:0;display:flex;width:1rem;height:1rem;justify-content:center;align-items:center;transform:translate(50%, -50%);border:.125rem solid #fff;border-radius:50%;background-color:#161616;color:#fff;cursor:pointer;box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}.bpk-comparison-tray__item-close::before{position:absolute;top:calc(-2.75rem/2 + 50%);left:calc(-2.75rem/2 + 50%);content:"";width:2.75rem;height:2.75rem}.bpk-comparison-tray__item-close svg{width:.5rem;height:.5rem;flex-shrink:0;fill:#fff}.bpk-comparison-tray__item-close:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-comparison-tray__item-placeholder{width:3.875rem;height:1.75rem;flex-shrink:0;border:.0625rem dashed #c1c7cf;border-radius:.25rem}
18
+ .bpk-comparison-tray{width:22.1875rem;max-width:100%}@media(max-width: 32rem){.bpk-comparison-tray{width:auto;min-width:0;flex:1}}.bpk-comparison-tray__item{position:relative;width:3.875rem;height:1.75rem;flex-shrink:0}.bpk-comparison-tray__item-image-container{width:100%;height:100%;background-color:#eff3f8;overflow:hidden;border-radius:.25rem}.bpk-comparison-tray__item-image-container img{object-fit:cover}.bpk-comparison-tray__item-close{position:relative;position:absolute;top:0;inset-inline-end:calc(-8*0.0625rem);display:flex;width:1rem;height:1rem;justify-content:center;align-items:center;transform:translateY(-50%);border:.125rem solid #fff;border-radius:50%;background-color:#161616;color:#fff;cursor:pointer;box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}.bpk-comparison-tray__item-close::before{position:absolute;top:calc(-2.75rem/2 + 50%);left:calc(-2.75rem/2 + 50%);content:"";width:2.75rem;height:2.75rem}.bpk-comparison-tray__item-close svg{width:.5rem;height:.5rem;flex-shrink:0;fill:#fff}.bpk-comparison-tray__item-close:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-comparison-tray__item-placeholder{width:3.875rem;height:1.75rem;flex-shrink:0;border:.0625rem dashed #c1c7cf;border-radius:.25rem}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "42.12.0",
3
+ "version": "42.13.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",