@skyscanner/backpack-web 41.2.0 → 41.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/bpk-component-autosuggest/index.js +2 -2
  2. package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.d.ts +13 -0
  3. package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.js +3 -3
  4. package/bpk-component-bottom-sheet/src/BpkBottomSheet.js +3 -2
  5. package/bpk-component-card-list/src/BpkCardList.js +2 -2
  6. package/bpk-component-card-list/src/BpkCardListGridStack/BpkCardListGridStack.js +2 -2
  7. package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.module.css +1 -1
  8. package/bpk-component-card-list/src/BpkExpand/ExpandAccessoryContent.js +2 -2
  9. package/bpk-component-chip-group/src/Nudger.js +2 -2
  10. package/bpk-component-code/index.d.ts +6 -0
  11. package/bpk-component-code/index.js +3 -1
  12. package/bpk-component-code/src/BpkCode.d.ts +9 -0
  13. package/bpk-component-code/src/BpkCode.js +14 -33
  14. package/bpk-component-code/src/BpkCodeBlock.d.ts +9 -0
  15. package/bpk-component-code/src/BpkCodeBlock.js +15 -28
  16. package/bpk-component-drawer/src/BpkDrawerContent.js +3 -2
  17. package/bpk-component-floating-notification/src/BpkFloatingNotification.js +2 -2
  18. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +2 -2
  19. package/bpk-component-grid-toggle/src/BpkGridToggle.js +3 -2
  20. package/bpk-component-link/index.d.ts +12 -3
  21. package/bpk-component-link/index.js +10 -1
  22. package/bpk-component-link/src/BpkButtonLink.d.ts +8 -0
  23. package/bpk-component-link/src/BpkButtonLink.js +10 -0
  24. package/bpk-component-link/src/BpkLink.d.ts +2 -15
  25. package/bpk-component-link/src/BpkLink.js +85 -40
  26. package/bpk-component-link/src/common-types.d.ts +44 -0
  27. package/bpk-component-link/src/common-types.js +1 -0
  28. package/bpk-component-loading-button/src/BpkLoadingButton.js +2 -2
  29. package/bpk-component-modal/src/BpkModalInner.js +3 -2
  30. package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.d.ts +4 -5
  31. package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.js +3 -2
  32. package/bpk-component-nudger/src/BpkNudger.js +3 -3
  33. package/bpk-component-page-indicator/src/NavButton.js +2 -2
  34. package/bpk-component-pagination/src/BpkPaginationNudger.js +2 -2
  35. package/bpk-component-popover/src/BpkPopover.js +7 -4
  36. package/bpk-component-price/src/BpkPrice.js +3 -0
  37. package/bpk-component-price/src/common-types.js +1 -0
  38. package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +3 -2
  39. package/bpk-component-snippet/src/BpkSnippet.js +2 -2
  40. package/bpk-component-theme-toggle/index.d.ts +4 -0
  41. package/bpk-component-theme-toggle/src/BpkThemeToggle.d.ts +16 -0
  42. package/bpk-component-theme-toggle/src/BpkThemeToggle.js +12 -7
  43. package/bpk-component-theme-toggle/src/theming.d.ts +136 -0
  44. package/bpk-component-theme-toggle/src/updateOnThemeChange.d.ts +42 -0
  45. package/bpk-component-theme-toggle/src/updateOnThemeChange.js +10 -8
  46. package/bpk-component-theme-toggle/src/utils.d.ts +3 -0
  47. package/bpk-component-theme-toggle/src/utils.js +1 -1
  48. package/package.json +1 -1
@@ -16,6 +16,6 @@
16
16
  * limitations under the License.
17
17
  */import BpkAutosuggest from "./src/BpkAutosuggest";
18
18
  import BpkAutosuggestSuggestion from "./src/BpkAutosuggestSuggestion";
19
- import BpkAutosuggestV2 from "./src/BpkAutosuggestV2/BpkAutosuggest";
19
+ import BpkAutosuggestV2, { defaultTheme } from "./src/BpkAutosuggestV2/BpkAutosuggest";
20
20
  export default BpkAutosuggest;
21
- export { BpkAutosuggestSuggestion, BpkAutosuggestV2 };
21
+ export { BpkAutosuggestSuggestion, BpkAutosuggestV2, defaultTheme };
@@ -64,5 +64,18 @@ export type BpkAutoSuggestProps<T> = {
64
64
  }) => void;
65
65
  focusInputOnSuggestionClick?: boolean;
66
66
  };
67
+ export declare const defaultTheme: {
68
+ container: string;
69
+ containerOpen: string;
70
+ suggestionsContainer: string;
71
+ suggestionsContainerOpen: string;
72
+ suggestionsList: string;
73
+ suggestion: string;
74
+ suggestionHighlighted: string;
75
+ sectionContainer: string;
76
+ sectionTitle: string;
77
+ input: string;
78
+ visuallyHidden: string;
79
+ };
67
80
  declare const BpkAutosuggest: import("react").ForwardRefExoticComponent<BpkAutoSuggestProps<any> & import("react").RefAttributes<HTMLInputElement>>;
68
81
  export default BpkAutosuggest;
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { useEffect, forwardRef, useRef } from 'react';
20
- import { useFloating, offset, flip, shift, size, arrow as floatingArrow, FloatingArrow, autoUpdate, FloatingPortal } from '@floating-ui/react';
20
+ import { useFloating, offset, shift, size, arrow as floatingArrow, FloatingArrow, autoUpdate, FloatingPortal } from '@floating-ui/react';
21
21
  import { useCombobox } from 'downshift';
22
22
  import { surfaceHighlightDay } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
23
23
  import BpkInput from "../../../bpk-component-input";
@@ -25,7 +25,7 @@ import { cssModules } from "../../../bpk-react-utils";
25
25
  import STYLES from "./BpkAutosuggest.module.css";
26
26
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
27
27
  const getClassName = cssModules(STYLES);
28
- const defaultTheme = {
28
+ export const defaultTheme = {
29
29
  container: getClassName('bpk-autosuggest__container'),
30
30
  containerOpen: getClassName('bpk-autosuggest__container--open'),
31
31
  suggestionsContainer: getClassName('bpk-autosuggest__suggestions-container'),
@@ -235,7 +235,7 @@ const BpkAutosuggest = /*#__PURE__*/forwardRef(({
235
235
  ...(isDesktop && {
236
236
  strategy: 'fixed'
237
237
  }),
238
- middleware: isDesktop ? [offset(4), flip(), shift(), size({
238
+ middleware: isDesktop ? [offset(4), shift(), size({
239
239
  apply({
240
240
  elements,
241
241
  rects
@@ -20,7 +20,7 @@ import { useCallback, useState } from 'react';
20
20
  import BpkBreakpoint, { BREAKPOINTS } from "../../bpk-component-breakpoint";
21
21
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
22
22
  import BpkCloseButton from "../../bpk-component-close-button";
23
- import { BpkButtonLink } from "../../bpk-component-link";
23
+ import BpkLink from "../../bpk-component-link";
24
24
  import BpkNavigationBar from "../../bpk-component-navigation-bar";
25
25
  import { TEXT_STYLES } from "../../bpk-component-text/src/BpkText";
26
26
  import { BpkDialogWrapper, cssModules } from "../../bpk-react-utils";
@@ -126,7 +126,8 @@ const BpkBottomSheet = ({
126
126
  label: closeLabel,
127
127
  onClick: handleClose
128
128
  }),
129
- trailingButton: actionText && onAction ? /*#__PURE__*/_jsx(BpkButtonLink, {
129
+ trailingButton: actionText && onAction ? /*#__PURE__*/_jsx(BpkLink, {
130
+ as: "button",
130
131
  onClick: onAction,
131
132
  children: actionText
132
133
  }) : null
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  import BpkBreakpoint, { BREAKPOINTS } from "../../bpk-component-breakpoint";
19
- import { BpkButtonV2 } from "../../bpk-component-button";
19
+ import BpkButton from "../../bpk-component-button";
20
20
  import BpkSectionHeader from "../../bpk-component-section-header";
21
21
  import { cssModules } from "../../bpk-react-utils";
22
22
  import BpkCardListGridStack from "./BpkCardListGridStack";
@@ -53,7 +53,7 @@ const BpkCardList = props => {
53
53
  }
54
54
  return accessoryDesktop !== ACCESSORY_DESKTOP_TYPES.button;
55
55
  };
56
- const headerButton = buttonContent && /*#__PURE__*/_jsx(BpkButtonV2, {
56
+ const headerButton = buttonContent && /*#__PURE__*/_jsx(BpkButton, {
57
57
  onClick: onButtonClick,
58
58
  href: buttonHref,
59
59
  "data-testid": "bpk-card-list-header-button",
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { Children, useState } from 'react';
20
- import { BpkButtonV2 } from "../../../bpk-component-button";
20
+ import BpkButton from "../../../bpk-component-button";
21
21
  import { cssModules } from "../../../bpk-react-utils";
22
22
  import ExpandAccessoryContent from "../BpkExpand/ExpandAccessoryContent";
23
23
  import { ACCESSORY_DESKTOP_TYPES } from "../common-types";
@@ -58,7 +58,7 @@ const BpkCardListGridStack = props => {
58
58
  });
59
59
  const buttonAccessoryContent = /*#__PURE__*/_jsx("div", {
60
60
  className: getClassName('bpk-card-list-grid-stack__accessory__button'),
61
- children: /*#__PURE__*/_jsx(BpkButtonV2, {
61
+ children: /*#__PURE__*/_jsx(BpkButton, {
62
62
  "data-testid": "bpk-card-list__accessory-button",
63
63
  onClick: onButtonClick,
64
64
  href: buttonHref,
@@ -15,4 +15,4 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- .bpk-card-list-row-rail__row,.bpk-card-list-row-rail__rail{display:flex;overflow-x:hidden;box-sizing:border-box;gap:.25rem;margin-block:-1.5rem;padding-block:1.5rem;scroll-snap-stop:always;scroll-snap-type:x mandatory;scrollbar-width:none}@media(max-width: 32rem){.bpk-card-list-row-rail__row,.bpk-card-list-row-rail__rail{overflow-x:scroll}}.bpk-card-list-row-rail__row::-webkit-scrollbar,.bpk-card-list-row-rail__rail::-webkit-scrollbar{display:none}.bpk-card-list-row-rail__row__card,.bpk-card-list-row-rail__rail__card{position:relative;padding:0 .5rem;flex:0 0 calc((100% - .5rem*(var(--initially-shown-cards, 3) - 1))/var(--initially-shown-cards, 3));overflow:visible;box-sizing:border-box;scroll-snap-align:start}@media(max-width: 32rem){.bpk-card-list-row-rail__row__card,.bpk-card-list-row-rail__rail__card{flex:0 0 calc((100% - .5rem*(var(--initially-shown-cards, 3) - 1))/max(1,var(--initially-shown-cards, 3) - .8))}.bpk-card-list-row-rail__row__card:first-child,.bpk-card-list-row-rail__rail__card:first-child{padding-left:.25rem}html[dir=rtl] .bpk-card-list-row-rail__row__card:first-child,html[dir=rtl] .bpk-card-list-row-rail__rail__card:first-child{padding-right:.25rem;padding-left:.5rem}}.bpk-card-list-row-rail__rail{-webkit-overflow-scrolling:touch}
18
+ .bpk-card-list-row-rail__row,.bpk-card-list-row-rail__rail{display:flex;overflow-x:hidden;box-sizing:border-box;gap:.25rem;margin-inline:-0.5rem;scroll-snap-stop:always;scroll-snap-type:x mandatory;scrollbar-width:none}@media(max-width: 32rem){.bpk-card-list-row-rail__row,.bpk-card-list-row-rail__rail{overflow-x:scroll}}.bpk-card-list-row-rail__row::-webkit-scrollbar,.bpk-card-list-row-rail__rail::-webkit-scrollbar{display:none}.bpk-card-list-row-rail__row__card,.bpk-card-list-row-rail__rail__card{position:relative;padding:0 .5rem;flex:0 0 calc((100% - .5rem*(var(--initially-shown-cards, 3) - 1))/var(--initially-shown-cards, 3));overflow:visible;box-sizing:border-box;scroll-snap-align:start}@media(max-width: 32rem){.bpk-card-list-row-rail__row__card,.bpk-card-list-row-rail__rail__card{flex-basis:calc((100% - .5rem*(var(--initially-shown-cards, 3) - 1))/max(1,var(--initially-shown-cards, 3) - .8))}}.bpk-card-list-row-rail__row__card{flex-basis:calc((100% - .25rem*(var(--initially-shown-cards, 3) - 1))/var(--initially-shown-cards, 3))}.bpk-card-list-row-rail__rail{-webkit-overflow-scrolling:touch}
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { BUTTON_TYPES, BpkButtonV2 } from "../../../bpk-component-button";
19
+ import BpkButton, { BUTTON_TYPES } from "../../../bpk-component-button";
20
20
  import { withButtonAlignment, withRtlSupport } from "../../../bpk-component-icon";
21
21
  import ChevronDown from "../../../bpk-component-icon/sm/chevron-down";
22
22
  import ChevronUp from "../../../bpk-component-icon/sm/chevron-up";
@@ -27,7 +27,7 @@ const ExpandAccessoryContent = ({
27
27
  children,
28
28
  collapsed,
29
29
  onExpandToggle
30
- }) => /*#__PURE__*/_jsxs(BpkButtonV2, {
30
+ }) => /*#__PURE__*/_jsxs(BpkButton, {
31
31
  "data-testid": "bpk-card-list__accessory-expand-button",
32
32
  type: BUTTON_TYPES.link,
33
33
  onClick: onExpandToggle,
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { useEffect, useState } from 'react';
20
- import { BpkButtonV2, BUTTON_TYPES } from "../../bpk-component-button";
20
+ import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
21
21
  import { CHIP_TYPES } from "../../bpk-component-chip";
22
22
  import { withButtonAlignment } from "../../bpk-component-icon/index";
23
23
  import ArrowLeft from "../../bpk-component-icon/sm/long-arrow-left";
@@ -76,7 +76,7 @@ const Nudger = ({
76
76
  const classNames = getClassName('bpk-chip-group-nudger', `bpk-chip-group-nudger--${leading ? "leading" : "trailing"}`);
77
77
  return show ? /*#__PURE__*/_jsx("div", {
78
78
  className: classNames,
79
- children: /*#__PURE__*/_jsx(BpkButtonV2, {
79
+ children: /*#__PURE__*/_jsx(BpkButton, {
80
80
  title: ariaLabel,
81
81
  type: CHIP_STYLE_TO_BUTTON_STYLE[chipStyle],
82
82
  iconOnly: true,
@@ -0,0 +1,6 @@
1
+ import BpkCode from './src/BpkCode';
2
+ import BpkCodeBlock from './src/BpkCodeBlock';
3
+ import type { Props as BpkCodeProps } from './src/BpkCode';
4
+ import type { Props as BpkCodeBlockProps } from './src/BpkCodeBlock';
5
+ export type { BpkCodeProps, BpkCodeBlockProps };
6
+ export { BpkCode, BpkCodeBlock };
@@ -14,6 +14,8 @@
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
- */import BpkCode from "./src/BpkCode";
17
+ */
18
+
19
+ import BpkCode from "./src/BpkCode";
18
20
  import BpkCodeBlock from "./src/BpkCodeBlock";
19
21
  export { BpkCode, BpkCodeBlock };
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export type Props = {
3
+ children: ReactNode;
4
+ alternate?: boolean;
5
+ className?: string;
6
+ [rest: string]: any;
7
+ };
8
+ declare const BpkCode: ({ alternate, children, className, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export default BpkCode;
@@ -14,42 +14,23 @@
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
- */import PropTypes from 'prop-types';
17
+ */
18
+
18
19
  import { cssModules } from "../../bpk-react-utils";
19
20
  import STYLES from "./BpkCode.module.css";
20
21
  import { jsx as _jsx } from "react/jsx-runtime";
21
22
  const getClassName = cssModules(STYLES);
22
- const BpkCode = props => {
23
- const {
24
- alternate,
25
- children,
26
- className,
27
- ...rest
28
- } = props;
29
- const classNames = [getClassName('bpk-code')];
30
- if (alternate) {
31
- classNames.push(getClassName('bpk-code--alternate'));
32
- }
33
- if (className) {
34
- classNames.push(className);
35
- }
36
- return (
37
- /*#__PURE__*/
38
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
39
- _jsx("code", {
40
- className: classNames.join(' '),
41
- ...rest,
42
- children: children
43
- })
44
- );
45
- };
46
- BpkCode.propTypes = {
47
- children: PropTypes.node.isRequired,
48
- className: PropTypes.string,
49
- alternate: PropTypes.bool
50
- };
51
- BpkCode.defaultProps = {
52
- className: null,
53
- alternate: false
23
+ const BpkCode = ({
24
+ alternate = false,
25
+ children,
26
+ className,
27
+ ...rest
28
+ }) => {
29
+ const classNames = getClassName('bpk-code', alternate && 'bpk-code--alternate', className);
30
+ return /*#__PURE__*/_jsx("code", {
31
+ className: classNames,
32
+ ...rest,
33
+ children: children
34
+ });
54
35
  };
55
36
  export default BpkCode;
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export type Props = {
3
+ children: ReactNode;
4
+ alternate?: boolean;
5
+ className?: string;
6
+ [rest: string]: any;
7
+ };
8
+ declare const BpkCodeBlock: ({ alternate, children, className, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export default BpkCodeBlock;
@@ -14,40 +14,27 @@
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
- */import PropTypes from 'prop-types';
17
+ */
18
+
18
19
  import { cssModules } from "../../bpk-react-utils";
19
20
  import STYLES from "./BpkCodeBlock.module.css";
20
21
  import { jsx as _jsx } from "react/jsx-runtime";
21
22
  const getClassName = cssModules(STYLES);
22
- const BpkCodeBlock = props => {
23
- const {
24
- alternate,
25
- children,
26
- className,
27
- ...rest
28
- } = props;
23
+ const BpkCodeBlock = ({
24
+ alternate = false,
25
+ children,
26
+ className,
27
+ ...rest
28
+ }) => {
29
29
  const preClassNames = getClassName('bpk-code__pre', alternate && 'bpk-code__pre--alternate', className);
30
30
  const codeClassNames = getClassName('bpk-code', 'bpk-code--block');
31
- return (
32
- /*#__PURE__*/
33
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
34
- _jsx("pre", {
35
- className: preClassNames,
36
- ...rest,
37
- children: /*#__PURE__*/_jsx("code", {
38
- className: codeClassNames,
39
- children: children
40
- })
31
+ return /*#__PURE__*/_jsx("pre", {
32
+ className: preClassNames,
33
+ ...rest,
34
+ children: /*#__PURE__*/_jsx("code", {
35
+ className: codeClassNames,
36
+ children: children
41
37
  })
42
- );
43
- };
44
- BpkCodeBlock.propTypes = {
45
- children: PropTypes.node.isRequired,
46
- alternate: PropTypes.bool,
47
- className: PropTypes.string
48
- };
49
- BpkCodeBlock.defaultProps = {
50
- alternate: false,
51
- className: null
38
+ });
52
39
  };
53
40
  export default BpkCodeBlock;
@@ -21,7 +21,7 @@ import { animations } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
21
21
 
22
22
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
23
23
  import BpkCloseButton from "../../bpk-component-close-button";
24
- import { BpkButtonLink } from "../../bpk-component-link";
24
+ import BpkLink from "../../bpk-component-link";
25
25
  import { cssModules } from "../../bpk-react-utils";
26
26
  import STYLES from "./BpkDrawerContent.module.css";
27
27
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -93,7 +93,8 @@ const BpkDrawerContent = ({
93
93
  id: headingId,
94
94
  className: headerClassNames.join(' '),
95
95
  children: title
96
- }), "\xA0", closeText ? /*#__PURE__*/_jsx(BpkButtonLink, {
96
+ }), "\xA0", closeText ? /*#__PURE__*/_jsx(BpkLink, {
97
+ as: "button",
97
98
  onClick: onClose,
98
99
  children: closeText
99
100
  }) : /*#__PURE__*/_jsx("div", {
@@ -19,7 +19,7 @@
19
19
  import { useEffect, useState } from 'react';
20
20
  import { CSSTransition } from 'react-transition-group';
21
21
  import BpkAriaLive from "../../bpk-component-aria-live";
22
- import { BUTTON_TYPES, BpkButtonV2 } from "../../bpk-component-button";
22
+ import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
23
23
  import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
24
24
  import { cssModules } from "../../bpk-react-utils";
25
25
  import STYLES from "./BpkFloatingNotification.module.css";
@@ -80,7 +80,7 @@ const BpkFloatingNotification = props => {
80
80
  children: text
81
81
  }), ctaText && /*#__PURE__*/_jsx("div", {
82
82
  className: getClassName('bpk-floating-notification__cta'),
83
- children: /*#__PURE__*/_jsx(BpkButtonV2, {
83
+ children: /*#__PURE__*/_jsx(BpkButton, {
84
84
  type: BUTTON_TYPES.linkOnDark,
85
85
  implicit: true,
86
86
  onClick: onClick,
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { BpkButtonV2, BUTTON_TYPES } from "../../bpk-component-button";
19
+ import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
20
20
  import { cssModules } from "../../bpk-react-utils";
21
21
  import STYLES from "./BpkGraphicPromo.module.css";
22
22
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
@@ -152,7 +152,7 @@ const BpkGraphicPromo = ({
152
152
  }), subheading && /*#__PURE__*/_jsx("p", {
153
153
  className: getClassName('bpk-graphic-promo__subheading'),
154
154
  children: subheading
155
- }), /*#__PURE__*/_jsx(BpkButtonV2, {
155
+ }), /*#__PURE__*/_jsx(BpkButton, {
156
156
  type: BUTTON_TYPES.primaryOnDark
157
157
  // TODO: className to be removed
158
158
  // eslint-disable-next-line @skyscanner/rules/forbid-component-props
@@ -18,7 +18,7 @@
18
18
 
19
19
  import PropTypes from 'prop-types';
20
20
  import { Component } from 'react';
21
- import { BpkButtonLink } from "../../bpk-component-link";
21
+ import BpkLink from "../../bpk-component-link";
22
22
  import { cssModules } from "../../bpk-react-utils";
23
23
  import STYLES from "./BpkGridToggle.module.css";
24
24
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
@@ -60,7 +60,8 @@ class BpkGridToggle extends Component {
60
60
  const onOrOff = gridEnabled ? 'off' : 'on';
61
61
  return /*#__PURE__*/_jsx("span", {
62
62
  className: className,
63
- children: /*#__PURE__*/_jsxs(BpkButtonLink, {
63
+ children: /*#__PURE__*/_jsxs(BpkLink, {
64
+ as: "button",
64
65
  title: "Keyboard Shortcut: ctrl + cmd + g",
65
66
  onClick: this.toggleGrid,
66
67
  children: ["Baseline grid ", onOrOff]
@@ -1,6 +1,15 @@
1
1
  import BpkButtonLink, { type Props as BpkButtonLinkProps } from './src/BpkButtonLink';
2
- import BpkLink, { type Props as BpkLinkProps } from './src/BpkLink';
2
+ import BpkLink from './src/BpkLink';
3
3
  import themeAttributes, { linkAlternateThemeAttributes } from './src/themeAttributes';
4
- export type { BpkButtonLinkProps, BpkLinkProps };
4
+ import type { BpkLinkProps } from './src/common-types';
5
+ /**
6
+ * @deprecated Use BpkLinkProps for polymorphic usage
7
+ */
8
+ export type { BpkButtonLinkProps };
9
+ /**
10
+ * @deprecated Use `<BpkLink as="button" />` instead.
11
+ */
12
+ export { BpkButtonLink };
13
+ export type { BpkLinkProps };
5
14
  export default BpkLink;
6
- export { BpkButtonLink, themeAttributes, linkAlternateThemeAttributes };
15
+ export { themeAttributes, linkAlternateThemeAttributes };
@@ -19,5 +19,14 @@
19
19
  import BpkButtonLink from "./src/BpkButtonLink";
20
20
  import BpkLink from "./src/BpkLink";
21
21
  import themeAttributes, { linkAlternateThemeAttributes } from "./src/themeAttributes";
22
+
23
+ /**
24
+ * @deprecated Use BpkLinkProps for polymorphic usage
25
+ */
26
+
27
+ /**
28
+ * @deprecated Use `<BpkLink as="button" />` instead.
29
+ */
30
+ export { BpkButtonLink };
22
31
  export default BpkLink;
23
- export { BpkButtonLink, themeAttributes, linkAlternateThemeAttributes };
32
+ export { themeAttributes, linkAlternateThemeAttributes };
@@ -1,5 +1,8 @@
1
1
  import type { ReactNode, MouseEvent, ButtonHTMLAttributes } from 'react';
2
2
  import themeAttributes from './themeAttributes';
3
+ /**
4
+ * @deprecated Use `BpkLinkProps<'button'>` instead.
5
+ */
3
6
  export interface Props extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'className' | 'onClick'> {
4
7
  /** The content of the link. */
5
8
  children: ReactNode;
@@ -8,6 +11,11 @@ export interface Props extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'cl
8
11
  alternate?: boolean;
9
12
  implicit?: boolean;
10
13
  }
14
+ /**
15
+ * @deprecated Use `<BpkLink as="button" />` instead.
16
+ * BpkButtonLink is maintained for backwards compatibility but will be removed in a future major version.
17
+ * @returns {JSX.Element} A button styled as a link.
18
+ */
11
19
  declare const BpkButtonLink: ({ alternate, children, className, implicit, onClick, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
12
20
  export { themeAttributes };
13
21
  export default BpkButtonLink;
@@ -21,6 +21,16 @@ import themeAttributes from "./themeAttributes";
21
21
  import STYLES from "./BpkLink.module.css";
22
22
  import { jsx as _jsx } from "react/jsx-runtime";
23
23
  const getClassName = cssModules(STYLES);
24
+
25
+ /**
26
+ * @deprecated Use `BpkLinkProps<'button'>` instead.
27
+ */
28
+
29
+ /**
30
+ * @deprecated Use `<BpkLink as="button" />` instead.
31
+ * BpkButtonLink is maintained for backwards compatibility but will be removed in a future major version.
32
+ * @returns {JSX.Element} A button styled as a link.
33
+ */
24
34
  const BpkButtonLink = ({
25
35
  alternate = false,
26
36
  children,
@@ -1,16 +1,3 @@
1
- import type { ReactNode, MouseEvent, AnchorHTMLAttributes } from 'react';
2
- import themeAttributes, { linkAlternateThemeAttributes } from './themeAttributes';
3
- export interface Props extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'className' | 'rel'> {
4
- /** The content of the link. */
5
- children: ReactNode;
6
- href: string | null;
7
- className?: string | null;
8
- onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
9
- blank?: boolean;
10
- rel?: string | null;
11
- alternate?: boolean;
12
- implicit?: boolean;
13
- }
14
- declare const BpkLink: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLAnchorElement>>;
1
+ import type { PolymorphicComponent } from './common-types';
2
+ declare const BpkLink: PolymorphicComponent;
15
3
  export default BpkLink;
16
- export { themeAttributes, linkAlternateThemeAttributes };
@@ -18,54 +18,99 @@
18
18
 
19
19
  import { forwardRef } from 'react';
20
20
  import { cssModules } from "../../bpk-react-utils";
21
- import themeAttributes, { linkAlternateThemeAttributes } from "./themeAttributes";
22
21
  import STYLES from "./BpkLink.module.css";
23
22
  import { jsx as _jsx } from "react/jsx-runtime";
24
23
  const getClassName = cssModules(STYLES);
25
- const BpkLink = /*#__PURE__*/forwardRef(({
24
+
25
+ /**
26
+ * Processes anchor-specific props and returns the transformed props.
27
+ * Handles href, blank (target="_blank"), and rel attributes.
28
+ * @param {Object} props - The props to process.
29
+ * @returns {Object} The transformed anchor props.
30
+ */
31
+ const processAnchorProps = props => {
32
+ const {
33
+ blank,
34
+ href,
35
+ rel,
36
+ ...otherProps
37
+ } = props;
38
+ return {
39
+ ...otherProps,
40
+ href: href ?? undefined,
41
+ ...(blank ? {
42
+ target: '_blank',
43
+ rel: rel || 'noopener noreferrer'
44
+ } : {}),
45
+ ...(!blank && rel ? {
46
+ rel
47
+ } : {})
48
+ };
49
+ };
50
+
51
+ /**
52
+ * Processes button-specific props and returns the transformed props.
53
+ * Ensures button has type="button" by default to prevent form submission.
54
+ * @param {Object} props - The props to process.
55
+ * @returns {Object} The transformed button props.
56
+ */
57
+ const processButtonProps = props => ({
58
+ type: 'button',
59
+ ...props // Allow override if explicitly provided
60
+ });
61
+ const getClassNames = (alternate, implicit, className) => {
62
+ const classNames = [getClassName('bpk-link'), className, implicit && getClassName('bpk-link--implicit'), alternate && getClassName('bpk-link--alternate')].filter(Boolean);
63
+
64
+ // Lookup table for underlined modifier based on implicit/alternate combination
65
+ const underlinedModifierMap = {
66
+ 'true-true': 'bpk-link-underlined-implicit--alternate',
67
+ 'true-false': 'bpk-link-underlined--implicit',
68
+ 'false-true': 'bpk-link-underlined--alternate'
69
+ };
70
+ const underlinedModifier = underlinedModifierMap[`${implicit}-${alternate}`] || null;
71
+ const underlinedClassNames = [getClassName('bpk-link-underlined'), underlinedModifier && getClassName(underlinedModifier)].filter(Boolean);
72
+ return {
73
+ linkClassName: classNames.join(' '),
74
+ underlinedClassName: underlinedClassNames.join(' ')
75
+ };
76
+ };
77
+ const BpkLinkInner = ({
26
78
  alternate = false,
27
- blank = false,
79
+ as: Element = 'a',
28
80
  children,
29
81
  className = null,
30
- href,
31
82
  implicit = false,
32
- onClick = () => {},
33
- rel: propRel = null,
34
83
  ...rest
35
84
  }, ref) => {
36
- const classNames = [getClassName('bpk-link')];
37
- const underlinedClassNames = [getClassName('bpk-link-underlined')];
38
- const target = blank ? '_blank' : undefined;
39
- const rel = blank ? propRel || 'noopener noreferrer' : propRel;
40
- if (className) {
41
- classNames.push(className);
42
- }
43
- if (implicit) {
44
- classNames.push(getClassName('bpk-link--implicit'));
45
- }
46
- if (alternate) {
47
- classNames.push(getClassName('bpk-link--alternate'));
48
- }
49
- if (implicit && !alternate) {
50
- underlinedClassNames.push(getClassName('bpk-link-underlined--implicit'));
51
- } else if (alternate && !implicit) {
52
- underlinedClassNames.push(getClassName('bpk-link-underlined--alternate'));
53
- } else if (implicit && alternate) {
54
- underlinedClassNames.push(getClassName('bpk-link-underlined-implicit--alternate'));
85
+ const {
86
+ linkClassName,
87
+ underlinedClassName
88
+ } = getClassNames(alternate, implicit, className);
89
+
90
+ // Process element-specific props based on the rendered element type
91
+ const baseProps = rest;
92
+ let elementProps = baseProps;
93
+ if (Element === 'a') {
94
+ elementProps = processAnchorProps(baseProps);
95
+ } else if (Element === 'button') {
96
+ elementProps = processButtonProps(baseProps);
55
97
  }
56
- return /*#__PURE__*/_jsx("a", {
57
- className: classNames.join(' '),
58
- href: href ?? undefined,
59
- onClick: onClick,
60
- target: target,
61
- rel: rel ?? undefined,
62
- ref: ref,
63
- ...rest,
64
- children: /*#__PURE__*/_jsx("span", {
65
- className: underlinedClassNames.join(' '),
66
- children: children
98
+ return (
99
+ /*#__PURE__*/
100
+ // Allowed: className and ref are passed to the underlying DOM element
101
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
102
+ _jsx(Element, {
103
+ className: linkClassName,
104
+ ref: ref,
105
+ ...elementProps,
106
+ children: /*#__PURE__*/_jsx("span", {
107
+ className: underlinedClassName,
108
+ children: children
109
+ })
67
110
  })
68
- });
69
- });
70
- export default BpkLink;
71
- export { themeAttributes, linkAlternateThemeAttributes };
111
+ );
112
+ };
113
+
114
+ // A polymorphic link component that can render as different HTML elements.
115
+ const BpkLink = /*#__PURE__*/forwardRef(BpkLinkInner);
116
+ export default BpkLink;