@skyscanner/backpack-web 41.15.0 → 41.15.2

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.
@@ -24,7 +24,7 @@ interface CommonProps {
24
24
  onClose: (arg0?: TouchEvent | MouseEvent | KeyboardEvent | SyntheticEvent<HTMLDialogElement, Event>, arg1?: {
25
25
  source: 'ESCAPE' | 'DOCUMENT_CLICK';
26
26
  }) => void;
27
- title?: string;
27
+ title?: string | ReactNode;
28
28
  wide?: boolean;
29
29
  isOpen: boolean;
30
30
  paddingStyles?: PaddingStyles;
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { useCallback, useState } from 'react';
19
+ import { useCallback, useState, isValidElement, cloneElement } from 'react';
20
20
  import BpkBreakpoint, { BREAKPOINTS } from "../../bpk-component-breakpoint";
21
21
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
22
22
  import BpkCloseButton from "../../bpk-component-close-button";
@@ -95,9 +95,16 @@ const BpkBottomSheet = ({
95
95
  }, [isAboveMobile, onClose]);
96
96
  const headingId = `bpk-bottom-sheet-heading-${id}`;
97
97
  const hiddenTitleId = `bpk-bottom-sheet-title-hidden-${id}`;
98
- const showHiddenTitle = !title && 'ariaLabel' in ariaProps && ariaProps.ariaLabel;
98
+ const hasTitle = !!title;
99
+ const showHiddenTitle = !hasTitle && 'ariaLabel' in ariaProps && ariaProps.ariaLabel;
99
100
  const dialogClassName = getClassName('bpk-bottom-sheet', wide && 'bpk-bottom-sheet--wide');
100
101
  const contentStyle = getContentStyles(paddingStyles);
102
+
103
+ // For custom title (ReactNode), wrap it with an element that has the correct id
104
+ // so BpkNavigationBar's aria-labelledby reference is valid
105
+ const titleWithId = hasTitle && typeof title !== 'string' && /*#__PURE__*/isValidElement(title) ? /*#__PURE__*/cloneElement(title, {
106
+ id: showHiddenTitle ? hiddenTitleId : headingId
107
+ }) : title;
101
108
  return /*#__PURE__*/_jsx(BpkDialogWrapper, {
102
109
  ...ariaProps,
103
110
  dialogClassName: dialogClassName,
@@ -122,9 +129,9 @@ const BpkBottomSheet = ({
122
129
  className: getClassName('bpk-bottom-sheet--header-wrapper'),
123
130
  children: [/*#__PURE__*/_jsx(BpkNavigationBar, {
124
131
  id: showHiddenTitle ? hiddenTitleId : headingId,
125
- title: title,
132
+ title: titleWithId,
126
133
  titleTextStyle: TEXT_STYLES.label1,
127
- titleTagName: title ? 'h2' : 'span',
134
+ titleTagName: hasTitle ? 'h2' : 'span',
128
135
  className: getClassName('bpk-bottom-sheet--header'),
129
136
  leadingButton: /*#__PURE__*/_jsx(BpkCloseButton, {
130
137
  label: closeLabel,
@@ -42,7 +42,7 @@ const useLegacyWarning = (query, legacy, isClient) => useMemo(() => {
42
42
  const BpkBreakpoint = ({
43
43
  children,
44
44
  legacy = false,
45
- matchSSR = false,
45
+ matchSSR,
46
46
  query
47
47
  }) => {
48
48
  /**
@@ -64,7 +64,7 @@ const BpkBreakpoint = ({
64
64
  return matches ? children : null;
65
65
  }
66
66
  if (typeof children === 'function') {
67
- return children(matchSSR);
67
+ return children(!!matchSSR);
68
68
  }
69
69
  return matchSSR ? children : null;
70
70
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "41.15.0",
3
+ "version": "41.15.2",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",