@sigmela/router 0.0.12 → 0.0.14

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.
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- import { ScreenStack, ScreenStackItem as RNNScreenStackItem } from 'react-native-screens';
4
- import { memo, useCallback, useEffect, useState, useSyncExternalStore } from 'react';
5
3
  import { RenderTabBar } from "./TabBar/RenderTabBar.js";
6
4
  import { ScreenStackItem } from "./ScreenStackItem.js";
7
5
  import { RouterContext } from "./RouterContext.js";
8
6
  import { StyleSheet } from 'react-native';
7
+ import { ScreenStackItem as RNNScreenStackItem, ScreenStack } from 'react-native-screens';
8
+ import { useSyncExternalStore, memo, useCallback, useEffect, useState } from 'react';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  const EMPTY_HISTORY = [];
11
11
  function useStackHistory(router, stackId) {
@@ -50,19 +50,17 @@ export const Navigation = /*#__PURE__*/memo(({
50
50
  stackAnimation: rootTransition,
51
51
  children: /*#__PURE__*/_jsx(RenderTabBar, {
52
52
  tabBar: router.tabBar,
53
- appearance: appearance?.tabBar
53
+ appearance: appearance
54
54
  })
55
55
  }), rootItems.map(item => /*#__PURE__*/_jsx(ScreenStackItem, {
56
56
  stackId: rootId,
57
57
  item: item,
58
58
  stackAnimation: rootTransition,
59
- screenStyle: appearance?.screenStyle,
60
- headerAppearance: appearance?.header
59
+ appearance: appearance
61
60
  }, item.key)), globalItems.map(item => /*#__PURE__*/_jsx(ScreenStackItem, {
61
+ appearance: appearance,
62
62
  stackId: globalId,
63
- item: item,
64
- screenStyle: appearance?.screenStyle,
65
- headerAppearance: appearance?.header
63
+ item: item
66
64
  }, item.key))]
67
65
  })
68
66
  });
@@ -9,7 +9,7 @@ export const ScreenStackItem = /*#__PURE__*/memo(({
9
9
  item,
10
10
  stackId,
11
11
  stackAnimation,
12
- screenStyle
12
+ appearance
13
13
  }) => {
14
14
  const router = useRouter();
15
15
  const onDismissed = () => {
@@ -32,22 +32,16 @@ export const ScreenStackItem = /*#__PURE__*/memo(({
32
32
  header,
33
33
  ...screenProps
34
34
  } = item.options || {};
35
- // Merge global header appearance with per-screen header options
36
- // const mergedHeader = {
37
- // ...(headerAppearance ?? {}),
38
- // ...(header ?? {}),
39
- // } as any;
40
- // Hide header by default if not specified
41
- const headerConfig = header ?? {
42
- hidden: true
35
+ const headerConfig = {
36
+ ...header,
37
+ hidden: !header?.title || header?.hidden,
38
+ backgroundColor: appearance?.header?.backgroundColor ?? 'transparent'
43
39
  };
44
-
45
- // console.log('headerConfig', headerAppearance, item.key);
46
40
  return /*#__PURE__*/_jsx(RNSScreenStackItem, {
47
41
  screenId: item.key,
48
42
  onDismissed: onDismissed,
49
43
  style: StyleSheet.absoluteFill,
50
- contentStyle: screenStyle,
44
+ contentStyle: appearance?.screenStyle,
51
45
  headerConfig: headerConfig,
52
46
  ...screenProps,
53
47
  stackAnimation: stackAnimation ?? item.options?.stackAnimation,
@@ -7,7 +7,8 @@ import { useRouter } from "./RouterContext.js";
7
7
  import { StyleSheet } from 'react-native';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export const StackRenderer = /*#__PURE__*/memo(({
10
- stack
10
+ stack,
11
+ appearance
11
12
  }) => {
12
13
  const router = useRouter();
13
14
  const stackId = stack.getId();
@@ -15,10 +16,11 @@ export const StackRenderer = /*#__PURE__*/memo(({
15
16
  const get = useCallback(() => router.getStackHistory(stackId), [router, stackId]);
16
17
  const historyForThisStack = useSyncExternalStore(subscribe, get, get);
17
18
  return /*#__PURE__*/_jsx(ScreenStack, {
18
- style: styles.flex,
19
+ style: [styles.flex, appearance?.screenStyle],
19
20
  children: historyForThisStack.map(item => /*#__PURE__*/_jsx(ScreenStackItem, {
20
- item: item,
21
- stackId: stackId
21
+ appearance: appearance,
22
+ stackId: stackId,
23
+ item: item
22
24
  }, item.key))
23
25
  });
24
26
  });
@@ -45,7 +45,7 @@ export const RenderTabBar = /*#__PURE__*/memo(({
45
45
  tabBarItemStyle,
46
46
  tintColor,
47
47
  backgroundColor
48
- } = appearance ?? {};
48
+ } = appearance?.tabBar ?? {};
49
49
  useEffect(() => {
50
50
  router.ensureTabSeed(index);
51
51
  }, [index, router]);
@@ -113,6 +113,7 @@ export const RenderTabBar = /*#__PURE__*/memo(({
113
113
  isFocused: isFocused,
114
114
  ...mappedTabProps,
115
115
  children: stack ? /*#__PURE__*/_jsx(StackRenderer, {
116
+ appearance: appearance,
116
117
  stack: stack
117
118
  }) : Screen ? /*#__PURE__*/_jsx(Screen, {}) : null
118
119
  }, tab.tabKey);
@@ -1,5 +1,5 @@
1
- import { Router } from './Router';
2
1
  import type { NavigationAppearance } from './types';
2
+ import { Router } from './Router';
3
3
  export interface NavigationProps {
4
4
  router: Router;
5
5
  appearance?: NavigationAppearance;
@@ -1,11 +1,9 @@
1
1
  import type { HistoryItem, ScreenOptions, NavigationAppearance } from './types';
2
- import { type StyleProp, type ViewStyle } from 'react-native';
3
2
  interface ScreenStackItemProps {
4
3
  item: HistoryItem;
5
4
  stackId?: string;
6
5
  stackAnimation?: ScreenOptions['stackAnimation'];
7
- screenStyle?: StyleProp<ViewStyle>;
8
- headerAppearance?: NavigationAppearance['header'];
6
+ appearance?: NavigationAppearance;
9
7
  }
10
8
  export declare const ScreenStackItem: import("react").NamedExoticComponent<ScreenStackItemProps>;
11
9
  export {};
@@ -1,6 +1,8 @@
1
+ import type { NavigationAppearance } from './types';
1
2
  import { NavigationStack } from './NavigationStack';
2
3
  export interface StackRendererProps {
3
4
  stack: NavigationStack;
5
+ appearance?: NavigationAppearance;
4
6
  }
5
7
  export declare const StackRenderer: import("react").NamedExoticComponent<StackRendererProps>;
6
8
  //# sourceMappingURL=StackRenderer.d.ts.map
@@ -2,7 +2,7 @@ import type { NavigationAppearance } from '../types';
2
2
  import type { TabBar } from './TabBar';
3
3
  export interface RenderTabBarProps {
4
4
  tabBar: TabBar;
5
- appearance?: NavigationAppearance['tabBar'];
5
+ appearance?: NavigationAppearance;
6
6
  }
7
7
  export declare const RenderTabBar: import("react").NamedExoticComponent<RenderTabBarProps>;
8
8
  //# sourceMappingURL=RenderTabBar.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigmela/router",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "React Native Router",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",