@skyscanner/backpack-web 36.13.0 → 36.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +5 -0
- package/bpk-component-calendar/src/BpkCalendarGrid.js +4 -1
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.d.ts +3 -1
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.js +5 -4
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.js +1 -0
- package/package.json +1 -1
|
@@ -13,6 +13,11 @@ type DefaultProps = {
|
|
|
13
13
|
minDate: Date;
|
|
14
14
|
onDateClick: () => void;
|
|
15
15
|
onDateKeyDown: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* A function to format a human-readable month, for example: "January 2018":
|
|
18
|
+
* If you just need to quickly prototype, use the following from [`date-fns`](https://date-fns.org/docs/format#usage)
|
|
19
|
+
*/
|
|
20
|
+
formatMonth: (month: Date) => string;
|
|
16
21
|
preventKeyboardFocus: boolean;
|
|
17
22
|
/**
|
|
18
23
|
* An object to indicate which configuration of the calendar is being used. Choices are `single` date selection or `range` date selection.
|
|
@@ -21,7 +21,7 @@ import { cssModules, isDeviceIos } from "../../bpk-react-utils";
|
|
|
21
21
|
import { addCalendarGridTransition } from "./BpkCalendarGridTransition";
|
|
22
22
|
import BpkCalendarWeek from "./BpkCalendarWeek";
|
|
23
23
|
import { CALENDAR_SELECTION_TYPE } from "./custom-proptypes";
|
|
24
|
-
import { addMonths, getCalendar, getCalendarNoCustomLabel, isSameMonth } from "./date-utils";
|
|
24
|
+
import { addMonths, getCalendar, getCalendarNoCustomLabel, isSameMonth, format } from "./date-utils";
|
|
25
25
|
import STYLES from "./BpkCalendarGrid.module.css";
|
|
26
26
|
|
|
27
27
|
// This should be imported after `./BpkCalendarGrid.module.css`.
|
|
@@ -47,6 +47,7 @@ class BpkCalendarGrid extends Component {
|
|
|
47
47
|
minDate: new Date(),
|
|
48
48
|
onDateClick: () => {},
|
|
49
49
|
onDateKeyDown: () => {},
|
|
50
|
+
formatMonth: month => format(month, 'MMMM yyyy'),
|
|
50
51
|
preventKeyboardFocus: false,
|
|
51
52
|
selectionConfiguration: {
|
|
52
53
|
type: CALENDAR_SELECTION_TYPE.single,
|
|
@@ -84,6 +85,7 @@ class BpkCalendarGrid extends Component {
|
|
|
84
85
|
dateModifiers,
|
|
85
86
|
dateProps,
|
|
86
87
|
focusedDate,
|
|
88
|
+
formatMonth,
|
|
87
89
|
ignoreOutsideDate,
|
|
88
90
|
isKeyboardFocusable,
|
|
89
91
|
markOutsideDays,
|
|
@@ -105,6 +107,7 @@ class BpkCalendarGrid extends Component {
|
|
|
105
107
|
className: classNames,
|
|
106
108
|
"aria-hidden": !isKeyboardFocusable,
|
|
107
109
|
role: "grid",
|
|
110
|
+
"aria-label": formatMonth(month),
|
|
108
111
|
children: /*#__PURE__*/_jsx("div", {
|
|
109
112
|
role: "rowgroup",
|
|
110
113
|
children: calendarMonthWeeks.map(dates => /*#__PURE__*/_jsx(BpkCalendarWeek, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode, ElementType, CSSProperties } from 'react';
|
|
2
2
|
import { Component } from 'react';
|
|
3
|
+
import type { DebouncedFunc } from 'lodash';
|
|
3
4
|
declare const computeScrollBarAwareHeight: (scrollerEl: HTMLElement | null, innerEl: HTMLElement | null) => string | null;
|
|
4
5
|
declare const computeScrollIndicatorClassName: (scrollerEl: HTMLElement | null, leadingIndicatorClassName?: string, trailingIndicatorClassName?: string) => string[] | null;
|
|
5
6
|
type Props = {
|
|
@@ -18,11 +19,12 @@ type State = {
|
|
|
18
19
|
scrollIndicatorClassName: string | null;
|
|
19
20
|
};
|
|
20
21
|
declare class BpkMobileScrollContainer extends Component<Props, State> {
|
|
22
|
+
debouncedResize: DebouncedFunc<() => void>;
|
|
21
23
|
static defaultProps: Partial<Props>;
|
|
22
24
|
constructor(props: Props);
|
|
23
25
|
componentDidMount(): void;
|
|
24
26
|
componentWillUnmount(): void;
|
|
25
|
-
onWindowResize:
|
|
27
|
+
onWindowResize: () => void;
|
|
26
28
|
setScrollIndicatorClassName: () => void;
|
|
27
29
|
setScrollBarAwareHeight: () => void;
|
|
28
30
|
innerEl: HTMLElement | null;
|
|
@@ -62,21 +62,22 @@ class BpkMobileScrollContainer extends Component {
|
|
|
62
62
|
computedHeight: 'auto',
|
|
63
63
|
scrollIndicatorClassName: null
|
|
64
64
|
};
|
|
65
|
+
this.debouncedResize = debounce(this.onWindowResize, 100);
|
|
65
66
|
}
|
|
66
67
|
componentDidMount() {
|
|
67
68
|
requestAnimationFrame(() => {
|
|
68
69
|
this.setScrollBarAwareHeight();
|
|
69
70
|
this.setScrollIndicatorClassName();
|
|
70
71
|
});
|
|
71
|
-
window.addEventListener('resize', this.
|
|
72
|
+
window.addEventListener('resize', this.debouncedResize);
|
|
72
73
|
}
|
|
73
74
|
componentWillUnmount() {
|
|
74
|
-
window.removeEventListener('resize', this.
|
|
75
|
+
window.removeEventListener('resize', this.debouncedResize);
|
|
75
76
|
}
|
|
76
|
-
onWindowResize =
|
|
77
|
+
onWindowResize = () => {
|
|
77
78
|
this.setScrollBarAwareHeight();
|
|
78
79
|
this.setScrollIndicatorClassName();
|
|
79
|
-
}
|
|
80
|
+
};
|
|
80
81
|
setScrollIndicatorClassName = () => {
|
|
81
82
|
const classNames = computeScrollIndicatorClassName(this.scrollerEl, this.props.leadingIndicatorClassName, this.props.trailingIndicatorClassName);
|
|
82
83
|
if (!classNames) {
|