@skyscanner/backpack-web 9.2.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bpk-animate-height/package.json +3 -3
- package/bpk-component-accordion/package.json +7 -7
- package/bpk-component-aria-live/README.md +2 -2
- package/bpk-component-aria-live/index.js +0 -1
- package/bpk-component-aria-live/package.json +8 -9
- package/bpk-component-aria-live/src/BpkAriaLive.js +21 -20
- package/bpk-component-autosuggest/package.json +4 -4
- package/bpk-component-badge/package.json +5 -5
- package/bpk-component-banner-alert/package.json +9 -9
- package/bpk-component-barchart/package.json +8 -8
- package/bpk-component-blockquote/package.json +2 -2
- package/bpk-component-breadcrumb/package.json +5 -5
- package/bpk-component-breakpoint/package.json +3 -3
- package/bpk-component-button/package.json +3 -3
- package/bpk-component-calendar/DOCS.md +1 -7
- package/bpk-component-calendar/README.md +0 -10
- package/bpk-component-calendar/index.js +0 -2
- package/bpk-component-calendar/package.json +9 -9
- package/bpk-component-calendar/src/BpkCalendarDate.js +0 -15
- package/bpk-component-calendar/src/BpkCalendarDate.module.scss +17 -50
- package/bpk-component-calendar/src/BpkCalendarGrid.module.scss +5 -5
- package/bpk-component-calendar/src/_variables.scss +1 -3
- package/bpk-component-card/package.json +4 -4
- package/bpk-component-checkbox/package.json +5 -5
- package/bpk-component-chip/package.json +5 -5
- package/bpk-component-close-button/package.json +4 -4
- package/bpk-component-code/package.json +2 -2
- package/bpk-component-content-cards/README.md +43 -0
- package/bpk-component-content-cards/index.js +21 -0
- package/bpk-component-content-cards/package.json +23 -0
- package/bpk-component-content-cards/src/BpkContentCard.js +83 -0
- package/bpk-component-content-cards/src/BpkContentCard.module.scss +87 -0
- package/bpk-component-content-cards/src/BpkContentCards.js +72 -0
- package/bpk-component-content-cards/src/BpkContentCards.module.css +18 -0
- package/bpk-component-content-cards/src/BpkContentCards.module.scss +51 -0
- package/bpk-component-content-container/package.json +2 -2
- package/bpk-component-datatable/README.md +78 -21
- package/bpk-component-datatable/package.json +5 -6
- package/bpk-component-datatable/src/BpkDataTable.js +176 -143
- package/bpk-component-datatable/src/BpkDataTable.module.scss +10 -14
- package/bpk-component-datatable/src/BpkDataTableColumn.js +37 -40
- package/bpk-component-datatable/src/BpkDataTableHeader.js +143 -0
- package/bpk-component-datatable/src/{BpkDataTableColumn.module.scss → BpkDataTableHeader.module.scss} +12 -11
- package/bpk-component-datatable/src/common-types.js +33 -11
- package/bpk-component-datatable/src/sort-types.js +6 -0
- package/bpk-component-datatable/src/utils.js +66 -9
- package/bpk-component-datepicker/package.json +9 -9
- package/bpk-component-description-list/package.json +2 -2
- package/bpk-component-dialog/package.json +8 -8
- package/bpk-component-drawer/package.json +9 -9
- package/bpk-component-fieldset/package.json +12 -12
- package/bpk-component-flare/package.json +4 -4
- package/bpk-component-floating-notification/README.md +0 -8
- package/bpk-component-floating-notification/index.js +0 -2
- package/bpk-component-floating-notification/package.json +5 -5
- package/bpk-component-floating-notification/src/BpkFloatingNotification.js +7 -26
- package/bpk-component-floating-notification/src/BpkFloatingNotification.module.scss +4 -17
- package/bpk-component-form-validation/package.json +10 -10
- package/bpk-component-graphic-promotion/{index.ts → index.js} +0 -0
- package/bpk-component-graphic-promotion/package.json +7 -6
- package/bpk-component-graphic-promotion/src/{BpkGraphicPromo.tsx → BpkGraphicPromo.js} +26 -16
- package/bpk-component-grid/package.json +2 -2
- package/bpk-component-grid-toggle/package.json +3 -3
- package/bpk-component-horizontal-nav/package.json +6 -6
- package/bpk-component-horizontal-nav/src/BpkHorizontalNav.module.scss +2 -2
- package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.module.scss +13 -13
- package/bpk-component-icon/package.json +7 -7
- package/bpk-component-image/package.json +6 -6
- package/bpk-component-infinite-scroll/package.json +6 -6
- package/bpk-component-input/package.json +6 -6
- package/bpk-component-label/package.json +2 -2
- package/bpk-component-link/package.json +4 -4
- package/bpk-component-list/README.md +8 -5
- package/bpk-component-list/package.json +2 -2
- package/bpk-component-list/src/BpkList.js +18 -2
- package/bpk-component-loading-button/package.json +6 -6
- package/bpk-component-map/package.json +6 -6
- package/bpk-component-mobile-scroll-container/package.json +3 -3
- package/bpk-component-modal/package.json +9 -9
- package/bpk-component-navigation-bar/package.json +8 -8
- package/bpk-component-navigation-bar/src/BpkNavigationBar.module.scss +2 -3
- package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.module.scss +4 -4
- package/bpk-component-navigation-bar/src/BpkNavigationBarIconButton.module.scss +3 -3
- package/bpk-component-nudger/package.json +7 -7
- package/bpk-component-overlay/package.json +4 -4
- package/bpk-component-pagination/package.json +4 -4
- package/bpk-component-panel/package.json +2 -2
- package/bpk-component-phone-input/package.json +9 -9
- package/bpk-component-popover/package.json +8 -8
- package/bpk-component-price/package.json +3 -3
- package/bpk-component-progress/package.json +5 -5
- package/bpk-component-radio/package.json +4 -4
- package/bpk-component-rating/package.json +4 -4
- package/bpk-component-rtl-toggle/package.json +2 -2
- package/bpk-component-scrollable-calendar/package.json +6 -6
- package/bpk-component-section-list/package.json +6 -6
- package/bpk-component-select/package.json +3 -3
- package/bpk-component-skip-link/package.json +2 -2
- package/bpk-component-slider/package.json +4 -4
- package/bpk-component-spinner/package.json +3 -3
- package/bpk-component-split-input/package.json +3 -3
- package/bpk-component-star-rating/package.json +5 -5
- package/bpk-component-switch/package.json +2 -2
- package/bpk-component-table/package.json +2 -2
- package/bpk-component-text/package.json +2 -2
- package/bpk-component-textarea/package.json +4 -4
- package/bpk-component-theme-toggle/package.json +5 -5
- package/bpk-component-ticket/package.json +4 -4
- package/bpk-component-tooltip/package.json +4 -4
- package/bpk-scrim-utils/package.json +2 -2
- package/bpk-theming/package.json +2 -2
- package/package.json +4 -4
- package/bpk-component-datatable/src/bpkHeaderRenderer.js +0 -110
- package/bpk-component-datatable/src/sorter.js +0 -166
- package/bpk-component-graphic-promotion/src/BpkGraphicPromo-test.tsx +0 -134
- package/bpk-component-graphic-promotion/src/accessibility-test.tsx +0 -147
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-star-rating",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Backpack rating star component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-component-icon": "^10.0.
|
|
18
|
-
"bpk-mixins": "^31.
|
|
17
|
+
"bpk-component-icon": "^10.0.4",
|
|
18
|
+
"bpk-mixins": "^31.6.3",
|
|
19
19
|
"bpk-react-utils": "^7.0.0",
|
|
20
20
|
"prop-types": "^15.7.2"
|
|
21
21
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"react": "^17.0.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"bpk-component-table": "^4.0.
|
|
27
|
-
"bpk-storybook-utils": "^2.0.
|
|
26
|
+
"bpk-component-table": "^4.0.4",
|
|
27
|
+
"bpk-storybook-utils": "^2.0.4"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-switch",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Backpack switch component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-mixins": "^31.
|
|
17
|
+
"bpk-mixins": "^31.6.3",
|
|
18
18
|
"bpk-react-utils": "^7.0.0",
|
|
19
19
|
"prop-types": "^15.5.8"
|
|
20
20
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-table",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Backpack table component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-mixins": "^31.
|
|
17
|
+
"bpk-mixins": "^31.6.3",
|
|
18
18
|
"bpk-react-utils": "^7.0.0",
|
|
19
19
|
"prop-types": "^15.7.2"
|
|
20
20
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-text",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.4",
|
|
4
4
|
"description": "Backpack text component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-mixins": "^31.
|
|
17
|
+
"bpk-mixins": "^31.6.3",
|
|
18
18
|
"bpk-react-utils": "^7.0.0",
|
|
19
19
|
"prop-types": "^15.7.2"
|
|
20
20
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-textarea",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Backpack textarea component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-mixins": "^31.
|
|
17
|
+
"bpk-mixins": "^31.6.3",
|
|
18
18
|
"bpk-react-utils": "^7.0.0",
|
|
19
19
|
"prop-types": "^15.7.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"bpk-component-label": "^6.0.
|
|
23
|
-
"bpk-storybook-utils": "^2.0.
|
|
22
|
+
"bpk-component-label": "^6.0.4",
|
|
23
|
+
"bpk-storybook-utils": "^2.0.4"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^17.0.2"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-theme-toggle",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Backpack theme toggle component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@skyscanner/bpk-foundations-web": "^9.
|
|
18
|
-
"bpk-component-label": "^6.0.
|
|
19
|
-
"bpk-component-select": "^6.0.
|
|
20
|
-
"bpk-mixins": "^31.
|
|
17
|
+
"@skyscanner/bpk-foundations-web": "^9.3.0",
|
|
18
|
+
"bpk-component-label": "^6.0.4",
|
|
19
|
+
"bpk-component-select": "^6.0.4",
|
|
20
|
+
"bpk-mixins": "^31.6.3",
|
|
21
21
|
"bpk-react-utils": "^7.0.0",
|
|
22
22
|
"prop-types": "^15.7.2"
|
|
23
23
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-ticket",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"description": "Backpack ticket component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-mixins": "^31.
|
|
17
|
+
"bpk-mixins": "^31.6.3",
|
|
18
18
|
"bpk-react-utils": "^7.0.0",
|
|
19
19
|
"prop-types": "^15.7.2"
|
|
20
20
|
},
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"react": "^17.0.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"bpk-component-button": "^7.0.
|
|
26
|
-
"bpk-component-icon": "^10.0.
|
|
25
|
+
"bpk-component-button": "^7.0.4",
|
|
26
|
+
"bpk-component-icon": "^10.0.4"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-tooltip",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.4",
|
|
4
4
|
"description": "Backpack tooltip component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@popperjs/core": "^2.11.5",
|
|
18
|
-
"bpk-mixins": "^31.
|
|
18
|
+
"bpk-mixins": "^31.6.3",
|
|
19
19
|
"bpk-react-utils": "^7.0.0",
|
|
20
20
|
"prop-types": "^15.7.2"
|
|
21
21
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"react": "^17.0.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@skyscanner/bpk-foundations-web": "^9.
|
|
27
|
-
"bpk-component-text": "^8.0.
|
|
26
|
+
"@skyscanner/bpk-foundations-web": "^9.3.0",
|
|
27
|
+
"bpk-component-text": "^8.0.4"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-scrim-utils",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"description": "Higher order component that adds an overlay behind components and manages scroll states.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"a11y-focus-scope": "^1.1.3",
|
|
18
18
|
"a11y-focus-store": "^1.0.0",
|
|
19
|
-
"bpk-mixins": "^31.
|
|
19
|
+
"bpk-mixins": "^31.6.3",
|
|
20
20
|
"bpk-react-utils": "^7.0.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
package/bpk-theming/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-theming",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Backpack theming utlities.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "c2217d61875a1f3aa2bb9ed9583c50e3f1523501",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@skyscanner/bpk-foundations-web": "^9.
|
|
17
|
+
"@skyscanner/bpk-foundations-web": "^9.3.0",
|
|
18
18
|
"prop-types": "^15.7.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@popperjs/core": "^2.11.5",
|
|
26
26
|
"@react-google-maps/api": "^2.12.0",
|
|
27
|
-
"@skyscanner/bpk-foundations-web": "^9.
|
|
28
|
-
"@skyscanner/bpk-svgs": "^14.3
|
|
27
|
+
"@skyscanner/bpk-foundations-web": "^9.3.0",
|
|
28
|
+
"@skyscanner/bpk-svgs": "^14.4.3",
|
|
29
29
|
"a11y-focus-scope": "^1.1.3",
|
|
30
30
|
"a11y-focus-store": "^1.0.0",
|
|
31
|
-
"bpk-mixins": "^31.
|
|
31
|
+
"bpk-mixins": "^31.6.3",
|
|
32
32
|
"d3-path": "^2.0.0",
|
|
33
33
|
"d3-scale": "^4.0.2",
|
|
34
34
|
"date-fns": "^2.21.1",
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Backpack - Skyscanner's Design System
|
|
3
|
-
*
|
|
4
|
-
* Copyright 2016 Skyscanner Ltd
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
/* @flow strict */
|
|
19
|
-
|
|
20
|
-
import React from 'react';
|
|
21
|
-
import { SortDirection } from 'react-virtualized';
|
|
22
|
-
|
|
23
|
-
import { cssModules } from '../../bpk-react-utils';
|
|
24
|
-
import BpkSmallArrowDownIcon from '../../bpk-component-icon/sm/arrow-down';
|
|
25
|
-
import BpkSmallArrowUpIcon from '../../bpk-component-icon/sm/arrow-up';
|
|
26
|
-
import { withRtlSupport } from '../../bpk-component-icon';
|
|
27
|
-
|
|
28
|
-
import { hasClassName } from './utils';
|
|
29
|
-
import STYLES from './BpkDataTableColumn.module.scss';
|
|
30
|
-
import { type SortDirectionType, type SortProps } from './sort-types';
|
|
31
|
-
|
|
32
|
-
const DownIcon = withRtlSupport(BpkSmallArrowDownIcon);
|
|
33
|
-
const UpIcon = withRtlSupport(BpkSmallArrowUpIcon);
|
|
34
|
-
|
|
35
|
-
const getClassName = cssModules(STYLES);
|
|
36
|
-
const upIconClassName = getClassName('bpk-data-table-column__sort-icon--up');
|
|
37
|
-
const downIconClassName = getClassName(
|
|
38
|
-
'bpk-data-table-column__sort-icon--down',
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
export const getSortIconDirection = (element: Element): ?SortDirectionType => {
|
|
42
|
-
if (
|
|
43
|
-
hasClassName(element, upIconClassName) ||
|
|
44
|
-
hasClassName(element.parentElement, upIconClassName)
|
|
45
|
-
) {
|
|
46
|
-
return SortDirection.ASC;
|
|
47
|
-
}
|
|
48
|
-
if (
|
|
49
|
-
hasClassName(element, downIconClassName) ||
|
|
50
|
-
hasClassName(element.parentElement, downIconClassName)
|
|
51
|
-
) {
|
|
52
|
-
return SortDirection.DESC;
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
type Props = {
|
|
58
|
-
dataKey: string,
|
|
59
|
-
label: string,
|
|
60
|
-
disableSort: boolean,
|
|
61
|
-
...$Exact<SortProps>,
|
|
62
|
-
};
|
|
63
|
-
export default ({
|
|
64
|
-
dataKey,
|
|
65
|
-
disableSort,
|
|
66
|
-
label,
|
|
67
|
-
sortBy,
|
|
68
|
-
sortDirection,
|
|
69
|
-
}: Props) => {
|
|
70
|
-
const children = [
|
|
71
|
-
<span
|
|
72
|
-
className={getClassName('bpk-data-table-column__header')}
|
|
73
|
-
key="label"
|
|
74
|
-
title={label}
|
|
75
|
-
>
|
|
76
|
-
{label}
|
|
77
|
-
</span>,
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
if (!disableSort) {
|
|
81
|
-
const upIconClassNames = [
|
|
82
|
-
getClassName('bpk-data-table-column__sort-icon'),
|
|
83
|
-
upIconClassName,
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
const downIconClassNames = [
|
|
87
|
-
getClassName('bpk-data-table-column__sort-icon'),
|
|
88
|
-
downIconClassName,
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
if (sortBy === dataKey) {
|
|
92
|
-
(sortDirection === SortDirection.ASC
|
|
93
|
-
? upIconClassNames
|
|
94
|
-
: downIconClassNames
|
|
95
|
-
).push(getClassName('bpk-data-table-column__sort-icon--selected'));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
children.push(
|
|
99
|
-
<div
|
|
100
|
-
className={getClassName('bpk-data-table-column__sort-icons')}
|
|
101
|
-
key="sort"
|
|
102
|
-
>
|
|
103
|
-
<UpIcon className={upIconClassNames.join(' ')} />
|
|
104
|
-
<DownIcon className={downIconClassNames.join(' ')} />
|
|
105
|
-
</div>,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return children;
|
|
110
|
-
};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Backpack - Skyscanner's Design System
|
|
3
|
-
*
|
|
4
|
-
* Copyright 2016 Skyscanner Ltd
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/* @flow strict */
|
|
20
|
-
import React from 'react';
|
|
21
|
-
import _sortBy from 'lodash/sortBy';
|
|
22
|
-
import { SortDirection } from 'react-virtualized';
|
|
23
|
-
|
|
24
|
-
import { getSortIconDirection } from './bpkHeaderRenderer';
|
|
25
|
-
import type { Props, SortProps, SortDirectionType } from './common-types';
|
|
26
|
-
|
|
27
|
-
export type Sorter<Row> = {
|
|
28
|
-
rowCount: number,
|
|
29
|
-
getRow(indext: number): Row,
|
|
30
|
-
propsChange(props: Props<Row>): void,
|
|
31
|
-
onHeaderClick(sortBy: string, eventTarget: Element, column: any): Sorter<Row>,
|
|
32
|
-
sortProps: SortProps,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const getSortDirection = (
|
|
36
|
-
sortProps: SortProps,
|
|
37
|
-
newSortBy: ?string,
|
|
38
|
-
newSortDirection: ?SortDirectionType,
|
|
39
|
-
defaultSortDirection: SortDirectionType,
|
|
40
|
-
): SortDirectionType => {
|
|
41
|
-
const { sortBy, sortDirection } = sortProps;
|
|
42
|
-
if (newSortDirection != null) {
|
|
43
|
-
return newSortDirection;
|
|
44
|
-
}
|
|
45
|
-
if (sortBy === newSortBy) {
|
|
46
|
-
return sortDirection === SortDirection.ASC
|
|
47
|
-
? SortDirection.DESC
|
|
48
|
-
: SortDirection.ASC;
|
|
49
|
-
}
|
|
50
|
-
return defaultSortDirection;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
class NaiveSorter<Row> {
|
|
54
|
-
sortProps: SortProps;
|
|
55
|
-
|
|
56
|
-
list: Array<Row>;
|
|
57
|
-
|
|
58
|
-
sortedList: Array<Row>;
|
|
59
|
-
|
|
60
|
-
rowCount: number;
|
|
61
|
-
|
|
62
|
-
constructor(props: Props<Row>) {
|
|
63
|
-
const children = React.Children.toArray(props.children);
|
|
64
|
-
|
|
65
|
-
const sortBy =
|
|
66
|
-
React.Children.count(props.children) > 0
|
|
67
|
-
? children[props.defaultColumnSortIndex].props.dataKey
|
|
68
|
-
: undefined;
|
|
69
|
-
const sortDirection =
|
|
70
|
-
children[props.defaultColumnSortIndex].props.defaultSortDirection ||
|
|
71
|
-
SortDirection.ASC;
|
|
72
|
-
|
|
73
|
-
this.sortProps = {
|
|
74
|
-
sortBy,
|
|
75
|
-
sortDirection,
|
|
76
|
-
sort: null,
|
|
77
|
-
};
|
|
78
|
-
this.list = props.rows;
|
|
79
|
-
this.sort();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getRow(index: number): Row {
|
|
83
|
-
return this.sortedList[index];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
sort() {
|
|
87
|
-
const sorted = _sortBy(this.list, this.sortProps.sortBy);
|
|
88
|
-
if (this.sortProps.sortDirection === 'DESC') {
|
|
89
|
-
sorted.reverse();
|
|
90
|
-
}
|
|
91
|
-
this.sortedList = sorted;
|
|
92
|
-
this.rowCount = this.sortedList.length;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
propsChange(nextProps: Props<Row>) {
|
|
96
|
-
this.list = nextProps.rows;
|
|
97
|
-
this.sort();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
onHeaderClick(sortBy: string, eventTarget: Element, column): Sorter<Row> {
|
|
101
|
-
const sortDirection = getSortDirection(
|
|
102
|
-
this.sortProps,
|
|
103
|
-
sortBy,
|
|
104
|
-
getSortIconDirection(eventTarget),
|
|
105
|
-
column.props.defaultSortDirection || SortDirection.ASC,
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
this.sortProps = {
|
|
109
|
-
sortBy,
|
|
110
|
-
sortDirection,
|
|
111
|
-
sort: null,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
this.sort();
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
class PropSorter<Row> {
|
|
120
|
-
sortProps: SortProps;
|
|
121
|
-
|
|
122
|
-
list: Array<Row>;
|
|
123
|
-
|
|
124
|
-
rowCount: number;
|
|
125
|
-
|
|
126
|
-
constructor(props: Props<Row>) {
|
|
127
|
-
this.sortProps = {
|
|
128
|
-
sortBy: props.sortBy,
|
|
129
|
-
sortDirection: props.sortDirection,
|
|
130
|
-
sort: props.sort,
|
|
131
|
-
};
|
|
132
|
-
this.list = props.rows;
|
|
133
|
-
this.rowCount = props.rows.length;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
getRow(index: number): Row {
|
|
137
|
-
return this.list[index];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
propsChange(nextProps: Props<Row>) {
|
|
141
|
-
this.sortProps = {
|
|
142
|
-
sortBy: nextProps.sortBy,
|
|
143
|
-
sortDirection: nextProps.sortDirection,
|
|
144
|
-
sort: nextProps.sort,
|
|
145
|
-
};
|
|
146
|
-
this.list = nextProps.rows;
|
|
147
|
-
this.rowCount = nextProps.rows.length;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
onHeaderClick(): Sorter<Row> {
|
|
151
|
-
return this;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const makeSorter = <Row>(props: Props<Row>): Sorter<Row> => {
|
|
156
|
-
if (
|
|
157
|
-
props.sort !== null &&
|
|
158
|
-
props.sortBy !== null &&
|
|
159
|
-
props.sortDirection !== null
|
|
160
|
-
) {
|
|
161
|
-
return new PropSorter(props);
|
|
162
|
-
}
|
|
163
|
-
return new NaiveSorter(props);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export default makeSorter;
|
|
@@ -1,134 +0,0 @@
|
|
|
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 React from 'react';
|
|
20
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
21
|
-
|
|
22
|
-
// @ts-expect-error Untyped import. Not added as a stub declaration so consumers still have the suppression in their node_modules when shipped untranspiled.
|
|
23
|
-
import { cssModules } from '../../bpk-react-utils';
|
|
24
|
-
|
|
25
|
-
import BpkGraphicPromo, { TEXT_ALIGN } from './BpkGraphicPromo';
|
|
26
|
-
import type { Props } from './BpkGraphicPromo';
|
|
27
|
-
import STYLES from './BpkGraphicPromo.module.scss';
|
|
28
|
-
|
|
29
|
-
const getClassName = cssModules(STYLES);
|
|
30
|
-
|
|
31
|
-
const props: Props = {
|
|
32
|
-
buttonText: 'Learn more',
|
|
33
|
-
headline: 'Ride your wave',
|
|
34
|
-
invertVertically: false,
|
|
35
|
-
onClick: jest.fn(),
|
|
36
|
-
sponsor: {
|
|
37
|
-
label: 'Sponsored',
|
|
38
|
-
logo: 'path/to/logo.png',
|
|
39
|
-
altText: 'Airline Name',
|
|
40
|
-
},
|
|
41
|
-
subheading:
|
|
42
|
-
'Portugal and 6 more countries have just been added to the UK travel green list',
|
|
43
|
-
tagline: 'Tagline',
|
|
44
|
-
textAlign: TEXT_ALIGN.start,
|
|
45
|
-
contentId: 'mock-content-id',
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
describe('BpkGraphicPromo', () => {
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
(props.onClick as jest.MockedFunction<Props['onClick']>).mockReset();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should render correctly with all properties set', () => {
|
|
54
|
-
const { asFragment } = render(<BpkGraphicPromo {...props} />);
|
|
55
|
-
|
|
56
|
-
expect(asFragment()).toMatchSnapshot();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should support custom class names', () => {
|
|
60
|
-
const { asFragment } = render(
|
|
61
|
-
<BpkGraphicPromo className="custom-classname" {...props} />,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
expect(asFragment()).toMatchSnapshot();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should render correctly when centre aligned', () => {
|
|
68
|
-
const customProps = { ...props, textAlign: TEXT_ALIGN.center };
|
|
69
|
-
const { asFragment } = render(<BpkGraphicPromo {...customProps} />);
|
|
70
|
-
|
|
71
|
-
expect(asFragment()).toMatchSnapshot();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should render correctly when right aligned', () => {
|
|
75
|
-
const customProps = { ...props, textAlign: TEXT_ALIGN.end };
|
|
76
|
-
const { asFragment } = render(<BpkGraphicPromo {...customProps} />);
|
|
77
|
-
|
|
78
|
-
expect(asFragment()).toMatchSnapshot();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should render correctly when inverted portrait', () => {
|
|
82
|
-
const customProps = { ...props, invertVertically: true };
|
|
83
|
-
const { asFragment } = render(<BpkGraphicPromo {...customProps} />);
|
|
84
|
-
|
|
85
|
-
expect(asFragment()).toMatchSnapshot();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('should not display tagline or subheading when not provided', () => {
|
|
89
|
-
const customProps = { ...props };
|
|
90
|
-
delete customProps.tagline;
|
|
91
|
-
delete customProps.subheading;
|
|
92
|
-
const { asFragment } = render(<BpkGraphicPromo {...customProps} />);
|
|
93
|
-
|
|
94
|
-
expect(asFragment()).toMatchSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should display the tagline and no sponsor for non-sponsored ad', () => {
|
|
98
|
-
const customProps = { ...props };
|
|
99
|
-
delete customProps.sponsor;
|
|
100
|
-
const { asFragment } = render(<BpkGraphicPromo {...customProps} />);
|
|
101
|
-
|
|
102
|
-
expect(asFragment()).toMatchSnapshot();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should redirect us to link when card is clicked', () => {
|
|
106
|
-
render(<BpkGraphicPromo {...props} />);
|
|
107
|
-
|
|
108
|
-
const graphicPromo = document.getElementsByClassName(
|
|
109
|
-
getClassName('bpk-graphic-promo'),
|
|
110
|
-
)[0];
|
|
111
|
-
fireEvent.click(graphicPromo);
|
|
112
|
-
|
|
113
|
-
expect(props.onClick).toHaveBeenCalledTimes(1);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('should redirect us to link when button is clicked', () => {
|
|
117
|
-
render(<BpkGraphicPromo {...props} />);
|
|
118
|
-
|
|
119
|
-
const graphicPromoCTA = document.getElementsByClassName(
|
|
120
|
-
getClassName('bpk-graphic-promo__cta'),
|
|
121
|
-
)[0];
|
|
122
|
-
fireEvent.click(graphicPromoCTA);
|
|
123
|
-
|
|
124
|
-
expect(props.onClick).toHaveBeenCalledTimes(1);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('should render as expected without a content ID', () => {
|
|
128
|
-
const { asFragment } = render(
|
|
129
|
-
<BpkGraphicPromo {...props} contentId={null} />,
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
expect(asFragment()).toMatchSnapshot();
|
|
133
|
-
});
|
|
134
|
-
});
|