@skyscanner/backpack-web 9.3.0 → 11.1.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 +8 -8
- package/bpk-component-accordion/src/BpkAccordion.module.scss +1 -1
- package/bpk-component-accordion/src/BpkAccordionItem.module.scss +1 -1
- 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-aria-live/src/BpkAriaLive.module.scss +1 -1
- package/bpk-component-autosuggest/package.json +5 -5
- package/bpk-component-autosuggest/src/BpkAutosuggest.module.scss +2 -2
- package/bpk-component-badge/package.json +6 -6
- package/bpk-component-badge/src/BpkBadge.module.scss +1 -1
- package/bpk-component-banner-alert/package.json +10 -10
- package/bpk-component-banner-alert/src/BpkAnimateAndFade.module.scss +1 -1
- package/bpk-component-banner-alert/src/BpkBannerAlert.module.scss +3 -3
- package/bpk-component-barchart/package.json +9 -9
- package/bpk-component-barchart/src/BpkBarchartBar.module.scss +3 -1
- package/bpk-component-barchart/src/BpkChartAxis.module.scss +1 -1
- package/bpk-component-barchart/src/BpkChartDataTable.module.scss +1 -1
- package/bpk-component-barchart/src/BpkChartGridLines.module.scss +2 -2
- package/bpk-component-blockquote/package.json +3 -3
- package/bpk-component-blockquote/src/BpkBlockquote.module.scss +1 -1
- package/bpk-component-breadcrumb/package.json +6 -6
- package/bpk-component-breadcrumb/src/BpkBreadcrumb.module.scss +1 -1
- package/bpk-component-breadcrumb/src/BpkBreadcrumbItem.module.scss +1 -1
- package/bpk-component-breakpoint/package.json +4 -4
- package/bpk-component-button/package.json +3 -3
- package/bpk-component-button/src/BpkButtonBase.module.scss +2 -2
- package/bpk-component-button/src/BpkButtonDestructive.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonFeatured.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonLink.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonLinkOnDark.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonOutline.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonPrimaryOnDark.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonPrimaryOnLight.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonSecondary.module.scss +1 -1
- package/bpk-component-button/src/BpkButtonSecondaryOnDark.module.scss +1 -1
- 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 +10 -10
- package/bpk-component-calendar/src/BpkCalendar.module.scss +2 -2
- package/bpk-component-calendar/src/BpkCalendarDate.js +0 -15
- package/bpk-component-calendar/src/BpkCalendarDate.module.scss +18 -51
- package/bpk-component-calendar/src/BpkCalendarGrid.module.scss +8 -7
- package/bpk-component-calendar/src/BpkCalendarGridHeader.module.scss +2 -2
- package/bpk-component-calendar/src/BpkCalendarGridTransition.module.scss +2 -2
- package/bpk-component-calendar/src/BpkCalendarNav.module.scss +3 -3
- package/bpk-component-calendar/src/_variables.scss +2 -4
- package/bpk-component-card/package.json +5 -5
- package/bpk-component-card/src/BpkCard.module.scss +1 -1
- package/bpk-component-checkbox/package.json +6 -6
- package/bpk-component-checkbox/src/BpkCheckbox.module.scss +1 -1
- package/bpk-component-chip/package.json +6 -6
- package/bpk-component-chip/src/BpkSelectableChip.module.scss +1 -1
- package/bpk-component-close-button/package.json +5 -5
- package/bpk-component-close-button/src/BpkCloseButton.module.scss +3 -2
- package/bpk-component-code/package.json +3 -3
- package/bpk-component-code/src/BpkCode.module.scss +1 -1
- package/bpk-component-code/src/BpkCodeBlock.module.scss +1 -1
- package/bpk-component-content-cards/{index.ts → index.js} +0 -0
- package/bpk-component-content-cards/package.json +5 -5
- package/bpk-component-content-cards/src/{BpkContentCard/BpkContentCard.tsx → BpkContentCard.js} +10 -11
- package/bpk-component-content-cards/src/{BpkContentCard/BpkContentCard.module.scss → BpkContentCard.module.scss} +1 -1
- package/bpk-component-content-cards/src/{BpkContentCards.tsx → BpkContentCards.js} +11 -11
- package/bpk-component-content-cards/src/BpkContentCards.module.scss +1 -1
- package/bpk-component-content-container/package.json +3 -3
- package/bpk-component-content-container/src/BpkContentContainer.module.scss +1 -1
- package/bpk-component-datatable/README.md +78 -21
- package/bpk-component-datatable/package.json +6 -7
- package/bpk-component-datatable/src/BpkDataTable.js +176 -143
- package/bpk-component-datatable/src/BpkDataTable.module.scss +11 -16
- 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 -12
- 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 +10 -10
- package/bpk-component-datepicker/src/BpkDatepicker.module.scss +1 -1
- package/bpk-component-description-list/package.json +3 -3
- package/bpk-component-description-list/src/BpkDescriptionList.module.scss +1 -1
- package/bpk-component-dialog/package.json +9 -9
- package/bpk-component-dialog/src/BpkDialog.module.scss +1 -1
- package/bpk-component-dialog/src/BpkDialogInner.module.scss +3 -1
- package/bpk-component-drawer/package.json +10 -10
- package/bpk-component-drawer/src/BpkDrawer.module.scss +1 -1
- package/bpk-component-drawer/src/BpkDrawerContent.module.scss +1 -1
- package/bpk-component-fieldset/package.json +13 -13
- package/bpk-component-fieldset/src/BpkFieldset.module.scss +1 -1
- package/bpk-component-flare/package.json +5 -5
- package/bpk-component-flare/src/bpk-content-bubble.module.scss +2 -1
- package/bpk-component-flare/src/bpk-flare-bar.module.scss +2 -1
- 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 +6 -6
- package/bpk-component-floating-notification/src/BpkFloatingNotification.js +7 -26
- package/bpk-component-floating-notification/src/BpkFloatingNotification.module.scss +5 -18
- package/bpk-component-form-validation/package.json +11 -11
- package/bpk-component-form-validation/src/BpkFormValidation.module.scss +1 -1
- 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-graphic-promotion/src/BpkGraphicPromo.module.scss +1 -1
- package/bpk-component-grid/package.json +3 -3
- package/bpk-component-grid/src/BpkGridColumn.module.scss +1 -1
- package/bpk-component-grid/src/BpkGridContainer.module.scss +1 -1
- package/bpk-component-grid/src/BpkGridRow.module.scss +1 -1
- package/bpk-component-grid-toggle/package.json +4 -4
- package/bpk-component-grid-toggle/src/BpkGridToggle.module.scss +1 -1
- package/bpk-component-horizontal-nav/package.json +7 -7
- package/bpk-component-horizontal-nav/src/BpkHorizontalNav.module.scss +3 -3
- package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.module.scss +15 -15
- package/bpk-component-icon/README.md +1 -1
- package/bpk-component-icon/package.json +8 -8
- package/bpk-component-icon/src/BpkIcon.module.scss +1 -1
- package/bpk-component-icon/src/withDescription.module.scss +1 -1
- package/bpk-component-image/package.json +7 -7
- package/bpk-component-image/src/BpkBackgroundImage.module.scss +1 -1
- package/bpk-component-image/src/BpkImage.module.scss +1 -1
- package/bpk-component-infinite-scroll/package.json +7 -7
- package/bpk-component-infinite-scroll/src/withInfiniteScroll.module.scss +1 -1
- package/bpk-component-input/package.json +7 -7
- package/bpk-component-input/src/BpkClearButton.module.scss +2 -2
- package/bpk-component-input/src/BpkInput.module.scss +1 -1
- package/bpk-component-label/package.json +3 -3
- package/bpk-component-label/src/BpkLabel.module.scss +1 -1
- package/bpk-component-link/package.json +5 -5
- package/bpk-component-link/src/BpkLink.module.scss +1 -1
- package/bpk-component-list/README.md +8 -5
- package/bpk-component-list/package.json +3 -3
- package/bpk-component-list/src/BpkList.js +18 -2
- package/bpk-component-list/src/BpkList.module.scss +1 -1
- package/bpk-component-loading-button/package.json +7 -7
- package/bpk-component-loading-button/src/BpkLoadingButton.module.scss +1 -1
- package/bpk-component-map/package.json +7 -7
- package/bpk-component-map/src/BpkIconMarker.module.scss +3 -2
- package/bpk-component-map/src/BpkIconMarkerBackground.module.scss +1 -1
- package/bpk-component-map/src/BpkMap.js +1 -0
- package/bpk-component-map/src/BpkPriceMarker.module.scss +3 -1
- package/bpk-component-map/src/DefaultLoadingElement.module.scss +1 -1
- package/bpk-component-mobile-scroll-container/README.md +1 -1
- package/bpk-component-mobile-scroll-container/package.json +4 -4
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.module.scss +3 -1
- package/bpk-component-modal/package.json +10 -10
- package/bpk-component-modal/src/BpkModal.module.scss +1 -1
- package/bpk-component-modal/src/BpkModalInner.module.scss +3 -1
- package/bpk-component-navigation-bar/package.json +9 -9
- package/bpk-component-navigation-bar/src/BpkNavigationBar.module.scss +4 -4
- package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.module.scss +5 -5
- package/bpk-component-navigation-bar/src/BpkNavigationBarIconButton.module.scss +4 -4
- package/bpk-component-nudger/package.json +8 -8
- package/bpk-component-nudger/src/BpkNudger.module.scss +1 -1
- package/bpk-component-overlay/package.json +5 -5
- package/bpk-component-overlay/src/BpkOverlay.module.scss +1 -1
- package/bpk-component-pagination/package.json +5 -5
- package/bpk-component-pagination/src/BpkPaginationList.module.scss +1 -1
- package/bpk-component-pagination/src/BpkPaginationNudger.module.scss +2 -2
- package/bpk-component-pagination/src/BpkPaginationPage.module.scss +1 -1
- package/bpk-component-panel/package.json +3 -3
- package/bpk-component-panel/src/BpkPanel.module.scss +1 -1
- package/bpk-component-phone-input/package.json +10 -10
- package/bpk-component-phone-input/src/BpkPhoneInput.module.scss +1 -1
- package/bpk-component-popover/package.json +9 -9
- package/bpk-component-popover/src/BpkPopover.module.scss +1 -2
- package/bpk-component-price/package.json +4 -4
- package/bpk-component-price/src/BpkPrice.module.scss +1 -1
- package/bpk-component-progress/package.json +6 -6
- package/bpk-component-progress/src/BpkProgress.module.scss +1 -1
- package/bpk-component-radio/package.json +5 -5
- package/bpk-component-radio/src/BpkRadio.module.scss +1 -2
- package/bpk-component-rating/package.json +5 -5
- package/bpk-component-rating/src/BpkRating.module.scss +1 -1
- package/bpk-component-rtl-toggle/package.json +3 -3
- package/bpk-component-scrollable-calendar/package.json +7 -7
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.module.scss +1 -1
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.module.scss +1 -2
- package/bpk-component-section-list/package.json +7 -7
- package/bpk-component-section-list/src/BpkSectionListItem.module.scss +1 -1
- package/bpk-component-section-list/src/BpkSectionListSection.module.scss +1 -1
- package/bpk-component-select/package.json +4 -4
- package/bpk-component-select/src/BpkSelect.module.scss +1 -1
- package/bpk-component-skip-link/package.json +3 -3
- package/bpk-component-skip-link/src/BpkSkipLink.module.scss +2 -1
- package/bpk-component-slider/package.json +5 -5
- package/bpk-component-slider/src/BpkSlider.module.scss +1 -2
- package/bpk-component-spinner/package.json +4 -4
- package/bpk-component-spinner/src/BpkSpinner.module.scss +1 -1
- package/bpk-component-split-input/package.json +4 -4
- package/bpk-component-split-input/src/BpkInputField.module.scss +1 -1
- package/bpk-component-split-input/src/BpkSplitInput.module.scss +1 -1
- package/bpk-component-star-rating/package.json +6 -6
- package/bpk-component-star-rating/src/BpkInteractiveStar.module.scss +3 -3
- package/bpk-component-star-rating/src/BpkStar.module.scss +1 -1
- package/bpk-component-switch/README.md +1 -1
- package/bpk-component-switch/package.json +3 -3
- package/bpk-component-switch/src/BpkSwitch.js +14 -13
- package/bpk-component-switch/src/BpkSwitch.module.scss +18 -12
- package/bpk-component-table/package.json +3 -3
- package/bpk-component-table/src/BpkTable.module.scss +1 -1
- package/bpk-component-text/package.json +3 -3
- package/bpk-component-text/src/BpkText.module.scss +1 -1
- package/bpk-component-textarea/package.json +5 -5
- package/bpk-component-textarea/src/BpkTextarea.module.scss +1 -1
- package/bpk-component-theme-toggle/package.json +6 -6
- package/bpk-component-theme-toggle/src/BpkThemeToggle.module.scss +1 -1
- package/bpk-component-ticket/package.json +5 -5
- package/bpk-component-ticket/src/BpkTicket.module.scss +1 -1
- package/bpk-component-tooltip/package.json +5 -5
- package/bpk-component-tooltip/src/BpkTooltip.module.scss +3 -2
- package/bpk-react-utils/README.md +1 -1
- package/bpk-react-utils/package.json +1 -1
- package/bpk-scrim-utils/package.json +3 -3
- package/bpk-scrim-utils/src/bpk-scrim-content.module.scss +1 -1
- package/bpk-scrim-utils/src/bpk-scrim.module.scss +1 -1
- package/bpk-theming/package.json +2 -2
- package/package.json +4 -4
- package/bpk-component-content-cards/src/BpkContentCard/BpkContentCard-test.tsx +0 -88
- package/bpk-component-content-cards/src/BpkContentCard/index.ts +0 -19
- package/bpk-component-content-cards/src/BpkContentCards-test.tsx +0 -126
- package/bpk-component-content-cards/src/accessibility-test.tsx +0 -64
- 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
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
@import '~bpk-mixins';
|
|
19
|
+
@import '~bpk-mixins/index.scss';
|
|
20
20
|
|
|
21
21
|
$bpk-spacing-v2: true;
|
|
22
|
-
|
|
23
22
|
$bpk-border-size-datatable: $bpk-border-size-xl * 2;
|
|
24
23
|
|
|
25
24
|
@mixin bpk-datatable-border-left() {
|
|
@@ -41,19 +40,8 @@ $bpk-border-size-datatable: $bpk-border-size-xl * 2;
|
|
|
41
40
|
.bpk-data-table {
|
|
42
41
|
width: 100%;
|
|
43
42
|
|
|
44
|
-
&__header-
|
|
45
|
-
|
|
46
|
-
height: 100%;
|
|
47
|
-
margin: bpk-spacing-base();
|
|
48
|
-
flex-direction: row;
|
|
49
|
-
align-items: center;
|
|
50
|
-
outline-offset: -(4 * $bpk-one-pixel-rem);
|
|
51
|
-
|
|
52
|
-
@include bpk-label-2;
|
|
53
|
-
|
|
54
|
-
&:hover {
|
|
55
|
-
cursor: pointer;
|
|
56
|
-
}
|
|
43
|
+
&__header-row {
|
|
44
|
+
overflow: hidden;
|
|
57
45
|
}
|
|
58
46
|
|
|
59
47
|
&__row {
|
|
@@ -67,7 +55,7 @@ $bpk-border-size-datatable: $bpk-border-size-xl * 2;
|
|
|
67
55
|
|
|
68
56
|
@include bpk-footnote;
|
|
69
57
|
|
|
70
|
-
&:last-child {
|
|
58
|
+
&:last-child:not(.bpk-data-table__header-row) {
|
|
71
59
|
border-bottom: $bpk-border-size-sm solid $bpk-color-sky-gray-tint-07;
|
|
72
60
|
}
|
|
73
61
|
|
|
@@ -92,4 +80,11 @@ $bpk-border-size-datatable: $bpk-border-size-xl * 2;
|
|
|
92
80
|
}
|
|
93
81
|
}
|
|
94
82
|
}
|
|
83
|
+
|
|
84
|
+
&__cell {
|
|
85
|
+
margin: bpk-spacing-base();
|
|
86
|
+
text-overflow: ellipsis;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
}
|
|
95
90
|
}
|
|
@@ -17,48 +17,45 @@
|
|
|
17
17
|
*/
|
|
18
18
|
/* @flow strict */
|
|
19
19
|
|
|
20
|
-
import React
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const { className, ...rest } = bpkDataTableColumn.props;
|
|
48
|
-
const classNames = [getClassName('bpk-data-table-column')];
|
|
49
|
-
|
|
50
|
-
if (className) {
|
|
51
|
-
classNames.push(className);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// $FlowFixMe[cannot-spread-inexact]
|
|
55
|
-
return <Column className={classNames.join(' ')} key={key} {...rest} />;
|
|
20
|
+
import React from 'react';
|
|
21
|
+
import PropTypes from 'prop-types';
|
|
22
|
+
|
|
23
|
+
import { SORT_DIRECTION_TYPES } from './sort-types';
|
|
24
|
+
import { type BpkDataTableColumnProps } from './common-types';
|
|
25
|
+
|
|
26
|
+
// BpkDataTableColumn is just a props wrapper
|
|
27
|
+
// to maintain backwards compatibility with the old API of BpkDataTable which takes columns as children
|
|
28
|
+
// The `react-table` library however expects columns as an array of objects
|
|
29
|
+
|
|
30
|
+
const BpkDataTableColumn = (props: BpkDataTableColumnProps) => (
|
|
31
|
+
<div {...props} />
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
BpkDataTableColumn.propTypes = {
|
|
35
|
+
dataKey: PropTypes.string.isRequired,
|
|
36
|
+
width: PropTypes.number.isRequired,
|
|
37
|
+
className: PropTypes.string,
|
|
38
|
+
disableSort: PropTypes.bool,
|
|
39
|
+
defaultSortDirection: PropTypes.oneOf(Object.keys(SORT_DIRECTION_TYPES)),
|
|
40
|
+
flexGrow: PropTypes.number,
|
|
41
|
+
label: PropTypes.string,
|
|
42
|
+
headerRenderer: PropTypes.func,
|
|
43
|
+
headerClassName: PropTypes.string,
|
|
44
|
+
headerStyle: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
|
45
|
+
cellRenderer: PropTypes.func,
|
|
46
|
+
cellDataGetter: PropTypes.func,
|
|
56
47
|
};
|
|
57
|
-
|
|
58
|
-
BpkDataTableColumn.propTypes = { ...Column.propTypes };
|
|
59
48
|
BpkDataTableColumn.defaultProps = {
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
className: null,
|
|
50
|
+
disableSort: false,
|
|
51
|
+
defaultSortDirection: SORT_DIRECTION_TYPES.ASC,
|
|
52
|
+
flexGrow: 0,
|
|
53
|
+
label: null,
|
|
54
|
+
headerRenderer: null,
|
|
55
|
+
headerClassName: null,
|
|
56
|
+
headerStyle: null,
|
|
57
|
+
cellRenderer: null,
|
|
58
|
+
cellDataGetter: null,
|
|
62
59
|
};
|
|
63
60
|
|
|
64
61
|
export default BpkDataTableColumn;
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
|
|
22
|
+
import { cssModules } from '../../bpk-react-utils';
|
|
23
|
+
import BpkSmallArrowDownIcon from '../../bpk-component-icon/sm/arrow-down';
|
|
24
|
+
import BpkSmallArrowUpIcon from '../../bpk-component-icon/sm/arrow-up';
|
|
25
|
+
import { withRtlSupport } from '../../bpk-component-icon';
|
|
26
|
+
|
|
27
|
+
import { SORT_DIRECTION_TYPES } from './sort-types';
|
|
28
|
+
import STYLES from './BpkDataTableHeader.module.scss';
|
|
29
|
+
import { type ColumnType } from './common-types';
|
|
30
|
+
|
|
31
|
+
const DownIcon = withRtlSupport(BpkSmallArrowDownIcon);
|
|
32
|
+
const UpIcon = withRtlSupport(BpkSmallArrowUpIcon);
|
|
33
|
+
|
|
34
|
+
const getClassName = cssModules(STYLES);
|
|
35
|
+
|
|
36
|
+
const KEYCODES = {
|
|
37
|
+
ENTER: 13,
|
|
38
|
+
SPACEBAR: 32,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const BpkDataTableHeader = ({ column }: { column: ColumnType }) => {
|
|
42
|
+
const {
|
|
43
|
+
defaultSortDirection,
|
|
44
|
+
disableSortBy,
|
|
45
|
+
flexGrow,
|
|
46
|
+
headerClassName,
|
|
47
|
+
headerStyle,
|
|
48
|
+
isSorted,
|
|
49
|
+
isSortedDesc,
|
|
50
|
+
label,
|
|
51
|
+
minWidth,
|
|
52
|
+
sortDirection,
|
|
53
|
+
width,
|
|
54
|
+
} = column;
|
|
55
|
+
|
|
56
|
+
const onHeaderClick = () => {
|
|
57
|
+
if (disableSortBy === true) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let isDescending;
|
|
61
|
+
|
|
62
|
+
if (isSorted) {
|
|
63
|
+
isDescending = isSortedDesc === false;
|
|
64
|
+
} else if (sortDirection) {
|
|
65
|
+
isDescending = sortDirection === SORT_DIRECTION_TYPES.DESC;
|
|
66
|
+
} else if (defaultSortDirection) {
|
|
67
|
+
isDescending = defaultSortDirection === SORT_DIRECTION_TYPES.DESC;
|
|
68
|
+
} else {
|
|
69
|
+
isDescending = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
column.toggleSortBy(isDescending);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const handleKeyboardEvent = (event: React.KeyboardEvent<HTMLElement>) => {
|
|
76
|
+
if (
|
|
77
|
+
event.keyCode === KEYCODES.ENTER ||
|
|
78
|
+
event.keyCode === KEYCODES.SPACEBAR
|
|
79
|
+
) {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
onHeaderClick();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const headerClassNames = getClassName(
|
|
86
|
+
'bpk-data-table-column__header',
|
|
87
|
+
headerClassName,
|
|
88
|
+
);
|
|
89
|
+
const upIconClassNames = getClassName(
|
|
90
|
+
'bpk-data-table-column__sort-icon--up',
|
|
91
|
+
'bpk-data-table-column__sort-icon',
|
|
92
|
+
isSorted && !isSortedDesc && 'bpk-data-table-column__sort-icon--selected',
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const downIconClassNames = getClassName(
|
|
96
|
+
'bpk-data-table-column__sort-icon--down',
|
|
97
|
+
'bpk-data-table-column__sort-icon',
|
|
98
|
+
isSorted && isSortedDesc && 'bpk-data-table-column__sort-icon--selected',
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div
|
|
103
|
+
{...column.getHeaderProps({
|
|
104
|
+
style: {
|
|
105
|
+
width,
|
|
106
|
+
minWidth,
|
|
107
|
+
flexGrow,
|
|
108
|
+
...headerStyle,
|
|
109
|
+
},
|
|
110
|
+
className: headerClassNames,
|
|
111
|
+
})}
|
|
112
|
+
>
|
|
113
|
+
<span
|
|
114
|
+
onClick={onHeaderClick}
|
|
115
|
+
onKeyDown={handleKeyboardEvent}
|
|
116
|
+
aria-label={label}
|
|
117
|
+
aria-pressed={isSorted}
|
|
118
|
+
role="button"
|
|
119
|
+
tabIndex={0}
|
|
120
|
+
>
|
|
121
|
+
{column.render('Header')}
|
|
122
|
+
</span>
|
|
123
|
+
{!disableSortBy && (
|
|
124
|
+
<div
|
|
125
|
+
className={getClassName('bpk-data-table-column__sort-icons')}
|
|
126
|
+
key="sort"
|
|
127
|
+
aria-hidden
|
|
128
|
+
>
|
|
129
|
+
<UpIcon
|
|
130
|
+
onClick={() => column.toggleSortBy(false)}
|
|
131
|
+
className={upIconClassNames}
|
|
132
|
+
/>
|
|
133
|
+
<DownIcon
|
|
134
|
+
onClick={() => column.toggleSortBy(true)}
|
|
135
|
+
className={downIconClassNames}
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default BpkDataTableHeader;
|
|
@@ -16,24 +16,24 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
@import '~bpk-mixins/index';
|
|
19
|
+
@import '~bpk-mixins/index.scss';
|
|
20
20
|
|
|
21
21
|
$bpk-spacing-v2: true;
|
|
22
|
-
|
|
23
22
|
$bpk-margin-size-sort-icons: bpk-spacing-sm() + bpk-spacing-md();
|
|
24
23
|
|
|
25
|
-
.bpk-data-table-
|
|
24
|
+
.bpk-data-table-column__header {
|
|
25
|
+
display: flex;
|
|
26
|
+
height: 100%;
|
|
26
27
|
margin: bpk-spacing-base();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
align-items: center;
|
|
30
|
+
outline-offset: -(bpk-spacing-sm());
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
@include bpk-label-2;
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
.bpk-data-table-column__sort-icons {
|
|
@@ -17,34 +17,56 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/* @flow strict */
|
|
20
|
-
import type { ChildrenArray, Element } from 'react';
|
|
21
|
-
|
|
22
|
-
import BpkDataTableColumn from './BpkDataTableColumn';
|
|
23
20
|
import type {
|
|
24
21
|
SortDirectionType as _SortDirectionType,
|
|
25
22
|
SortProps as _SortProps,
|
|
26
23
|
} from './sort-types';
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export type DataTableProps = {
|
|
25
|
+
type CommonColumnProps = {
|
|
26
|
+
defaultSortDirection: _SortDirectionType,
|
|
27
|
+
flexGrow: number,
|
|
33
28
|
headerClassName: ?string,
|
|
34
|
-
|
|
29
|
+
headerStyle: ?{},
|
|
30
|
+
label: ?string,
|
|
31
|
+
minWidth: ?number,
|
|
32
|
+
width: number,
|
|
35
33
|
};
|
|
36
34
|
|
|
37
35
|
export type Props<Row> = {
|
|
38
|
-
...$Exact<DataTableProps>,
|
|
39
36
|
rows: Array<Row>,
|
|
40
|
-
children:
|
|
37
|
+
children: Node,
|
|
38
|
+
height: number,
|
|
41
39
|
width: ?number,
|
|
42
40
|
headerHeight: number,
|
|
41
|
+
rowHeight: number,
|
|
43
42
|
className: ?string,
|
|
44
43
|
defaultColumnSortIndex: number,
|
|
44
|
+
headerClassName: ?string,
|
|
45
|
+
rowClassName: ?string,
|
|
45
46
|
onRowClick: (Row) => mixed,
|
|
46
47
|
...$Exact<_SortProps>,
|
|
47
48
|
};
|
|
48
49
|
|
|
50
|
+
export type ColumnType = {
|
|
51
|
+
disableSortBy: boolean,
|
|
52
|
+
getHeaderProps: Function,
|
|
53
|
+
isSorted: boolean,
|
|
54
|
+
isSortedDesc: boolean,
|
|
55
|
+
render: Function,
|
|
56
|
+
sortDirection: _SortDirectionType,
|
|
57
|
+
toggleSortBy: Function,
|
|
58
|
+
...$Exact<CommonColumnProps>,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type BpkDataTableColumnProps = {
|
|
62
|
+
cellDataGetter: ?Function,
|
|
63
|
+
cellRenderer: ?Function,
|
|
64
|
+
className: ?string,
|
|
65
|
+
dataKey: string,
|
|
66
|
+
disableSort: boolean,
|
|
67
|
+
headerRenderer: ?Function,
|
|
68
|
+
...$Exact<CommonColumnProps>,
|
|
69
|
+
};
|
|
70
|
+
|
|
49
71
|
export type SortDirectionType = _SortDirectionType;
|
|
50
72
|
export type SortProps = _SortProps;
|
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
// This file exists to break a cycle that would otherwise happen between
|
|
22
22
|
// BpkDataTableColumn.js and common-types.js
|
|
23
|
+
|
|
24
|
+
export const SORT_DIRECTION_TYPES = {
|
|
25
|
+
ASC: 'ASC',
|
|
26
|
+
DESC: 'DESC',
|
|
27
|
+
};
|
|
28
|
+
|
|
23
29
|
export type SortDirectionType = 'ASC' | ' DESC';
|
|
24
30
|
|
|
25
31
|
export type SortProps = {
|
|
@@ -17,14 +17,71 @@
|
|
|
17
17
|
*/
|
|
18
18
|
/* @flow strict */
|
|
19
19
|
|
|
20
|
+
// TODO: Remove these functions once we want to change the API to match the react-table library API
|
|
21
|
+
// To maintain backwards compatibility with the old API of BpkDataTable which takes columns as children
|
|
22
|
+
// The `react-table` library however expects columns as an array of objects
|
|
20
23
|
// eslint-disable-next-line import/prefer-default-export
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
export const getColumns = (columns) =>
|
|
25
|
+
columns.map((column) => {
|
|
26
|
+
const { cellDataGetter, cellRenderer, headerRenderer } = column.props;
|
|
27
|
+
// To maintain backwards compatibility with the old API of BpkDataTable we rename the parameters
|
|
28
|
+
// And create an interface so that the function signature doesn't depend on the underlying library
|
|
29
|
+
const columnCellRenderer = ({
|
|
30
|
+
column: { id: dataKey },
|
|
31
|
+
columns: columnsData,
|
|
32
|
+
row: { id: rowID, values: rowData },
|
|
33
|
+
sortedRows,
|
|
34
|
+
value: cellData,
|
|
35
|
+
}) => {
|
|
36
|
+
const columnIndex = columnsData.map((col) => col.id).indexOf(dataKey);
|
|
37
|
+
const rowIndex = sortedRows.map((row) => row.id).indexOf(rowID);
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
return cellRenderer({
|
|
40
|
+
cellData,
|
|
41
|
+
columnIndex,
|
|
42
|
+
dataKey,
|
|
43
|
+
rowData,
|
|
44
|
+
rowIndex,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const columnCellDataGetter = ({
|
|
49
|
+
column: { id: dataKey },
|
|
50
|
+
row: { values: rowData },
|
|
51
|
+
}) => cellDataGetter({ dataKey, rowData });
|
|
52
|
+
|
|
53
|
+
const columnHeaderRenderer = ({
|
|
54
|
+
column: { disableSortBy: disableSort, id: dataKey, label },
|
|
55
|
+
}) => headerRenderer({ dataKey, label, disableSort });
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
className,
|
|
59
|
+
dataKey,
|
|
60
|
+
defaultSortDirection,
|
|
61
|
+
disableSort,
|
|
62
|
+
flexGrow,
|
|
63
|
+
headerClassName,
|
|
64
|
+
headerStyle,
|
|
65
|
+
label,
|
|
66
|
+
minWidth,
|
|
67
|
+
style,
|
|
68
|
+
width,
|
|
69
|
+
} = column.props;
|
|
70
|
+
return {
|
|
71
|
+
Header: headerRenderer ? columnHeaderRenderer : label,
|
|
72
|
+
accessor: dataKey,
|
|
73
|
+
...((cellRenderer || cellDataGetter) && {
|
|
74
|
+
Cell: columnCellRenderer || columnCellDataGetter,
|
|
75
|
+
}),
|
|
76
|
+
className,
|
|
77
|
+
disableSortBy: disableSort,
|
|
78
|
+
defaultSortDirection,
|
|
79
|
+
flexGrow,
|
|
80
|
+
headerClassName,
|
|
81
|
+
headerStyle,
|
|
82
|
+
label,
|
|
83
|
+
minWidth,
|
|
84
|
+
style,
|
|
85
|
+
width,
|
|
86
|
+
};
|
|
87
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-datepicker",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.5",
|
|
4
4
|
"description": "Backpack datepicker component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-component-breakpoint": "^5.0.
|
|
18
|
-
"bpk-component-calendar": "^
|
|
19
|
-
"bpk-component-input": "^7.0.
|
|
20
|
-
"bpk-component-modal": "^6.0.
|
|
21
|
-
"bpk-component-popover": "^8.0.
|
|
22
|
-
"bpk-mixins": "^31.
|
|
23
|
-
"bpk-react-utils": "^7.0.
|
|
17
|
+
"bpk-component-breakpoint": "^5.0.5",
|
|
18
|
+
"bpk-component-calendar": "^13.0.2",
|
|
19
|
+
"bpk-component-input": "^7.0.5",
|
|
20
|
+
"bpk-component-modal": "^6.0.5",
|
|
21
|
+
"bpk-component-popover": "^8.0.5",
|
|
22
|
+
"bpk-mixins": "^31.6.3",
|
|
23
|
+
"bpk-react-utils": "^7.0.1",
|
|
24
24
|
"prop-types": "^15.7.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "^17.0.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@skyscanner/bpk-foundations-web": "^9.
|
|
31
|
-
"bpk-storybook-utils": "^2.0.
|
|
30
|
+
"@skyscanner/bpk-foundations-web": "^9.3.0",
|
|
31
|
+
"bpk-storybook-utils": "^2.0.5"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-description-list",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Backpack description list component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-mixins": "^31.
|
|
18
|
-
"bpk-react-utils": "^7.0.
|
|
17
|
+
"bpk-mixins": "^31.6.3",
|
|
18
|
+
"bpk-react-utils": "^7.0.1",
|
|
19
19
|
"prop-types": "^15.7.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-dialog",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.5",
|
|
4
4
|
"description": "Backpack dialog component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"bpk-component-close-button": "^4.0.
|
|
18
|
-
"bpk-component-flare": "^3.0.
|
|
19
|
-
"bpk-mixins": "^31.
|
|
20
|
-
"bpk-react-utils": "^7.0.
|
|
21
|
-
"bpk-scrim-utils": "^6.0.
|
|
17
|
+
"bpk-component-close-button": "^4.0.5",
|
|
18
|
+
"bpk-component-flare": "^3.0.5",
|
|
19
|
+
"bpk-mixins": "^31.6.3",
|
|
20
|
+
"bpk-react-utils": "^7.0.1",
|
|
21
|
+
"bpk-scrim-utils": "^6.0.5",
|
|
22
22
|
"prop-types": "^15.7.2"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": "^17.0.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"bpk-component-button": "^7.0.
|
|
29
|
-
"bpk-component-icon": "^10.0.
|
|
30
|
-
"bpk-component-text": "^8.0.
|
|
28
|
+
"bpk-component-button": "^7.0.5",
|
|
29
|
+
"bpk-component-icon": "^10.0.5",
|
|
30
|
+
"bpk-component-text": "^8.0.5"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
@import '~bpk-mixins/index';
|
|
19
|
+
@import '~bpk-mixins/index.scss';
|
|
20
20
|
|
|
21
21
|
$bpk-spacing-v2: true;
|
|
22
22
|
|
|
@@ -31,6 +31,7 @@ $bpk-spacing-v2: true;
|
|
|
31
31
|
outline: 0;
|
|
32
32
|
background-color: $bpk-modal-background-color;
|
|
33
33
|
opacity: $bpk-modal-opacity;
|
|
34
|
+
|
|
34
35
|
// FIX: Prevents ugly flickering when tapping inside the dialog in Mobile Safari
|
|
35
36
|
-webkit-tap-highlight-color: transparent;
|
|
36
37
|
|
|
@@ -55,6 +56,7 @@ $bpk-spacing-v2: true;
|
|
|
55
56
|
|
|
56
57
|
&__flare {
|
|
57
58
|
height: bpk-spacing-lg() * 10;
|
|
59
|
+
|
|
58
60
|
// We inherit radius from the outer modal so they match and align correctly to the container.
|
|
59
61
|
border-radius: inherit;
|
|
60
62
|
background-color: $bpk-color-sky-blue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpk-component-drawer",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.5",
|
|
4
4
|
"description": "Backpack drawer component.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@skyscanner/bpk-foundations-web": "^9.
|
|
18
|
-
"bpk-component-close-button": "^4.0.
|
|
19
|
-
"bpk-component-icon": "^10.0.
|
|
20
|
-
"bpk-component-link": "^4.0.
|
|
21
|
-
"bpk-mixins": "^31.
|
|
22
|
-
"bpk-react-utils": "^7.0.
|
|
23
|
-
"bpk-scrim-utils": "^6.0.
|
|
17
|
+
"@skyscanner/bpk-foundations-web": "^9.3.0",
|
|
18
|
+
"bpk-component-close-button": "^4.0.5",
|
|
19
|
+
"bpk-component-icon": "^10.0.5",
|
|
20
|
+
"bpk-component-link": "^4.0.5",
|
|
21
|
+
"bpk-mixins": "^31.6.3",
|
|
22
|
+
"bpk-react-utils": "^7.0.1",
|
|
23
|
+
"bpk-scrim-utils": "^6.0.5",
|
|
24
24
|
"prop-types": "^15.7.2",
|
|
25
25
|
"react-transition-group": "^2.5.3"
|
|
26
26
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"react": "^17.0.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"bpk-component-button": "^7.0.
|
|
32
|
-
"bpk-component-text": "^8.0.
|
|
31
|
+
"bpk-component-button": "^7.0.5",
|
|
32
|
+
"bpk-component-text": "^8.0.5"
|
|
33
33
|
}
|
|
34
34
|
}
|