@react-navigation/elements 2.0.0-alpha.12 → 2.0.0-alpha.13

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.
@@ -4,23 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getDefaultSidebarWidth = void 0;
7
- var _reactNative = require("react-native");
7
+ const APPROX_APP_BAR_HEIGHT = 56;
8
+ const DEFAULT_DRAWER_WIDTH = 360;
8
9
  const getDefaultSidebarWidth = _ref => {
9
10
  let {
10
- height,
11
11
  width
12
12
  } = _ref;
13
- /*
14
- * Default sidebar width is screen width - header height
15
- * with a max width of 280 on mobile and 320 on tablet
16
- * https://material.io/components/navigation-drawer
13
+ /**
14
+ * Default sidebar width is 360dp
15
+ * On screens smaller than 320dp, ideally the drawer would collapse to a tab bar
16
+ * https://m3.material.io/components/navigation-drawer/specs
17
17
  */
18
- const smallerAxisSize = Math.min(height, width);
19
- const isLandscape = width > height;
20
- const isTablet = smallerAxisSize >= 600;
21
- const appBarHeight = _reactNative.Platform.OS === 'ios' ? isLandscape ? 32 : 44 : 56;
22
- const maxWidth = isTablet ? 320 : 280;
23
- return Math.min(smallerAxisSize - appBarHeight, maxWidth);
18
+ if (width - APPROX_APP_BAR_HEIGHT <= 360) {
19
+ return width - APPROX_APP_BAR_HEIGHT;
20
+ }
21
+ return DEFAULT_DRAWER_WIDTH;
24
22
  };
25
23
  exports.getDefaultSidebarWidth = getDefaultSidebarWidth;
26
24
  //# sourceMappingURL=getDefaultSidebarWidth.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","getDefaultSidebarWidth","_ref","height","width","smallerAxisSize","Math","min","isLandscape","isTablet","appBarHeight","Platform","OS","maxWidth","exports"],"sourceRoot":"../../src","sources":["getDefaultSidebarWidth.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,sBAAsB,GAAGC,IAAA,IAMhC;EAAA,IANiC;IACrCC,MAAM;IACNC;EAIF,CAAC,GAAAF,IAAA;EACC;AACF;AACA;AACA;AACA;EACE,MAAMG,eAAe,GAAGC,IAAI,CAACC,GAAG,CAACJ,MAAM,EAAEC,KAAK,CAAC;EAC/C,MAAMI,WAAW,GAAGJ,KAAK,GAAGD,MAAM;EAClC,MAAMM,QAAQ,GAAGJ,eAAe,IAAI,GAAG;EACvC,MAAMK,YAAY,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAIJ,WAAW,GAAG,EAAE,GAAG,EAAE,GAAI,EAAE;EACzE,MAAMK,QAAQ,GAAGJ,QAAQ,GAAG,GAAG,GAAG,GAAG;EAErC,OAAOH,IAAI,CAACC,GAAG,CAACF,eAAe,GAAGK,YAAY,EAAEG,QAAQ,CAAC;AAC3D,CAAC;AAACC,OAAA,CAAAb,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"names":["APPROX_APP_BAR_HEIGHT","DEFAULT_DRAWER_WIDTH","getDefaultSidebarWidth","_ref","width","exports"],"sourceRoot":"../../src","sources":["getDefaultSidebarWidth.tsx"],"mappings":";;;;;;AAAA,MAAMA,qBAAqB,GAAG,EAAE;AAChC,MAAMC,oBAAoB,GAAG,GAAG;AAEzB,MAAMC,sBAAsB,GAAGC,IAAA,IAAkC;EAAA,IAAjC;IAAEC;EAAyB,CAAC,GAAAD,IAAA;EACjE;AACF;AACA;AACA;AACA;EACE,IAAIC,KAAK,GAAGJ,qBAAqB,IAAI,GAAG,EAAE;IACxC,OAAOI,KAAK,GAAGJ,qBAAqB;EACtC;EAEA,OAAOC,oBAAoB;AAC7B,CAAC;AAACI,OAAA,CAAAH,sBAAA,GAAAA,sBAAA"}
@@ -1,19 +1,17 @@
1
- import { Platform } from 'react-native';
1
+ const APPROX_APP_BAR_HEIGHT = 56;
2
+ const DEFAULT_DRAWER_WIDTH = 360;
2
3
  export const getDefaultSidebarWidth = _ref => {
3
4
  let {
4
- height,
5
5
  width
6
6
  } = _ref;
7
- /*
8
- * Default sidebar width is screen width - header height
9
- * with a max width of 280 on mobile and 320 on tablet
10
- * https://material.io/components/navigation-drawer
7
+ /**
8
+ * Default sidebar width is 360dp
9
+ * On screens smaller than 320dp, ideally the drawer would collapse to a tab bar
10
+ * https://m3.material.io/components/navigation-drawer/specs
11
11
  */
12
- const smallerAxisSize = Math.min(height, width);
13
- const isLandscape = width > height;
14
- const isTablet = smallerAxisSize >= 600;
15
- const appBarHeight = Platform.OS === 'ios' ? isLandscape ? 32 : 44 : 56;
16
- const maxWidth = isTablet ? 320 : 280;
17
- return Math.min(smallerAxisSize - appBarHeight, maxWidth);
12
+ if (width - APPROX_APP_BAR_HEIGHT <= 360) {
13
+ return width - APPROX_APP_BAR_HEIGHT;
14
+ }
15
+ return DEFAULT_DRAWER_WIDTH;
18
16
  };
19
17
  //# sourceMappingURL=getDefaultSidebarWidth.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","getDefaultSidebarWidth","_ref","height","width","smallerAxisSize","Math","min","isLandscape","isTablet","appBarHeight","OS","maxWidth"],"sourceRoot":"../../src","sources":["getDefaultSidebarWidth.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,sBAAsB,GAAGC,IAAA,IAMhC;EAAA,IANiC;IACrCC,MAAM;IACNC;EAIF,CAAC,GAAAF,IAAA;EACC;AACF;AACA;AACA;AACA;EACE,MAAMG,eAAe,GAAGC,IAAI,CAACC,GAAG,CAACJ,MAAM,EAAEC,KAAK,CAAC;EAC/C,MAAMI,WAAW,GAAGJ,KAAK,GAAGD,MAAM;EAClC,MAAMM,QAAQ,GAAGJ,eAAe,IAAI,GAAG;EACvC,MAAMK,YAAY,GAAGV,QAAQ,CAACW,EAAE,KAAK,KAAK,GAAIH,WAAW,GAAG,EAAE,GAAG,EAAE,GAAI,EAAE;EACzE,MAAMI,QAAQ,GAAGH,QAAQ,GAAG,GAAG,GAAG,GAAG;EAErC,OAAOH,IAAI,CAACC,GAAG,CAACF,eAAe,GAAGK,YAAY,EAAEE,QAAQ,CAAC;AAC3D,CAAC"}
1
+ {"version":3,"names":["APPROX_APP_BAR_HEIGHT","DEFAULT_DRAWER_WIDTH","getDefaultSidebarWidth","_ref","width"],"sourceRoot":"../../src","sources":["getDefaultSidebarWidth.tsx"],"mappings":"AAAA,MAAMA,qBAAqB,GAAG,EAAE;AAChC,MAAMC,oBAAoB,GAAG,GAAG;AAEhC,OAAO,MAAMC,sBAAsB,GAAGC,IAAA,IAAkC;EAAA,IAAjC;IAAEC;EAAyB,CAAC,GAAAD,IAAA;EACjE;AACF;AACA;AACA;AACA;EACE,IAAIC,KAAK,GAAGJ,qBAAqB,IAAI,GAAG,EAAE;IACxC,OAAOI,KAAK,GAAGJ,qBAAqB;EACtC;EAEA,OAAOC,oBAAoB;AAC7B,CAAC"}
@@ -1,5 +1,4 @@
1
- export declare const getDefaultSidebarWidth: ({ height, width, }: {
2
- height: number;
1
+ export declare const getDefaultSidebarWidth: ({ width }: {
3
2
  width: number;
4
3
  }) => number;
5
4
  //# sourceMappingURL=getDefaultSidebarWidth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultSidebarWidth.d.ts","sourceRoot":"","sources":["../../../src/getDefaultSidebarWidth.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB;YAIzB,MAAM;WACP,MAAM;YAcd,CAAC"}
1
+ {"version":3,"file":"getDefaultSidebarWidth.d.ts","sourceRoot":"","sources":["../../../src/getDefaultSidebarWidth.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB;WAAwB,MAAM;YAWhE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/elements",
3
3
  "description": "UI Components for React Navigation",
4
- "version": "2.0.0-alpha.12",
4
+ "version": "2.0.0-alpha.13",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "react-navigation",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@react-native-masked-view/masked-view": "0.3.0",
44
- "@react-navigation/native": "^7.0.0-alpha.14",
44
+ "@react-navigation/native": "^7.0.0-alpha.15",
45
45
  "@testing-library/react-native": "^12.4.3",
46
46
  "@types/react": "~18.2.45",
47
47
  "del-cli": "^5.1.0",
@@ -51,7 +51,7 @@
51
51
  "typescript": "^5.3.3"
52
52
  },
53
53
  "peerDependencies": {
54
- "@react-navigation/native": "^7.0.0-alpha.14",
54
+ "@react-navigation/native": "^7.0.0-alpha.15",
55
55
  "react": ">= 18.2.0",
56
56
  "react-native": ">= 0.72.0",
57
57
  "react-native-safe-area-context": ">= 4.0.0"
@@ -70,5 +70,5 @@
70
70
  ]
71
71
  ]
72
72
  },
73
- "gitHead": "d0b5489cb3eb8092d05b8d058ba5774d0538cec6"
73
+ "gitHead": "b1ed6b0d299189c62f0dc8d7171c243adc674a30"
74
74
  }
@@ -1,22 +1,15 @@
1
- import { Platform } from 'react-native';
1
+ const APPROX_APP_BAR_HEIGHT = 56;
2
+ const DEFAULT_DRAWER_WIDTH = 360;
2
3
 
3
- export const getDefaultSidebarWidth = ({
4
- height,
5
- width,
6
- }: {
7
- height: number;
8
- width: number;
9
- }) => {
10
- /*
11
- * Default sidebar width is screen width - header height
12
- * with a max width of 280 on mobile and 320 on tablet
13
- * https://material.io/components/navigation-drawer
4
+ export const getDefaultSidebarWidth = ({ width }: { width: number }) => {
5
+ /**
6
+ * Default sidebar width is 360dp
7
+ * On screens smaller than 320dp, ideally the drawer would collapse to a tab bar
8
+ * https://m3.material.io/components/navigation-drawer/specs
14
9
  */
15
- const smallerAxisSize = Math.min(height, width);
16
- const isLandscape = width > height;
17
- const isTablet = smallerAxisSize >= 600;
18
- const appBarHeight = Platform.OS === 'ios' ? (isLandscape ? 32 : 44) : 56;
19
- const maxWidth = isTablet ? 320 : 280;
10
+ if (width - APPROX_APP_BAR_HEIGHT <= 360) {
11
+ return width - APPROX_APP_BAR_HEIGHT;
12
+ }
20
13
 
21
- return Math.min(smallerAxisSize - appBarHeight, maxWidth);
14
+ return DEFAULT_DRAWER_WIDTH;
22
15
  };