@skyscanner/backpack-web 33.3.1 → 34.0.0-premajor

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/bpk-component-accordion/index.js +1 -1
  2. package/bpk-component-accordion/src/BpkAccordionItem.js +12 -13
  3. package/bpk-component-accordion/src/BpkAccordionItem.module.css +1 -1
  4. package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.js +5 -3
  5. package/bpk-component-banner-alert/index.js +1 -1
  6. package/bpk-component-banner-alert/src/AnimateAndFade.js +37 -35
  7. package/bpk-component-banner-alert/src/BpkBannerAlertInner.js +12 -6
  8. package/bpk-component-barchart/src/BpkBarchart.js +9 -10
  9. package/bpk-component-barchart/src/BpkBarchartBar.js +1 -2
  10. package/bpk-component-barchart/src/BpkBarchartBars.js +2 -2
  11. package/bpk-component-barchart/src/BpkBarchartDefs.js +1 -2
  12. package/bpk-component-barchart/src/BpkChartAxis.js +1 -2
  13. package/bpk-component-barchart/src/BpkChartDataTable.js +1 -2
  14. package/bpk-component-bottom-sheet/src/BpkBottomSheet.js +4 -6
  15. package/bpk-component-breadcrumb/src/BpkBreadcrumb.js +1 -2
  16. package/bpk-component-breadcrumb/src/BpkBreadcrumbItem.js +18 -14
  17. package/bpk-component-breadcrumb/src/BpkBreadcrumbItem.module.css +1 -1
  18. package/bpk-component-breakpoint/index.d.ts +2 -1
  19. package/bpk-component-breakpoint/src/BpkBreakpoint.js +5 -19
  20. package/bpk-component-breakpoint/src/useMediaQuery.js +10 -12
  21. package/bpk-component-button/index.js +5 -5
  22. package/bpk-component-button/src/BpkButtonDestructive.js +10 -9
  23. package/bpk-component-button/src/BpkButtonFeatured.js +10 -9
  24. package/bpk-component-button/src/BpkButtonLink.js +11 -10
  25. package/bpk-component-button/src/BpkButtonLinkOnDark.js +11 -10
  26. package/bpk-component-button/src/BpkButtonPrimary.js +2 -2
  27. package/bpk-component-button/src/BpkButtonPrimaryOnDark.js +10 -9
  28. package/bpk-component-button/src/BpkButtonPrimaryOnLight.js +10 -9
  29. package/bpk-component-button/src/BpkButtonSecondary.js +10 -10
  30. package/bpk-component-button/src/BpkButtonSecondaryOnDark.js +10 -9
  31. package/bpk-component-calendar/index.js +1 -1
  32. package/bpk-component-calendar/src/BpkCalendarContainer.js +3 -3
  33. package/bpk-component-calendar/src/BpkCalendarGrid.js +3 -2
  34. package/bpk-component-calendar/src/BpkCalendarGrid.module.css +1 -1
  35. package/bpk-component-calendar/src/BpkCalendarGridHeader.js +4 -1
  36. package/bpk-component-calendar/src/BpkCalendarGridTransition.js +6 -4
  37. package/bpk-component-calendar/src/BpkCalendarNav.js +10 -5
  38. package/bpk-component-calendar/src/Week.js +6 -3
  39. package/bpk-component-calendar/src/composeCalendar.js +9 -4
  40. package/bpk-component-calendar/src/date-utils.js +14 -14
  41. package/bpk-component-card/src/BpkCardWrapper.js +1 -2
  42. package/bpk-component-card/src/BpkDividedCard.js +19 -15
  43. package/bpk-component-card-button/src/BpkSaveButton.js +14 -6
  44. package/bpk-component-checkbox/src/BpkCheckbox.js +1 -2
  45. package/bpk-component-chip/index.d.ts +3 -5
  46. package/bpk-component-chip/index.js +3 -2
  47. package/bpk-component-chip/src/BpkDismissibleChip.js +7 -2
  48. package/bpk-component-chip/src/BpkIconChip.d.ts +25 -0
  49. package/bpk-component-chip/src/BpkIconChip.js +31 -0
  50. package/bpk-component-chip/src/BpkSelectableChip.d.ts +0 -2
  51. package/bpk-component-chip/src/BpkSelectableChip.js +5 -6
  52. package/bpk-component-chip/src/BpkSelectableChip.module.css +1 -1
  53. package/bpk-component-chip/src/commonTypes.d.ts +1 -1
  54. package/bpk-component-chip/src/commonTypes.js +1 -24
  55. package/bpk-component-close-button/src/BpkCloseButton.js +3 -2
  56. package/bpk-component-close-button/src/BpkCloseButton.module.css +1 -1
  57. package/bpk-component-content-cards/src/BpkContentCard.js +9 -4
  58. package/bpk-component-content-cards/src/BpkContentCards.js +2 -7
  59. package/bpk-component-content-cards/src/BpkContentCards.module.css +1 -1
  60. package/bpk-component-datatable/src/BpkDataTable.js +4 -4
  61. package/bpk-component-datatable/src/BpkDataTableHeader.js +14 -11
  62. package/bpk-component-datatable/src/BpkDataTableHeader.module.css +1 -1
  63. package/bpk-component-datepicker/src/BpkDatepicker.js +3 -5
  64. package/bpk-component-description-list/index.js +1 -1
  65. package/bpk-component-description-list/src/ComponentFactory.js +10 -5
  66. package/bpk-component-dialog/src/BpkDialog.js +7 -6
  67. package/bpk-component-dialog/src/BpkDialog.module.css +1 -1
  68. package/bpk-component-dialog/src/BpkDialogInner.js +7 -5
  69. package/bpk-component-drawer/src/BpkDrawer.js +1 -4
  70. package/bpk-component-drawer/src/BpkDrawerContent.js +8 -7
  71. package/bpk-component-fieldset/src/BpkFieldset.js +10 -9
  72. package/bpk-component-flare/index.js +2 -2
  73. package/bpk-component-flare/src/BpkContentBubble.js +5 -3
  74. package/bpk-component-flare/src/BpkFlareBar.js +15 -7
  75. package/bpk-component-flare/src/__generated__/corner-radius.d.ts +6 -0
  76. package/bpk-component-flare/src/__generated__/pointer.d.ts +6 -0
  77. package/bpk-component-floating-notification/src/BpkFloatingNotification.js +10 -4
  78. package/bpk-component-form-validation/src/BpkFormValidation.js +6 -6
  79. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +10 -14
  80. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.module.css +1 -1
  81. package/bpk-component-grid-toggle/src/BpkGridToggle.js +8 -6
  82. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.js +16 -14
  83. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.module.css +1 -1
  84. package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.js +2 -2
  85. package/bpk-component-icon/index.js +1 -1
  86. package/bpk-component-icon/lg/aircraft.js +1 -2
  87. package/bpk-component-icon/lg/beach.js +1 -2
  88. package/bpk-component-icon/lg/call-back.js +1 -2
  89. package/bpk-component-icon/lg/camper-van.js +1 -2
  90. package/bpk-component-icon/lg/car-wash.js +1 -2
  91. package/bpk-component-icon/lg/cars.js +1 -2
  92. package/bpk-component-icon/lg/clean.js +1 -2
  93. package/bpk-component-icon/lg/cloakroom.js +1 -2
  94. package/bpk-component-icon/lg/content--copy.js +1 -2
  95. package/bpk-component-icon/lg/data.js +1 -2
  96. package/bpk-component-icon/lg/depart.js +1 -2
  97. package/bpk-component-icon/lg/download.js +1 -2
  98. package/bpk-component-icon/lg/education.js +1 -2
  99. package/bpk-component-icon/lg/explore.js +1 -2
  100. package/bpk-component-icon/lg/fast-track.js +1 -2
  101. package/bpk-component-icon/lg/fast-train.js +1 -2
  102. package/bpk-component-icon/lg/flight-landing.js +1 -2
  103. package/bpk-component-icon/lg/flight-takeoff.js +1 -2
  104. package/bpk-component-icon/lg/flight.js +1 -2
  105. package/bpk-component-icon/lg/legroom--extra.js +1 -2
  106. package/bpk-component-icon/lg/legroom--normal.js +1 -2
  107. package/bpk-component-icon/lg/legroom--reduced.js +1 -2
  108. package/bpk-component-icon/lg/logout.js +1 -2
  109. package/bpk-component-icon/lg/lounge.js +1 -2
  110. package/bpk-component-icon/lg/mail.js +1 -2
  111. package/bpk-component-icon/lg/mileage.js +1 -2
  112. package/bpk-component-icon/lg/new-window.js +1 -2
  113. package/bpk-component-icon/lg/plane-seat.js +1 -2
  114. package/bpk-component-icon/lg/return.js +1 -2
  115. package/bpk-component-icon/lg/scales.js +1 -2
  116. package/bpk-component-icon/lg/share--ios.js +1 -2
  117. package/bpk-component-icon/lg/social-distancing.js +1 -2
  118. package/bpk-component-icon/lg/speaker.js +1 -2
  119. package/bpk-component-icon/lg/taxi.js +1 -2
  120. package/bpk-component-icon/lg/unmute.js +1 -2
  121. package/bpk-component-icon/lg/wallet.js +1 -2
  122. package/bpk-component-icon/lg/weather--cloudy.js +1 -2
  123. package/bpk-component-icon/lg/weather--partly-cloudy.js +1 -2
  124. package/bpk-component-icon/lg/weather--rain.js +1 -2
  125. package/bpk-component-icon/lg/weather--thunderstorm.js +1 -2
  126. package/bpk-component-icon/lg/window--reduce.js +1 -2
  127. package/bpk-component-icon/lg/world--emea.js +1 -2
  128. package/bpk-component-icon/sm/aircraft.js +1 -2
  129. package/bpk-component-icon/sm/beach.js +1 -2
  130. package/bpk-component-icon/sm/bus.js +1 -2
  131. package/bpk-component-icon/sm/call-back.js +1 -2
  132. package/bpk-component-icon/sm/camper-van.js +1 -2
  133. package/bpk-component-icon/sm/car-wash.js +1 -2
  134. package/bpk-component-icon/sm/cars.js +1 -2
  135. package/bpk-component-icon/sm/chauffeur.js +1 -2
  136. package/bpk-component-icon/sm/clean.js +1 -2
  137. package/bpk-component-icon/sm/content--copy.js +1 -2
  138. package/bpk-component-icon/sm/data.js +1 -2
  139. package/bpk-component-icon/sm/depart.js +1 -2
  140. package/bpk-component-icon/sm/direct.js +1 -2
  141. package/bpk-component-icon/sm/download.js +1 -2
  142. package/bpk-component-icon/sm/education.js +1 -2
  143. package/bpk-component-icon/sm/explore.js +1 -2
  144. package/bpk-component-icon/sm/fast-track.js +1 -2
  145. package/bpk-component-icon/sm/fast-train.js +1 -2
  146. package/bpk-component-icon/sm/flight-landing.js +1 -2
  147. package/bpk-component-icon/sm/flight-takeoff.js +1 -2
  148. package/bpk-component-icon/sm/flight.js +1 -2
  149. package/bpk-component-icon/sm/hotels--jacuzzi.js +1 -2
  150. package/bpk-component-icon/sm/infant.js +1 -2
  151. package/bpk-component-icon/sm/legroom--extra.js +1 -2
  152. package/bpk-component-icon/sm/legroom--normal.js +1 -2
  153. package/bpk-component-icon/sm/legroom--reduced.js +1 -2
  154. package/bpk-component-icon/sm/logout.js +1 -2
  155. package/bpk-component-icon/sm/mail.js +1 -2
  156. package/bpk-component-icon/sm/mileage.js +1 -2
  157. package/bpk-component-icon/sm/new-window.js +1 -2
  158. package/bpk-component-icon/sm/onsen.js +1 -2
  159. package/bpk-component-icon/sm/plane-seat.js +1 -2
  160. package/bpk-component-icon/sm/return.js +1 -2
  161. package/bpk-component-icon/sm/share--ios.js +1 -2
  162. package/bpk-component-icon/sm/social-distancing.js +1 -2
  163. package/bpk-component-icon/sm/taxi.js +1 -2
  164. package/bpk-component-icon/sm/unmute.js +1 -2
  165. package/bpk-component-icon/sm/weather--cloudy.js +1 -2
  166. package/bpk-component-icon/sm/weather--rain.js +1 -2
  167. package/bpk-component-icon/sm/weather--thunderstorm.js +1 -2
  168. package/bpk-component-icon/sm/weather--wind.js +1 -2
  169. package/bpk-component-icon/sm/window--reduce.js +1 -2
  170. package/bpk-component-icon/src/classNameModifierHOCFactory.js +3 -0
  171. package/bpk-component-icon/src/withDescription.js +1 -2
  172. package/bpk-component-icon/src/withRtlSupport.js +1 -1
  173. package/bpk-component-image/index.js +2 -2
  174. package/bpk-component-image/src/BpkBackgroundImage.js +4 -3
  175. package/bpk-component-image/src/BpkImage.js +6 -4
  176. package/bpk-component-infinite-scroll/src/withInfiniteScroll.js +4 -5
  177. package/bpk-component-info-banner/src/AnimateAndFade.js +37 -35
  178. package/bpk-component-info-banner/src/BpkInfoBanner.module.css +1 -1
  179. package/bpk-component-info-banner/src/BpkInfoBannerInner.js +17 -14
  180. package/bpk-component-input/index.js +1 -1
  181. package/bpk-component-input/src/BpkClearButton.js +3 -1
  182. package/bpk-component-input/src/BpkInput.js +6 -4
  183. package/bpk-component-input/src/withOpenEvents.js +4 -1
  184. package/bpk-component-label/src/BpkLabel.js +1 -2
  185. package/bpk-component-link/index.js +2 -2
  186. package/bpk-component-list/src/BpkList.js +4 -1
  187. package/bpk-component-loading-button/src/BpkLoadingButton.js +7 -5
  188. package/bpk-component-map/index.js +4 -4
  189. package/bpk-component-map/src/BpkIconMarker.js +2 -3
  190. package/bpk-component-map/src/BpkMap.js +2 -2
  191. package/bpk-component-map/src/BpkPriceMarker.js +8 -7
  192. package/bpk-component-map/src/BpkPriceMarkerV2/BpkPriceMarker.js +2 -3
  193. package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.js +5 -2
  194. package/bpk-component-modal/index.js +4 -3
  195. package/bpk-component-modal/src/BpkModal.d.ts +2 -1
  196. package/bpk-component-modal/src/BpkModal.js +8 -3
  197. package/bpk-component-modal/src/BpkModalInner.d.ts +2 -0
  198. package/bpk-component-modal/src/BpkModalInner.js +25 -10
  199. package/bpk-component-modal/src/BpkModalInner.module.css +1 -1
  200. package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +1 -1
  201. package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +2 -0
  202. package/bpk-component-modal/src/BpkModalV2/BpkModal.js +20 -10
  203. package/bpk-component-navigation-bar/index.js +1 -1
  204. package/bpk-component-navigation-bar/src/BpkNavigationBar.js +8 -7
  205. package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.js +5 -2
  206. package/bpk-component-navigation-bar/src/BpkNavigationBarIconButton.js +5 -2
  207. package/bpk-component-nudger/index.js +1 -1
  208. package/bpk-component-nudger/src/BpkConfigurableNudger.js +17 -6
  209. package/bpk-component-nudger/src/BpkNudger.js +17 -7
  210. package/bpk-component-overlay/src/BpkOverlay.js +1 -2
  211. package/bpk-component-page-indicator/src/BpkPageIndicator.js +1 -2
  212. package/bpk-component-page-indicator/src/BpkPageIndicator.module.css +1 -1
  213. package/bpk-component-page-indicator/src/NavButton.js +1 -1
  214. package/bpk-component-pagination/src/BpkPagination.js +1 -2
  215. package/bpk-component-pagination/src/BpkPaginationList.js +1 -1
  216. package/bpk-component-pagination/src/BpkPaginationNudger.js +14 -6
  217. package/bpk-component-pagination/src/BpkPaginationPage.js +4 -1
  218. package/bpk-component-phone-input/src/BpkPhoneInput.js +16 -6
  219. package/bpk-component-popover/src/BpkPopover.js +106 -63
  220. package/bpk-component-popover/src/BpkPopoverPortal.js +123 -119
  221. package/bpk-component-popover/src/keyboardFocusScope.js +1 -1
  222. package/bpk-component-price/src/BpkPrice.js +19 -8
  223. package/bpk-component-progress/src/BpkProgress.js +1 -2
  224. package/bpk-component-radio/src/BpkRadio.js +1 -2
  225. package/bpk-component-rating/src/BpkRating.js +19 -8
  226. package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +4 -1
  227. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.js +7 -5
  228. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.js +7 -4
  229. package/bpk-component-section-header/src/BpkSectionHeader.js +10 -5
  230. package/bpk-component-section-list/index.js +1 -1
  231. package/bpk-component-section-list/src/BpkSectionListItem.js +11 -6
  232. package/bpk-component-section-list/src/BpkSectionListSection.js +2 -3
  233. package/bpk-component-select/src/BpkSelect.js +1 -2
  234. package/bpk-component-slider/src/BpkSlider.js +6 -2
  235. package/bpk-component-spinner/index.js +3 -3
  236. package/bpk-component-spinner/src/BpkExtraLargeSpinner.js +9 -7
  237. package/bpk-component-spinner/src/BpkLargeSpinner.js +9 -7
  238. package/bpk-component-spinner/src/BpkSpinner.js +9 -7
  239. package/bpk-component-split-input/src/BpkInputField.js +2 -2
  240. package/bpk-component-split-input/src/BpkSplitInput.js +3 -3
  241. package/bpk-component-star-rating/index.js +4 -4
  242. package/bpk-component-star-rating/src/BpkInteractiveStar.js +6 -2
  243. package/bpk-component-star-rating/src/BpkInteractiveStarRating.js +1 -1
  244. package/bpk-component-star-rating/src/BpkStar.js +22 -15
  245. package/bpk-component-swap-button/src/BpkSwapButton.js +2 -1
  246. package/bpk-component-switch/src/BpkSwitch.js +1 -2
  247. package/bpk-component-table/index.js +2 -2
  248. package/bpk-component-text/src/BpkText.js +10 -5
  249. package/bpk-component-theme-toggle/src/BpkThemeToggle.js +6 -4
  250. package/bpk-component-theme-toggle/src/updateOnThemeChange.js +1 -1
  251. package/bpk-component-tooltip/src/BpkTooltip.js +2 -3
  252. package/bpk-component-tooltip/src/BpkTooltipPortal.js +7 -6
  253. package/bpk-mixins/_chips.scss +9 -0
  254. package/bpk-react-utils/index.js +3 -3
  255. package/bpk-react-utils/src/BpkDialogWrapper/BpkDialogWrapper.js +2 -2
  256. package/bpk-react-utils/src/Portal.js +1 -0
  257. package/bpk-react-utils/src/withDefaultProps.js +4 -1
  258. package/bpk-scrim-utils/src/withScrim.js +3 -3
  259. package/bpk-scrim-utils/src/withScrimmedPortal.js +1 -1
  260. package/bpk-theming/src/BpkThemeProvider.js +1 -1
  261. package/package.json +5 -3
  262. package/unstable__bpk-mixins/_chips.scss +9 -0
  263. package/bpk-component-button/src/commonButtonTests.js +0 -133
@@ -35,7 +35,10 @@ const withDefaultProps = (WrappedComponent, defaultProps) => {
35
35
  if (innerClassName) {
36
36
  classNames.push(innerClassName);
37
37
  }
38
- return /*#__PURE__*/_jsx(WrappedComponent, {
38
+ return /*#__PURE__*/_jsx(WrappedComponent
39
+ // General HOC difficult/impossible to remove
40
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
41
+ , {
39
42
  className: classNames.join(' '),
40
43
  ...defaultRest,
41
44
  ...rest,
@@ -16,17 +16,17 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
+ import { Component } from 'react';
20
+
19
21
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
20
22
  import focusScope from 'a11y-focus-scope';
21
23
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
22
24
  import focusStore from 'a11y-focus-store';
23
- import { Component } from 'react';
24
25
  import { cssModules, isDeviceIpad, isDeviceIphone, wrapDisplayName } from "../../bpk-react-utils";
25
26
  import BpkScrim from "./BpkScrim";
26
27
  import { fixBody, lockScroll, restoreScroll, storeScroll, unfixBody, unlockScroll } from "./scroll-utils";
27
28
  import STYLES from "./bpk-scrim-content.module.css";
28
- import { jsx as _jsx } from "react/jsx-runtime";
29
- import { jsxs as _jsxs } from "react/jsx-runtime";
29
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
30
30
  const getClassName = cssModules(STYLES);
31
31
  const withScrim = WrappedComponent => {
32
32
  class WithScrim extends Component {
@@ -18,8 +18,8 @@
18
18
 
19
19
  import { useState, useEffect } from 'react';
20
20
  import { createPortal } from 'react-dom';
21
- import withScrim from "./withScrim";
22
21
  import BpkScrim from "./BpkScrim";
22
+ import withScrim from "./withScrim";
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
24
  const getPortalElement = target => {
25
25
  const portalElement = target && typeof target === 'function' ? target() : null;
@@ -16,8 +16,8 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { Component } from 'react';
20
19
  import PropTypes from 'prop-types';
20
+ import { Component } from 'react';
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  const uniq = (arr = []) => {
23
23
  const seen = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "33.3.1",
3
+ "version": "34.0.0-premajor",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,9 +22,11 @@
22
22
  "access": "public"
23
23
  },
24
24
  "dependencies": {
25
- "@popperjs/core": "^2.11.5",
25
+ "@floating-ui/dom": "^1.6.3",
26
+ "@floating-ui/react": "^0.26.12",
27
+ "@popperjs/core": "^2.11.8",
26
28
  "@react-google-maps/api": "^2.12.0",
27
- "@skyscanner/bpk-foundations-web": "^17.5.3",
29
+ "@skyscanner/bpk-foundations-web": "^17.9.0",
28
30
  "@skyscanner/bpk-svgs": "^19.1.0",
29
31
  "a11y-focus-scope": "^1.1.3",
30
32
  "a11y-focus-store": "^1.0.0",
@@ -237,4 +237,13 @@
237
237
  color: tokens.$bpk-text-disabled-day;
238
238
  cursor: not-allowed;
239
239
  }
240
+
241
+ &--icon-only {
242
+ padding-inline-end: tokens.bpk-spacing-md();
243
+ padding-inline-start: tokens.bpk-spacing-md();
244
+
245
+ &__leading-accessory-view {
246
+ @include margins.bpk-margin-trailing(0);
247
+ }
248
+ }
240
249
  }
@@ -1,133 +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
- import { render } from '@testing-library/react';
20
- import { jsx as _jsx } from "react/jsx-runtime";
21
- const commonButtonTests = ButtonToTest => {
22
- describe('ButtonToTest', () => {
23
- it('should render correctly', () => {
24
- const {
25
- asFragment
26
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
27
- children: "My button"
28
- }));
29
- expect(asFragment()).toMatchSnapshot();
30
- });
31
- it('should render correctly with a "href" attribute', () => {
32
- const {
33
- asFragment
34
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
35
- href: "#",
36
- children: "My button"
37
- }));
38
- expect(asFragment()).toMatchSnapshot();
39
- });
40
- it('should render correctly with a "disabled" attribute', () => {
41
- const {
42
- asFragment
43
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
44
- disabled: true,
45
- children: "My button"
46
- }));
47
- expect(asFragment()).toMatchSnapshot();
48
- });
49
- it('should render correctly with a "large" attribute', () => {
50
- const {
51
- asFragment
52
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
53
- large: true,
54
- children: "My button"
55
- }));
56
- expect(asFragment()).toMatchSnapshot();
57
- });
58
- it('should render correctly with an "iconOnly" attribute', () => {
59
- const {
60
- asFragment
61
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
62
- iconOnly: true,
63
- children: "My button"
64
- }));
65
- expect(asFragment()).toMatchSnapshot();
66
- });
67
- it('should respect the class names entered as a string', () => {
68
- const {
69
- asFragment
70
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
71
- large: true,
72
- className: "custom-class-1 custom-class-2",
73
- children: "My button"
74
- }));
75
- expect(asFragment()).toMatchSnapshot();
76
- });
77
- it('should add only bpk specific classes if className prop is set to empty string', () => {
78
- const {
79
- asFragment
80
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
81
- large: true,
82
- className: "",
83
- children: "My button"
84
- }));
85
- expect(asFragment()).toMatchSnapshot();
86
- });
87
- it('should render correctly with "blank" attribute', () => {
88
- const {
89
- asFragment
90
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
91
- href: "#",
92
- blank: true,
93
- children: "My button"
94
- }));
95
- expect(asFragment()).toMatchSnapshot();
96
- });
97
- it('should render correctly with "rel" attribute', () => {
98
- const {
99
- asFragment
100
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
101
- href: "#",
102
- rel: "rel-attr",
103
- children: "My button"
104
- }));
105
- expect(asFragment()).toMatchSnapshot();
106
- });
107
- it('should render correctly with "blank" and "rel" attributes', () => {
108
- const {
109
- asFragment
110
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
111
- href: "#",
112
- blank: true,
113
- rel: "rel-overwrite",
114
- children: "My button"
115
- }));
116
- expect(asFragment()).toMatchSnapshot();
117
- });
118
- it('should render correctly with "disabled" and "href" attributes', () => {
119
- const {
120
- asFragment
121
- } = render( /*#__PURE__*/_jsx(ButtonToTest, {
122
- href: "#",
123
- disabled: true,
124
- children: "My button"
125
- }));
126
- expect(asFragment()).toMatchSnapshot();
127
- });
128
- });
129
- };
130
-
131
- // We export these to reuse them in other tests for buttons.
132
- // eslint-disable-next-line jest/no-export
133
- export default commonButtonTests;