@skyscanner/backpack-web 42.27.3 → 43.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/bpk-component-accordion/src/BpkAccordionItem.d.ts +1 -1
  2. package/bpk-component-accordion/src/withAccordionItemState.d.ts +2 -7
  3. package/bpk-component-accordion/src/withAccordionItemState.js +4 -6
  4. package/bpk-component-accordion/src/withSingleItemAccordionState.d.ts +1 -1
  5. package/bpk-component-aria-live/src/BpkAriaLive.d.ts +1 -1
  6. package/bpk-component-aria-live/src/BpkAriaLive.story-helpers.d.ts +2 -2
  7. package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.d.ts +4 -4
  8. package/bpk-component-badge/src/BpkBadge.module.css +1 -1
  9. package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +4 -7
  10. package/bpk-component-banner-alert/src/AnimateAndFade.js +14 -10
  11. package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +0 -10
  12. package/bpk-component-banner-alert/src/withBannerAlertState.js +3 -13
  13. package/bpk-component-barchart/src/BpkBarchart.js +24 -41
  14. package/bpk-component-barchart/src/BpkBarchartBar.js +7 -16
  15. package/bpk-component-barchart/src/BpkBarchartBars.js +6 -14
  16. package/bpk-component-barchart/src/BpkChartAxis.js +5 -12
  17. package/bpk-component-barchart/src/BpkChartDataTable.js +1 -4
  18. package/bpk-component-barchart/src/BpkChartGridLines.js +3 -8
  19. package/bpk-component-calendar/index.d.ts +2 -2
  20. package/bpk-component-calendar/index.js +2 -2
  21. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +3 -28
  22. package/bpk-component-calendar/src/BpkCalendarContainer.js +47 -34
  23. package/bpk-component-calendar/src/BpkCalendarDate.d.ts +0 -1
  24. package/bpk-component-calendar/src/BpkCalendarDate.js +32 -31
  25. package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +13 -14
  26. package/bpk-component-calendar/src/BpkCalendarGrid.js +28 -37
  27. package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +0 -4
  28. package/bpk-component-calendar/src/BpkCalendarGridHeader.js +2 -6
  29. package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +0 -5
  30. package/bpk-component-calendar/src/BpkCalendarGridTransition.js +0 -5
  31. package/bpk-component-calendar/src/BpkCalendarWeek.d.ts +0 -1
  32. package/bpk-component-calendar/src/BpkCalendarWeek.js +19 -27
  33. package/bpk-component-calendar/src/custom-proptypes.d.ts +1 -1
  34. package/bpk-component-card-list/src/BpkCardList.js +0 -3
  35. package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.js +1 -3
  36. package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListRowRailContainer.js +1 -14
  37. package/bpk-component-card-list/src/BpkCardListRowRail/utils.d.ts +1 -2
  38. package/bpk-component-card-list/src/BpkCardListRowRail/utils.js +0 -21
  39. package/bpk-component-card-list/src/common-types.d.ts +4 -7
  40. package/bpk-component-chatbot-input/src/hooks/useChatbotInput.d.ts +1 -1
  41. package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.d.ts +1 -1
  42. package/bpk-component-datepicker/src/BpkDatepicker.d.ts +6 -192
  43. package/bpk-component-datepicker/src/BpkDatepicker.js +46 -53
  44. package/bpk-component-dialog/src/BpkDialogInner.d.ts +0 -7
  45. package/bpk-component-drawer/src/BpkDrawerContent.d.ts +2 -2
  46. package/bpk-component-drawer/src/BpkDrawerContent.js +13 -1
  47. package/bpk-component-fieldset/src/BpkFieldset.d.ts +1 -1
  48. package/bpk-component-floating-notification/src/BpkFloatingNotification.js +4 -1
  49. package/bpk-component-grid-toggle/src/BpkGridToggle.js +9 -7
  50. package/bpk-component-image/src/BpkBackgroundImage.d.ts +1 -9
  51. package/bpk-component-image/src/BpkBackgroundImage.js +18 -18
  52. package/bpk-component-image/src/BpkImage.d.ts +1 -8
  53. package/bpk-component-image/src/BpkImage.js +10 -18
  54. package/bpk-component-image/src/withLazyLoading.d.ts +0 -4
  55. package/bpk-component-image/src/withLazyLoading.js +2 -6
  56. package/bpk-component-infinite-scroll/src/withInfiniteScroll.js +6 -8
  57. package/bpk-component-info-banner/src/AnimateAndFade.d.ts +4 -7
  58. package/bpk-component-info-banner/src/AnimateAndFade.js +14 -10
  59. package/bpk-component-info-banner/src/withBannerAlertState.d.ts +0 -10
  60. package/bpk-component-info-banner/src/withBannerAlertState.js +3 -13
  61. package/bpk-component-input/index.d.ts +2 -2
  62. package/bpk-component-input/index.js +2 -2
  63. package/bpk-component-input/src/BpkInput.d.ts +0 -13
  64. package/bpk-component-input/src/BpkInput.js +13 -12
  65. package/bpk-component-input/src/common-types.d.ts +0 -32
  66. package/bpk-component-input/src/common-types.js +1 -56
  67. package/bpk-component-input/src/withOpenEvents.d.ts +1 -12
  68. package/bpk-component-input/src/withOpenEvents.js +2 -14
  69. package/bpk-component-layout/src/types.d.ts +19 -35
  70. package/bpk-component-map/src/BpkBasicMapMarker.d.ts +1 -8
  71. package/bpk-component-map/src/BpkBasicMapMarker.js +0 -6
  72. package/bpk-component-map/src/BpkIconMarker.js +4 -10
  73. package/bpk-component-map/src/BpkIconMarkerBackground.js +3 -8
  74. package/bpk-component-map/src/BpkMap.js +14 -30
  75. package/bpk-component-map/src/withGoogleMapsScript.js +4 -8
  76. package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.d.ts +0 -1
  77. package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.js +1 -5
  78. package/bpk-component-modal/index.d.ts +1 -2
  79. package/bpk-component-modal/index.js +1 -3
  80. package/bpk-component-navigation-bar/src/BpkNavigationBar.d.ts +2 -2
  81. package/bpk-component-phone-input/src/BpkPhoneInput.js +6 -14
  82. package/bpk-component-progress/src/BpkProgress.d.ts +0 -8
  83. package/bpk-component-progress/src/BpkProgress.js +10 -16
  84. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendar.d.ts +0 -14
  85. package/bpk-component-section-list/src/BpkSectionListItem.js +4 -10
  86. package/bpk-component-section-list/src/BpkSectionListSection.js +1 -4
  87. package/bpk-component-segmented-control/src/BpkSegmentedControl.d.ts +1 -1
  88. package/bpk-component-select/src/BpkSelect.d.ts +1 -1
  89. package/bpk-component-slider/src/BpkSlider.js +1 -1
  90. package/bpk-component-spinner/src/SpinnerLayout.story-helpers.d.ts +1 -7
  91. package/bpk-component-spinner/src/SpinnerLayout.story-helpers.js +0 -4
  92. package/bpk-component-split-input/src/BpkInputField.d.ts +2 -6
  93. package/bpk-component-split-input/src/BpkInputField.js +2 -6
  94. package/bpk-component-split-input/src/BpkSplitInput.d.ts +0 -6
  95. package/bpk-component-split-input/src/BpkSplitInput.js +7 -13
  96. package/bpk-component-star-rating/src/withInteractiveStarRatingState.d.ts +0 -3
  97. package/bpk-component-star-rating/src/withInteractiveStarRatingState.js +0 -3
  98. package/bpk-component-ticket/src/BpkTicket.js +6 -14
  99. package/bpk-mixins/_badges.scss +3 -3
  100. package/bpk-react-utils/index.d.ts +3 -1
  101. package/bpk-react-utils/src/BpkDialogWrapper/BpkDialogWrapper.js +1 -0
  102. package/bpk-react-utils/src/Portal.d.ts +10 -22
  103. package/bpk-react-utils/src/Portal.js +22 -19
  104. package/bpk-react-utils/src/TransitionInitialMount.d.ts +4 -2
  105. package/bpk-react-utils/src/TransitionInitialMount.js +23 -14
  106. package/bpk-scrim-utils/index.d.ts +0 -7
  107. package/bpk-scrim-utils/src/withScrim.d.ts +0 -7
  108. package/bpk-scrim-utils/src/withScrim.js +10 -15
  109. package/package.json +3 -3
  110. package/bpk-component-modal/src/legacy-prop-types.js +0 -74
@@ -98,7 +98,6 @@ export const usePageScrollSync = ({
98
98
  container,
99
99
  currentIndex,
100
100
  enabled,
101
- initialPageIndex,
102
101
  initiallyShownCards,
103
102
  setCurrentIndex,
104
103
  visibilityList
@@ -106,26 +105,6 @@ export const usePageScrollSync = ({
106
105
  const isUserScrollingRef = useRef(false);
107
106
  const scrollEndTimeoutRef = useRef(null);
108
107
  const lastCurrentIndexRef = useRef(currentIndex);
109
- const hasInitialScrolled = useRef(false);
110
-
111
- // Effect 0: Initial scroll (instant, runs once on mount)
112
- useEffect(() => {
113
- if (hasInitialScrolled.current) {
114
- return;
115
- }
116
- hasInitialScrolled.current = true;
117
- if (!enabled || initialPageIndex === 0) {
118
- return;
119
- }
120
- const targetCard = cardRefs.current?.[initialPageIndex * initiallyShownCards];
121
- if (targetCard) {
122
- targetCard.scrollIntoView({
123
- behavior: 'instant',
124
- block: 'nearest',
125
- inline: 'start'
126
- });
127
- }
128
- }, [cardRefs, enabled, initialPageIndex, initiallyShownCards]); // Run once on mount only
129
108
 
130
109
  // Effect 1: Programmatic scroll when currentIndex changes
131
110
  useEffect(() => {
@@ -17,7 +17,7 @@ declare const ACCESSORY_MOBILE_TYPES: {
17
17
  readonly button: "button";
18
18
  };
19
19
  type ExpandProps = {
20
- children: string | ReactElement;
20
+ children: string | ReactElement<any>;
21
21
  collapsed: boolean;
22
22
  onExpandToggle: () => void;
23
23
  };
@@ -29,15 +29,14 @@ type AccessibilityLabels = {
29
29
  slideLabel?: (index: number, childrenLength: number) => string;
30
30
  };
31
31
  type CardListBaseProps = {
32
- cardList: ReactElement[];
32
+ cardList: Array<ReactElement<any>>;
33
33
  layoutMobile: LayoutMobile;
34
34
  layoutDesktop: LayoutDesktop;
35
35
  accessoryDesktop?: (typeof ACCESSORY_DESKTOP_TYPES)[keyof typeof ACCESSORY_DESKTOP_TYPES];
36
36
  accessoryMobile?: (typeof ACCESSORY_MOBILE_TYPES)[keyof typeof ACCESSORY_MOBILE_TYPES];
37
37
  initiallyShownCardsDesktop?: number;
38
38
  initiallyShownCardsMobile?: number;
39
- initiallyInViewCardIndex?: number;
40
- chipGroup?: ReactElement;
39
+ chipGroup?: ReactElement<any>;
41
40
  buttonContent?: React.ReactNode;
42
41
  onButtonClick?: () => void;
43
42
  onExpandClick?: () => void;
@@ -53,7 +52,7 @@ type TitleProps = {
53
52
  description?: never;
54
53
  };
55
54
  type CardListGridStackProps = {
56
- children: ReactElement[];
55
+ children: Array<ReactElement<any>>;
57
56
  initiallyShownCards: number;
58
57
  layout: typeof LAYOUTS.grid | typeof LAYOUTS.stack;
59
58
  accessory?: typeof ACCESSORY_DESKTOP_TYPES.expand | typeof ACCESSORY_DESKTOP_TYPES.button | typeof ACCESSORY_MOBILE_TYPES.expand | typeof ACCESSORY_MOBILE_TYPES.button;
@@ -70,7 +69,6 @@ type CardListRowRailProps = {
70
69
  accessory?: typeof ACCESSORY_DESKTOP_TYPES.pagination;
71
70
  isMobile?: boolean;
72
71
  accessibilityLabels?: AccessibilityLabels;
73
- initiallyInViewCardIndex: number;
74
72
  };
75
73
  type CardListCarouselProps = {
76
74
  children: Array<ReactElement<HTMLDivElement | HTMLAnchorElement>>;
@@ -81,7 +79,6 @@ type CardListCarouselProps = {
81
79
  isMobile?: boolean;
82
80
  carouselLabel?: (initiallyShownCards: number, childrenLength: number) => string;
83
81
  slideLabel?: (index: number, childrenLength: number) => string;
84
- initialPageIndex: number;
85
82
  };
86
83
  type CardListProps = CardListBaseProps;
87
84
  export default CardListProps;
@@ -16,7 +16,7 @@ interface UseChatbotInputOptions {
16
16
  onKeyDown?: (e: KeyboardEvent) => void;
17
17
  }
18
18
  interface UseChatbotInputReturn {
19
- inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement>;
19
+ inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement | null>;
20
20
  isFocused: boolean;
21
21
  isDisabled: boolean;
22
22
  isOverLimit: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { RefObject } from 'react';
2
2
  interface UseTextAreaAutoResizeProps {
3
- ref: RefObject<HTMLTextAreaElement>;
3
+ ref: RefObject<HTMLTextAreaElement | null>;
4
4
  value: string;
5
5
  enabled?: boolean;
6
6
  maxLines?: number;
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import type { ReactElement, RefObject } from 'react';
2
+ import type { ReactElement, Ref } from 'react';
3
3
  import type { DaysOfWeek, ReactComponent, SelectionConfiguration } from '../../bpk-component-calendar';
4
4
  type Props = {
5
5
  changeMonthLabel: string;
@@ -17,14 +17,14 @@ type Props = {
17
17
  * The "pagewrap" element id is a convention we use internally at Skyscanner. In most cases it should "just work".
18
18
  */
19
19
  getApplicationElement: () => HTMLElement | null;
20
- nextMonthLabel: string;
21
- previousMonthLabel: string;
22
20
  weekStartsOn: number;
23
- calendarComponent: ReactComponent;
21
+ nextMonthLabel?: string | null;
22
+ previousMonthLabel?: string | null;
23
+ calendarComponent?: ReactComponent;
24
24
  /**
25
25
  * By default BpkInput. If passed, it should be a DOM node with a ref attached to it.
26
26
  */
27
- inputComponent: ReactElement | null;
27
+ inputComponent?: ReactElement<any> | null;
28
28
  dateModifiers?: {};
29
29
  fixedWidth?: boolean;
30
30
  inputProps?: {};
@@ -51,193 +51,7 @@ type State = {
51
51
  declare class BpkDatepicker extends Component<Props, State> {
52
52
  inputRef: (ref: HTMLInputElement) => void;
53
53
  elementRef?: HTMLInputElement;
54
- focusRef?: RefObject<HTMLInputElement>;
55
- static defaultProps: {
56
- calendarComponent: {
57
- new (props: Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
58
- onDateClick: ((date: Date) => void) | null;
59
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
60
- month: Date;
61
- minDate: Date;
62
- maxDate: Date;
63
- }> & {
64
- [rest: string]: any;
65
- }): {
66
- componentDidUpdate(prevProps: Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
67
- onDateClick: ((date: Date) => void) | null;
68
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
69
- month: Date;
70
- minDate: Date;
71
- maxDate: Date;
72
- }> & {
73
- [rest: string]: any;
74
- }): void;
75
- handleDateFocus: (event: UIEvent, { date, source }: {
76
- date: Date;
77
- source: string;
78
- }) => void;
79
- handleDateSelect: (date: Date) => void;
80
- handleMonthChange: (event: UIEvent, { month, source }: {
81
- month: Date;
82
- source: string;
83
- }) => void;
84
- handleDateKeyDown: (event: KeyboardEvent) => void;
85
- render(): import("react/jsx-runtime").JSX.Element;
86
- context: unknown;
87
- setState<K extends keyof {
88
- preventKeyboardFocus: boolean;
89
- focusedDate: Date;
90
- }>(state: {
91
- preventKeyboardFocus: boolean;
92
- focusedDate: Date;
93
- } | ((prevState: Readonly<{
94
- preventKeyboardFocus: boolean;
95
- focusedDate: Date;
96
- }>, props: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
97
- onDateClick: ((date: Date) => void) | null;
98
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
99
- month: Date;
100
- minDate: Date;
101
- maxDate: Date;
102
- }> & {
103
- [rest: string]: any;
104
- }>) => {
105
- preventKeyboardFocus: boolean;
106
- focusedDate: Date;
107
- } | Pick<{
108
- preventKeyboardFocus: boolean;
109
- focusedDate: Date;
110
- }, K> | null) | Pick<{
111
- preventKeyboardFocus: boolean;
112
- focusedDate: Date;
113
- }, K> | null, callback?: (() => void) | undefined): void;
114
- forceUpdate(callback?: (() => void) | undefined): void;
115
- readonly props: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
116
- onDateClick: ((date: Date) => void) | null;
117
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
118
- month: Date;
119
- minDate: Date;
120
- maxDate: Date;
121
- }> & {
122
- [rest: string]: any;
123
- }>;
124
- state: Readonly<{
125
- preventKeyboardFocus: boolean;
126
- focusedDate: Date;
127
- }>;
128
- refs: {
129
- [key: string]: import("react").ReactInstance;
130
- };
131
- componentDidMount?(): void;
132
- shouldComponentUpdate?(nextProps: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
133
- onDateClick: ((date: Date) => void) | null;
134
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
135
- month: Date;
136
- minDate: Date;
137
- maxDate: Date;
138
- }> & {
139
- [rest: string]: any;
140
- }>, nextState: Readonly<{
141
- preventKeyboardFocus: boolean;
142
- focusedDate: Date;
143
- }>, nextContext: any): boolean;
144
- componentWillUnmount?(): void;
145
- componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
146
- getSnapshotBeforeUpdate?(prevProps: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
147
- onDateClick: ((date: Date) => void) | null;
148
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
149
- month: Date;
150
- minDate: Date;
151
- maxDate: Date;
152
- }> & {
153
- [rest: string]: any;
154
- }>, prevState: Readonly<{
155
- preventKeyboardFocus: boolean;
156
- focusedDate: Date;
157
- }>): any;
158
- componentWillMount?(): void;
159
- UNSAFE_componentWillMount?(): void;
160
- componentWillReceiveProps?(nextProps: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
161
- onDateClick: ((date: Date) => void) | null;
162
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
163
- month: Date;
164
- minDate: Date;
165
- maxDate: Date;
166
- }> & {
167
- [rest: string]: any;
168
- }>, nextContext: any): void;
169
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
170
- onDateClick: ((date: Date) => void) | null;
171
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
172
- month: Date;
173
- minDate: Date;
174
- maxDate: Date;
175
- }> & {
176
- [rest: string]: any;
177
- }>, nextContext: any): void;
178
- componentWillUpdate?(nextProps: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
179
- onDateClick: ((date: Date) => void) | null;
180
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
181
- month: Date;
182
- minDate: Date;
183
- maxDate: Date;
184
- }> & {
185
- [rest: string]: any;
186
- }>, nextState: Readonly<{
187
- preventKeyboardFocus: boolean;
188
- focusedDate: Date;
189
- }>, nextContext: any): void;
190
- UNSAFE_componentWillUpdate?(nextProps: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
191
- onDateClick: ((date: Date) => void) | null;
192
- onDateKeyDown: ((event: KeyboardEvent) => void) | null;
193
- month: Date;
194
- minDate: Date;
195
- maxDate: Date;
196
- }> & {
197
- [rest: string]: any;
198
- }>, nextState: Readonly<{
199
- preventKeyboardFocus: boolean;
200
- focusedDate: Date;
201
- }>, nextContext: any): void;
202
- };
203
- defaultProps: {
204
- fixedWidth: boolean;
205
- maxDate: Date;
206
- minDate: Date;
207
- onDateSelect: null;
208
- onMonthChange: null;
209
- selectionConfiguration: {
210
- type: "single";
211
- date: null;
212
- };
213
- initiallyFocusedDate: null;
214
- markToday: boolean;
215
- markOutsideDays: boolean;
216
- };
217
- contextType?: import("react").Context<any> | undefined;
218
- };
219
- inputComponent: null;
220
- dateModifiers: {};
221
- inputProps: {};
222
- fixedWidth: boolean;
223
- markOutsideDays: boolean;
224
- markToday: boolean;
225
- maxDate: Date;
226
- minDate: Date;
227
- nextMonthLabel: null;
228
- onDateSelect: null;
229
- onOpenChange: null;
230
- onMonthChange: null;
231
- previousMonthLabel: null;
232
- selectionConfiguration: {
233
- type: "single";
234
- date: null;
235
- };
236
- initiallyFocusedDate: null;
237
- renderTarget: null;
238
- isOpen: boolean;
239
- valid: null;
240
- };
54
+ focusRef?: Ref<HTMLDivElement>;
241
55
  constructor(props: Props);
242
56
  componentDidUpdate(prevProps: Props, prevState: State): void;
243
57
  onOpen: () => void;
@@ -18,7 +18,7 @@
18
18
 
19
19
  import { createRef, Component } from 'react';
20
20
  import BpkBreakpoint, { BREAKPOINTS } from "../../bpk-component-breakpoint";
21
- import { composeCalendar, BpkCalendarGridHeader, BpkCalendarGrid, BpkCalendarDate, withCalendarState, CALENDAR_SELECTION_TYPE, DateUtils, BpkCalendarNav } from "../../bpk-component-calendar";
21
+ import { composeCalendar, BpkCalendarGridHeader, BpkCalendarGrid, BpkCalendarDate, withCalendarState, CALENDAR_SELECTION_TYPE, DEFAULT_MARK_TODAY, DEFAULT_MAX_DATE, DEFAULT_MIN_DATE, DateUtils, BpkCalendarNav } from "../../bpk-component-calendar";
22
22
  import BpkInput, { withOpenEvents } from "../../bpk-component-input";
23
23
  import BpkModal from "../../bpk-component-modal";
24
24
  import BpkPopover from "../../bpk-component-popover";
@@ -26,35 +26,18 @@ import { setNativeValue, getDataComponentAttribute } from "../../bpk-react-utils
26
26
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
27
27
  const Input = withOpenEvents(BpkInput);
28
28
  const DefaultCalendar = withCalendarState(composeCalendar(BpkCalendarNav, BpkCalendarGridHeader, BpkCalendarGrid, BpkCalendarDate));
29
+ const DEFAULT_SELECTION_CONFIGURATION = {
30
+ type: CALENDAR_SELECTION_TYPE.single,
31
+ date: null
32
+ };
29
33
  class BpkDatepicker extends Component {
30
- static defaultProps = {
31
- calendarComponent: DefaultCalendar,
32
- inputComponent: null,
33
- dateModifiers: {},
34
- inputProps: {},
35
- fixedWidth: true,
36
- markOutsideDays: true,
37
- markToday: DefaultCalendar.defaultProps.markToday,
38
- maxDate: DefaultCalendar.defaultProps.maxDate,
39
- minDate: DefaultCalendar.defaultProps.minDate,
40
- nextMonthLabel: null,
41
- onDateSelect: null,
42
- onOpenChange: null,
43
- onMonthChange: null,
44
- previousMonthLabel: null,
45
- selectionConfiguration: {
46
- type: CALENDAR_SELECTION_TYPE.single,
47
- date: null
48
- },
49
- initiallyFocusedDate: null,
50
- renderTarget: null,
51
- isOpen: false,
52
- valid: null
53
- };
54
34
  constructor(props) {
55
35
  super(props);
36
+ const {
37
+ isOpen = false
38
+ } = props;
56
39
  this.state = {
57
- isOpen: props.isOpen
40
+ isOpen
58
41
  };
59
42
  this.focusRef = /*#__PURE__*/createRef();
60
43
  this.inputRef = ref => {
@@ -63,9 +46,12 @@ class BpkDatepicker extends Component {
63
46
  }
64
47
  componentDidUpdate(prevProps, prevState) {
65
48
  const {
66
- isOpen
49
+ isOpen = false
67
50
  } = this.props;
68
- if (prevProps.isOpen !== isOpen && prevState.isOpen !== isOpen) {
51
+ const {
52
+ isOpen: prevIsOpen = false
53
+ } = prevProps;
54
+ if (prevIsOpen !== isOpen && prevState.isOpen !== isOpen) {
69
55
  if (isOpen) {
70
56
  this.onOpen();
71
57
  } else {
@@ -74,19 +60,25 @@ class BpkDatepicker extends Component {
74
60
  }
75
61
  }
76
62
  onOpen = () => {
63
+ const {
64
+ onOpenChange = null
65
+ } = this.props;
77
66
  this.setState({
78
67
  isOpen: true
79
68
  });
80
- if (this.props.onOpenChange) {
81
- this.props.onOpenChange(true);
69
+ if (onOpenChange) {
70
+ onOpenChange(true);
82
71
  }
83
72
  };
84
73
  onClose = () => {
74
+ const {
75
+ onOpenChange = null
76
+ } = this.props;
85
77
  this.setState({
86
78
  isOpen: false
87
79
  });
88
- if (this.props.onOpenChange) {
89
- this.props.onOpenChange(false);
80
+ if (onOpenChange) {
81
+ onOpenChange(false);
90
82
  }
91
83
  };
92
84
 
@@ -133,23 +125,23 @@ class BpkDatepicker extends Component {
133
125
  };
134
126
  handleDateSelect = (startDate, endDate = null) => {
135
127
  const {
136
- maxDate,
137
- minDate,
128
+ maxDate = DEFAULT_MAX_DATE,
129
+ minDate = DEFAULT_MIN_DATE,
138
130
  onClose,
139
- onDateSelect,
140
- selectionConfiguration
131
+ onDateSelect = null,
132
+ selectionConfiguration = DEFAULT_SELECTION_CONFIGURATION
141
133
  } = this.props;
142
134
 
143
135
  // When the calendar is a single date we always want to close it when a date is selected
144
136
  // or if its a range calendar we only want to close the calendar when a range is selected.
145
137
  // If a custom onClose function is provided then we don't want to run the internal version.
146
- if (selectionConfiguration && (selectionConfiguration.type === CALENDAR_SELECTION_TYPE.single || selectionConfiguration.type === CALENDAR_SELECTION_TYPE.range && endDate) && !onClose) {
138
+ if ((selectionConfiguration.type === CALENDAR_SELECTION_TYPE.single || selectionConfiguration.type === CALENDAR_SELECTION_TYPE.range && endDate) && !onClose) {
147
139
  this.onClose();
148
140
  }
149
141
  if (onDateSelect) {
150
142
  const newStartDate = DateUtils.dateToBoundaries(startDate, DateUtils.startOfDay(minDate), DateUtils.startOfDay(maxDate));
151
143
  const newEndDate = DateUtils.dateToBoundaries(endDate, DateUtils.startOfDay(minDate), DateUtils.startOfDay(maxDate));
152
- if (selectionConfiguration && selectionConfiguration.type === CALENDAR_SELECTION_TYPE.range && selectionConfiguration.startDate && !selectionConfiguration.endDate && (DateUtils.isAfter(newEndDate, selectionConfiguration.startDate) || DateUtils.isSameDay(newEndDate, selectionConfiguration.startDate))) {
144
+ if (selectionConfiguration.type === CALENDAR_SELECTION_TYPE.range && selectionConfiguration.startDate && !selectionConfiguration.endDate && (DateUtils.isAfter(newEndDate, selectionConfiguration.startDate) || DateUtils.isSameDay(newEndDate, selectionConfiguration.startDate))) {
153
145
  onDateSelect(selectionConfiguration.startDate, newEndDate);
154
146
  this.elementRef && setNativeValue(this.elementRef, this.props.formatDate(newEndDate));
155
147
  } else {
@@ -160,34 +152,35 @@ class BpkDatepicker extends Component {
160
152
  };
161
153
  render() {
162
154
  const {
163
- calendarComponent: Calendar,
155
+ calendarComponent,
164
156
  changeMonthLabel,
165
157
  closeButtonText,
166
- dateModifiers,
158
+ dateModifiers = {},
167
159
  daysOfWeek,
168
- fixedWidth,
160
+ fixedWidth = true,
169
161
  formatDate,
170
162
  formatDateFull,
171
163
  formatMonth,
172
164
  getApplicationElement,
173
165
  id,
174
- initiallyFocusedDate,
175
- inputComponent,
176
- inputProps,
177
- markOutsideDays,
178
- markToday,
179
- maxDate,
180
- minDate,
181
- nextMonthLabel,
182
- onMonthChange,
183
- previousMonthLabel,
184
- renderTarget,
185
- selectionConfiguration,
166
+ initiallyFocusedDate = null,
167
+ inputComponent = null,
168
+ inputProps = {},
169
+ markOutsideDays = true,
170
+ markToday = DEFAULT_MARK_TODAY,
171
+ maxDate = DEFAULT_MAX_DATE,
172
+ minDate = DEFAULT_MIN_DATE,
173
+ nextMonthLabel = null,
174
+ onMonthChange = null,
175
+ previousMonthLabel = null,
176
+ renderTarget = null,
177
+ selectionConfiguration = DEFAULT_SELECTION_CONFIGURATION,
186
178
  title,
187
179
  valid,
188
180
  weekStartsOn,
189
181
  ...rest
190
182
  } = this.props;
183
+ const Calendar = calendarComponent || DefaultCalendar;
191
184
 
192
185
  // The following props are not used in render
193
186
  delete rest.onDateSelect;
@@ -51,13 +51,6 @@ declare const _default: {
51
51
  UNSAFE_componentWillUpdate?(nextProps: Readonly<import("../../bpk-scrim-utils/src/withScrim").Props & Omit<Props, "dialogRef">>, nextState: Readonly<{}>, nextContext: any): void;
52
52
  };
53
53
  displayName: string;
54
- defaultProps: {
55
- onClose: null;
56
- isIphone: boolean;
57
- isIpad: boolean;
58
- containerClassName: null;
59
- closeOnScrimClick: boolean;
60
- };
61
54
  contextType?: import("react").Context<any> | undefined;
62
55
  };
63
56
  export default _default;
@@ -1,7 +1,7 @@
1
- import type { ReactNode, RefObject } from 'react';
1
+ import type { ReactNode, Ref } from 'react';
2
2
  type Props = {
3
3
  children: ReactNode;
4
- dialogRef: () => RefObject<HTMLElement>;
4
+ dialogRef: Ref<HTMLElement>;
5
5
  onCloseAnimationComplete: () => void;
6
6
  onClose: () => void;
7
7
  id: string;
@@ -16,6 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
+ import { useCallback, useRef } from 'react';
19
20
  import { Transition } from 'react-transition-group';
20
21
  import { animations } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
21
22
 
@@ -66,7 +67,18 @@ const BpkDrawerContent = ({
66
67
  contentClassNames.push(contentClassName);
67
68
  }
68
69
  const headingId = `bpk-drawer-heading-${id}`;
70
+ const nodeRef = useRef(null);
71
+ const setRefs = useCallback(el => {
72
+ nodeRef.current = el;
73
+ const consumerRef = dialogRef;
74
+ if (typeof consumerRef === 'function') {
75
+ consumerRef(el);
76
+ } else if (consumerRef) {
77
+ consumerRef.current = el;
78
+ }
79
+ }, [dialogRef]);
69
80
  return /*#__PURE__*/_jsx(Transition, {
81
+ nodeRef: nodeRef,
70
82
  timeout: {
71
83
  enter: 0,
72
84
  exit: parseInt(animations.durationSm, 10)
@@ -85,7 +97,7 @@ const BpkDrawerContent = ({
85
97
  '--dynamic-width': width
86
98
  },
87
99
  className: [drawerClassNames.join(' '), getClassName(`bpk-drawer--${status}`, mobileModalDisplay ? `bpk-drawer__modal-mobile-view--${status}` : undefined)].join(' '),
88
- ref: dialogRef,
100
+ ref: setRefs,
89
101
  ...rest,
90
102
  children: [/*#__PURE__*/_jsxs("header", {
91
103
  className: getClassName('bpk-drawer__header'),
@@ -1,6 +1,6 @@
1
1
  import type { ReactElement } from 'react';
2
2
  type BaseProps = {
3
- children: ReactElement;
3
+ children: ReactElement<any>;
4
4
  disabled?: boolean;
5
5
  valid?: boolean | null;
6
6
  required?: boolean;
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { useEffect, useState } from 'react';
19
+ import { useEffect, useRef, useState } from 'react';
20
20
  import { CSSTransition } from 'react-transition-group';
21
21
  import BpkAriaLive, { ARIA_LIVE_POLITENESS_SETTINGS } from "../../bpk-component-aria-live";
22
22
  import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
@@ -31,6 +31,7 @@ export const NOTIFICATION_TYPES = {
31
31
  };
32
32
  const BpkFloatingNotification = props => {
33
33
  const [showMessage, setShowMessage] = useState(true);
34
+ const nodeRef = useRef(null);
34
35
  const {
35
36
  animateOnEnter = true,
36
37
  animateOnExit = true,
@@ -54,6 +55,7 @@ const BpkFloatingNotification = props => {
54
55
  });
55
56
  return /*#__PURE__*/_jsx(CSSTransition, {
56
57
  in: showMessage,
58
+ nodeRef: nodeRef,
57
59
  classNames: {
58
60
  exit: getClassName('bpk-floating-notification--leave'),
59
61
  exitActive: getClassName('bpk-floating-notification--leave-active'),
@@ -66,6 +68,7 @@ const BpkFloatingNotification = props => {
66
68
  exit: animateOnExit,
67
69
  onExited: onExit,
68
70
  children: /*#__PURE__*/_jsxs("div", {
71
+ ref: nodeRef,
69
72
  className: classNames,
70
73
  ...getDataComponentAttribute('FloatingNotification'),
71
74
  ...rest,
@@ -35,7 +35,10 @@ class BpkGridToggle extends Component {
35
35
  document.addEventListener('keydown', this.handleKeyDown);
36
36
  }
37
37
  componentWillUnmount() {
38
- document.querySelector(this.props.targetContainer).classList.remove(GRID_CLASS_NAME);
38
+ const {
39
+ targetContainer = 'body'
40
+ } = this.props;
41
+ document.querySelector(targetContainer).classList.remove(GRID_CLASS_NAME);
39
42
  document.removeEventListener('keydown', this.handleKeyDown);
40
43
  }
41
44
  handleKeyDown = e => {
@@ -44,15 +47,18 @@ class BpkGridToggle extends Component {
44
47
  }
45
48
  };
46
49
  toggleGrid = e => {
50
+ const {
51
+ targetContainer = 'body'
52
+ } = this.props;
47
53
  e.preventDefault();
48
- document.querySelector(this.props.targetContainer).classList.toggle(GRID_CLASS_NAME);
54
+ document.querySelector(targetContainer).classList.toggle(GRID_CLASS_NAME);
49
55
  this.setState(state => ({
50
56
  gridEnabled: !state.gridEnabled
51
57
  }));
52
58
  };
53
59
  render() {
54
60
  const {
55
- className
61
+ className = null
56
62
  } = this.props;
57
63
  const {
58
64
  gridEnabled
@@ -73,8 +79,4 @@ BpkGridToggle.propTypes = {
73
79
  targetContainer: PropTypes.string,
74
80
  className: PropTypes.string
75
81
  };
76
- BpkGridToggle.defaultProps = {
77
- targetContainer: 'body',
78
- className: null
79
- };
80
82
  export default BpkGridToggle;
@@ -14,21 +14,13 @@ export type BpkBackgroundImageProps = {
14
14
  };
15
15
  declare class BpkBackgroundImage extends Component<BpkBackgroundImageProps> {
16
16
  trackImg?: HTMLImageElement | null;
17
- static defaultProps: {
18
- className: string;
19
- inView: boolean;
20
- loading: boolean;
21
- onLoad: null;
22
- onError: null;
23
- style: {};
24
- imageStyle: {};
25
- };
26
17
  constructor(props: BpkBackgroundImageProps);
27
18
  componentDidMount(): void;
28
19
  componentDidUpdate(prevProps: BpkBackgroundImageProps): void;
29
20
  onBackgroundImageError: () => void;
30
21
  onBackgroundImageLoad: () => void;
31
22
  getAspectRatio: () => number;
23
+ spinnerNodeRef: import("react").RefObject<HTMLDivElement>;
32
24
  startImageLoad: () => void;
33
25
  render(): import("react/jsx-runtime").JSX.Element;
34
26
  }