@skyscanner/backpack-web 36.13.0 → 36.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +5 -0
- package/bpk-component-calendar/src/BpkCalendarGrid.js +4 -1
- package/bpk-component-info-banner/src/BpkInfoBanner.module.css +1 -1
- package/bpk-component-info-banner/src/BpkInfoBannerInner.js +17 -28
- 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, {
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-info-banner{padding:.5rem 1rem;overflow:hidden;border-radius:.5rem;margin:0;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner--style-default{background-color:#eff3f8}.bpk-info-banner--style-onContrast{background-color:#fff}.bpk-info-banner__header{display:flex;flex-direction:row;align-items:flex-start}.bpk-info-banner__header--expandable{cursor:pointer}.bpk-info-banner__icon,.bpk-info-banner__toggle{padding:.125rem 0}.bpk-info-banner__message{padding:.25rem .5rem;flex-grow:1}.bpk-info-banner__success-icon{fill:#0c838a}.bpk-info-banner__warning-icon{fill:#f55d42}.bpk-info-banner__error-icon{fill:#e70866}.bpk-info-banner__info-icon{fill:#626971}.bpk-info-banner__toggle-button{padding:0;border:0;background-color:rgba(0,0,0,0);cursor:pointer;appearance:none
|
|
18
|
+
.bpk-info-banner{padding:.5rem 1rem;overflow:hidden;border-radius:.5rem;margin:0;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner--style-default{background-color:#eff3f8}.bpk-info-banner--style-onContrast{background-color:#fff}.bpk-info-banner__header{display:flex;flex-direction:row;align-items:flex-start}.bpk-info-banner__header--expandable{width:100%;padding:0;border:none;background-color:rgba(0,0,0,0);text-align:start;cursor:pointer}.bpk-info-banner__icon,.bpk-info-banner__toggle{padding:.125rem 0}.bpk-info-banner__message{padding:.25rem .5rem;flex-grow:1}.bpk-info-banner__success-icon{fill:#0c838a}.bpk-info-banner__warning-icon{fill:#f55d42}.bpk-info-banner__error-icon{fill:#e70866}.bpk-info-banner__info-icon{fill:#626971}.bpk-info-banner__toggle-button{padding:0;border:0;background-color:rgba(0,0,0,0);cursor:pointer;appearance:none;fill:#626971}.bpk-info-banner__children-container{color:#161616;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner__children-container--with-action{padding:.25rem 0 .25rem}.bpk-info-banner__children-container--no-action{padding:.25rem 0 .5rem}
|
|
@@ -67,20 +67,13 @@ const getIconForType = (type, CustomIcon) => {
|
|
|
67
67
|
children: /*#__PURE__*/_jsx(AlignedIcon, {})
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
|
-
const ToggleButton = props => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
title: props.label,
|
|
78
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
79
|
-
className: classNames,
|
|
80
|
-
children: props.expanded ? /*#__PURE__*/_jsx(CollapseIcon, {}) : /*#__PURE__*/_jsx(ExpandIcon, {})
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
};
|
|
70
|
+
const ToggleButton = props => /*#__PURE__*/_jsxs("div", {
|
|
71
|
+
className: getClassName('bpk-info-banner__toggle-button'),
|
|
72
|
+
children: [props.expanded ? /*#__PURE__*/_jsx(CollapseIcon, {}) : /*#__PURE__*/_jsx(ExpandIcon, {}), /*#__PURE__*/_jsx("span", {
|
|
73
|
+
className: "visually-hidden",
|
|
74
|
+
children: props.label
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
84
77
|
const BpkInfoBannerInner = ({
|
|
85
78
|
action = null,
|
|
86
79
|
animateOnEnter = false,
|
|
@@ -113,26 +106,23 @@ const BpkInfoBannerInner = ({
|
|
|
113
106
|
const isExpandable = configuration === CONFIGURATION.EXPANDABLE;
|
|
114
107
|
const dismissable = configuration === CONFIGURATION.DISMISSABLE;
|
|
115
108
|
const showChildren = isExpandable && expanded;
|
|
116
|
-
const
|
|
109
|
+
const classNames = getClassName('bpk-info-banner', `bpk-info-banner--${type}`, `bpk-info-banner--style-${style}`, bannerClassName && bannerClassName);
|
|
117
110
|
const headerClassNames = getClassName('bpk-info-banner__header', isExpandable && 'bpk-info-banner__header--expandable');
|
|
118
111
|
const childrenContainerClassName = action && isExpandable ? getClassName('bpk-info-banner__children-container--with-action') : getClassName('bpk-info-banner__children-container--no-action');
|
|
119
|
-
|
|
120
|
-
/* eslint-disable
|
|
121
|
-
jsx-a11y/no-static-element-interactions,
|
|
122
|
-
jsx-a11y/click-events-have-key-events,
|
|
123
|
-
*/
|
|
124
|
-
// Disabling 'click-events-have-key-events and interactive-supports-focus' because header element is not focusable.
|
|
125
|
-
// ToggleButton is focusable and works for this.
|
|
112
|
+
const BannerHeader = isExpandable ? 'button' : 'div';
|
|
126
113
|
return /*#__PURE__*/_jsx(AnimateAndFade, {
|
|
127
114
|
animateOnEnter: animateOnEnter,
|
|
128
115
|
animateOnLeave: dismissable || animateOnLeave,
|
|
129
116
|
show: show,
|
|
130
117
|
...rest,
|
|
131
|
-
children: /*#__PURE__*/_jsxs("
|
|
132
|
-
className:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
118
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
119
|
+
className: classNames,
|
|
120
|
+
children: [/*#__PURE__*/_jsxs(BannerHeader, {
|
|
121
|
+
"aria-expanded": isExpandable ? expanded : undefined,
|
|
122
|
+
type: isExpandable ? 'button' : undefined
|
|
123
|
+
// BannerHeader is just <button> or <div>, so className should be allowed.
|
|
124
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
125
|
+
,
|
|
136
126
|
className: headerClassNames,
|
|
137
127
|
onClick: onBannerExpandToggle,
|
|
138
128
|
children: [/*#__PURE__*/_jsx("span", {
|
|
@@ -168,6 +158,5 @@ const BpkInfoBannerInner = ({
|
|
|
168
158
|
})]
|
|
169
159
|
})
|
|
170
160
|
});
|
|
171
|
-
/* eslint-enable */
|
|
172
161
|
};
|
|
173
162
|
export default BpkInfoBannerInner;
|
|
@@ -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) {
|