@skyscanner/backpack-web 23.2.2 → 24.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 (133) hide show
  1. package/bpk-component-aria-live/src/BpkAriaLive.js +0 -1
  2. package/bpk-component-badge/src/BpkBadge.js +0 -1
  3. package/{bpk-scrim-utils/src/customPropTypes.js → bpk-component-banner-alert/index.d.ts} +16 -14
  4. package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +61 -0
  5. package/bpk-component-banner-alert/src/AnimateAndFade.js +3 -9
  6. package/bpk-component-banner-alert/src/BpkBannerAlert.d.ts +29 -0
  7. package/bpk-component-banner-alert/src/BpkBannerAlert.js +42 -21
  8. package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.d.ts +30 -0
  9. package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.js +31 -33
  10. package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.d.ts +35 -0
  11. package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.js +15 -28
  12. package/bpk-component-banner-alert/src/BpkBannerAlertInner.d.ts +58 -0
  13. package/bpk-component-banner-alert/src/BpkBannerAlertInner.js +65 -87
  14. package/bpk-component-banner-alert/src/common-types.d.ts +44 -0
  15. package/bpk-component-banner-alert/src/common-types.js +5 -23
  16. package/bpk-component-banner-alert/src/themeAttributes.d.ts +20 -0
  17. package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +169 -0
  18. package/bpk-component-banner-alert/src/withBannerAlertState.js +10 -29
  19. package/bpk-component-boilerplate/src/BpkBoilerplate.js +0 -1
  20. package/bpk-component-button/src/BpkButtonV2/BpkButton.js +0 -1
  21. package/bpk-component-calendar/index.d.ts +30 -0
  22. package/bpk-component-calendar/index.js +5 -4
  23. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +464 -0
  24. package/bpk-component-calendar/src/BpkCalendarContainer.js +19 -29
  25. package/bpk-component-calendar/src/BpkCalendarDate.d.ts +62 -0
  26. package/bpk-component-calendar/src/BpkCalendarDate.js +15 -39
  27. package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +68 -0
  28. package/bpk-component-calendar/src/BpkCalendarGrid.js +9 -40
  29. package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +36 -0
  30. package/bpk-component-calendar/src/BpkCalendarGridHeader.js +33 -52
  31. package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +56 -0
  32. package/bpk-component-calendar/src/BpkCalendarGridTransition.js +43 -42
  33. package/bpk-component-calendar/src/BpkCalendarNav.d.ts +37 -0
  34. package/bpk-component-calendar/src/BpkCalendarNav.js +18 -32
  35. package/bpk-component-calendar/src/Week.d.ts +51 -0
  36. package/bpk-component-calendar/src/Week.js +48 -70
  37. package/bpk-component-calendar/src/composeCalendar.d.ts +55 -0
  38. package/bpk-component-calendar/src/composeCalendar.js +34 -95
  39. package/bpk-component-calendar/src/custom-proptypes-legacy.js +140 -0
  40. package/bpk-component-calendar/src/custom-proptypes.d.ts +46 -0
  41. package/bpk-component-calendar/src/custom-proptypes.js +2 -61
  42. package/bpk-component-calendar/src/date-utils.d.ts +54 -0
  43. package/bpk-component-calendar/src/utils.d.ts +26 -0
  44. package/bpk-component-calendar/src/utils.js +1 -0
  45. package/bpk-component-calendar/test-utils.d.ts +56 -0
  46. package/bpk-component-calendar/test-utils.js +2 -2
  47. package/bpk-component-card/index.d.ts +24 -0
  48. package/bpk-component-card/src/BpkCard.d.ts +39 -0
  49. package/bpk-component-card/src/BpkCard.js +9 -25
  50. package/bpk-component-card/src/BpkCardWrapper.d.ts +33 -0
  51. package/bpk-component-card/src/BpkCardWrapper.js +10 -18
  52. package/bpk-component-card/src/BpkDividedCard.d.ts +43 -0
  53. package/bpk-component-card/src/BpkDividedCard.js +9 -24
  54. package/bpk-component-chip/index.d.ts +32 -0
  55. package/bpk-component-chip/src/BpkDismissibleChip.d.ts +28 -0
  56. package/bpk-component-chip/src/BpkDismissibleChip.js +9 -8
  57. package/bpk-component-chip/src/BpkDropdownChip.d.ts +29 -0
  58. package/bpk-component-chip/src/BpkDropdownChip.js +39 -25
  59. package/bpk-component-chip/src/BpkSelectableChip.d.ts +39 -0
  60. package/bpk-component-chip/src/BpkSelectableChip.js +33 -48
  61. package/bpk-component-chip/src/commonTypes.d.ts +56 -0
  62. package/bpk-component-chip/src/commonTypes.js +8 -2
  63. package/bpk-component-dialog/src/BpkDialog.d.ts +1 -12
  64. package/bpk-component-dialog/src/BpkDialog.js +1 -2
  65. package/bpk-component-dialog/src/BpkDialogInner.d.ts +256 -2
  66. package/bpk-component-dialog/src/BpkDialogInner.js +0 -4
  67. package/bpk-component-dialog/src/common-types.d.ts +20 -21
  68. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -4
  69. package/bpk-component-icon/src/classNameModifierHOCFactory.js +0 -1
  70. package/bpk-component-icon/src/withAlignment.js +1 -1
  71. package/bpk-component-icon/src/withDescription.js +1 -1
  72. package/bpk-component-icon/src/withRtlSupport.js +0 -2
  73. package/bpk-component-input/index.d.ts +39 -0
  74. package/bpk-component-input/src/BpkClearButton.d.ts +28 -0
  75. package/bpk-component-input/src/BpkClearButton.js +6 -14
  76. package/bpk-component-input/src/BpkInput.d.ts +46 -0
  77. package/bpk-component-input/src/BpkInput.js +7 -3
  78. package/bpk-component-input/src/common-types.d.ts +91 -0
  79. package/bpk-component-input/src/common-types.js +4 -1
  80. package/bpk-component-input/src/withOpenEvents.d.ts +121 -0
  81. package/bpk-component-input/src/withOpenEvents.js +14 -25
  82. package/bpk-component-modal/index.d.ts +26 -0
  83. package/bpk-component-modal/index.js +13 -6
  84. package/bpk-component-modal/src/BpkModal.d.ts +32 -0
  85. package/bpk-component-modal/src/BpkModal.js +24 -44
  86. package/bpk-component-modal/src/BpkModalInner.d.ts +39 -0
  87. package/bpk-component-modal/src/BpkModalInner.js +67 -84
  88. package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +18 -0
  89. package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +35 -0
  90. package/bpk-component-modal/src/BpkModalV2/BpkModal.js +131 -0
  91. package/bpk-component-modal/src/legacy-prop-types.js +86 -0
  92. package/bpk-component-modal/src/themeAttributes.js +1 -0
  93. package/bpk-component-rtl-toggle/index.d.ts +23 -0
  94. package/bpk-component-rtl-toggle/src/BpkRtlToggle.d.ts +41 -0
  95. package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +9 -12
  96. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.d.ts +151 -0
  97. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.js +9 -2
  98. package/bpk-component-rtl-toggle/src/utils.d.ts +25 -0
  99. package/bpk-component-text/index.d.ts +21 -0
  100. package/bpk-component-text/index.js +0 -6
  101. package/bpk-component-text/src/BpkText.d.ts +60 -0
  102. package/bpk-component-text/src/BpkText.js +16 -56
  103. package/bpk-component-text/src/BpkText.module.css +1 -1
  104. package/bpk-component-tooltip/index.d.ts +24 -0
  105. package/bpk-component-tooltip/src/BpkTooltip.d.ts +29 -0
  106. package/bpk-component-tooltip/src/BpkTooltip.js +9 -26
  107. package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +60 -0
  108. package/bpk-component-tooltip/src/BpkTooltipPortal.js +13 -21
  109. package/bpk-component-tooltip/src/constants.d.ts +31 -0
  110. package/bpk-component-tooltip/src/constants.js +3 -1
  111. package/bpk-react-utils/index.d.ts +58 -0
  112. package/bpk-react-utils/index.js +1 -0
  113. package/bpk-react-utils/src/Portal.d.ts +76 -0
  114. package/bpk-react-utils/src/Portal.js +33 -43
  115. package/bpk-react-utils/src/TransitionInitialMount.d.ts +27 -0
  116. package/bpk-react-utils/src/TransitionInitialMount.js +7 -8
  117. package/bpk-react-utils/src/cssModules.d.ts +22 -0
  118. package/bpk-react-utils/src/deprecated.js +2 -1
  119. package/bpk-react-utils/src/deviceDetection.d.ts +22 -0
  120. package/bpk-react-utils/src/deviceDetection.js +3 -1
  121. package/bpk-react-utils/src/isRTL.d.ts +20 -0
  122. package/bpk-react-utils/src/isRTL.js +3 -1
  123. package/bpk-react-utils/src/withDefaultProps.d.ts +33 -0
  124. package/bpk-react-utils/src/withDefaultProps.js +11 -24
  125. package/bpk-react-utils/src/wrapDisplayName.d.ts +21 -0
  126. package/bpk-scrim-utils/index.d.ts +283 -0
  127. package/bpk-scrim-utils/src/BpkScrim.d.ts +24 -0
  128. package/bpk-scrim-utils/src/BpkScrim.js +5 -10
  129. package/bpk-scrim-utils/src/scroll-utils.d.ts +24 -0
  130. package/bpk-scrim-utils/src/scroll-utils.js +1 -1
  131. package/bpk-scrim-utils/src/withScrim.d.ts +96 -0
  132. package/bpk-scrim-utils/src/withScrim.js +5 -12
  133. package/package.json +1 -1
@@ -0,0 +1,464 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import type { ComponentType } from 'react';
20
+ import type { SelectionConfiguration } from './custom-proptypes';
21
+ type Props = {
22
+ fixedWidth: boolean;
23
+ maxDate: Date;
24
+ minDate: Date;
25
+ onDateSelect?: ((date: Date, newDate?: Date) => void) | null;
26
+ onMonthChange?: ((event: UIEvent, { month, source }: {
27
+ month: Date;
28
+ source: string;
29
+ }) => void) | null;
30
+ selectionConfiguration: SelectionConfiguration;
31
+ initiallyFocusedDate: Date | null;
32
+ };
33
+ type InjectedProps = {
34
+ onDateClick: ((date: Date) => void) | null;
35
+ onDateKeyDown: ((event: KeyboardEvent) => void) | null;
36
+ month: Date;
37
+ };
38
+ type CalendarProps<P> = Omit<P & Props, keyof InjectedProps>;
39
+ type State = {
40
+ preventKeyboardFocus: boolean;
41
+ focusedDate: Date;
42
+ };
43
+ declare const withCalendarState: <P extends {}>(Calendar: ComponentType<P & InjectedProps>) => {
44
+ new (props: CalendarProps<P>): {
45
+ UNSAFE_componentWillReceiveProps(nextProps: CalendarProps<P>): void;
46
+ handleDateFocus: (event: UIEvent, { date, source }: {
47
+ date: Date;
48
+ source: string;
49
+ }) => void;
50
+ handleDateSelect: (date: Date) => void;
51
+ handleMonthChange: (event: UIEvent, { month, source }: {
52
+ month: Date;
53
+ source: string;
54
+ }) => void;
55
+ handleDateKeyDown: (event: KeyboardEvent) => void;
56
+ render(): JSX.Element;
57
+ context: any;
58
+ setState<K extends keyof State>(state: State | ((prevState: Readonly<State>, props: Readonly<CalendarProps<P>>) => State | Pick<State, K> | null) | Pick<State, K> | null, callback?: (() => void) | undefined): void;
59
+ forceUpdate(callback?: (() => void) | undefined): void;
60
+ readonly props: Readonly<CalendarProps<P>> & Readonly<{
61
+ children?: import("react").ReactNode;
62
+ }>;
63
+ state: Readonly<State>;
64
+ refs: {
65
+ [key: string]: import("react").ReactInstance;
66
+ };
67
+ componentDidMount?(): void;
68
+ shouldComponentUpdate?(nextProps: Readonly<CalendarProps<P>>, nextState: Readonly<State>, nextContext: any): boolean;
69
+ componentWillUnmount?(): void;
70
+ componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
71
+ getSnapshotBeforeUpdate?(prevProps: Readonly<CalendarProps<P>>, prevState: Readonly<State>): any;
72
+ componentDidUpdate?(prevProps: Readonly<CalendarProps<P>>, prevState: Readonly<State>, snapshot?: any): void;
73
+ componentWillMount?(): void;
74
+ UNSAFE_componentWillMount?(): void;
75
+ componentWillReceiveProps?(nextProps: Readonly<CalendarProps<P>>, nextContext: any): void;
76
+ componentWillUpdate?(nextProps: Readonly<CalendarProps<P>>, nextState: Readonly<State>, nextContext: any): void;
77
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<CalendarProps<P>>, nextState: Readonly<State>, nextContext: any): void;
78
+ };
79
+ defaultProps: {
80
+ fixedWidth: boolean;
81
+ maxDate: Date;
82
+ minDate: Date;
83
+ onDateSelect: null;
84
+ onMonthChange: null;
85
+ selectionConfiguration: {
86
+ type: "single";
87
+ date: null;
88
+ };
89
+ initiallyFocusedDate: null;
90
+ };
91
+ contextType?: import("react").Context<any> | undefined;
92
+ };
93
+ declare const _default: {
94
+ new (props: CalendarProps<{
95
+ changeMonthLabel?: string | null | undefined;
96
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
97
+ formatDateFull: (date: Date) => string | Date;
98
+ formatMonth: (date: Date) => string | Date;
99
+ id: string;
100
+ maxDate: Date;
101
+ minDate: Date;
102
+ month: Date;
103
+ nextMonthLabel?: string | null | undefined;
104
+ previousMonthLabel?: string | null | undefined;
105
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
106
+ className?: string | null | undefined;
107
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
108
+ fixedWidth?: boolean | undefined;
109
+ focusedDate?: Date | null | undefined;
110
+ markOutsideDays?: boolean | undefined;
111
+ markToday?: boolean | undefined;
112
+ onMonthChange?: ((event: UIEvent, { month, source }: {
113
+ month: Date;
114
+ source: string;
115
+ }) => void) | null | undefined;
116
+ onDateClick?: ((date: Date) => void) | null | undefined;
117
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
118
+ preventKeyboardFocus?: boolean | undefined;
119
+ selectionConfiguration?: SelectionConfiguration | undefined;
120
+ gridClassName?: string | null | undefined;
121
+ weekDayKey?: string | undefined;
122
+ navProps?: {} | null | undefined;
123
+ headerProps?: {} | null | undefined;
124
+ gridProps?: {} | null | undefined;
125
+ dateProps?: {} | null | undefined;
126
+ }>): {
127
+ UNSAFE_componentWillReceiveProps(nextProps: CalendarProps<{
128
+ changeMonthLabel?: string | null | undefined;
129
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
130
+ formatDateFull: (date: Date) => string | Date;
131
+ formatMonth: (date: Date) => string | Date;
132
+ id: string;
133
+ maxDate: Date;
134
+ minDate: Date;
135
+ month: Date;
136
+ nextMonthLabel?: string | null | undefined;
137
+ previousMonthLabel?: string | null | undefined;
138
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
139
+ className?: string | null | undefined;
140
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
141
+ fixedWidth?: boolean | undefined;
142
+ focusedDate?: Date | null | undefined;
143
+ markOutsideDays?: boolean | undefined;
144
+ markToday?: boolean | undefined;
145
+ onMonthChange?: ((event: UIEvent, { month, source }: {
146
+ month: Date;
147
+ source: string;
148
+ }) => void) | null | undefined;
149
+ onDateClick?: ((date: Date) => void) | null | undefined;
150
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
151
+ preventKeyboardFocus?: boolean | undefined;
152
+ selectionConfiguration?: SelectionConfiguration | undefined;
153
+ gridClassName?: string | null | undefined;
154
+ weekDayKey?: string | undefined;
155
+ navProps?: {} | null | undefined;
156
+ headerProps?: {} | null | undefined;
157
+ gridProps?: {} | null | undefined;
158
+ dateProps?: {} | null | undefined;
159
+ }>): void;
160
+ handleDateFocus: (event: UIEvent, { date, source }: {
161
+ date: Date;
162
+ source: string;
163
+ }) => void;
164
+ handleDateSelect: (date: Date) => void;
165
+ handleMonthChange: (event: UIEvent, { month, source }: {
166
+ month: Date;
167
+ source: string;
168
+ }) => void;
169
+ handleDateKeyDown: (event: KeyboardEvent) => void;
170
+ render(): JSX.Element;
171
+ context: any;
172
+ setState<K extends keyof State>(state: State | ((prevState: Readonly<State>, props: Readonly<CalendarProps<{
173
+ changeMonthLabel?: string | null | undefined;
174
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
175
+ formatDateFull: (date: Date) => string | Date;
176
+ formatMonth: (date: Date) => string | Date;
177
+ id: string;
178
+ maxDate: Date;
179
+ minDate: Date;
180
+ month: Date;
181
+ nextMonthLabel?: string | null | undefined;
182
+ previousMonthLabel?: string | null | undefined;
183
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
184
+ className?: string | null | undefined;
185
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
186
+ fixedWidth?: boolean | undefined;
187
+ focusedDate?: Date | null | undefined;
188
+ markOutsideDays?: boolean | undefined;
189
+ markToday?: boolean | undefined;
190
+ onMonthChange?: ((event: UIEvent, { month, source }: {
191
+ month: Date;
192
+ source: string;
193
+ }) => void) | null | undefined;
194
+ onDateClick?: ((date: Date) => void) | null | undefined;
195
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
196
+ preventKeyboardFocus?: boolean | undefined;
197
+ selectionConfiguration?: SelectionConfiguration | undefined;
198
+ gridClassName?: string | null | undefined;
199
+ weekDayKey?: string | undefined;
200
+ navProps?: {} | null | undefined;
201
+ headerProps?: {} | null | undefined;
202
+ gridProps?: {} | null | undefined;
203
+ dateProps?: {} | null | undefined;
204
+ }>>) => State | Pick<State, K> | null) | Pick<State, K> | null, callback?: (() => void) | undefined): void;
205
+ forceUpdate(callback?: (() => void) | undefined): void;
206
+ readonly props: Readonly<CalendarProps<{
207
+ changeMonthLabel?: string | null | undefined;
208
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
209
+ formatDateFull: (date: Date) => string | Date;
210
+ formatMonth: (date: Date) => string | Date;
211
+ id: string;
212
+ maxDate: Date;
213
+ minDate: Date;
214
+ month: Date;
215
+ nextMonthLabel?: string | null | undefined;
216
+ previousMonthLabel?: string | null | undefined;
217
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
218
+ className?: string | null | undefined;
219
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
220
+ fixedWidth?: boolean | undefined;
221
+ focusedDate?: Date | null | undefined;
222
+ markOutsideDays?: boolean | undefined;
223
+ markToday?: boolean | undefined;
224
+ onMonthChange?: ((event: UIEvent, { month, source }: {
225
+ month: Date;
226
+ source: string;
227
+ }) => void) | null | undefined;
228
+ onDateClick?: ((date: Date) => void) | null | undefined;
229
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
230
+ preventKeyboardFocus?: boolean | undefined;
231
+ selectionConfiguration?: SelectionConfiguration | undefined;
232
+ gridClassName?: string | null | undefined;
233
+ weekDayKey?: string | undefined;
234
+ navProps?: {} | null | undefined;
235
+ headerProps?: {} | null | undefined;
236
+ gridProps?: {} | null | undefined;
237
+ dateProps?: {} | null | undefined;
238
+ }>> & Readonly<{
239
+ children?: import("react").ReactNode;
240
+ }>;
241
+ state: Readonly<State>;
242
+ refs: {
243
+ [key: string]: import("react").ReactInstance;
244
+ };
245
+ componentDidMount?(): void;
246
+ shouldComponentUpdate?(nextProps: Readonly<CalendarProps<{
247
+ changeMonthLabel?: string | null | undefined;
248
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
249
+ formatDateFull: (date: Date) => string | Date;
250
+ formatMonth: (date: Date) => string | Date;
251
+ id: string;
252
+ maxDate: Date;
253
+ minDate: Date;
254
+ month: Date;
255
+ nextMonthLabel?: string | null | undefined;
256
+ previousMonthLabel?: string | null | undefined;
257
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
258
+ className?: string | null | undefined;
259
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
260
+ fixedWidth?: boolean | undefined;
261
+ focusedDate?: Date | null | undefined;
262
+ markOutsideDays?: boolean | undefined;
263
+ markToday?: boolean | undefined;
264
+ onMonthChange?: ((event: UIEvent, { month, source }: {
265
+ month: Date;
266
+ source: string;
267
+ }) => void) | null | undefined;
268
+ onDateClick?: ((date: Date) => void) | null | undefined;
269
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
270
+ preventKeyboardFocus?: boolean | undefined;
271
+ selectionConfiguration?: SelectionConfiguration | undefined;
272
+ gridClassName?: string | null | undefined;
273
+ weekDayKey?: string | undefined;
274
+ navProps?: {} | null | undefined;
275
+ headerProps?: {} | null | undefined;
276
+ gridProps?: {} | null | undefined;
277
+ dateProps?: {} | null | undefined;
278
+ }>>, nextState: Readonly<State>, nextContext: any): boolean;
279
+ componentWillUnmount?(): void;
280
+ componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
281
+ getSnapshotBeforeUpdate?(prevProps: Readonly<CalendarProps<{
282
+ changeMonthLabel?: string | null | undefined;
283
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
284
+ formatDateFull: (date: Date) => string | Date;
285
+ formatMonth: (date: Date) => string | Date;
286
+ id: string;
287
+ maxDate: Date;
288
+ minDate: Date;
289
+ month: Date;
290
+ nextMonthLabel?: string | null | undefined;
291
+ previousMonthLabel?: string | null | undefined;
292
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
293
+ className?: string | null | undefined;
294
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
295
+ fixedWidth?: boolean | undefined;
296
+ focusedDate?: Date | null | undefined;
297
+ markOutsideDays?: boolean | undefined;
298
+ markToday?: boolean | undefined;
299
+ onMonthChange?: ((event: UIEvent, { month, source }: {
300
+ month: Date;
301
+ source: string;
302
+ }) => void) | null | undefined;
303
+ onDateClick?: ((date: Date) => void) | null | undefined;
304
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
305
+ preventKeyboardFocus?: boolean | undefined;
306
+ selectionConfiguration?: SelectionConfiguration | undefined;
307
+ gridClassName?: string | null | undefined;
308
+ weekDayKey?: string | undefined;
309
+ navProps?: {} | null | undefined;
310
+ headerProps?: {} | null | undefined;
311
+ gridProps?: {} | null | undefined;
312
+ dateProps?: {} | null | undefined;
313
+ }>>, prevState: Readonly<State>): any;
314
+ componentDidUpdate?(prevProps: Readonly<CalendarProps<{
315
+ changeMonthLabel?: string | null | undefined;
316
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
317
+ formatDateFull: (date: Date) => string | Date;
318
+ formatMonth: (date: Date) => string | Date;
319
+ id: string;
320
+ maxDate: Date;
321
+ minDate: Date;
322
+ month: Date;
323
+ nextMonthLabel?: string | null | undefined;
324
+ previousMonthLabel?: string | null | undefined;
325
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
326
+ className?: string | null | undefined;
327
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
328
+ fixedWidth?: boolean | undefined;
329
+ focusedDate?: Date | null | undefined;
330
+ markOutsideDays?: boolean | undefined;
331
+ markToday?: boolean | undefined;
332
+ onMonthChange?: ((event: UIEvent, { month, source }: {
333
+ month: Date;
334
+ source: string;
335
+ }) => void) | null | undefined;
336
+ onDateClick?: ((date: Date) => void) | null | undefined;
337
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
338
+ preventKeyboardFocus?: boolean | undefined;
339
+ selectionConfiguration?: SelectionConfiguration | undefined;
340
+ gridClassName?: string | null | undefined;
341
+ weekDayKey?: string | undefined;
342
+ navProps?: {} | null | undefined;
343
+ headerProps?: {} | null | undefined;
344
+ gridProps?: {} | null | undefined;
345
+ dateProps?: {} | null | undefined;
346
+ }>>, prevState: Readonly<State>, snapshot?: any): void;
347
+ componentWillMount?(): void;
348
+ UNSAFE_componentWillMount?(): void;
349
+ componentWillReceiveProps?(nextProps: Readonly<CalendarProps<{
350
+ changeMonthLabel?: string | null | undefined;
351
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
352
+ formatDateFull: (date: Date) => string | Date;
353
+ formatMonth: (date: Date) => string | Date;
354
+ id: string;
355
+ maxDate: Date;
356
+ minDate: Date;
357
+ month: Date;
358
+ nextMonthLabel?: string | null | undefined;
359
+ previousMonthLabel?: string | null | undefined;
360
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
361
+ className?: string | null | undefined;
362
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
363
+ fixedWidth?: boolean | undefined;
364
+ focusedDate?: Date | null | undefined;
365
+ markOutsideDays?: boolean | undefined;
366
+ markToday?: boolean | undefined;
367
+ onMonthChange?: ((event: UIEvent, { month, source }: {
368
+ month: Date;
369
+ source: string;
370
+ }) => void) | null | undefined;
371
+ onDateClick?: ((date: Date) => void) | null | undefined;
372
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
373
+ preventKeyboardFocus?: boolean | undefined;
374
+ selectionConfiguration?: SelectionConfiguration | undefined;
375
+ gridClassName?: string | null | undefined;
376
+ weekDayKey?: string | undefined;
377
+ navProps?: {} | null | undefined;
378
+ headerProps?: {} | null | undefined;
379
+ gridProps?: {} | null | undefined;
380
+ dateProps?: {} | null | undefined;
381
+ }>>, nextContext: any): void;
382
+ componentWillUpdate?(nextProps: Readonly<CalendarProps<{
383
+ changeMonthLabel?: string | null | undefined;
384
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
385
+ formatDateFull: (date: Date) => string | Date;
386
+ formatMonth: (date: Date) => string | Date;
387
+ id: string;
388
+ maxDate: Date;
389
+ minDate: Date;
390
+ month: Date;
391
+ nextMonthLabel?: string | null | undefined;
392
+ previousMonthLabel?: string | null | undefined;
393
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
394
+ className?: string | null | undefined;
395
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
396
+ fixedWidth?: boolean | undefined;
397
+ focusedDate?: Date | null | undefined;
398
+ markOutsideDays?: boolean | undefined;
399
+ markToday?: boolean | undefined;
400
+ onMonthChange?: ((event: UIEvent, { month, source }: {
401
+ month: Date;
402
+ source: string;
403
+ }) => void) | null | undefined;
404
+ onDateClick?: ((date: Date) => void) | null | undefined;
405
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
406
+ preventKeyboardFocus?: boolean | undefined;
407
+ selectionConfiguration?: SelectionConfiguration | undefined;
408
+ gridClassName?: string | null | undefined;
409
+ weekDayKey?: string | undefined;
410
+ navProps?: {} | null | undefined;
411
+ headerProps?: {} | null | undefined;
412
+ gridProps?: {} | null | undefined;
413
+ dateProps?: {} | null | undefined;
414
+ }>>, nextState: Readonly<State>, nextContext: any): void;
415
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<CalendarProps<{
416
+ changeMonthLabel?: string | null | undefined;
417
+ daysOfWeek: import("./custom-proptypes").DaysOfWeek;
418
+ formatDateFull: (date: Date) => string | Date;
419
+ formatMonth: (date: Date) => string | Date;
420
+ id: string;
421
+ maxDate: Date;
422
+ minDate: Date;
423
+ month: Date;
424
+ nextMonthLabel?: string | null | undefined;
425
+ previousMonthLabel?: string | null | undefined;
426
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
427
+ className?: string | null | undefined;
428
+ dateModifiers?: import("./custom-proptypes").DateModifiers | undefined;
429
+ fixedWidth?: boolean | undefined;
430
+ focusedDate?: Date | null | undefined;
431
+ markOutsideDays?: boolean | undefined;
432
+ markToday?: boolean | undefined;
433
+ onMonthChange?: ((event: UIEvent, { month, source }: {
434
+ month: Date;
435
+ source: string;
436
+ }) => void) | null | undefined;
437
+ onDateClick?: ((date: Date) => void) | null | undefined;
438
+ onDateKeyDown?: ((event: KeyboardEvent) => void) | null | undefined;
439
+ preventKeyboardFocus?: boolean | undefined;
440
+ selectionConfiguration?: SelectionConfiguration | undefined;
441
+ gridClassName?: string | null | undefined;
442
+ weekDayKey?: string | undefined;
443
+ navProps?: {} | null | undefined;
444
+ headerProps?: {} | null | undefined;
445
+ gridProps?: {} | null | undefined;
446
+ dateProps?: {} | null | undefined;
447
+ }>>, nextState: Readonly<State>, nextContext: any): void;
448
+ };
449
+ defaultProps: {
450
+ fixedWidth: boolean;
451
+ maxDate: Date;
452
+ minDate: Date;
453
+ onDateSelect: null;
454
+ onMonthChange: null;
455
+ selectionConfiguration: {
456
+ type: "single";
457
+ date: null;
458
+ };
459
+ initiallyFocusedDate: null;
460
+ };
461
+ contextType?: import("react").Context<any> | undefined;
462
+ };
463
+ export default _default;
464
+ export { withCalendarState };
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.withCalendarState = exports.default = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
8
7
  var _react = require("react");
9
8
  var _bpkReactUtils = require("../../bpk-react-utils");
10
- var _customProptypes = _interopRequireWildcard(require("./custom-proptypes"));
9
+ var _customProptypes = require("./custom-proptypes");
11
10
  var _BpkCalendarNav = _interopRequireDefault(require("./BpkCalendarNav"));
12
11
  var _BpkCalendarGrid = require("./BpkCalendarGrid");
13
12
  var _BpkCalendarGridHeader = _interopRequireDefault(require("./BpkCalendarGridHeader"));
@@ -15,9 +14,7 @@ var _BpkCalendarDate = _interopRequireDefault(require("./BpkCalendarDate"));
15
14
  var _composeCalendar = _interopRequireDefault(require("./composeCalendar"));
16
15
  var _dateUtils = require("./date-utils");
17
16
  var _jsxRuntime = require("react/jsx-runtime");
18
- const _excluded = ["maxDate", "minDate", "selectionConfiguration"];
19
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+ const _excluded = ["maxDate", "minDate", "onDateSelect", "onMonthChange", "selectionConfiguration"];
21
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
19
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -41,23 +38,26 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
41
38
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
39
  * See the License for the specific language governing permissions and
43
40
  * limitations under the License.
44
- */ /**
45
- * Updates the current focused date
46
- * @param {Object} currentProps current input properties
47
- * @param {Object} nextProps next input properties when component changes
48
- * @returns {Boolean} if the selected date has changed
49
- */
41
+ */
42
+ /**
43
+ * Updates the current focused date
44
+ * @param {Object} currentProps current input properties
45
+ * @param {Object} nextProps next input properties when component changes
46
+ * @returns {Boolean} if the selected date has changed
47
+ */
50
48
  const focusedDateHasChanged = (currentProps, nextProps) => {
51
49
  const currentSelectConfig = currentProps.selectionConfiguration;
52
50
  const nextSelectConfig = nextProps.selectionConfiguration;
53
- const rawNextSelectedDate = nextSelectConfig.date || nextSelectConfig.startDate;
54
- const rawSelectedDate = currentSelectConfig.date || currentSelectConfig.startDate;
51
+ const rawNextSelectedDate = nextSelectConfig.type === _customProptypes.CALENDAR_SELECTION_TYPE.single ? nextSelectConfig.date : nextSelectConfig.startDate;
52
+ const rawSelectedDate = currentSelectConfig.type === _customProptypes.CALENDAR_SELECTION_TYPE.single ? currentSelectConfig.date : currentSelectConfig.startDate;
55
53
  if (!rawSelectedDate && !rawNextSelectedDate) {
56
54
  return false;
57
55
  }
58
56
  if (rawSelectedDate && !rawNextSelectedDate || !rawSelectedDate && rawNextSelectedDate) {
59
57
  return true;
60
58
  }
59
+
60
+ // @ts-expect-error TS reporting incorrectly as we are already checking above that the dates are not null
61
61
  return !(0, _dateUtils.isSameDay)(rawNextSelectedDate, rawSelectedDate);
62
62
  };
63
63
 
@@ -153,7 +153,6 @@ const withCalendarState = Calendar => {
153
153
  });
154
154
  });
155
155
  _defineProperty(this, "handleDateKeyDown", event => {
156
- event.persist();
157
156
  const reverse = (0, _bpkReactUtils.isRTL)() ? -1 : 1;
158
157
  const {
159
158
  focusedDate
@@ -243,20 +242,20 @@ const withCalendarState = Calendar => {
243
242
  {
244
243
  maxDate,
245
244
  minDate,
245
+ onDateSelect,
246
+ onMonthChange,
246
247
  selectionConfiguration
247
248
  } = _this$props,
248
249
  calendarProps = _objectWithoutProperties(_this$props, _excluded);
249
- delete calendarProps.onDateSelect;
250
- delete calendarProps.onMonthChange;
251
250
  const sanitisedMinDate = (0, _dateUtils.startOfDay)(minDate);
252
251
  const sanitisedMaxDate = (0, _dateUtils.startOfDay)(maxDate);
253
252
  const sanitisedFocusedDate = (0, _dateUtils.dateToBoundaries)(this.state.focusedDate, sanitisedMinDate, sanitisedMaxDate);
254
253
  const month = (0, _dateUtils.startOfMonth)(sanitisedFocusedDate);
255
254
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Calendar, _objectSpread(_objectSpread({
256
- onDateClick: this.handleDateSelect,
257
- onDateKeyDown: this.handleDateKeyDown,
258
255
  onMonthChange: this.handleMonthChange,
256
+ onDateClick: this.handleDateSelect,
259
257
  month: month,
258
+ onDateKeyDown: this.handleDateKeyDown,
260
259
  preventKeyboardFocus: this.state.preventKeyboardFocus,
261
260
  focusedDate: sanitisedFocusedDate
262
261
  }, calendarProps), {}, {
@@ -266,16 +265,7 @@ const withCalendarState = Calendar => {
266
265
  }));
267
266
  }
268
267
  }
269
- BpkCalendarContainer.propTypes = {
270
- fixedWidth: _propTypes.default.bool,
271
- maxDate: _propTypes.default.instanceOf(Date),
272
- minDate: _propTypes.default.instanceOf(Date),
273
- onDateSelect: _propTypes.default.func,
274
- onMonthChange: _propTypes.default.func,
275
- selectionConfiguration: _customProptypes.default.SelectionConfiguration,
276
- initiallyFocusedDate: _propTypes.default.instanceOf(Date)
277
- };
278
- BpkCalendarContainer.defaultProps = {
268
+ _defineProperty(BpkCalendarContainer, "defaultProps", {
279
269
  fixedWidth: true,
280
270
  maxDate: (0, _dateUtils.addMonths)(new Date(), 12),
281
271
  minDate: new Date(),
@@ -286,7 +276,7 @@ const withCalendarState = Calendar => {
286
276
  date: null
287
277
  },
288
278
  initiallyFocusedDate: null
289
- };
279
+ });
290
280
  return BpkCalendarContainer;
291
281
  };
292
282
  exports.withCalendarState = withCalendarState;
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import type { KeyboardEvent } from 'react';
20
+ import { PureComponent } from 'react';
21
+ import type { DateModifiers } from './custom-proptypes';
22
+ export declare const SELECTION_TYPES: {
23
+ readonly none: "none";
24
+ readonly single: "single";
25
+ readonly start: "start";
26
+ readonly middle: "middle";
27
+ readonly end: "end";
28
+ readonly sameDay: "sameDay";
29
+ };
30
+ export declare const ROW_TYPES: {
31
+ readonly start: "start";
32
+ readonly middle: "middle";
33
+ readonly end: "end";
34
+ readonly both: "both";
35
+ };
36
+ export type SelectionTypes = typeof SELECTION_TYPES[keyof typeof SELECTION_TYPES];
37
+ export type Props = DefaultProps & {
38
+ date: Date;
39
+ };
40
+ type DefaultProps = {
41
+ className: string | null;
42
+ isBlocked: boolean;
43
+ isFocused: boolean;
44
+ isKeyboardFocusable: boolean;
45
+ isOutside: boolean;
46
+ isSelected: boolean;
47
+ isToday: boolean;
48
+ modifiers: DateModifiers;
49
+ onClick: ((date: Date) => void) | null;
50
+ onDateKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;
51
+ preventKeyboardFocus?: boolean;
52
+ selectionType: SelectionTypes;
53
+ style: {};
54
+ };
55
+ declare class BpkCalendarDate extends PureComponent<Props> {
56
+ static defaultProps: DefaultProps;
57
+ componentDidMount(): void;
58
+ componentDidUpdate(prevProps: Props): void;
59
+ button: HTMLButtonElement | null;
60
+ render(): JSX.Element;
61
+ }
62
+ export default BpkCalendarDate;