@react-navigation/elements 2.3.7 → 2.4.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.
Files changed (117) hide show
  1. package/lib/module/Header/HeaderButton.js +7 -3
  2. package/lib/module/Header/HeaderButton.js.map +1 -1
  3. package/lib/module/Header/HeaderSearchBar.js +2 -3
  4. package/lib/module/Header/HeaderSearchBar.js.map +1 -1
  5. package/lib/module/Header/HeaderTitle.js +1 -1
  6. package/lib/module/Header/HeaderTitle.js.map +1 -1
  7. package/lib/module/PlatformPressable.js +18 -15
  8. package/lib/module/PlatformPressable.js.map +1 -1
  9. package/lib/module/Screen.js +1 -2
  10. package/lib/module/Screen.js.map +1 -1
  11. package/lib/typescript/src/Header/HeaderButton.d.ts +2 -1
  12. package/lib/typescript/src/Header/HeaderButton.d.ts.map +1 -1
  13. package/lib/typescript/src/Header/HeaderSearchBar.d.ts.map +1 -1
  14. package/lib/typescript/src/MaskedView.d.ts +1 -1
  15. package/lib/typescript/src/MaskedView.d.ts.map +1 -1
  16. package/lib/typescript/src/PlatformPressable.d.ts +13 -7
  17. package/lib/typescript/src/PlatformPressable.d.ts.map +1 -1
  18. package/lib/typescript/src/Screen.d.ts.map +1 -1
  19. package/lib/typescript/src/getDefaultSidebarWidth.d.ts.map +1 -1
  20. package/package.json +15 -13
  21. package/src/Header/HeaderButton.tsx +21 -12
  22. package/src/Header/HeaderSearchBar.tsx +2 -3
  23. package/src/Header/HeaderTitle.tsx +1 -1
  24. package/src/PlatformPressable.tsx +51 -34
  25. package/src/Screen.tsx +2 -3
  26. package/lib/commonjs/Background.js +0 -28
  27. package/lib/commonjs/Background.js.map +0 -1
  28. package/lib/commonjs/Button.js +0 -113
  29. package/lib/commonjs/Button.js.map +0 -1
  30. package/lib/commonjs/Header/Header.js +0 -344
  31. package/lib/commonjs/Header/Header.js.map +0 -1
  32. package/lib/commonjs/Header/HeaderBackButton.js +0 -195
  33. package/lib/commonjs/Header/HeaderBackButton.js.map +0 -1
  34. package/lib/commonjs/Header/HeaderBackContext.js +0 -9
  35. package/lib/commonjs/Header/HeaderBackContext.js.map +0 -1
  36. package/lib/commonjs/Header/HeaderBackground.js +0 -53
  37. package/lib/commonjs/Header/HeaderBackground.js.map +0 -1
  38. package/lib/commonjs/Header/HeaderButton.js +0 -60
  39. package/lib/commonjs/Header/HeaderButton.js.map +0 -1
  40. package/lib/commonjs/Header/HeaderHeightContext.js +0 -9
  41. package/lib/commonjs/Header/HeaderHeightContext.js.map +0 -1
  42. package/lib/commonjs/Header/HeaderIcon.js +0 -43
  43. package/lib/commonjs/Header/HeaderIcon.js.map +0 -1
  44. package/lib/commonjs/Header/HeaderSearchBar.js +0 -291
  45. package/lib/commonjs/Header/HeaderSearchBar.js.map +0 -1
  46. package/lib/commonjs/Header/HeaderShownContext.js +0 -9
  47. package/lib/commonjs/Header/HeaderShownContext.js.map +0 -1
  48. package/lib/commonjs/Header/HeaderTitle.js +0 -45
  49. package/lib/commonjs/Header/HeaderTitle.js.map +0 -1
  50. package/lib/commonjs/Header/getDefaultHeaderHeight.js +0 -38
  51. package/lib/commonjs/Header/getDefaultHeaderHeight.js.map +0 -1
  52. package/lib/commonjs/Header/getHeaderTitle.js +0 -10
  53. package/lib/commonjs/Header/getHeaderTitle.js.map +0 -1
  54. package/lib/commonjs/Header/useHeaderHeight.js +0 -18
  55. package/lib/commonjs/Header/useHeaderHeight.js.map +0 -1
  56. package/lib/commonjs/Label/Label.js +0 -29
  57. package/lib/commonjs/Label/Label.js.map +0 -1
  58. package/lib/commonjs/Label/getLabel.js +0 -10
  59. package/lib/commonjs/Label/getLabel.js.map +0 -1
  60. package/lib/commonjs/MaskedView.android.js +0 -13
  61. package/lib/commonjs/MaskedView.android.js.map +0 -1
  62. package/lib/commonjs/MaskedView.ios.js +0 -13
  63. package/lib/commonjs/MaskedView.ios.js.map +0 -1
  64. package/lib/commonjs/MaskedView.js +0 -16
  65. package/lib/commonjs/MaskedView.js.map +0 -1
  66. package/lib/commonjs/MaskedViewNative.js +0 -37
  67. package/lib/commonjs/MaskedViewNative.js.map +0 -1
  68. package/lib/commonjs/MissingIcon.js +0 -28
  69. package/lib/commonjs/MissingIcon.js.map +0 -1
  70. package/lib/commonjs/PlatformPressable.js +0 -147
  71. package/lib/commonjs/PlatformPressable.js.map +0 -1
  72. package/lib/commonjs/ResourceSavingView.js +0 -63
  73. package/lib/commonjs/ResourceSavingView.js.map +0 -1
  74. package/lib/commonjs/SafeAreaProviderCompat.js +0 -130
  75. package/lib/commonjs/SafeAreaProviderCompat.js.map +0 -1
  76. package/lib/commonjs/Screen.js +0 -89
  77. package/lib/commonjs/Screen.js.map +0 -1
  78. package/lib/commonjs/Text.js +0 -27
  79. package/lib/commonjs/Text.js.map +0 -1
  80. package/lib/commonjs/assets/back-icon-mask.png +0 -0
  81. package/lib/commonjs/assets/back-icon.png +0 -0
  82. package/lib/commonjs/assets/back-icon@1x.android.png +0 -0
  83. package/lib/commonjs/assets/back-icon@1x.ios.png +0 -0
  84. package/lib/commonjs/assets/back-icon@2x.android.png +0 -0
  85. package/lib/commonjs/assets/back-icon@2x.ios.png +0 -0
  86. package/lib/commonjs/assets/back-icon@3x.android.png +0 -0
  87. package/lib/commonjs/assets/back-icon@3x.ios.png +0 -0
  88. package/lib/commonjs/assets/back-icon@4x.android.png +0 -0
  89. package/lib/commonjs/assets/back-icon@4x.ios.png +0 -0
  90. package/lib/commonjs/assets/clear-icon.png +0 -0
  91. package/lib/commonjs/assets/clear-icon@1x.png +0 -0
  92. package/lib/commonjs/assets/clear-icon@2x.png +0 -0
  93. package/lib/commonjs/assets/clear-icon@3x.png +0 -0
  94. package/lib/commonjs/assets/clear-icon@4x.png +0 -0
  95. package/lib/commonjs/assets/close-icon.png +0 -0
  96. package/lib/commonjs/assets/close-icon@1x.png +0 -0
  97. package/lib/commonjs/assets/close-icon@2x.png +0 -0
  98. package/lib/commonjs/assets/close-icon@3x.png +0 -0
  99. package/lib/commonjs/assets/close-icon@4x.png +0 -0
  100. package/lib/commonjs/assets/search-icon.png +0 -0
  101. package/lib/commonjs/assets/search-icon@1x.android.png +0 -0
  102. package/lib/commonjs/assets/search-icon@1x.ios.png +0 -0
  103. package/lib/commonjs/assets/search-icon@2x.android.png +0 -0
  104. package/lib/commonjs/assets/search-icon@2x.ios.png +0 -0
  105. package/lib/commonjs/assets/search-icon@3x.android.png +0 -0
  106. package/lib/commonjs/assets/search-icon@3x.ios.png +0 -0
  107. package/lib/commonjs/assets/search-icon@4x.android.png +0 -0
  108. package/lib/commonjs/assets/search-icon@4x.ios.png +0 -0
  109. package/lib/commonjs/getDefaultSidebarWidth.js +0 -23
  110. package/lib/commonjs/getDefaultSidebarWidth.js.map +0 -1
  111. package/lib/commonjs/getNamedContext.js +0 -23
  112. package/lib/commonjs/getNamedContext.js.map +0 -1
  113. package/lib/commonjs/index.js +0 -205
  114. package/lib/commonjs/index.js.map +0 -1
  115. package/lib/commonjs/package.json +0 -1
  116. package/lib/commonjs/types.js +0 -6
  117. package/lib/commonjs/types.js.map +0 -1
@@ -17,12 +17,15 @@ type HoverEffectProps = {
17
17
  activeOpacity?: number;
18
18
  };
19
19
 
20
- export type Props = Omit<PressableProps, 'style'> & {
20
+ export type Props = Omit<PressableProps, 'style' | 'onPress'> & {
21
+ href?: string;
21
22
  pressColor?: string;
22
23
  pressOpacity?: number;
23
24
  hoverEffect?: HoverEffectProps;
24
25
  style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
25
- href?: string;
26
+ onPress?: (
27
+ e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
28
+ ) => void;
26
29
  children: React.ReactNode;
27
30
  };
28
31
 
@@ -37,19 +40,22 @@ const useNativeDriver = Platform.OS !== 'web';
37
40
  /**
38
41
  * PlatformPressable provides an abstraction on top of Pressable to handle platform differences.
39
42
  */
40
- export function PlatformPressable({
41
- disabled,
42
- onPress,
43
- onPressIn,
44
- onPressOut,
45
- android_ripple,
46
- pressColor,
47
- pressOpacity = 0.3,
48
- hoverEffect,
49
- style,
50
- children,
51
- ...rest
52
- }: Props) {
43
+ function PlatformPressableInternal(
44
+ {
45
+ disabled,
46
+ onPress,
47
+ onPressIn,
48
+ onPressOut,
49
+ android_ripple,
50
+ pressColor,
51
+ pressOpacity = 0.3,
52
+ hoverEffect,
53
+ style,
54
+ children,
55
+ ...rest
56
+ }: Props,
57
+ ref: React.Ref<React.ComponentRef<typeof AnimatedPressable>>
58
+ ) {
53
59
  const { dark } = useTheme();
54
60
  const [opacity] = React.useState(() => new Animated.Value(1));
55
61
 
@@ -66,18 +72,31 @@ export function PlatformPressable({
66
72
  }).start();
67
73
  };
68
74
 
69
- const handlePress = (e: GestureResponderEvent) => {
70
- if (Platform.OS === 'web' && rest.href != null) {
71
- // @ts-expect-error: these properties exist on web, but not in React Native
72
- const hasModifierKey = e.metaKey || e.altKey || e.ctrlKey || e.shiftKey; // ignore clicks with modifier keys
73
- // @ts-expect-error: these properties exist on web, but not in React Native
74
- const isLeftClick = e.button == null || e.button === 0; // only handle left clicks
75
- const isSelfTarget = [undefined, null, '', 'self'].includes(
76
- // @ts-expect-error: these properties exist on web, but not in React Native
77
- e.currentTarget?.target
78
- ); // let browser handle "target=_blank" etc.
75
+ const handlePress = (
76
+ e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
77
+ ) => {
78
+ if (Platform.OS === 'web' && rest.href !== null) {
79
+ // ignore clicks with modifier keys
80
+ const hasModifierKey =
81
+ ('metaKey' in e && e.metaKey) ||
82
+ ('altKey' in e && e.altKey) ||
83
+ ('ctrlKey' in e && e.ctrlKey) ||
84
+ ('shiftKey' in e && e.shiftKey);
85
+
86
+ // only handle left clicks
87
+ const isLeftClick =
88
+ 'button' in e ? e.button == null || e.button === 0 : true;
89
+
90
+ // let browser handle "target=_blank" etc.
91
+ const isSelfTarget =
92
+ e.currentTarget && 'target' in e.currentTarget
93
+ ? [undefined, null, '', 'self'].includes(e.currentTarget.target)
94
+ : true;
95
+
79
96
  if (!hasModifierKey && isLeftClick && isSelfTarget) {
80
97
  e.preventDefault();
98
+ // call `onPress` only when browser default is prevented
99
+ // this prevents app from handling the click when a link is being opened
81
100
  onPress?.(e);
82
101
  }
83
102
  } else {
@@ -97,10 +116,9 @@ export function PlatformPressable({
97
116
 
98
117
  return (
99
118
  <AnimatedPressable
119
+ ref={ref}
100
120
  accessible
101
- accessibilityRole={
102
- Platform.OS === 'web' && rest.href != null ? 'link' : 'button'
103
- }
121
+ role={Platform.OS === 'web' && rest.href != null ? 'link' : 'button'}
104
122
  onPress={disabled ? undefined : handlePress}
105
123
  onPressIn={handlePressIn}
106
124
  onPressOut={handlePressOut}
@@ -137,6 +155,10 @@ export function PlatformPressable({
137
155
  );
138
156
  }
139
157
 
158
+ export const PlatformPressable = React.forwardRef(PlatformPressableInternal);
159
+
160
+ PlatformPressable.displayName = 'PlatformPressable';
161
+
140
162
  const css = String.raw;
141
163
 
142
164
  const CLASS_NAME = `__react-navigation_elements_Pressable_hover`;
@@ -174,12 +196,7 @@ const HoverEffect = ({
174
196
 
175
197
  return (
176
198
  <>
177
- <style
178
- // @ts-expect-error: href and precedence are only available on React 19
179
- href={CLASS_NAME}
180
- // eslint-disable-next-line @eslint-react/dom/no-unknown-property
181
- precedence="elements"
182
- >
199
+ <style href={CLASS_NAME} precedence="elements">
183
200
  {CSS_TEXT}
184
201
  </style>
185
202
  <div
package/src/Screen.tsx CHANGED
@@ -62,8 +62,7 @@ export function Screen(props: Props) {
62
62
 
63
63
  return (
64
64
  <Background
65
- accessibilityElementsHidden={!focused}
66
- importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}
65
+ aria-hidden={!focused}
67
66
  style={[styles.container, style]}
68
67
  // On Fabric we need to disable collapsing for the background to ensure
69
68
  // that we won't render unnecessary views due to the view flattening.
@@ -94,7 +93,7 @@ export function Screen(props: Props) {
94
93
  value={isParentHeaderShown || headerShown !== false}
95
94
  >
96
95
  <HeaderHeightContext.Provider
97
- value={headerShown ? headerHeight : parentHeaderHeight ?? 0}
96
+ value={headerShown ? headerHeight : (parentHeaderHeight ?? 0)}
98
97
  >
99
98
  {children}
100
99
  </HeaderHeightContext.Provider>
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Background = Background;
7
- var _native = require("@react-navigation/native");
8
- var React = _interopRequireWildcard(require("react"));
9
- var _reactNative = require("react-native");
10
- var _jsxRuntime = require("react/jsx-runtime");
11
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- function Background({
14
- style,
15
- ...rest
16
- }) {
17
- const {
18
- colors
19
- } = (0, _native.useTheme)();
20
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
21
- ...rest,
22
- style: [{
23
- flex: 1,
24
- backgroundColor: colors.background
25
- }, style]
26
- });
27
- }
28
- //# sourceMappingURL=Background.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_native","require","React","_interopRequireWildcard","_reactNative","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Background","style","rest","colors","useTheme","jsx","Animated","View","flex","backgroundColor","background"],"sourceRoot":"../../src","sources":["Background.tsx"],"m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AOf,SAASW,UAAUA,CAAC;EAAEC,KAAK;EAAE,GAAGC;AAAY,CAAC,EAAE;EACpD,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,gBAAQ,EAAC,CAAC;EAE7B,oBACE,IAAAzB,WAAA,CAAA0B,GAAA,EAAC3B,YAAA,CAAA4B,QAAQ,CAACC,IAAI;IAAA,GACRL,IAAI;IACRD,KAAK,EAAE,CAAC;MAAEO,IAAI,EAAE,CAAC;MAAEC,eAAe,EAAEN,MAAM,CAACO;IAAW,CAAC,EAAET,KAAK;EAAE,CACjE,CAAC;AAEN","ignoreList":[]}
@@ -1,113 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Button = Button;
7
- var _native = require("@react-navigation/native");
8
- var _color = _interopRequireDefault(require("color"));
9
- var React = _interopRequireWildcard(require("react"));
10
- var _reactNative = require("react-native");
11
- var _PlatformPressable = require("./PlatformPressable.js");
12
- var _Text = require("./Text.js");
13
- var _jsxRuntime = require("react/jsx-runtime");
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- const BUTTON_RADIUS = 40;
18
- function Button(props) {
19
- if ('screen' in props || 'action' in props) {
20
- // @ts-expect-error: This is already type-checked by the prop types
21
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonLink, {
22
- ...props
23
- });
24
- } else {
25
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonBase, {
26
- ...props
27
- });
28
- }
29
- }
30
- function ButtonLink({
31
- screen,
32
- params,
33
- action,
34
- href,
35
- ...rest
36
- }) {
37
- // @ts-expect-error: This is already type-checked by the prop types
38
- const props = (0, _native.useLinkProps)({
39
- screen,
40
- params,
41
- action,
42
- href
43
- });
44
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonBase, {
45
- ...rest,
46
- ...props
47
- });
48
- }
49
- function ButtonBase({
50
- variant = 'tinted',
51
- color: customColor,
52
- android_ripple,
53
- style,
54
- children,
55
- ...rest
56
- }) {
57
- const {
58
- colors,
59
- fonts
60
- } = (0, _native.useTheme)();
61
- const color = customColor ?? colors.primary;
62
- let backgroundColor;
63
- let textColor;
64
- switch (variant) {
65
- case 'plain':
66
- backgroundColor = 'transparent';
67
- textColor = color;
68
- break;
69
- case 'tinted':
70
- backgroundColor = (0, _color.default)(color).fade(0.85).string();
71
- textColor = color;
72
- break;
73
- case 'filled':
74
- backgroundColor = color;
75
- textColor = (0, _color.default)(color).isDark() ? 'white' : (0, _color.default)(color).darken(0.71).string();
76
- break;
77
- }
78
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PlatformPressable.PlatformPressable, {
79
- ...rest,
80
- android_ripple: {
81
- radius: BUTTON_RADIUS,
82
- color: (0, _color.default)(textColor).fade(0.85).string(),
83
- ...android_ripple
84
- },
85
- pressOpacity: _reactNative.Platform.OS === 'ios' ? undefined : 1,
86
- hoverEffect: {
87
- color: textColor
88
- },
89
- style: [{
90
- backgroundColor
91
- }, styles.button, style],
92
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.Text, {
93
- style: [{
94
- color: textColor
95
- }, fonts.regular, styles.text],
96
- children: children
97
- })
98
- });
99
- }
100
- const styles = _reactNative.StyleSheet.create({
101
- button: {
102
- paddingHorizontal: 24,
103
- paddingVertical: 10,
104
- borderRadius: BUTTON_RADIUS
105
- },
106
- text: {
107
- fontSize: 14,
108
- lineHeight: 20,
109
- letterSpacing: 0.1,
110
- textAlign: 'center'
111
- }
112
- });
113
- //# sourceMappingURL=Button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_native","require","_color","_interopRequireDefault","React","_interopRequireWildcard","_reactNative","_PlatformPressable","_Text","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","BUTTON_RADIUS","Button","props","jsx","ButtonLink","ButtonBase","screen","params","action","href","rest","useLinkProps","variant","color","customColor","android_ripple","style","children","colors","fonts","useTheme","primary","backgroundColor","textColor","Color","fade","string","isDark","darken","PlatformPressable","radius","pressOpacity","Platform","OS","undefined","hoverEffect","styles","button","Text","regular","text","StyleSheet","create","paddingHorizontal","paddingVertical","borderRadius","fontSize","lineHeight","letterSpacing","textAlign"],"sourceRoot":"../../src","sources":["Button.tsx"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAEA,IAAAM,kBAAA,GAAAN,OAAA;AAIA,IAAAO,KAAA,GAAAP,OAAA;AAA8B,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAA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IACRK,cAAc,EAAE;MACde,MAAM,EAAE9B,aAAa;MACrBa,KAAK,EAAE,IAAAW,cAAK,EAACD,SAAS,CAAC,CAACE,IAAI,CAAC,IAAI,CAAC,CAACC,MAAM,CAAC,CAAC;MAC3C,GAAGX;IACL,CAAE;IACFgB,YAAY,EAAEC,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAGC,SAAS,GAAG,CAAE;IACpDC,WAAW,EAAE;MAAEtB,KAAK,EAAEU;IAAU,CAAE;IAClCP,KAAK,EAAE,CAAC;MAAEM;IAAgB,CAAC,EAAEc,MAAM,CAACC,MAAM,EAAErB,KAAK,CAAE;IAAAC,QAAA,eAEnD,IAAAtC,WAAA,CAAAwB,GAAA,EAACzB,KAAA,CAAA4D,IAAI;MAACtB,KAAK,EAAE,CAAC;QAAEH,KAAK,EAAEU;MAAU,CAAC,EAAEJ,KAAK,CAACoB,OAAO,EAAEH,MAAM,CAACI,IAAI,CAAE;MAAAvB,QAAA,EAC7DA;IAAQ,CACL;EAAC,CACU,CAAC;AAExB;AAEA,MAAMmB,MAAM,GAAGK,uBAAU,CAACC,MAAM,CAAC;EAC/BL,MAAM,EAAE;IACNM,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBC,YAAY,EAAE7C;EAChB,CAAC;EACDwC,IAAI,EAAE;IACJM,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE,GAAG;IAClBC,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,344 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Header = Header;
7
- var _native = require("@react-navigation/native");
8
- var _color = _interopRequireDefault(require("color"));
9
- var React = _interopRequireWildcard(require("react"));
10
- var _reactNative = require("react-native");
11
- var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
12
- var _searchIcon = _interopRequireDefault(require("../assets/search-icon.png"));
13
- var _getDefaultHeaderHeight = require("./getDefaultHeaderHeight.js");
14
- var _HeaderBackButton = require("./HeaderBackButton.js");
15
- var _HeaderBackground = require("./HeaderBackground.js");
16
- var _HeaderButton = require("./HeaderButton.js");
17
- var _HeaderIcon = require("./HeaderIcon.js");
18
- var _HeaderSearchBar = require("./HeaderSearchBar.js");
19
- var _HeaderShownContext = require("./HeaderShownContext.js");
20
- var _HeaderTitle = require("./HeaderTitle.js");
21
- var _jsxRuntime = require("react/jsx-runtime");
22
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
- // Width of the screen in split layout on portrait mode on iPad Mini
26
- const IPAD_MINI_MEDIUM_WIDTH = 414;
27
- const warnIfHeaderStylesDefined = styles => {
28
- Object.keys(styles).forEach(styleProp => {
29
- const value = styles[styleProp];
30
- if (styleProp === 'position' && value === 'absolute') {
31
- console.warn("position: 'absolute' is not supported on headerStyle. If you would like to render content under the header, use the 'headerTransparent' option.");
32
- } else if (value !== undefined) {
33
- console.warn(`${styleProp} was given a value of ${value}, this has no effect on headerStyle.`);
34
- }
35
- });
36
- };
37
- function Header(props) {
38
- const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
39
- const frame = (0, _reactNativeSafeAreaContext.useSafeAreaFrame)();
40
- const {
41
- colors
42
- } = (0, _native.useTheme)();
43
- const navigation = (0, _native.useNavigation)();
44
- const isParentHeaderShown = React.useContext(_HeaderShownContext.HeaderShownContext);
45
- const [searchBarVisible, setSearchBarVisible] = React.useState(false);
46
- const [titleLayout, setTitleLayout] = React.useState(undefined);
47
- const onTitleLayout = e => {
48
- const {
49
- height,
50
- width
51
- } = e.nativeEvent.layout;
52
- setTitleLayout(titleLayout => {
53
- if (titleLayout && height === titleLayout.height && width === titleLayout.width) {
54
- return titleLayout;
55
- }
56
- return {
57
- height,
58
- width
59
- };
60
- });
61
- };
62
- const {
63
- layout = frame,
64
- modal = false,
65
- back,
66
- title,
67
- headerTitle: customTitle,
68
- headerTitleAlign = _reactNative.Platform.OS === 'ios' ? 'center' : 'left',
69
- headerLeft = back ? props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderBackButton.HeaderBackButton, {
70
- ...props
71
- }) : undefined,
72
- headerSearchBarOptions,
73
- headerTransparent,
74
- headerTintColor,
75
- headerBackground,
76
- headerRight,
77
- headerTitleAllowFontScaling: titleAllowFontScaling,
78
- headerTitleStyle: titleStyle,
79
- headerLeftContainerStyle: leftContainerStyle,
80
- headerRightContainerStyle: rightContainerStyle,
81
- headerTitleContainerStyle: titleContainerStyle,
82
- headerBackButtonDisplayMode = _reactNative.Platform.OS === 'ios' ? 'default' : 'minimal',
83
- headerBackTitleStyle,
84
- headerBackgroundContainerStyle: backgroundContainerStyle,
85
- headerStyle: customHeaderStyle,
86
- headerShadowVisible,
87
- headerPressColor,
88
- headerPressOpacity,
89
- headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top
90
- } = props;
91
- const defaultHeight = (0, _getDefaultHeaderHeight.getDefaultHeaderHeight)(layout, modal, headerStatusBarHeight);
92
- const {
93
- height = defaultHeight,
94
- minHeight,
95
- maxHeight,
96
- backgroundColor,
97
- borderBottomColor,
98
- borderBottomEndRadius,
99
- borderBottomLeftRadius,
100
- borderBottomRightRadius,
101
- borderBottomStartRadius,
102
- borderBottomWidth,
103
- borderColor,
104
- borderEndColor,
105
- borderEndWidth,
106
- borderLeftColor,
107
- borderLeftWidth,
108
- borderRadius,
109
- borderRightColor,
110
- borderRightWidth,
111
- borderStartColor,
112
- borderStartWidth,
113
- borderStyle,
114
- borderTopColor,
115
- borderTopEndRadius,
116
- borderTopLeftRadius,
117
- borderTopRightRadius,
118
- borderTopStartRadius,
119
- borderTopWidth,
120
- borderWidth,
121
- boxShadow,
122
- elevation,
123
- shadowColor,
124
- shadowOffset,
125
- shadowOpacity,
126
- shadowRadius,
127
- opacity,
128
- transform,
129
- ...unsafeStyles
130
- } = _reactNative.StyleSheet.flatten(customHeaderStyle || {});
131
- if (process.env.NODE_ENV !== 'production') {
132
- warnIfHeaderStylesDefined(unsafeStyles);
133
- }
134
- const safeStyles = {
135
- backgroundColor,
136
- borderBottomColor,
137
- borderBottomEndRadius,
138
- borderBottomLeftRadius,
139
- borderBottomRightRadius,
140
- borderBottomStartRadius,
141
- borderBottomWidth,
142
- borderColor,
143
- borderEndColor,
144
- borderEndWidth,
145
- borderLeftColor,
146
- borderLeftWidth,
147
- borderRadius,
148
- borderRightColor,
149
- borderRightWidth,
150
- borderStartColor,
151
- borderStartWidth,
152
- borderStyle,
153
- borderTopColor,
154
- borderTopEndRadius,
155
- borderTopLeftRadius,
156
- borderTopRightRadius,
157
- borderTopStartRadius,
158
- borderTopWidth,
159
- borderWidth,
160
- boxShadow,
161
- elevation,
162
- shadowColor,
163
- shadowOffset,
164
- shadowOpacity,
165
- shadowRadius,
166
- opacity,
167
- transform
168
- };
169
-
170
- // Setting a property to undefined triggers default style
171
- // So we need to filter them out
172
- // Users can use `null` instead
173
- for (const styleProp in safeStyles) {
174
- // @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles
175
- if (safeStyles[styleProp] === undefined) {
176
- // @ts-expect-error don't need to care about index signature for deletion
177
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
178
- delete safeStyles[styleProp];
179
- }
180
- }
181
- const backgroundStyle = {
182
- ...(headerTransparent && {
183
- backgroundColor: 'transparent'
184
- }),
185
- ...((headerTransparent || headerShadowVisible === false) && {
186
- borderBottomWidth: 0,
187
- ..._reactNative.Platform.select({
188
- android: {
189
- elevation: 0
190
- },
191
- web: {
192
- boxShadow: 'none'
193
- },
194
- default: {
195
- shadowOpacity: 0
196
- }
197
- })
198
- }),
199
- ...safeStyles
200
- };
201
- const iconTintColor = headerTintColor ?? _reactNative.Platform.select({
202
- ios: colors.primary,
203
- default: colors.text
204
- });
205
- const leftButton = headerLeft ? headerLeft({
206
- tintColor: iconTintColor,
207
- pressColor: headerPressColor,
208
- pressOpacity: headerPressOpacity,
209
- displayMode: headerBackButtonDisplayMode,
210
- titleLayout,
211
- screenLayout: layout,
212
- canGoBack: Boolean(back),
213
- onPress: back ? navigation.goBack : undefined,
214
- label: back?.title,
215
- labelStyle: headerBackTitleStyle,
216
- href: back?.href
217
- }) : null;
218
- const rightButton = headerRight ? headerRight({
219
- tintColor: iconTintColor,
220
- pressColor: headerPressColor,
221
- pressOpacity: headerPressOpacity,
222
- canGoBack: Boolean(back)
223
- }) : null;
224
- const headerTitle = typeof customTitle !== 'function' ? props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTitle.HeaderTitle, {
225
- ...props
226
- }) : customTitle;
227
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
228
- pointerEvents: "box-none",
229
- style: [{
230
- height,
231
- minHeight,
232
- maxHeight,
233
- opacity,
234
- transform
235
- }],
236
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
237
- pointerEvents: "box-none",
238
- style: [_reactNative.StyleSheet.absoluteFill, backgroundContainerStyle],
239
- children: headerBackground ? headerBackground({
240
- style: backgroundStyle
241
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderBackground.HeaderBackground, {
242
- pointerEvents:
243
- // Allow touch through the header when background color is transparent
244
- headerTransparent && (backgroundStyle.backgroundColor === 'transparent' || (0, _color.default)(backgroundStyle.backgroundColor).alpha() === 0) ? 'none' : 'auto',
245
- style: backgroundStyle
246
- })
247
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
248
- pointerEvents: "none",
249
- style: {
250
- height: headerStatusBarHeight
251
- }
252
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
253
- pointerEvents: "box-none",
254
- style: [styles.content, _reactNative.Platform.OS === 'ios' && frame.width >= IPAD_MINI_MEDIUM_WIDTH ? styles.large : null],
255
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
256
- pointerEvents: "box-none",
257
- style: [styles.start, !searchBarVisible && headerTitleAlign === 'center' && styles.expand, {
258
- marginStart: insets.left
259
- }, leftContainerStyle],
260
- children: leftButton
261
- }), _reactNative.Platform.OS === 'ios' || !searchBarVisible ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
262
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
263
- pointerEvents: "box-none",
264
- style: [styles.title, {
265
- // Avoid the title from going offscreen or overlapping buttons
266
- maxWidth: headerTitleAlign === 'center' ? layout.width - ((leftButton ? headerBackButtonDisplayMode !== 'minimal' ? 80 : 32 : 16) + (rightButton || headerSearchBarOptions ? 16 : 0) + Math.max(insets.left, insets.right)) * 2 : layout.width - ((leftButton ? 52 : 16) + (rightButton || headerSearchBarOptions ? 52 : 16) + insets.left - insets.right)
267
- }, headerTitleAlign === 'left' && leftButton ? {
268
- marginStart: 4
269
- } : {
270
- marginHorizontal: 16
271
- }, titleContainerStyle],
272
- children: headerTitle({
273
- children: title,
274
- allowFontScaling: titleAllowFontScaling,
275
- tintColor: headerTintColor,
276
- onLayout: onTitleLayout,
277
- style: titleStyle
278
- })
279
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
280
- pointerEvents: "box-none",
281
- style: [styles.end, styles.expand, {
282
- marginEnd: insets.right
283
- }, rightContainerStyle],
284
- children: [rightButton, headerSearchBarOptions ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderButton.HeaderButton, {
285
- tintColor: iconTintColor,
286
- pressColor: headerPressColor,
287
- pressOpacity: headerPressOpacity,
288
- onPress: () => {
289
- setSearchBarVisible(true);
290
- headerSearchBarOptions?.onOpen?.();
291
- },
292
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderIcon.HeaderIcon, {
293
- source: _searchIcon.default,
294
- tintColor: iconTintColor
295
- })
296
- }) : null]
297
- })]
298
- }) : null, _reactNative.Platform.OS === 'ios' || searchBarVisible ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderSearchBar.HeaderSearchBar, {
299
- ...headerSearchBarOptions,
300
- visible: searchBarVisible,
301
- onClose: () => {
302
- setSearchBarVisible(false);
303
- headerSearchBarOptions?.onClose?.();
304
- },
305
- tintColor: headerTintColor,
306
- style: [_reactNative.Platform.OS === 'ios' ? [_reactNative.StyleSheet.absoluteFill, {
307
- paddingTop: headerStatusBarHeight ? 0 : 4
308
- }, {
309
- backgroundColor: backgroundColor ?? colors.card
310
- }] : !leftButton && {
311
- marginStart: 8
312
- }]
313
- }) : null]
314
- })]
315
- });
316
- }
317
- const styles = _reactNative.StyleSheet.create({
318
- content: {
319
- flex: 1,
320
- flexDirection: 'row',
321
- alignItems: 'stretch'
322
- },
323
- large: {
324
- marginHorizontal: 5
325
- },
326
- title: {
327
- justifyContent: 'center'
328
- },
329
- start: {
330
- flexDirection: 'row',
331
- alignItems: 'center',
332
- justifyContent: 'flex-start'
333
- },
334
- end: {
335
- flexDirection: 'row',
336
- alignItems: 'center',
337
- justifyContent: 'flex-end'
338
- },
339
- expand: {
340
- flexGrow: 1,
341
- flexBasis: 0
342
- }
343
- });
344
- //# sourceMappingURL=Header.js.map