@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
@@ -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, BpkButtonV2, SIZE_TYPES } from "../../bpk-component-button";
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(BpkButtonV2, {
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 { BpkButtonLink } from "../../bpk-component-link";
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(BpkButtonLink, {
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 type { ComponentProps, MouseEvent, ReactNode } from 'react';
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 ComponentProps<typeof BpkButtonLink> {
5
- children: ReactNode;
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 { BpkButtonLink } from "../../bpk-component-link";
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(BpkButtonLink, {
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 { BpkButtonV2, BUTTON_TYPES } from "../../bpk-component-button";
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(BpkButtonV2, {
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(BpkButtonV2, {
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, 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 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(BpkButtonV2, {
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 { BpkButtonV2, BUTTON_TYPES } from "../../bpk-component-button";
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(BpkButtonV2, {
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 { BpkButtonLink } from "../../bpk-component-link";
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(BpkButtonLink, {
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(BpkButtonLink, {
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(BpkButtonLink, {
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);
@@ -25,6 +25,9 @@ const getPriceTextStyle = size => {
25
25
  if (size === SIZES.small) {
26
26
  return TEXT_STYLES.heading4;
27
27
  }
28
+ if (size === SIZES.medium) {
29
+ return TEXT_STYLES.heading3;
30
+ }
28
31
  if (size === SIZES.large) {
29
32
  return TEXT_STYLES.xxl;
30
33
  }
@@ -17,6 +17,7 @@
17
17
  */export const SIZES = {
18
18
  xsmall: 'xsmall',
19
19
  small: 'small',
20
+ medium: 'medium',
20
21
  large: 'large'
21
22
  };
22
23
  export const ALIGNS = {
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import { Component } from 'react';
20
- import { BpkButtonLink } from "../../bpk-component-link";
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(BpkButtonLink, {
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 { BpkButtonV2, BUTTON_TYPES } from "../../bpk-component-button";
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(BpkButtonV2, {
123
+ }), buttonText && onClick && /*#__PURE__*/_jsx(BpkButton, {
124
124
  type: buttonStyle,
125
125
  onClick: onClick,
126
126
  children: buttonText
@@ -0,0 +1,4 @@
1
+ import BpkThemeToggle from './src/BpkThemeToggle';
2
+ import updateOnThemeChange from './src/updateOnThemeChange';
3
+ export default BpkThemeToggle;
4
+ export { updateOnThemeChange };
@@ -0,0 +1,16 @@
1
+ import type { ChangeEvent } from 'react';
2
+ import { Component } from 'react';
3
+ type Props = Record<string, never>;
4
+ type State = {
5
+ selectedTheme: string;
6
+ };
7
+ declare class BpkThemeToggle extends Component<Props, State> {
8
+ constructor(props: Props);
9
+ componentDidMount(): void;
10
+ componentWillUnmount(): void;
11
+ handleKeyDown: (e: KeyboardEvent) => void;
12
+ handleChange: (e: ChangeEvent<HTMLSelectElement>) => void;
13
+ cycleTheme: () => void;
14
+ render(): import("react/jsx-runtime").JSX.Element;
15
+ }
16
+ export default BpkThemeToggle;
@@ -17,7 +17,10 @@
17
17
  */
18
18
 
19
19
  import { Component } from 'react';
20
+
21
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
20
22
  import BpkLabel from "../../bpk-component-label";
23
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
21
24
  import BpkSelect from "../../bpk-component-select";
22
25
  import { cssModules } from "../../bpk-react-utils";
23
26
  import bpkCustomThemes from "./theming";
@@ -29,11 +32,13 @@ const getClassName = cssModules(STYLES);
29
32
  const availableThemes = Object.keys(bpkCustomThemes);
30
33
  const setTheme = theme => {
31
34
  const htmlElement = getHtmlElement();
32
- htmlElement.dispatchEvent(new CustomEvent(THEME_CHANGE_EVENT, {
33
- detail: {
34
- theme
35
- }
36
- }));
35
+ if (htmlElement) {
36
+ htmlElement.dispatchEvent(new CustomEvent(THEME_CHANGE_EVENT, {
37
+ detail: {
38
+ theme
39
+ }
40
+ }));
41
+ }
37
42
  };
38
43
  class BpkThemeToggle extends Component {
39
44
  constructor(props) {
@@ -58,7 +63,7 @@ class BpkThemeToggle extends Component {
58
63
  this.setState({
59
64
  selectedTheme
60
65
  });
61
- setTheme(bpkCustomThemes[selectedTheme]);
66
+ setTheme(selectedTheme ? bpkCustomThemes[selectedTheme] : undefined);
62
67
  };
63
68
  cycleTheme = () => {
64
69
  let {
@@ -73,7 +78,7 @@ class BpkThemeToggle extends Component {
73
78
  this.setState({
74
79
  selectedTheme
75
80
  });
76
- setTheme(bpkCustomThemes[selectedTheme]);
81
+ setTheme(selectedTheme ? bpkCustomThemes[selectedTheme] : undefined);
77
82
  };
78
83
  render() {
79
84
  const {
@@ -0,0 +1,136 @@
1
+ export type Theme = {
2
+ themeName: string;
3
+ primaryColor: string;
4
+ logoFillColor: string;
5
+ accordionActiveColor: string;
6
+ accordionColor: string;
7
+ accordionHoverColor: string;
8
+ badgeBackgroundColor: string;
9
+ badgeSuccessBackgroundColor: string;
10
+ badgeDestructiveBackgroundColor: string;
11
+ bannerAlertPrimaryColor: string;
12
+ bannerAlertSuccessColor: string;
13
+ bannerAlertWarnColor: string;
14
+ bannerAlertErrorColor: string;
15
+ barchartBarBackgroundColor: string;
16
+ barchartBarHoverBackgroundColor: string;
17
+ barchartBarActiveBackgroundColor: string;
18
+ barchartBarSelectedBackgroundColor: string;
19
+ blockquoteBarColor: string;
20
+ buttonFontSize: string;
21
+ buttonPrimaryTextColor: string;
22
+ buttonPrimaryHoverTextColor: string;
23
+ buttonPrimaryActiveTextColor: string;
24
+ buttonPrimaryGradientStartColor: string;
25
+ buttonPrimaryGradientEndColor: string;
26
+ buttonPrimaryBackgroundColor: string;
27
+ buttonPrimaryHoverBackgroundColor: string;
28
+ buttonPrimaryActiveBackgroundColor: string;
29
+ buttonSecondaryTextColor: string;
30
+ buttonSecondaryHoverTextColor: string;
31
+ buttonSecondaryActiveTextColor: string;
32
+ buttonSecondaryBorderColor: string;
33
+ buttonSecondaryHoverBorderColor: string;
34
+ buttonSecondaryActiveBorderColor: string;
35
+ buttonSecondaryBackgroundColor: string;
36
+ buttonSecondaryHoverBackgroundColor: string;
37
+ buttonSecondaryActiveBackgroundColor: string;
38
+ buttonFeaturedTextColor: string;
39
+ buttonFeaturedHoverTextColor: string;
40
+ buttonFeaturedActiveTextColor: string;
41
+ buttonFeaturedGradientStartColor: string;
42
+ buttonFeaturedGradientEndColor: string;
43
+ buttonFeaturedBackgroundColor: string;
44
+ buttonFeaturedHoverBackgroundColor: string;
45
+ buttonFeaturedActiveBackgroundColor: string;
46
+ buttonDestructiveTextColor: string;
47
+ buttonDestructiveHoverTextColor: string;
48
+ buttonDestructiveActiveTextColor: string;
49
+ buttonDestructiveBorderColor: string;
50
+ buttonDestructiveHoverBorderColor: string;
51
+ buttonDestructiveActiveBorderColor: string;
52
+ buttonDestructiveBackgroundColor: string;
53
+ buttonDestructiveHoverBackgroundColor: string;
54
+ buttonDestructiveActiveBackgroundColor: string;
55
+ chipDefaultSelectedBackgroundColor: string;
56
+ chipDefaultSelectedTextColor: string;
57
+ chipOnDarkSelectedBackgroundColor: string;
58
+ chipOnDarkSelectedTextColor: string;
59
+ chipOnImageSelectedBackgroundColor: string;
60
+ chipOnImageSelectedHoverBackgroundColor: string;
61
+ chipOnImageSelectedActiveBackgroundColor: string;
62
+ chipOnImageSelectedTextColor: string;
63
+ fieldsetLabelTextColor: string;
64
+ formValidationIconFill: string;
65
+ formValidationTextColor: string;
66
+ inputInvalidBorderColor: string;
67
+ linkColor: string;
68
+ linkHoverColor: string;
69
+ linkActiveColor: string;
70
+ linkVisitedColor: string;
71
+ linkAlternateColor: string;
72
+ linkAlternateHoverColor: string;
73
+ linkAlternateActiveColor: string;
74
+ linkAlternateVisitedColor: string;
75
+ horizontalNavBarSelectedColor: string;
76
+ horizontalNavLinkSelectedColor: string;
77
+ horizontalNavLinkColor: string;
78
+ horizontalNavLinkHoverColor: string;
79
+ horizontalNavLinkActiveColor: string;
80
+ selectInvalidBorderColor: string;
81
+ spinnerPrimaryColor: string;
82
+ starRatingFilledColor: string;
83
+ sliderBarColor: string;
84
+ textareaInvalidBorderColor: string;
85
+ paginationNudgerActiveColor: string;
86
+ paginationNudgerColor: string;
87
+ paginationNudgerHoverColor: string;
88
+ paginationSelectedBackgroundColor: string;
89
+ progressBarFillColor: string;
90
+ calendarDateTextColor: string;
91
+ calendarDateTextHoverColor: string;
92
+ calendarDateTextActiveColor: string;
93
+ calendarDateTextFocusColor: string;
94
+ calendarDateTextSelectedColor: string;
95
+ calendarDateSelectedBackgroundColor: string;
96
+ calendarDateFocusedBorderColor: string;
97
+ calendarNudgerIconColor: string;
98
+ calendarNudgerIconHoverColor: string;
99
+ calendarNudgerIconActiveColor: string;
100
+ checkboxCheckedColor: string;
101
+ radioCheckedColor: string;
102
+ switchCheckedColor: string;
103
+ ratingHighTextColor: string;
104
+ ratingHighColor: string;
105
+ ratingMediumTextColor: string;
106
+ ratingMediumColor: string;
107
+ ratingLowColor: string;
108
+ iconMarkerDefaultBackgroundColor: string;
109
+ iconMarkerDefaultSelectedColor: string;
110
+ iconMarkerDefaultDisabledColor: string;
111
+ iconMarkerDefaultDisabledBackgroundColor: string;
112
+ priceMarkerBackgroundColor: string;
113
+ priceMarkerSelectedBorderColor: string;
114
+ priceMarkerSelectedColor: string;
115
+ priceMarkerViewedBackgroundColor: string;
116
+ priceMarkerViewedBorderColor: string;
117
+ priceMarkerViewedColor: string;
118
+ skipLinkBackgroundColor: string;
119
+ navigationBarIconButtonColor: string;
120
+ navigationBarIconButtonHoverColor: string;
121
+ navigationBarIconButtonActiveColor: string;
122
+ navigationBarButtonLinkColor: string;
123
+ navigationBarButtonLinkHoverColor: string;
124
+ navigationBarButtonLinkActiveColor: string;
125
+ navigationBarButtonLinkVisitedColor: string;
126
+ navigationBarTitleColor: string;
127
+ navigationBarBackgroundColor: string;
128
+ docsSidebarBackground: string;
129
+ docsSidebarLink: string;
130
+ docsSidebarLinkBorder: string;
131
+ docsSidebarSelectedArrowColor: string;
132
+ };
133
+ declare const bpkCustomThemes: {
134
+ [key: string]: Theme;
135
+ };
136
+ export default bpkCustomThemes;
@@ -0,0 +1,42 @@
1
+ import type { ComponentType, ReactNode } from 'react';
2
+ import type { Theme } from './theming';
3
+ type ThemeChangeEvent = CustomEvent<{
4
+ theme: Theme | null;
5
+ }>;
6
+ type UpdateOnThemeChangeProps = {
7
+ children: ReactNode;
8
+ };
9
+ type UpdateOnThemeChangeState = {
10
+ theme: Theme | null;
11
+ };
12
+ declare const updateOnThemeChange: <P extends object>(EnhancedComponent: ComponentType<P & {
13
+ theme: Theme | null;
14
+ }>) => {
15
+ new (props: P & UpdateOnThemeChangeProps): {
16
+ componentDidMount(): void;
17
+ componentWillUnmount(): void;
18
+ onThemeChange: (e: ThemeChangeEvent) => void;
19
+ render(): import("react/jsx-runtime").JSX.Element;
20
+ context: unknown;
21
+ setState<K extends "theme">(state: UpdateOnThemeChangeState | ((prevState: Readonly<UpdateOnThemeChangeState>, props: Readonly<P & UpdateOnThemeChangeProps>) => UpdateOnThemeChangeState | Pick<UpdateOnThemeChangeState, K> | null) | Pick<UpdateOnThemeChangeState, K> | null, callback?: (() => void) | undefined): void;
22
+ forceUpdate(callback?: (() => void) | undefined): void;
23
+ readonly props: Readonly<P & UpdateOnThemeChangeProps>;
24
+ state: Readonly<UpdateOnThemeChangeState>;
25
+ refs: {
26
+ [key: string]: import("react").ReactInstance;
27
+ };
28
+ shouldComponentUpdate?(nextProps: Readonly<P & UpdateOnThemeChangeProps>, nextState: Readonly<UpdateOnThemeChangeState>, nextContext: any): boolean;
29
+ componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
30
+ getSnapshotBeforeUpdate?(prevProps: Readonly<P & UpdateOnThemeChangeProps>, prevState: Readonly<UpdateOnThemeChangeState>): any;
31
+ componentDidUpdate?(prevProps: Readonly<P & UpdateOnThemeChangeProps>, prevState: Readonly<UpdateOnThemeChangeState>, snapshot?: any): void;
32
+ componentWillMount?(): void;
33
+ UNSAFE_componentWillMount?(): void;
34
+ componentWillReceiveProps?(nextProps: Readonly<P & UpdateOnThemeChangeProps>, nextContext: any): void;
35
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P & UpdateOnThemeChangeProps>, nextContext: any): void;
36
+ componentWillUpdate?(nextProps: Readonly<P & UpdateOnThemeChangeProps>, nextState: Readonly<UpdateOnThemeChangeState>, nextContext: any): void;
37
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<P & UpdateOnThemeChangeProps>, nextState: Readonly<UpdateOnThemeChangeState>, nextContext: any): void;
38
+ };
39
+ displayName: string;
40
+ contextType?: import("react").Context<any> | undefined;
41
+ };
42
+ export default updateOnThemeChange;
@@ -16,24 +16,29 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import PropTypes from 'prop-types';
20
19
  import { Component } from 'react';
21
20
  import { wrapDisplayName } from "../../bpk-react-utils";
22
21
  import { getHtmlElement, THEME_CHANGE_EVENT } from "./utils";
23
22
  import { jsx as _jsx } from "react/jsx-runtime";
24
23
  const updateOnThemeChange = EnhancedComponent => {
25
24
  class UpdateOnThemeChange extends Component {
26
- constructor() {
27
- super();
25
+ constructor(props) {
26
+ super(props);
28
27
  this.state = {
29
28
  theme: null
30
29
  };
31
30
  }
32
31
  componentDidMount() {
33
- getHtmlElement().addEventListener(THEME_CHANGE_EVENT, this.onThemeChange, false);
32
+ const htmlElement = getHtmlElement();
33
+ if (htmlElement) {
34
+ htmlElement.addEventListener(THEME_CHANGE_EVENT, this.onThemeChange, false);
35
+ }
34
36
  }
35
37
  componentWillUnmount() {
36
- getHtmlElement().removeEventListener(THEME_CHANGE_EVENT, this.onThemeChange, false);
38
+ const htmlElement = getHtmlElement();
39
+ if (htmlElement) {
40
+ htmlElement.removeEventListener(THEME_CHANGE_EVENT, this.onThemeChange, false);
41
+ }
37
42
  }
38
43
  onThemeChange = e => {
39
44
  const {
@@ -52,9 +57,6 @@ const updateOnThemeChange = EnhancedComponent => {
52
57
  }
53
58
  }
54
59
  UpdateOnThemeChange.displayName = wrapDisplayName(EnhancedComponent, 'updateOnThemeChange');
55
- UpdateOnThemeChange.propTypes = {
56
- children: PropTypes.node.isRequired
57
- };
58
60
  return UpdateOnThemeChange;
59
61
  };
60
62
  export default updateOnThemeChange;
@@ -0,0 +1,3 @@
1
+ declare const THEME_CHANGE_EVENT = "bpkchangetheme";
2
+ declare const getHtmlElement: () => HTMLElement | null;
3
+ export { THEME_CHANGE_EVENT, getHtmlElement };
@@ -16,5 +16,5 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  const THEME_CHANGE_EVENT = 'bpkchangetheme';
19
- const getHtmlElement = () => typeof document !== 'undefined' ? document.querySelector('html') : {};
19
+ const getHtmlElement = () => typeof document !== 'undefined' ? document.querySelector('html') : null;
20
20
  export { THEME_CHANGE_EVENT, getHtmlElement };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "41.2.0",
3
+ "version": "41.4.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",