@skyscanner/backpack-web 31.10.1 → 32.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-component-accordion/src/BpkAccordion.module.css +2 -2
- package/bpk-component-accordion/src/BpkAccordionItem.module.css +2 -2
- package/bpk-component-aria-live/src/BpkAriaLive.module.css +2 -2
- package/bpk-component-autosuggest/src/BpkAutosuggest.module.css +2 -2
- package/bpk-component-badge/index.js +1 -3
- package/bpk-component-badge/src/BpkBadge.module.css +2 -2
- package/bpk-component-banner-alert/src/BpkAnimateAndFade.module.css +2 -2
- package/bpk-component-banner-alert/src/BpkBannerAlert.module.css +2 -2
- package/bpk-component-barchart/src/BpkBarchart.module.css +2 -2
- package/bpk-component-barchart/src/BpkBarchartBar.module.css +2 -2
- package/bpk-component-barchart/src/BpkChartAxis.module.css +2 -2
- package/bpk-component-barchart/src/BpkChartDataTable.module.css +2 -2
- package/bpk-component-barchart/src/BpkChartGridLines.module.css +2 -2
- package/bpk-component-blockquote/src/BpkBlockquote.module.css +2 -2
- package/bpk-component-boilerplate/src/BpkBoilerplate.module.css +2 -2
- package/bpk-component-bottom-sheet/src/BpkBottomSheet.module.css +2 -2
- package/bpk-component-bottom-sheet/src/BpkBottomSheetInner.module.css +2 -2
- package/bpk-component-breadcrumb/src/BpkBreadcrumb.module.css +2 -2
- package/bpk-component-breadcrumb/src/BpkBreadcrumbItem.module.css +2 -2
- package/bpk-component-button/src/BpkButtonBase.module.css +2 -2
- package/bpk-component-button/src/BpkButtonDestructive.module.css +2 -2
- package/bpk-component-button/src/BpkButtonFeatured.module.css +2 -2
- package/bpk-component-button/src/BpkButtonLink.module.css +2 -2
- package/bpk-component-button/src/BpkButtonLinkOnDark.module.css +2 -2
- package/bpk-component-button/src/BpkButtonPrimaryOnDark.module.css +2 -2
- package/bpk-component-button/src/BpkButtonPrimaryOnLight.module.css +2 -2
- package/bpk-component-button/src/BpkButtonSecondary.module.css +2 -2
- package/bpk-component-button/src/BpkButtonSecondaryOnDark.module.css +2 -2
- package/bpk-component-button/src/BpkButtonV2/BpkButton.module.css +2 -2
- package/bpk-component-calendar/src/BpkCalendar.module.css +2 -2
- package/bpk-component-calendar/src/BpkCalendarDate.module.css +2 -2
- package/bpk-component-calendar/src/BpkCalendarGrid.module.css +2 -2
- package/bpk-component-calendar/src/BpkCalendarGridHeader.module.css +2 -2
- package/bpk-component-calendar/src/BpkCalendarGridTransition.module.css +2 -2
- package/bpk-component-calendar/src/BpkCalendarNav.module.css +2 -2
- package/bpk-component-card/src/BpkCard.module.css +2 -2
- package/bpk-component-card/src/BpkCardWrapper.module.css +2 -2
- package/bpk-component-card/src/BpkDividedCard.module.css +2 -2
- package/bpk-component-card-button/src/BpkSaveButton.module.css +2 -2
- package/bpk-component-checkbox/src/BpkCheckbox.module.css +2 -2
- package/bpk-component-chip/src/BpkSelectableChip.module.css +2 -2
- package/bpk-component-close-button/src/BpkCloseButton.module.css +2 -2
- package/bpk-component-code/src/BpkCode.module.css +2 -2
- package/bpk-component-code/src/BpkCodeBlock.module.css +2 -2
- package/bpk-component-content-cards/src/BpkContentCard.module.css +2 -2
- package/bpk-component-content-cards/src/BpkContentCards.module.css +2 -2
- package/bpk-component-datatable/index.js +3 -2
- package/bpk-component-datatable/src/BpkDataTable.js +38 -103
- package/bpk-component-datatable/src/BpkDataTable.module.css +2 -2
- package/bpk-component-datatable/src/BpkDataTableHeader.js +22 -2
- package/bpk-component-datatable/src/BpkDataTableHeader.module.css +2 -2
- package/bpk-component-datatable/src/common-types.js +22 -0
- package/bpk-component-datatable/src/utils.js +14 -148
- package/bpk-component-datepicker/src/BpkDatepicker.module.css +2 -2
- package/bpk-component-description-list/src/BpkDescriptionList.module.css +2 -2
- package/bpk-component-dialog/src/BpkDialog.module.css +2 -2
- package/bpk-component-dialog/src/BpkDialogInner.module.css +2 -2
- package/bpk-component-drawer/src/BpkDrawer.module.css +2 -2
- package/bpk-component-drawer/src/BpkDrawerContent.module.css +2 -2
- package/bpk-component-fieldset/src/BpkFieldset.module.css +2 -2
- package/bpk-component-flare/src/bpk-content-bubble.module.css +2 -2
- package/bpk-component-flare/src/bpk-flare-bar.module.css +2 -2
- package/bpk-component-floating-notification/src/BpkFloatingNotification.module.css +2 -2
- package/bpk-component-form-validation/src/BpkFormValidation.module.css +2 -2
- package/bpk-component-graphic-promotion/src/BpkGraphicPromo.module.css +2 -2
- package/bpk-component-grid-toggle/src/BpkGridToggle.module.css +2 -2
- package/bpk-component-horizontal-nav/src/BpkHorizontalNav.module.css +2 -2
- package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.module.css +2 -2
- package/bpk-component-icon/src/BpkIcon.module.css +2 -2
- package/bpk-component-icon/src/withDescription.module.css +2 -2
- package/bpk-component-image/src/BpkBackgroundImage.module.css +2 -2
- package/bpk-component-image/src/BpkImage.module.css +2 -2
- package/bpk-component-infinite-scroll/src/withInfiniteScroll.module.css +2 -2
- package/bpk-component-info-banner/src/BpkAnimateAndFade.module.css +2 -2
- package/bpk-component-info-banner/src/BpkInfoBanner.module.css +2 -2
- package/bpk-component-input/src/BpkClearButton.module.css +2 -2
- package/bpk-component-input/src/BpkInput.module.css +2 -2
- package/bpk-component-label/src/BpkLabel.module.css +2 -2
- package/bpk-component-link/src/BpkLink.module.css +2 -2
- package/bpk-component-list/src/BpkList.module.css +2 -2
- package/bpk-component-loading-button/src/BpkLoadingButton.module.css +2 -2
- package/bpk-component-map/src/BpkIconMarker.module.css +2 -2
- package/bpk-component-map/src/BpkIconMarkerBackground.module.css +2 -2
- package/bpk-component-map/src/BpkMap.module.css +2 -2
- package/bpk-component-map/src/BpkPriceMarker.module.css +2 -2
- package/bpk-component-map/src/BpkPriceMarkerV2/BpkPriceMarker.module.css +2 -2
- package/bpk-component-map/src/DefaultLoadingElement.module.css +2 -2
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.module.css +2 -2
- package/bpk-component-modal/src/BpkModal.module.css +2 -2
- package/bpk-component-modal/src/BpkModalInner.module.css +2 -2
- package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +2 -2
- package/bpk-component-navigation-bar/src/BpkNavigationBar.module.css +2 -2
- package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.module.css +2 -2
- package/bpk-component-navigation-bar/src/BpkNavigationBarIconButton.module.css +2 -2
- package/bpk-component-nudger/src/BpkNudger.module.css +2 -2
- package/bpk-component-overlay/src/BpkOverlay.module.css +2 -2
- package/bpk-component-page-indicator/src/BpkPageIndicator.module.css +2 -2
- package/bpk-component-pagination/src/BpkPagination.module.css +2 -2
- package/bpk-component-pagination/src/BpkPaginationList.module.css +2 -2
- package/bpk-component-pagination/src/BpkPaginationNudger.module.css +2 -2
- package/bpk-component-pagination/src/BpkPaginationPage.module.css +2 -2
- package/bpk-component-panel/src/BpkPanel.module.css +2 -2
- package/bpk-component-phone-input/src/BpkPhoneInput.module.css +2 -2
- package/bpk-component-popover/src/BpkPopover.module.css +2 -2
- package/bpk-component-price/src/BpkPrice.module.css +2 -2
- package/bpk-component-progress/src/BpkProgress.module.css +2 -2
- package/bpk-component-radio/src/BpkRadio.module.css +2 -2
- package/bpk-component-rating/src/BpkRating.module.css +2 -2
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.module.css +2 -2
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.module.css +2 -2
- package/bpk-component-section-header/src/BpkSectionHeader.module.css +2 -2
- package/bpk-component-section-list/src/BpkSectionListItem.module.css +2 -2
- package/bpk-component-section-list/src/BpkSectionListSection.module.css +2 -2
- package/bpk-component-select/src/BpkSelect.module.css +2 -2
- package/bpk-component-skip-link/src/BpkSkipLink.module.css +2 -2
- package/bpk-component-slider/src/BpkSlider.module.css +2 -2
- package/bpk-component-spinner/src/BpkSpinner.module.css +2 -2
- package/bpk-component-split-input/src/BpkInputField.module.css +2 -2
- package/bpk-component-split-input/src/BpkSplitInput.module.css +2 -2
- package/bpk-component-star-rating/src/BpkInteractiveStar.module.css +2 -2
- package/bpk-component-star-rating/src/BpkStar.module.css +2 -2
- package/bpk-component-star-rating/src/BpkStarRating.module.css +2 -2
- package/bpk-component-swap-button/src/BpkSwapButton.module.css +2 -2
- package/bpk-component-switch/src/BpkSwitch.module.css +2 -2
- package/bpk-component-table/src/BpkTable.module.css +2 -2
- package/bpk-component-text/src/BpkText.module.css +2 -2
- package/bpk-component-textarea/src/BpkTextarea.module.css +2 -2
- package/bpk-component-theme-toggle/src/BpkThemeToggle.module.css +2 -2
- package/bpk-component-ticket/src/BpkTicket.module.css +2 -2
- package/bpk-component-tooltip/src/BpkTooltip.module.css +2 -2
- package/bpk-mixins/{src/mixins/_badges-v2.scss → _badges-v2.scss} +3 -1
- package/bpk-mixins/{src/mixins/_badges.scss → _badges.scss} +13 -9
- package/bpk-mixins/{src/mixins/_borders.scss → _borders.scss} +11 -9
- package/bpk-mixins/{src/mixins/_breakpoints.scss → _breakpoints.scss} +3 -1
- package/bpk-mixins/{src/mixins/_buttons.scss → _buttons.scss} +7 -4
- package/bpk-mixins/{src/mixins/_cards.scss → _cards.scss} +6 -1
- package/bpk-mixins/{src/mixins/_chips.scss → _chips.scss} +8 -0
- package/bpk-mixins/{src/mixins/_forms.scss → _forms.scss} +5 -1
- package/bpk-mixins/_icons.scss +88 -0
- package/bpk-mixins/_index.scss +20 -17
- package/bpk-mixins/{src/mixins/_layers.scss → _layers.scss} +18 -15
- package/bpk-mixins/{src/mixins/_margins.scss → _margins.scss} +4 -0
- package/bpk-mixins/{src/mixins/_panels.scss → _panels.scss} +6 -2
- package/bpk-mixins/{src/mixins/_radii.scss → _radii.scss} +3 -1
- package/bpk-mixins/{src/mixins/_scroll-indicators.scss → _scroll-indicators.scss} +3 -1
- package/bpk-mixins/{src/mixins/_shadows.scss → _shadows.scss} +3 -1
- package/bpk-mixins/{src/mixins/_svgs.scss → _spinners.scss} +5 -68
- package/bpk-mixins/{src/_bonds.scss → _tokens.scss} +2 -0
- package/bpk-mixins/{src/mixins/_typography.scss → _typography.scss} +6 -2
- package/bpk-mixins/{src/mixins/_utils.scss → _utils.scss} +4 -0
- package/bpk-scrim-utils/src/bpk-scrim-content.module.css +2 -2
- package/bpk-scrim-utils/src/bpk-scrim.module.css +2 -2
- package/bpk-stylesheets/base.css +1 -2
- package/bpk-stylesheets/font.css +2 -2
- package/bpk-stylesheets/index.scss +18 -14
- package/bpk-stylesheets/normalize.css +422 -0
- package/package.json +15 -2
- package/unstable__bpk-mixins/_badges-v2.scss +240 -0
- package/unstable__bpk-mixins/_badges.scss +240 -0
- package/unstable__bpk-mixins/_borders.scss +268 -0
- package/unstable__bpk-mixins/_breakpoints.scss +221 -0
- package/unstable__bpk-mixins/_buttons.scss +568 -0
- package/unstable__bpk-mixins/_cards.scss +94 -0
- package/unstable__bpk-mixins/_chips.scss +240 -0
- package/unstable__bpk-mixins/_forms.scss +1049 -0
- package/unstable__bpk-mixins/_icons.scss +88 -0
- package/{bpk-mixins/sass-functions.js → unstable__bpk-mixins/_index.scss} +19 -10
- package/unstable__bpk-mixins/_layers.scss +199 -0
- package/unstable__bpk-mixins/_margins.scss +75 -0
- package/unstable__bpk-mixins/_panels.scss +71 -0
- package/unstable__bpk-mixins/_radii.scss +80 -0
- package/unstable__bpk-mixins/_scroll-indicators.scss +79 -0
- package/unstable__bpk-mixins/_shadows.scss +58 -0
- package/unstable__bpk-mixins/_spinners.scss +102 -0
- package/{bpk-component-datatable/src/sort-types.js → unstable__bpk-mixins/_tokens.scss} +3 -6
- package/unstable__bpk-mixins/_typography.scss +1039 -0
- package/unstable__bpk-mixins/_utils.scss +266 -0
- package/bpk-component-badge/src/BpkBadgeV2/BpkBadge.d.ts +0 -22
- package/bpk-component-badge/src/BpkBadgeV2/BpkBadge.js +0 -47
- package/bpk-component-badge/src/BpkBadgeV2/BpkBadge.module.css +0 -18
- package/bpk-component-datatable/src/BpkDataTableColumn.js +0 -54
- package/bpk-component-datatable/src/BpkDataTableColumn.module.css +0 -18
- package/bpk-component-datatable/src/hasChildrenOfType.js +0 -35
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-checkbox{position:relative;display:inline-block;padding-left:1.75rem;margin:0;font-size:1rem;line-height:1.5rem;font-weight:400}html[dir=rtl] .bpk-checkbox{padding-right:1.75rem;padding-left:0}.bpk-checkbox__label{vertical-align:baseline}.bpk-checkbox__label--small{margin:0;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-checkbox--white{color:#fff}.bpk-checkbox--disabled{color:rgba(0,0,0,.2);cursor:not-allowed}.bpk-checkbox--disabled--white{color:rgba(255,255,255,.5)}.bpk-checkbox--invalid input[type=checkbox]{border:.1875rem solid #e70866}.bpk-checkbox__input{position:absolute;top:.125rem;left:0;width:1.25rem;height:1.25rem;margin:0;padding:0;border:.1875rem solid #626971;border-radius:.25rem;cursor:pointer;vertical-align:text-bottom;appearance:none}html[dir=rtl] .bpk-checkbox__input{right:0;left:auto}@media screen\0 {.bpk-checkbox__input{background:none !important}}.bpk-checkbox__input:checked,.bpk-checkbox__input:indeterminate{background-color:#0062e3;background-color:var(--bpk-checkbox-checked-color, rgb(0, 98, 227));border-color:#0062e3;border-color:var(--bpk-checkbox-checked-color, rgb(0, 98, 227))}.bpk-checkbox__input:checked:disabled,.bpk-checkbox__input:indeterminate:disabled{border-color:rgba(0,0,0,.2);background:none}.bpk-checkbox__input:checked:not(:indeterminate)::before,.bpk-checkbox__input:checked:not(:indeterminate)::after{position:absolute;content:"";transform:rotate(45deg);border-radius:2px;background-color:#fff}.bpk-checkbox__input:checked:not(:indeterminate)::before{top:.4375rem;left:0;width:.5rem;height:.1875rem}.bpk-checkbox__input:checked:not(:indeterminate)::after{top:.125rem;left:.4375rem;width:.1875rem;height:.6875rem}.bpk-checkbox__input:checked:not(:indeterminate):disabled::before,.bpk-checkbox__input:checked:not(:indeterminate):disabled::after{background-color:rgba(0,0,0,.2)}.bpk-checkbox__input:disabled{border-color:rgba(0,0,0,.2)}.bpk-checkbox__input-indeterminate::before{position:absolute;top:.3125rem;left:.125rem;content:"";width:.625rem;height:.1875rem;border-radius:2px;background-color:#fff}.bpk-checkbox__input:disabled{cursor:inherit}.bpk-checkbox__input-white{background-color:#fff}.bpk-checkbox__asterisk{color:#e70866}
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-chip{display:inline-flex;height:2rem;padding:0 1rem;align-items:center;border:none;border-radius:.5rem;cursor:pointer}.bpk-chip__leading-accessory-view{display:inline-flex;fill:currentcolor;margin-left:0;margin-right:.5rem}html[dir=rtl] .bpk-chip__leading-accessory-view{margin-left:.5rem;margin-right:0}.bpk-chip__trailing-accessory-view{display:inline-flex;fill:currentcolor;margin-left:.5rem;margin-right:-0.5rem}html[dir=rtl] .bpk-chip__trailing-accessory-view{margin-right:.5rem}html[dir=rtl] .bpk-chip__trailing-accessory-view{margin-left:-0.5rem}.bpk-chip--on-dark{background-color:rgba(0,0,0,0);color:#fff;box-shadow:0 0 0 1px rgba(255,255,255,.5) inset}.bpk-no-touch-support .bpk-chip--on-dark:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px #fff inset}:global(.bpk-no-touch-support) .bpk-chip--on-dark:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px #fff inset}.bpk-chip--on-dark:active:not(:disabled){box-shadow:0 0 0 1px #fff inset}.bpk-chip--on-dark-selected{color:#161616;color:var(--bpk-chip-on-dark-selected-text-color, rgb(22, 22, 22));background-color:#fff;background-color:var(--bpk-chip-on-dark-selected-background-color, rgb(255, 255, 255));box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-no-touch-support .bpk-chip--on-dark-selected:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px rgba(0,0,0,0) inset}:global(.bpk-no-touch-support) .bpk-chip--on-dark-selected:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-chip--on-dark-selected:active:not(:disabled){box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-no-touch-support .bpk-chip--on-dark-dismissible:hover:not(:active):not(:disabled) svg{fill:currentcolor}:global(.bpk-no-touch-support) .bpk-chip--on-dark-dismissible:hover:not(:active):not(:disabled) svg{fill:currentcolor}.bpk-chip--on-dark-dismissible:active:not(:disabled) svg{fill:currentcolor}.bpk-chip--on-dark-dismissible__trailing-accessory-view{fill:#626971}.bpk-chip--on-dark-disabled{box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-chip--default{background-color:rgba(0,0,0,0);color:#161616;box-shadow:0 0 0 1px #c1c7cf inset}.bpk-no-touch-support .bpk-chip--default:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px #05203c inset}:global(.bpk-no-touch-support) .bpk-chip--default:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px #05203c inset}.bpk-chip--default:active:not(:disabled){box-shadow:0 0 0 1px #05203c inset}.bpk-chip--default-selected{color:#fff;color:var(--bpk-chip-default-selected-text-color, rgb(255, 255, 255));background-color:#05203c;background-color:var(--bpk-chip-default-selected-background-color, rgb(5, 32, 60));box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-no-touch-support .bpk-chip--default-selected:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px rgba(0,0,0,0) inset}:global(.bpk-no-touch-support) .bpk-chip--default-selected:hover:not(:active):not(:disabled){box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-chip--default-selected:active:not(:disabled){box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-no-touch-support .bpk-chip--default-dismissible:hover:not(:active):not(:disabled) svg{fill:currentcolor}:global(.bpk-no-touch-support) .bpk-chip--default-dismissible:hover:not(:active):not(:disabled) svg{fill:currentcolor}.bpk-chip--default-dismissible:active:not(:disabled) svg{fill:currentcolor}.bpk-chip--default-dismissible__trailing-accessory-view{fill:rgba(255,255,255,.5)}.bpk-chip--default-disabled{box-shadow:0 0 0 1px rgba(0,0,0,0) inset}.bpk-chip--on-image{background-color:#fff;color:#161616;box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}.bpk-no-touch-support .bpk-chip--on-image:hover:not(:active):not(:disabled){background-color:#eff3f8}:global(.bpk-no-touch-support) .bpk-chip--on-image:hover:not(:active):not(:disabled){background-color:#eff3f8}.bpk-chip--on-image:active:not(:disabled){background-color:#eff3f8}.bpk-chip--on-image-selected{color:#fff;color:var(--bpk-chip-on-image-selected-text-color, rgb(255, 255, 255));background-color:#05203c;background-color:var(--bpk-chip-on-image-selected-background-color, rgb(5, 32, 60))}.bpk-no-touch-support .bpk-chip--on-image-selected:hover:not(:active):not(:disabled){background-color:#05203c;background-color:var(--bpk-chip-on-image-selected-hover-background-color, rgb(5, 32, 60))}:global(.bpk-no-touch-support) .bpk-chip--on-image-selected:hover:not(:active):not(:disabled){background-color:#05203c;background-color:var(--bpk-chip-on-image-selected-hover-background-color, rgb(5, 32, 60))}.bpk-chip--on-image-selected:active:not(:disabled){background-color:#05203c;background-color:var(--bpk-chip-on-image-selected-active-background-color, rgb(5, 32, 60))}.bpk-no-touch-support .bpk-chip--on-image-dismissible:hover:not(:active):not(:disabled) svg{fill:currentcolor}:global(.bpk-no-touch-support) .bpk-chip--on-image-dismissible:hover:not(:active):not(:disabled) svg{fill:currentcolor}.bpk-chip--on-image-dismissible:active:not(:disabled) svg{fill:currentcolor}.bpk-chip--on-image-dismissible__trailing-accessory-view{fill:rgba(255,255,255,.5)}.bpk-chip--on-image-disabled{box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}.bpk-chip--disabled{background-color:#e0e4e9;color:rgba(0,0,0,.2);cursor:not-allowed}
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-close-button{width:1.5rem;height:1.5rem;margin-right:-0.125rem;margin-left:-0.125rem;padding:0;border:0;background-color:rgba(0,0,0,0);color:#626971;cursor:pointer;appearance:none;position:relative}.bpk-close-button::before{position:absolute;top:calc(-2.75rem/2 + 50%);left:calc(-2.75rem/2 + 50%);content:"";width:2.75rem;height:2.75rem}.bpk-no-touch-support .bpk-close-button:hover:not(:active):not(:disabled){color:#161616}:global(.bpk-no-touch-support) .bpk-close-button:hover:not(:active):not(:disabled){color:#161616}.bpk-close-button:active{color:#161616}.bpk-close-button__icon{vertical-align:-0.125rem;fill:currentcolor}
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-code{display:inline;padding:0 .25rem;background-color:#e0e4e9;color:#161616;text-align:left;white-space:nowrap;vertical-align:bottom;border-radius:.25rem}html[dir=rtl] .bpk-code{direction:ltr}.bpk-code--alternate{background-color:#eff3f8;text-shadow:none}
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-code--block{display:block;margin:0;padding:0;background-color:rgba(0,0,0,0);white-space:inherit;overflow:auto;-ms-overflow-style:none}.bpk-code--block::-webkit-scrollbar{display:none}.bpk-code__pre{margin:0 0 1rem;padding:1.5rem;background-color:#e0e4e9;border-radius:.25rem}.bpk-code__pre--alternate{background-color:rgba(0,0,0,0);box-shadow:0 0 0 1px #c1c7cf inset}
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-content-card--link{color:inherit;font:inherit;text-decoration:inherit}.bpk-content-card--horizontal{display:grid;column-gap:2.5rem;grid-template-columns:minmax(10%, 38.75rem) 40%;align-items:center}@media(max-width: 32rem){.bpk-content-card--horizontal{grid-template-columns:1fr}}.bpk-content-card--horizontal .bpk-content-card--image-container{width:100%;height:26.25rem}@media(max-width: 32rem){.bpk-content-card--horizontal .bpk-content-card--image-container{max-height:11.25rem;margin-bottom:1rem}}@media(max-width: 64rem){.bpk-content-card--horizontal .bpk-content-card--image-container{height:100%}}.bpk-content-card--vertical .bpk-content-card--image{height:28.75rem;margin-bottom:1rem}@media(max-width: 48rem){.bpk-content-card--vertical .bpk-content-card--image{width:100%;height:auto;max-height:16.25rem}}@media(max-width: 32rem){.bpk-content-card--vertical .bpk-content-card--image{max-height:11.25rem}}.bpk-content-card--headline{margin-bottom:.25rem;font-size:1.25rem;line-height:1.5rem;font-weight:700}.bpk-content-card--description{color:#626971;font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-content-card--image{width:100%;height:100%;border-radius:.75rem;object-fit:cover}
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-content-cards--header-text{margin-bottom:1rem;font-size:2rem;line-height:2.5rem;font-weight:700}@media(max-width: 32rem){.bpk-content-cards--header-text{font-size:1.5rem;line-height:1.75rem;font-weight:700}}.bpk-content-cards--layout{display:grid;grid-template-columns:repeat(auto-fit, minmax(3.125rem, 1fr));grid-auto-flow:column;gap:1.5rem}@media(max-width: 48rem){.bpk-content-cards--layout{grid-template-columns:1fr;grid-auto-flow:row;gap:1.5rem}}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
+
|
|
18
19
|
import BpkDataTable from "./src/BpkDataTable";
|
|
19
|
-
|
|
20
|
-
export
|
|
20
|
+
export { BpkDataTable };
|
|
21
|
+
export default BpkDataTable;
|
|
@@ -14,14 +14,16 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
18
19
|
import { useMemo, useState } from 'react';
|
|
20
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
19
21
|
import { useTable, useSortBy } from 'react-table';
|
|
20
22
|
import { cssModules } from "../../bpk-react-utils";
|
|
21
23
|
import STYLES from "./BpkDataTable.module.css";
|
|
22
|
-
import { SORT_DIRECTION_TYPES } from "./
|
|
24
|
+
import { SORT_DIRECTION_TYPES } from "./common-types";
|
|
23
25
|
import BpkDataTableHeader from "./BpkDataTableHeader";
|
|
24
|
-
import {
|
|
26
|
+
import { createColumnsSchema } from "./utils";
|
|
25
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
28
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
29
|
const getClassName = cssModules(STYLES);
|
|
@@ -31,39 +33,37 @@ const KEYCODES = {
|
|
|
31
33
|
};
|
|
32
34
|
const BpkDataTable = props => {
|
|
33
35
|
const {
|
|
34
|
-
|
|
35
|
-
className,
|
|
36
|
+
className = null,
|
|
36
37
|
columns: columnsData,
|
|
37
|
-
defaultColumnSortIndex,
|
|
38
|
+
defaultColumnSortIndex = 0,
|
|
38
39
|
headerClassName,
|
|
39
|
-
headerHeight,
|
|
40
|
+
headerHeight = '3.75rem',
|
|
40
41
|
height,
|
|
41
42
|
onRowClick,
|
|
42
43
|
rowClassName,
|
|
43
|
-
rowHeight,
|
|
44
|
+
rowHeight = '3.75rem',
|
|
44
45
|
rowStyle,
|
|
45
46
|
rows: rowsData,
|
|
46
|
-
sort,
|
|
47
|
-
sortBy,
|
|
48
|
-
sortDirection,
|
|
47
|
+
sort = null,
|
|
48
|
+
sortBy = null,
|
|
49
|
+
sortDirection = SORT_DIRECTION_TYPES.ASC,
|
|
49
50
|
width,
|
|
50
51
|
...restOfProps
|
|
51
52
|
} = props;
|
|
52
53
|
const [rowSelected, updateRowSelected] = useState(undefined);
|
|
53
54
|
const classNames = getClassName('bpk-data-table', className);
|
|
54
|
-
const getRowClassNames = (
|
|
55
|
+
const getRowClassNames = (index, consumerClassName) => {
|
|
55
56
|
const rowClassNames = getClassName('bpk-data-table__row', rowSelected === index && 'bpk-data-table__row--selected', onRowClick !== undefined && 'bpk-data-table__row--clickable', index === -1 && 'bpk-data-table__header-row', consumerClassName && (typeof consumerClassName === 'function' ? consumerClassName({
|
|
56
57
|
index
|
|
57
58
|
}) : consumerClassName));
|
|
58
59
|
return rowClassNames;
|
|
59
60
|
};
|
|
60
61
|
const headerClassNames = getClassName('bpk-data-table__row', 'bpk-data-table__header-row', headerClassName);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}, [children, columnsData]);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Call createColumnsSchema to modify the columns data to match the API expected by the hooks of the react-table library.
|
|
65
|
+
*/
|
|
66
|
+
const columns = useMemo(() => createColumnsSchema(columnsData), [columnsData]);
|
|
67
67
|
const data = useMemo(() => rowsData, [rowsData]);
|
|
68
68
|
const {
|
|
69
69
|
getTableBodyProps,
|
|
@@ -82,16 +82,16 @@ const BpkDataTable = props => {
|
|
|
82
82
|
}
|
|
83
83
|
}, useSortBy);
|
|
84
84
|
const onRowClicked = index => {
|
|
85
|
-
if (rowSelected === index) {
|
|
86
|
-
updateRowSelected(undefined);
|
|
87
|
-
} else {
|
|
88
|
-
updateRowSelected(index);
|
|
89
|
-
}
|
|
90
85
|
if (onRowClick !== undefined) {
|
|
86
|
+
if (rowSelected === index) {
|
|
87
|
+
updateRowSelected(undefined);
|
|
88
|
+
} else {
|
|
89
|
+
updateRowSelected(index);
|
|
90
|
+
}
|
|
91
91
|
onRowClick(rows[index].original);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
const
|
|
94
|
+
const handleRowKeyboardEvent = (event, i) => {
|
|
95
95
|
if (event.keyCode === KEYCODES.ENTER || event.keyCode === KEYCODES.SPACEBAR) {
|
|
96
96
|
event.preventDefault();
|
|
97
97
|
onRowClicked(i);
|
|
@@ -100,8 +100,8 @@ const BpkDataTable = props => {
|
|
|
100
100
|
return /*#__PURE__*/_jsxs("div", {
|
|
101
101
|
...getTableProps({
|
|
102
102
|
style: {
|
|
103
|
-
width
|
|
104
|
-
height
|
|
103
|
+
width,
|
|
104
|
+
height
|
|
105
105
|
},
|
|
106
106
|
className: classNames
|
|
107
107
|
}),
|
|
@@ -110,14 +110,21 @@ const BpkDataTable = props => {
|
|
|
110
110
|
children: headerGroups.map(headerGroup => /*#__PURE__*/_jsx("div", {
|
|
111
111
|
...headerGroup.getHeaderGroupProps({
|
|
112
112
|
style: {
|
|
113
|
-
height:
|
|
113
|
+
height: headerHeight
|
|
114
114
|
},
|
|
115
115
|
className: headerClassNames
|
|
116
116
|
}),
|
|
117
117
|
children: headerGroup.headers.map(column => {
|
|
118
|
+
// if consumer passes a custom sort function for a specific column (using sortBy to specify the column id),
|
|
119
|
+
// we need to pass them to react-table by setting the sortType and sortDirection properties on the column
|
|
118
120
|
if (sort && sortBy) {
|
|
119
121
|
if (column.id === sortBy) {
|
|
120
|
-
|
|
122
|
+
if (typeof sort === 'function') {
|
|
123
|
+
// abstract the sort function to be used by react-table as consumers don't need to be aware of more data than the row values.
|
|
124
|
+
column.sortType = (rowA, rowB, columnID, desc) => sort(rowA?.values, rowB?.values, columnID, desc); // eslint-disable-line no-param-reassign
|
|
125
|
+
} else {
|
|
126
|
+
column.sortType = sort; // eslint-disable-line no-param-reassign
|
|
127
|
+
}
|
|
121
128
|
column.sortDirection = sortDirection; // eslint-disable-line no-param-reassign
|
|
122
129
|
}
|
|
123
130
|
}
|
|
@@ -134,14 +141,14 @@ const BpkDataTable = props => {
|
|
|
134
141
|
return /*#__PURE__*/_jsx("div", {
|
|
135
142
|
onClick: () => onRowClicked(i),
|
|
136
143
|
role: "button",
|
|
137
|
-
onKeyDown: event =>
|
|
144
|
+
onKeyDown: event => handleRowKeyboardEvent(event, i),
|
|
138
145
|
tabIndex: 0,
|
|
139
146
|
...row.getRowProps({
|
|
140
147
|
style: {
|
|
141
148
|
...rowStyle,
|
|
142
|
-
height:
|
|
149
|
+
height: rowHeight
|
|
143
150
|
},
|
|
144
|
-
className: getRowClassNames(
|
|
151
|
+
className: getRowClassNames(i, rowClassName)
|
|
145
152
|
}),
|
|
146
153
|
children: row.cells.map(cell => {
|
|
147
154
|
if (cell.column.className) {
|
|
@@ -164,76 +171,4 @@ const BpkDataTable = props => {
|
|
|
164
171
|
})]
|
|
165
172
|
});
|
|
166
173
|
};
|
|
167
|
-
BpkDataTable.propTypes = {
|
|
168
|
-
rows: PropTypes.arrayOf(Object).isRequired,
|
|
169
|
-
/**
|
|
170
|
-
* @deprecated Use the columns prop instead to pass the columns to the BpkDataTable component.
|
|
171
|
-
*/
|
|
172
|
-
children: PropTypes.node,
|
|
173
|
-
/**
|
|
174
|
-
* Array of objects describing the columns of the table.
|
|
175
|
-
* Note: Header and Cell props are functions to format the header and cell data respectively and should implement the following signatures:
|
|
176
|
-
* ```Header: function({disableSortBy, accessor, label})```,
|
|
177
|
-
* ```Cell: function({rowData, rowIndex, accessor, columnIndex, cellData})```
|
|
178
|
-
*/
|
|
179
|
-
columns: PropTypes.arrayOf(PropTypes.shape({
|
|
180
|
-
accessor: PropTypes.string.isRequired,
|
|
181
|
-
Header: PropTypes.func,
|
|
182
|
-
disableSortBy: PropTypes.bool,
|
|
183
|
-
width: PropTypes.string,
|
|
184
|
-
minWidth: PropTypes.string,
|
|
185
|
-
flexGrow: PropTypes.number,
|
|
186
|
-
className: PropTypes.string,
|
|
187
|
-
headerClassName: PropTypes.string,
|
|
188
|
-
headerStyle: {},
|
|
189
|
-
Cell: PropTypes.func,
|
|
190
|
-
label: PropTypes.string,
|
|
191
|
-
style: {},
|
|
192
|
-
defaultSortDirection: PropTypes.oneOf(Object.keys(SORT_DIRECTION_TYPES))
|
|
193
|
-
})),
|
|
194
|
-
/**
|
|
195
|
-
* Table height. Please provide this value in rem.
|
|
196
|
-
*/
|
|
197
|
-
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
198
|
-
/**
|
|
199
|
-
* Table width. Please provide this value in rem.
|
|
200
|
-
* If not provided, the table will expand to fill the available space.
|
|
201
|
-
*/
|
|
202
|
-
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
203
|
-
/**
|
|
204
|
-
* Height of the header row. Please provide this value in rem.
|
|
205
|
-
*/
|
|
206
|
-
headerHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
207
|
-
/**
|
|
208
|
-
* Height of each row. Please provide this value in rem.
|
|
209
|
-
*/
|
|
210
|
-
rowHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
211
|
-
className: PropTypes.string,
|
|
212
|
-
/**
|
|
213
|
-
* The data will be sorted by default based on this column.
|
|
214
|
-
*/
|
|
215
|
-
defaultColumnSortIndex: PropTypes.number,
|
|
216
|
-
/**
|
|
217
|
-
* For custom sorting, pass a sort function.
|
|
218
|
-
*/
|
|
219
|
-
sort: PropTypes.func,
|
|
220
|
-
/**
|
|
221
|
-
* Use sortBy to specify which column the custom sorting will be applied to.
|
|
222
|
-
*/
|
|
223
|
-
sortBy: PropTypes.string,
|
|
224
|
-
/**
|
|
225
|
-
* Use sortDirection to set the direction of sorting. By default, it will be ascending.
|
|
226
|
-
*/
|
|
227
|
-
sortDirection: PropTypes.oneOf(Object.keys(SORT_DIRECTION_TYPES))
|
|
228
|
-
};
|
|
229
|
-
BpkDataTable.defaultProps = {
|
|
230
|
-
width: null,
|
|
231
|
-
headerHeight: '3.75rem',
|
|
232
|
-
rowHeight: '3.75rem',
|
|
233
|
-
className: null,
|
|
234
|
-
defaultColumnSortIndex: 0,
|
|
235
|
-
sort: null,
|
|
236
|
-
sortBy: null,
|
|
237
|
-
sortDirection: SORT_DIRECTION_TYPES.ASC
|
|
238
|
-
};
|
|
239
174
|
export default BpkDataTable;
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-data-table{width:100%}.bpk-data-table__header-row{overflow:hidden}.bpk-data-table__row{display:flex;flex-direction:row;align-items:center;border:1px solid #c1c7cf;border-bottom:none;outline-offset:-0.25rem;color:#161616;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-data-table__row:last-child:not(.bpk-data-table__header-row){border-bottom:1px solid #c1c7cf}.bpk-data-table__row--clickable:not(.bpk-data-table__header-row):hover{background-color:#eff3f8;cursor:pointer;box-shadow:6px 0 0 0 #0062e3 inset}html[dir=rtl] .bpk-data-table__row--clickable:not(.bpk-data-table__header-row):hover{box-shadow:-6px 0 0 0 #0062e3 inset}.bpk-data-table__row--selected{background-color:#fff7cf;box-shadow:6px 0 0 0 #0062e3 inset}html[dir=rtl] .bpk-data-table__row--selected{box-shadow:-6px 0 0 0 #0062e3 inset}.bpk-data-table__cell{margin:1rem;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}
|
|
@@ -14,12 +14,16 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { cssModules } from "../../bpk-react-utils";
|
|
20
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
18
21
|
import BpkSmallArrowDownIcon from "../../bpk-component-icon/sm/arrow-down";
|
|
22
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
19
23
|
import BpkSmallArrowUpIcon from "../../bpk-component-icon/sm/arrow-up";
|
|
20
24
|
import { withRtlSupport } from "../../bpk-component-icon";
|
|
21
|
-
import { SORT_DIRECTION_TYPES } from "./sort-types";
|
|
22
25
|
import STYLES from "./BpkDataTableHeader.module.css";
|
|
26
|
+
import { SORT_DIRECTION_TYPES } from "./common-types";
|
|
23
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
28
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
29
|
const DownIcon = withRtlSupport(BpkSmallArrowDownIcon);
|
|
@@ -29,6 +33,11 @@ const KEYCODES = {
|
|
|
29
33
|
ENTER: 13,
|
|
30
34
|
SPACEBAR: 32
|
|
31
35
|
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Internal component to render the header of a column.
|
|
39
|
+
* @returns {JSX.Element} data table header component
|
|
40
|
+
*/
|
|
32
41
|
const BpkDataTableHeader = ({
|
|
33
42
|
column
|
|
34
43
|
}) => {
|
|
@@ -45,6 +54,11 @@ const BpkDataTableHeader = ({
|
|
|
45
54
|
sortDirection,
|
|
46
55
|
width
|
|
47
56
|
} = column;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Callback for when the header is clicked to sort the column unless disableSortBy is true.
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
48
62
|
const onHeaderClick = () => {
|
|
49
63
|
if (disableSortBy === true) {
|
|
50
64
|
return;
|
|
@@ -61,6 +75,12 @@ const BpkDataTableHeader = ({
|
|
|
61
75
|
}
|
|
62
76
|
column.toggleSortBy(isDescending);
|
|
63
77
|
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Callback for handling keyboard events on the header to sort the column.
|
|
81
|
+
* @param {KeyboardEvent} event keyboard event on the header
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
64
84
|
const handleKeyboardEvent = event => {
|
|
65
85
|
if (event.keyCode === KEYCODES.ENTER || event.keyCode === KEYCODES.SPACEBAR) {
|
|
66
86
|
event.preventDefault();
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-data-table-column__header{display:flex;height:100%;margin:1rem;flex-direction:row;align-items:center;outline-offset:-0.25rem;font-size:.875rem;line-height:1.25rem;font-weight:700}.bpk-data-table-column__header:hover{cursor:pointer}.bpk-data-table-column__sort-icons{margin:0 0 0 .75rem}html[dir=rtl] .bpk-data-table-column__sort-icons{margin:0 .75rem 0 0}.bpk-data-table-column__sort-icon{display:block;fill:#c1c7cf}.bpk-data-table-column__sort-icon:hover{fill:#c1c7cf}.bpk-data-table-column__sort-icon--selected,.bpk-data-table-column__sort-icon--selected:hover{fill:#0062e3}.bpk-data-table-column__sort-icon--up{margin-bottom:-0.25rem}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export const SORT_DIRECTION_TYPES = {
|
|
20
|
+
ASC: 'ASC',
|
|
21
|
+
DESC: 'DESC'
|
|
22
|
+
};
|
|
@@ -14,153 +14,14 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/const ROOT_FONT_SIZE_PX = 16;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {String|Number} value width or height of data table or its columns, or rows
|
|
22
|
-
* @returns {String} the value in rem
|
|
23
17
|
*/
|
|
24
|
-
export const pxToRem = value => {
|
|
25
|
-
let parsed = value;
|
|
26
|
-
if (typeof value === 'number' || typeof value === 'string' && value.includes('px')) {
|
|
27
|
-
console.warn("Height in px is deprecated. Please pass the equivalent value in rem.");
|
|
28
|
-
parsed = `${value / ROOT_FONT_SIZE_PX}rem`;
|
|
29
|
-
}
|
|
30
|
-
return parsed;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* TODO: Remove this function once BpkDataTableColumns is removed
|
|
35
|
-
* This function takes the children of BpkDataTableColumns and converts them to an array of objects
|
|
36
|
-
* to temporarily maintain backwards compatibility with the old API of BpkDataTable
|
|
37
|
-
*
|
|
38
|
-
* @param {Array} columns the BpkDataTableColumns children
|
|
39
|
-
* @returns {Array} An array of column objects that can be passed to the react-table library
|
|
40
|
-
*/
|
|
41
|
-
export const getColumns = columns => {
|
|
42
|
-
console.warn('BpkDataTableColumns is deprecated. Please pass an array of objects to the columns prop instead.');
|
|
43
|
-
let columnsArray = [];
|
|
44
|
-
if (!columns) return columnsArray;
|
|
45
|
-
columnsArray = columns.map(column => {
|
|
46
|
-
const {
|
|
47
|
-
cellDataGetter,
|
|
48
|
-
cellRenderer,
|
|
49
|
-
headerRenderer
|
|
50
|
-
} = column.props;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* TODO: Remove this function once BpkDataTableColumns is removed
|
|
54
|
-
* This function takes the react-table column and row data and returns the cell data
|
|
55
|
-
* to temporarily maintain backwards compatibility with the old API of BpkDataTable
|
|
56
|
-
* and create an interface so that the function signature doesn't depend on the underlying library
|
|
57
|
-
*
|
|
58
|
-
* @param {Object} Object containing the react-table column and row data
|
|
59
|
-
* @returns {Node} JSX to render in the cell
|
|
60
|
-
*/
|
|
61
|
-
const columnCellRenderer = ({
|
|
62
|
-
column: {
|
|
63
|
-
id: dataKey
|
|
64
|
-
},
|
|
65
|
-
columns: columnsData,
|
|
66
|
-
row: {
|
|
67
|
-
id: rowID,
|
|
68
|
-
values: rowData
|
|
69
|
-
},
|
|
70
|
-
sortedRows,
|
|
71
|
-
value: cellData
|
|
72
|
-
}) => {
|
|
73
|
-
const columnIndex = columnsData.map(col => col.id).indexOf(dataKey);
|
|
74
|
-
const rowIndex = sortedRows.map(row => row.id).indexOf(rowID);
|
|
75
|
-
return cellRenderer({
|
|
76
|
-
cellData,
|
|
77
|
-
columnIndex,
|
|
78
|
-
dataKey,
|
|
79
|
-
rowData,
|
|
80
|
-
rowIndex
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* TODO: Remove this function once BpkDataTableColumns is removed
|
|
86
|
-
* This function takes the react-table column and row data and returns the cell data
|
|
87
|
-
* to temporarily maintain backwards compatibility with the old API of BpkDataTable
|
|
88
|
-
* and create an interface so that the function signature doesn't depend on the underlying library
|
|
89
|
-
*
|
|
90
|
-
* @param {Object} Object containing the react-table column and row data
|
|
91
|
-
* @returns {Node} JSX to render in the cell
|
|
92
|
-
*/
|
|
93
|
-
const columnCellDataGetter = ({
|
|
94
|
-
column: {
|
|
95
|
-
id: dataKey
|
|
96
|
-
},
|
|
97
|
-
row: {
|
|
98
|
-
values: rowData
|
|
99
|
-
}
|
|
100
|
-
}) => cellDataGetter({
|
|
101
|
-
dataKey,
|
|
102
|
-
rowData
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* TODO: Remove this function once BpkDataTableColumns is removed
|
|
107
|
-
* This function takes the react-table column data and returns the header data
|
|
108
|
-
* to temporarily maintain backwards compatibility with the old API of BpkDataTable
|
|
109
|
-
* and create an interface so that the function signature doesn't depend on the underlying library
|
|
110
|
-
*
|
|
111
|
-
* @param {Object} Object containing the react-table column data
|
|
112
|
-
* @returns {Node} JSX to render in the header
|
|
113
|
-
*/
|
|
114
|
-
const columnHeaderRenderer = ({
|
|
115
|
-
column: {
|
|
116
|
-
disableSortBy: disableSort,
|
|
117
|
-
id: dataKey,
|
|
118
|
-
label
|
|
119
|
-
}
|
|
120
|
-
}) => headerRenderer({
|
|
121
|
-
dataKey,
|
|
122
|
-
label,
|
|
123
|
-
disableSort
|
|
124
|
-
});
|
|
125
|
-
const {
|
|
126
|
-
className,
|
|
127
|
-
dataKey,
|
|
128
|
-
defaultSortDirection,
|
|
129
|
-
disableSort,
|
|
130
|
-
flexGrow,
|
|
131
|
-
headerClassName,
|
|
132
|
-
headerStyle,
|
|
133
|
-
label,
|
|
134
|
-
minWidth,
|
|
135
|
-
style,
|
|
136
|
-
width
|
|
137
|
-
} = column.props;
|
|
138
|
-
return {
|
|
139
|
-
Header: headerRenderer ? columnHeaderRenderer : label,
|
|
140
|
-
accessor: dataKey,
|
|
141
|
-
...((cellRenderer || cellDataGetter) && {
|
|
142
|
-
Cell: columnCellRenderer || columnCellDataGetter
|
|
143
|
-
}),
|
|
144
|
-
className,
|
|
145
|
-
disableSortBy: disableSort,
|
|
146
|
-
defaultSortDirection,
|
|
147
|
-
flexGrow,
|
|
148
|
-
headerClassName,
|
|
149
|
-
headerStyle,
|
|
150
|
-
label,
|
|
151
|
-
minWidth: pxToRem(minWidth),
|
|
152
|
-
style,
|
|
153
|
-
width: pxToRem(width)
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
return columnsArray;
|
|
157
|
-
};
|
|
158
18
|
|
|
159
19
|
/**
|
|
20
|
+
* This function abstracts the Cell and Header of the react-table API.
|
|
21
|
+
* The columns API defined in Backpack will therefore be independent of the react-table columns API which consumers don't need to be aware of.
|
|
22
|
+
* @param {Array} columns Array of column objects compatible with the API defined in Backpack
|
|
23
|
+
* @returns {Array} An array of column objects that can be directly passed to the hooks of the react-table library
|
|
160
24
|
*
|
|
161
|
-
* @param {Array} columns Array of column objects
|
|
162
|
-
* @returns {Array} An array of column objects that can be passed to the react-table library
|
|
163
|
-
* This function abstract the Cell and Header of the react-table API
|
|
164
25
|
*/
|
|
165
26
|
export const createColumnsSchema = columns => {
|
|
166
27
|
let columnsArray = [];
|
|
@@ -177,7 +38,9 @@ export const createColumnsSchema = columns => {
|
|
|
177
38
|
},
|
|
178
39
|
sortedRows,
|
|
179
40
|
value: cellData
|
|
180
|
-
}) =>
|
|
41
|
+
}) =>
|
|
42
|
+
// @ts-ignore Cell is called only when column has a Cell which we check below in the return statement
|
|
43
|
+
column.Cell({
|
|
181
44
|
rowData,
|
|
182
45
|
rowIndex: sortedRows.map(row => row.id).indexOf(rowID),
|
|
183
46
|
accessor,
|
|
@@ -186,13 +49,15 @@ export const createColumnsSchema = columns => {
|
|
|
186
49
|
});
|
|
187
50
|
const Header = ({
|
|
188
51
|
column: {
|
|
189
|
-
disableSortBy
|
|
52
|
+
disableSortBy,
|
|
190
53
|
id: accessor,
|
|
191
54
|
label
|
|
192
55
|
}
|
|
193
|
-
}) =>
|
|
56
|
+
}) =>
|
|
57
|
+
// @ts-ignore Header is called only when column has a Header which we check below in the return statement
|
|
58
|
+
column.Header({
|
|
194
59
|
label,
|
|
195
|
-
|
|
60
|
+
disableSortBy,
|
|
196
61
|
accessor
|
|
197
62
|
});
|
|
198
63
|
return {
|
|
@@ -204,4 +69,5 @@ export const createColumnsSchema = columns => {
|
|
|
204
69
|
};
|
|
205
70
|
});
|
|
206
71
|
return columnsArray;
|
|
207
|
-
};
|
|
72
|
+
};
|
|
73
|
+
export default createColumnsSchema;
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-datepicker__calendar{margin:0 auto}.bpk-datepicker__input{display:inline-block;width:100%}
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
17
|
+
*/
|
|
18
|
+
.bpk-description-list{margin:0}.bpk-description-list__term{font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-description-list__details{margin:0;margin-left:1.5rem}html[dir=rtl] .bpk-description-list__details{margin-right:1.5rem;margin-left:0}
|