@skyscanner/backpack-web 33.0.0 → 33.2.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-banner-alert/src/BpkBannerAlertInner.js +0 -1
- package/bpk-component-horizontal-nav/src/BpkHorizontalNav.js +5 -1
- package/bpk-component-input/src/withOpenEvents.js +7 -6
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.js +4 -0
- package/bpk-component-navigation-bar/src/BpkNavigationBar.js +9 -11
- package/package.json +1 -1
|
@@ -156,7 +156,6 @@ const BpkBannerAlertInner = ({
|
|
|
156
156
|
}), dismissable && /*#__PURE__*/_jsx("span", {
|
|
157
157
|
className: getClassName('bpk-banner-alert__toggle'),
|
|
158
158
|
children: /*#__PURE__*/_jsx(BpkCloseButton, {
|
|
159
|
-
className: getClassName('bpk-banner-alert__toggle-button'),
|
|
160
159
|
onClick: onBannerDismiss,
|
|
161
160
|
"aria-label": dismissButtonLabel,
|
|
162
161
|
label: dismissButtonLabel
|
|
@@ -78,6 +78,7 @@ class BpkHorizontalNav extends Component {
|
|
|
78
78
|
};
|
|
79
79
|
render() {
|
|
80
80
|
const {
|
|
81
|
+
ariaLabel,
|
|
81
82
|
autoScrollToSelected,
|
|
82
83
|
children: rawChildren,
|
|
83
84
|
className,
|
|
@@ -113,6 +114,7 @@ class BpkHorizontalNav extends Component {
|
|
|
113
114
|
/*#__PURE__*/
|
|
114
115
|
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
|
|
115
116
|
_jsx(BpkMobileScrollContainer, {
|
|
117
|
+
ariaLabel: ariaLabel,
|
|
116
118
|
innerContainerTagName: "nav",
|
|
117
119
|
className: classNames,
|
|
118
120
|
leadingIndicatorClassName: leadingScrollIndicatorClassName,
|
|
@@ -131,6 +133,7 @@ class BpkHorizontalNav extends Component {
|
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
BpkHorizontalNav.propTypes = {
|
|
136
|
+
ariaLabel: PropTypes.string,
|
|
134
137
|
children: PropTypes.node.isRequired,
|
|
135
138
|
/**
|
|
136
139
|
* Ensures that the selected item is within view when loaded on narrow-screened devices.
|
|
@@ -139,7 +142,7 @@ BpkHorizontalNav.propTypes = {
|
|
|
139
142
|
className: PropTypes.string,
|
|
140
143
|
leadingScrollIndicatorClassName: PropTypes.string,
|
|
141
144
|
/**
|
|
142
|
-
* When set to "false", the bottom border on the component isn't included. This refers
|
|
145
|
+
* When set to "false", the bottom border on the component isn't included. This refers
|
|
143
146
|
* to the underline on the whole "BpkHorizontalNav", not the line that appears under the selected item.
|
|
144
147
|
*/
|
|
145
148
|
showUnderline: PropTypes.bool,
|
|
@@ -147,6 +150,7 @@ BpkHorizontalNav.propTypes = {
|
|
|
147
150
|
type: PropTypes.oneOf(Object.keys(HORIZONTAL_NAV_TYPES))
|
|
148
151
|
};
|
|
149
152
|
BpkHorizontalNav.defaultProps = {
|
|
153
|
+
ariaLabel: null,
|
|
150
154
|
autoScrollToSelected: false,
|
|
151
155
|
className: null,
|
|
152
156
|
leadingScrollIndicatorClassName: null,
|
|
@@ -22,11 +22,11 @@ import STYLES from "./BpkInput.module.css";
|
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
const getClassName = cssModules(STYLES);
|
|
24
24
|
const KEYCODES = {
|
|
25
|
-
ENTER:
|
|
26
|
-
SPACEBAR:
|
|
25
|
+
ENTER: 'Enter',
|
|
26
|
+
SPACEBAR: 'Space'
|
|
27
27
|
};
|
|
28
|
-
const handleKeyEvent =
|
|
29
|
-
if (e
|
|
28
|
+
const handleKeyEvent = callback => e => {
|
|
29
|
+
if (e.code === KEYCODES.ENTER || e.code === KEYCODES.SPACEBAR) {
|
|
30
30
|
e.preventDefault();
|
|
31
31
|
if (callback) {
|
|
32
32
|
callback();
|
|
@@ -107,8 +107,9 @@ const withOpenEvents = InputComponent => {
|
|
|
107
107
|
}
|
|
108
108
|
const eventHandlers = {
|
|
109
109
|
onClick: withEventHandler(onOpen, onClick),
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
// @ts-expect-error for some reason the type KeyboardEvent was not being recognized as
|
|
111
|
+
// a valid type to UIEvent even though it is a valid subtype type of UIEvent
|
|
112
|
+
onKeyDown: withEventHandler(handleKeyEvent(onOpen), onKeyDown)
|
|
112
113
|
};
|
|
113
114
|
if (hasTouchSupport) {
|
|
114
115
|
// Prevents the mobile keyboard from opening (iOS / Android), while not announcing it as 'read only' to a screen reader
|
|
@@ -59,6 +59,7 @@ const computeScrollIndicatorClassName = (scrollerEl, leadingIndicatorClassName =
|
|
|
59
59
|
return classNames;
|
|
60
60
|
};
|
|
61
61
|
const propTypes = {
|
|
62
|
+
ariaLabel: PropTypes.string,
|
|
62
63
|
children: PropTypes.node.isRequired,
|
|
63
64
|
scrollerRef: PropTypes.func,
|
|
64
65
|
innerContainerTagName: PropTypes.string,
|
|
@@ -69,6 +70,7 @@ const propTypes = {
|
|
|
69
70
|
showScrollbar: PropTypes.bool
|
|
70
71
|
};
|
|
71
72
|
const defaultProps = {
|
|
73
|
+
ariaLabel: null,
|
|
72
74
|
scrollerRef: null,
|
|
73
75
|
innerContainerTagName: 'div',
|
|
74
76
|
className: null,
|
|
@@ -121,6 +123,7 @@ class BpkMobileScrollContainer extends Component {
|
|
|
121
123
|
render() {
|
|
122
124
|
const classNames = [getClassName('bpk-mobile-scroll-container')];
|
|
123
125
|
const {
|
|
126
|
+
ariaLabel,
|
|
124
127
|
children,
|
|
125
128
|
className,
|
|
126
129
|
innerContainerTagName,
|
|
@@ -156,6 +159,7 @@ class BpkMobileScrollContainer extends Component {
|
|
|
156
159
|
onScroll: this.setScrollIndicatorClassName,
|
|
157
160
|
className: scrollerClassNames,
|
|
158
161
|
children: /*#__PURE__*/_jsx(InnerContainer, {
|
|
162
|
+
"aria-label": ariaLabel,
|
|
159
163
|
ref: el => {
|
|
160
164
|
this.innerEl = el;
|
|
161
165
|
},
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { cloneElement } from 'react';
|
|
20
19
|
import { cssModules } from "../../bpk-react-utils";
|
|
21
20
|
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
22
21
|
import STYLES from "./BpkNavigationBar.module.css";
|
|
@@ -24,16 +23,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
24
|
const getClassNames = cssModules(STYLES);
|
|
26
25
|
export const BAR_STYLES = {
|
|
27
|
-
|
|
26
|
+
default: 'default',
|
|
28
27
|
onDark: 'on-dark'
|
|
29
28
|
};
|
|
30
|
-
const cloneWithClasses = (elem, ...newStyles) => {
|
|
31
|
-
const className = getClassNames(elem.props.className, ...newStyles);
|
|
32
|
-
return /*#__PURE__*/cloneElement(elem, {
|
|
33
|
-
...elem.props,
|
|
34
|
-
className
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
29
|
const BpkNavigationBar = props => {
|
|
38
30
|
const {
|
|
39
31
|
barStyle = BAR_STYLES.default,
|
|
@@ -53,12 +45,18 @@ const BpkNavigationBar = props => {
|
|
|
53
45
|
"aria-labelledby": titleId,
|
|
54
46
|
className: getClassNames('bpk-navigation-bar', `bpk-navigation-bar--${barStyle}`, sticky && 'bpk-navigation-bar__sticky', className),
|
|
55
47
|
...rest,
|
|
56
|
-
children: [leadingButton &&
|
|
48
|
+
children: [leadingButton && /*#__PURE__*/_jsx("div", {
|
|
49
|
+
className: getClassNames('bpk-navigation-bar__leading-item', `bpk-navigation-bar__leading-item--${barStyle}`),
|
|
50
|
+
children: leadingButton
|
|
51
|
+
}), typeof title === 'string' ? /*#__PURE__*/_jsx(BpkText, {
|
|
57
52
|
id: titleId,
|
|
58
53
|
textStyle: TEXT_STYLES.heading5,
|
|
59
54
|
className: getClassNames('bpk-navigation-bar__title', `bpk-navigation-bar__title--${barStyle}`),
|
|
60
55
|
children: title
|
|
61
|
-
}) : title, trailingButton &&
|
|
56
|
+
}) : title, trailingButton && /*#__PURE__*/_jsx("div", {
|
|
57
|
+
className: getClassNames('bpk-navigation-bar__trailing-item', `bpk-navigation-bar__trailing-item-${barStyle}`),
|
|
58
|
+
children: trailingButton
|
|
59
|
+
})]
|
|
62
60
|
});
|
|
63
61
|
};
|
|
64
62
|
export default BpkNavigationBar;
|