@skyscanner/backpack-web 30.0.0 → 30.1.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.
@@ -36,6 +36,7 @@ type Props = {
36
36
  children: ReactNode | ((matches: boolean) => ReactNode | null);
37
37
  query: string | (typeof BREAKPOINTS)[keyof typeof BREAKPOINTS];
38
38
  legacy?: boolean;
39
+ matchSSR?: boolean;
39
40
  };
40
41
  declare const BpkBreakpoint: ({ children, legacy, query }: Props) => JSX.Element;
41
42
  export { BREAKPOINTS };
@@ -35,15 +35,26 @@ const BREAKPOINTS = {
35
35
  const BpkBreakpoint = ({
36
36
  children,
37
37
  legacy = false,
38
+ matchSSR = false,
38
39
  query
39
40
  }) => {
41
+ const isSSR = () => !(typeof window !== 'undefined' && window.document && window.document.createElement);
40
42
  if (!legacy && !Object.values(BREAKPOINTS).includes(query)) {
41
43
  console.warn(`Invalid query ${query}. Use one of the supported queries or pass the legacy prop.`);
42
44
  }
43
- return /*#__PURE__*/_jsx(MediaQuery, {
44
- query: query,
45
- children: children
46
- });
45
+ if (!isSSR()) {
46
+ return /*#__PURE__*/_jsx(MediaQuery, {
47
+ query: query,
48
+ children: children
49
+ });
50
+ }
51
+
52
+ // Below code is executed when running in SSR mode
53
+
54
+ if (typeof children === 'function') {
55
+ return children(matchSSR);
56
+ }
57
+ return matchSSR ? children : null;
47
58
  };
48
59
  export { BREAKPOINTS };
49
60
  export default BpkBreakpoint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "30.0.0",
3
+ "version": "30.1.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",