@skyscanner/backpack-web 41.2.0 → 41.3.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-autosuggest/index.js +2 -2
- package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.d.ts +13 -0
- package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.js +3 -3
- package/bpk-component-bottom-sheet/src/BpkBottomSheet.js +3 -2
- package/bpk-component-card-list/src/BpkCardList.js +2 -2
- package/bpk-component-card-list/src/BpkCardListGridStack/BpkCardListGridStack.js +2 -2
- package/bpk-component-card-list/src/BpkExpand/ExpandAccessoryContent.js +2 -2
- package/bpk-component-chip-group/src/Nudger.js +2 -2
- package/bpk-component-drawer/src/BpkDrawerContent.js +3 -2
- package/bpk-component-floating-notification/src/BpkFloatingNotification.js +2 -2
- package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +2 -2
- package/bpk-component-grid-toggle/src/BpkGridToggle.js +3 -2
- package/bpk-component-link/index.d.ts +12 -3
- package/bpk-component-link/index.js +10 -1
- package/bpk-component-link/src/BpkButtonLink.d.ts +8 -0
- package/bpk-component-link/src/BpkButtonLink.js +10 -0
- package/bpk-component-link/src/BpkLink.d.ts +2 -15
- package/bpk-component-link/src/BpkLink.js +85 -40
- package/bpk-component-link/src/common-types.d.ts +44 -0
- package/bpk-component-link/src/common-types.js +1 -0
- package/bpk-component-loading-button/src/BpkLoadingButton.js +2 -2
- package/bpk-component-modal/src/BpkModalInner.js +3 -2
- package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.d.ts +4 -5
- package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.js +3 -2
- package/bpk-component-nudger/src/BpkNudger.js +3 -3
- package/bpk-component-page-indicator/src/NavButton.js +2 -2
- package/bpk-component-pagination/src/BpkPaginationNudger.js +2 -2
- package/bpk-component-popover/src/BpkPopover.js +7 -4
- package/bpk-component-price/src/BpkPrice.js +3 -0
- package/bpk-component-price/src/common-types.js +1 -0
- package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +3 -2
- package/bpk-component-snippet/src/BpkSnippet.js +2 -2
- 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,
|
|
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),
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
61
|
+
children: /*#__PURE__*/_jsx(BpkButton, {
|
|
62
62
|
"data-testid": "bpk-card-list__accessory-button",
|
|
63
63
|
onClick: onButtonClick,
|
|
64
64
|
href: buttonHref,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { BUTTON_TYPES
|
|
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(
|
|
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 {
|
|
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(
|
|
79
|
+
children: /*#__PURE__*/_jsx(BpkButton, {
|
|
80
80
|
title: ariaLabel,
|
|
81
81
|
type: CHIP_STYLE_TO_BUTTON_STYLE[chipStyle],
|
|
82
82
|
iconOnly: true,
|
|
@@ -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
|
|
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(
|
|
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
|
|
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(
|
|
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 {
|
|
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(
|
|
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
|
|
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(
|
|
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
|
|
2
|
+
import BpkLink from './src/BpkLink';
|
|
3
3
|
import themeAttributes, { linkAlternateThemeAttributes } from './src/themeAttributes';
|
|
4
|
-
|
|
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 {
|
|
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 {
|
|
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 {
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
71
|
-
|
|
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;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef, ElementType, ReactNode, Ref } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Polymorphic component types following Chakra UI pattern.
|
|
4
|
+
* Allows BpkLink to be rendered as different HTML elements while
|
|
5
|
+
* preserving proper type inference for element-specific props.
|
|
6
|
+
*/
|
|
7
|
+
/** Supported element types for BpkLink */
|
|
8
|
+
export type LinkAs = 'a' | 'button' | 'span' | 'div';
|
|
9
|
+
/** Base props that are common to all BpkLink variants */
|
|
10
|
+
export type BpkLinkBaseProps = {
|
|
11
|
+
/** The content of the link. */
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/** Additional CSS class(es) to apply. */
|
|
14
|
+
className?: string | null;
|
|
15
|
+
/** Use alternate (light) styling for dark backgrounds. */
|
|
16
|
+
alternate?: boolean;
|
|
17
|
+
/** Use implicit styling (no underline until hover). */
|
|
18
|
+
implicit?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Props specific to anchor elements */
|
|
21
|
+
export type AnchorOnlyProps = {
|
|
22
|
+
/** The URL the link points to. */
|
|
23
|
+
href: string | null;
|
|
24
|
+
/** Opens link in a new tab/window. */
|
|
25
|
+
blank?: boolean;
|
|
26
|
+
/** The relationship between linked and current document. */
|
|
27
|
+
rel?: string | null;
|
|
28
|
+
};
|
|
29
|
+
/** Props for the `as` prop */
|
|
30
|
+
type AsProps<E extends ElementType> = {
|
|
31
|
+
/** The element type to render as. Defaults to 'a'. */
|
|
32
|
+
as?: E;
|
|
33
|
+
};
|
|
34
|
+
/** Polymorphic props type that merges base props with element-specific props */
|
|
35
|
+
type PolymorphicProps<E extends ElementType> = BpkLinkBaseProps & AsProps<E> & Omit<ComponentPropsWithoutRef<E>, keyof BpkLinkBaseProps | 'as'>;
|
|
36
|
+
/** Full props type with conditional anchor-specific props */
|
|
37
|
+
export type BpkLinkProps<E extends ElementType = 'a'> = E extends 'a' ? Omit<PolymorphicProps<E>, 'href' | 'rel'> & AnchorOnlyProps : PolymorphicProps<E>;
|
|
38
|
+
/** Polymorphic ref type mapping element types to their ref types */
|
|
39
|
+
export type PolymorphicRef<E extends LinkAs> = E extends 'a' ? Ref<HTMLAnchorElement> : E extends 'button' ? Ref<HTMLButtonElement> : E extends 'span' ? Ref<HTMLSpanElement> : E extends 'div' ? Ref<HTMLDivElement> : never;
|
|
40
|
+
/** Polymorphic component type for BpkLink */
|
|
41
|
+
export type PolymorphicComponent = <E extends LinkAs = 'a'>(props: BpkLinkProps<E> & {
|
|
42
|
+
ref?: PolymorphicRef<E>;
|
|
43
|
+
}) => JSX.Element | null;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { BUTTON_TYPES,
|
|
19
|
+
import BpkButton, { BUTTON_TYPES, SIZE_TYPES } from "../../bpk-component-button";
|
|
20
20
|
import { withButtonAlignment, withLargeButtonAlignment, withRtlSupport } from "../../bpk-component-icon";
|
|
21
21
|
import ArrowIconLg from "../../bpk-component-icon/lg/long-arrow-right";
|
|
22
22
|
import ArrowIconSm from "../../bpk-component-icon/sm/long-arrow-right";
|
|
@@ -108,7 +108,7 @@ const BpkLoadingButton = props => {
|
|
|
108
108
|
if (primaryOnDark) {
|
|
109
109
|
type = BUTTON_TYPES.primaryOnDark;
|
|
110
110
|
}
|
|
111
|
-
return /*#__PURE__*/_jsx(
|
|
111
|
+
return /*#__PURE__*/_jsx(BpkButton, {
|
|
112
112
|
iconOnly: iconOnly,
|
|
113
113
|
disabled: showBtnDisabled,
|
|
114
114
|
size: large ? SIZE_TYPES.large : SIZE_TYPES.small,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
20
20
|
import BpkCloseButton from "../../bpk-component-close-button";
|
|
21
|
-
import
|
|
21
|
+
import BpkLink from "../../bpk-component-link";
|
|
22
22
|
import BpkNavigationBar, { BAR_STYLES } from "../../bpk-component-navigation-bar";
|
|
23
23
|
import { TransitionInitialMount, cssModules } from "../../bpk-react-utils";
|
|
24
24
|
import STYLES from "./BpkModalInner.module.css";
|
|
@@ -98,7 +98,8 @@ const BpkModalInner = ({
|
|
|
98
98
|
children: title
|
|
99
99
|
}),
|
|
100
100
|
leadingButton: accessoryViewFinal,
|
|
101
|
-
trailingButton: closeText ? /*#__PURE__*/_jsx(
|
|
101
|
+
trailingButton: closeText ? /*#__PURE__*/_jsx(BpkLink, {
|
|
102
|
+
as: "button",
|
|
102
103
|
onClick: onClose,
|
|
103
104
|
alternate: modalStyle === MODAL_STYLING.surfaceContrast,
|
|
104
105
|
children: closeText
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BpkButtonLink } from '../../bpk-component-link';
|
|
1
|
+
import { type BpkLinkProps } from '../../bpk-component-link';
|
|
3
2
|
import { type BarStyle } from './BpkNavigationBar';
|
|
4
|
-
export interface Props extends
|
|
5
|
-
|
|
6
|
-
onClick: (event: MouseEvent<HTMLElement>) => void;
|
|
3
|
+
export interface Props extends Omit<BpkLinkProps<'button'>, 'as'> {
|
|
4
|
+
/** Additional CSS class(es) to apply to the wrapper span. */
|
|
7
5
|
className?: string;
|
|
6
|
+
/** The bar style to determine link color variant. */
|
|
8
7
|
barStyle?: BarStyle;
|
|
9
8
|
[rest: string]: any;
|
|
10
9
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import
|
|
19
|
+
import BpkLink from "../../bpk-component-link";
|
|
20
20
|
import { BAR_STYLES } from "./BpkNavigationBar";
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
22
|
const BpkNavigationBarButtonLink = ({
|
|
@@ -26,7 +26,8 @@ const BpkNavigationBarButtonLink = ({
|
|
|
26
26
|
...rest
|
|
27
27
|
}) => /*#__PURE__*/_jsx("span", {
|
|
28
28
|
className: className,
|
|
29
|
-
children: /*#__PURE__*/_jsx(
|
|
29
|
+
children: /*#__PURE__*/_jsx(BpkLink, {
|
|
30
|
+
as: "button",
|
|
30
31
|
alternate: barStyle === BAR_STYLES.onDark,
|
|
31
32
|
...rest,
|
|
32
33
|
children: children
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { useRef } from 'react';
|
|
20
|
-
import {
|
|
20
|
+
import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
|
|
21
21
|
import { withButtonAlignment } from "../../bpk-component-icon";
|
|
22
22
|
import MinusIcon from "../../bpk-component-icon/sm/minus";
|
|
23
23
|
import PlusIcon from "../../bpk-component-icon/sm/plus";
|
|
@@ -95,7 +95,7 @@ const BpkNudger = ({
|
|
|
95
95
|
})]
|
|
96
96
|
}), /*#__PURE__*/_jsxs("div", {
|
|
97
97
|
className: nudgerClassNames,
|
|
98
|
-
children: [/*#__PURE__*/_jsx(
|
|
98
|
+
children: [/*#__PURE__*/_jsx(BpkButton, {
|
|
99
99
|
type: BUTTON_TYPES[buttonType],
|
|
100
100
|
iconOnly: true,
|
|
101
101
|
onClick: () => {
|
|
@@ -135,7 +135,7 @@ const BpkNudger = ({
|
|
|
135
135
|
},
|
|
136
136
|
className: inputClassNames,
|
|
137
137
|
...rest
|
|
138
|
-
}), /*#__PURE__*/_jsx(
|
|
138
|
+
}), /*#__PURE__*/_jsx(BpkButton, {
|
|
139
139
|
type: BUTTON_TYPES[buttonType],
|
|
140
140
|
iconOnly: true,
|
|
141
141
|
onClick: () => {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { BUTTON_TYPES
|
|
19
|
+
import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
|
|
20
20
|
import { withButtonAlignment, withRtlSupport } from "../../bpk-component-icon";
|
|
21
21
|
import LeftArrowIcon from "../../bpk-component-icon/lg/chevron-left";
|
|
22
22
|
import RightArrowIcon from "../../bpk-component-icon/lg/chevron-right";
|
|
@@ -35,7 +35,7 @@ const NavButton = ({
|
|
|
35
35
|
disabled = false,
|
|
36
36
|
onClick = () => {},
|
|
37
37
|
type = BUTTON_TYPES.link
|
|
38
|
-
}) => /*#__PURE__*/_jsx(
|
|
38
|
+
}) => /*#__PURE__*/_jsx(BpkButton, {
|
|
39
39
|
iconOnly: true,
|
|
40
40
|
type: type,
|
|
41
41
|
onClick: e => {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import PropTypes from 'prop-types';
|
|
20
|
-
import {
|
|
20
|
+
import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
|
|
21
21
|
import { withRtlSupport, withButtonAlignment } from "../../bpk-component-icon";
|
|
22
22
|
import ArrowLeftIcon from "../../bpk-component-icon/sm/arrow-left";
|
|
23
23
|
import ArrowRightIcon from "../../bpk-component-icon/sm/arrow-right";
|
|
@@ -37,7 +37,7 @@ const BpkPaginationNudger = props => {
|
|
|
37
37
|
} = props;
|
|
38
38
|
return /*#__PURE__*/_jsx("div", {
|
|
39
39
|
className: getClassName('bpk-pagination-nudger'),
|
|
40
|
-
children: /*#__PURE__*/_jsxs(
|
|
40
|
+
children: /*#__PURE__*/_jsxs(BpkButton, {
|
|
41
41
|
type: BUTTON_TYPES.link,
|
|
42
42
|
onClick: onNudge,
|
|
43
43
|
disabled: disabled,
|
|
@@ -22,7 +22,7 @@ import { surfaceHighlightDay } from '@skyscanner/bpk-foundations-web/tokens/base
|
|
|
22
22
|
|
|
23
23
|
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
24
24
|
import BpkCloseButton from "../../bpk-component-close-button";
|
|
25
|
-
import
|
|
25
|
+
import BpkLink from "../../bpk-component-link";
|
|
26
26
|
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
27
27
|
import { TransitionInitialMount, cssModules } from "../../bpk-react-utils";
|
|
28
28
|
import { ARROW_ID } from "./constants";
|
|
@@ -179,7 +179,8 @@ const BpkPopover = ({
|
|
|
179
179
|
setIsOpenState(false);
|
|
180
180
|
},
|
|
181
181
|
...closeButtonProps
|
|
182
|
-
}) : closeButtonText && /*#__PURE__*/_jsx(
|
|
182
|
+
}) : closeButtonText && /*#__PURE__*/_jsx(BpkLink, {
|
|
183
|
+
as: "button",
|
|
183
184
|
onClick: event => {
|
|
184
185
|
bindEventSource(EVENT_SOURCES.CLOSE_LINK, onClose, event);
|
|
185
186
|
setIsOpenState(false);
|
|
@@ -196,13 +197,15 @@ const BpkPopover = ({
|
|
|
196
197
|
children: children
|
|
197
198
|
}), actionText && onAction && /*#__PURE__*/_jsx("div", {
|
|
198
199
|
className: getClassName('bpk-popover__action'),
|
|
199
|
-
children: /*#__PURE__*/_jsx(
|
|
200
|
+
children: /*#__PURE__*/_jsx(BpkLink, {
|
|
201
|
+
as: "button",
|
|
200
202
|
onClick: onAction,
|
|
201
203
|
children: actionText
|
|
202
204
|
})
|
|
203
205
|
}), !labelAsTitle && closeButtonText && /*#__PURE__*/_jsx("footer", {
|
|
204
206
|
className: getClassName('bpk-popover__footer'),
|
|
205
|
-
children: /*#__PURE__*/_jsx(
|
|
207
|
+
children: /*#__PURE__*/_jsx(BpkLink, {
|
|
208
|
+
as: "button",
|
|
206
209
|
onClick: event => {
|
|
207
210
|
bindEventSource(EVENT_SOURCES.CLOSE_LINK, onClose, event);
|
|
208
211
|
setIsOpenState(false);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { Component } from 'react';
|
|
20
|
-
import
|
|
20
|
+
import BpkLink from "../../bpk-component-link";
|
|
21
21
|
import { getHtmlElement, DIRECTIONS, DIRECTION_CHANGE_EVENT } from "./utils";
|
|
22
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
23
|
const getDirection = () => {
|
|
@@ -59,7 +59,8 @@ class BpkRtlToggle extends Component {
|
|
|
59
59
|
};
|
|
60
60
|
render() {
|
|
61
61
|
const onOrOff = this.state.direction === DIRECTIONS.RTL ? 'off' : 'on';
|
|
62
|
-
return /*#__PURE__*/_jsxs(
|
|
62
|
+
return /*#__PURE__*/_jsxs(BpkLink, {
|
|
63
|
+
as: "button",
|
|
63
64
|
title: "Keyboard Shortcut: ctrl + cmd + r",
|
|
64
65
|
onClick: this.toggleRtl,
|
|
65
66
|
children: ["RTL ", onOrOff]
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import BpkBreakpoint, { BREAKPOINTS } from "../../bpk-component-breakpoint";
|
|
20
|
-
import {
|
|
20
|
+
import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
|
|
21
21
|
import BpkImage, { BORDER_RADIUS_STYLES, withLazyLoading } from "../../bpk-component-image";
|
|
22
22
|
import BpkText, { TEXT_STYLES } from "../../bpk-component-text/src/BpkText";
|
|
23
23
|
import { cssModules } from "../../bpk-react-utils";
|
|
@@ -120,7 +120,7 @@ const BpkSnippet = ({
|
|
|
120
120
|
textStyle: isMobile ? BODY_STYLE.bodyDefault : bodyStyle,
|
|
121
121
|
children: bodyText
|
|
122
122
|
})
|
|
123
|
-
}), buttonText && onClick && /*#__PURE__*/_jsx(
|
|
123
|
+
}), buttonText && onClick && /*#__PURE__*/_jsx(BpkButton, {
|
|
124
124
|
type: buttonStyle,
|
|
125
125
|
onClick: onClick,
|
|
126
126
|
children: buttonText
|