@symbiote-native/navigation 1.0.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.
- package/LICENSE +21 -0
- package/build/angular/drawer/index.d.ts +76 -0
- package/build/angular/drawer/index.js +508 -0
- package/build/angular/drawer-screen.directive.d.ts +14 -0
- package/build/angular/drawer-screen.directive.js +87 -0
- package/build/angular/index.d.ts +23 -0
- package/build/angular/index.js +22 -0
- package/build/angular/injectors/index.d.ts +13 -0
- package/build/angular/injectors/index.js +8 -0
- package/build/angular/injectors/inject-drawer-navigation.d.ts +4 -0
- package/build/angular/injectors/inject-drawer-navigation.js +12 -0
- package/build/angular/injectors/inject-focus-effect.d.ts +2 -0
- package/build/angular/injectors/inject-focus-effect.js +29 -0
- package/build/angular/injectors/inject-is-focused.d.ts +2 -0
- package/build/angular/injectors/inject-is-focused.js +20 -0
- package/build/angular/injectors/inject-navigation-state.d.ts +3 -0
- package/build/angular/injectors/inject-navigation-state.js +35 -0
- package/build/angular/injectors/inject-navigation.d.ts +7 -0
- package/build/angular/injectors/inject-navigation.js +16 -0
- package/build/angular/injectors/inject-route.d.ts +3 -0
- package/build/angular/injectors/inject-route.js +20 -0
- package/build/angular/injectors/inject-stack-navigation.d.ts +4 -0
- package/build/angular/injectors/inject-stack-navigation.js +15 -0
- package/build/angular/injectors/inject-tab-navigation.d.ts +4 -0
- package/build/angular/injectors/inject-tab-navigation.js +11 -0
- package/build/angular/linking.d.ts +3 -0
- package/build/angular/linking.js +43 -0
- package/build/angular/navigation-context.service.d.ts +13 -0
- package/build/angular/navigation-context.service.js +105 -0
- package/build/angular/navigation-scope.directive.d.ts +10 -0
- package/build/angular/navigation-scope.directive.js +90 -0
- package/build/angular/screen.directive.d.ts +22 -0
- package/build/angular/screen.directive.js +90 -0
- package/build/angular/search-bar-ref.directive.d.ts +10 -0
- package/build/angular/search-bar-ref.directive.js +88 -0
- package/build/angular/stack/index.d.ts +55 -0
- package/build/angular/stack/index.js +386 -0
- package/build/angular/tab-screen.directive.d.ts +14 -0
- package/build/angular/tab-screen.directive.js +87 -0
- package/build/angular/tabs/index.d.ts +42 -0
- package/build/angular/tabs/index.js +263 -0
- package/build/core/constants.d.ts +27 -0
- package/build/core/constants.js +61 -0
- package/build/core/drawer-options/index.d.ts +64 -0
- package/build/core/drawer-options/index.js +200 -0
- package/build/core/drawer-router-state/index.d.ts +21 -0
- package/build/core/drawer-router-state/index.js +40 -0
- package/build/core/guards.d.ts +2 -0
- package/build/core/guards.js +22 -0
- package/build/core/header-bar-buttons.d.ts +9 -0
- package/build/core/header-bar-buttons.js +163 -0
- package/build/core/index.d.ts +29 -0
- package/build/core/index.js +32 -0
- package/build/core/linking-config/index.d.ts +13 -0
- package/build/core/linking-config/index.js +171 -0
- package/build/core/navigation-events/index.d.ts +16 -0
- package/build/core/navigation-events/index.js +57 -0
- package/build/core/navigator-handles/index.d.ts +30 -0
- package/build/core/navigator-handles/index.js +15 -0
- package/build/core/navigator-props.d.ts +216 -0
- package/build/core/navigator-props.js +7 -0
- package/build/core/navigator-state/index.d.ts +36 -0
- package/build/core/navigator-state/index.js +81 -0
- package/build/core/render-drawer.d.ts +13 -0
- package/build/core/render-drawer.js +88 -0
- package/build/core/render-stack.d.ts +35 -0
- package/build/core/render-stack.js +294 -0
- package/build/core/render-tabs.d.ts +20 -0
- package/build/core/render-tabs.js +97 -0
- package/build/core/screen-options.d.ts +4 -0
- package/build/core/screen-options.js +133 -0
- package/build/core/search-bar-commands.d.ts +10 -0
- package/build/core/search-bar-commands.js +42 -0
- package/build/core/state-persistence/index.d.ts +3 -0
- package/build/core/state-persistence/index.js +23 -0
- package/build/core/tab-options.d.ts +13 -0
- package/build/core/tab-options.js +10 -0
- package/build/core/tab-router-state/index.d.ts +19 -0
- package/build/core/tab-router-state/index.js +51 -0
- package/build/react/collect-registry.d.ts +4 -0
- package/build/react/collect-registry.js +15 -0
- package/build/react/drawer/index.d.ts +29 -0
- package/build/react/drawer/index.js +277 -0
- package/build/react/drawer-screen.d.ts +14 -0
- package/build/react/drawer-screen.js +8 -0
- package/build/react/hooks/index.d.ts +12 -0
- package/build/react/hooks/index.js +8 -0
- package/build/react/hooks/use-drawer-navigation.d.ts +4 -0
- package/build/react/hooks/use-drawer-navigation.js +12 -0
- package/build/react/hooks/use-focus-effect.d.ts +2 -0
- package/build/react/hooks/use-focus-effect.js +29 -0
- package/build/react/hooks/use-is-focused.d.ts +1 -0
- package/build/react/hooks/use-is-focused.js +22 -0
- package/build/react/hooks/use-navigation-state/index.d.ts +2 -0
- package/build/react/hooks/use-navigation-state/index.js +39 -0
- package/build/react/hooks/use-navigation.d.ts +7 -0
- package/build/react/hooks/use-navigation.js +16 -0
- package/build/react/hooks/use-route.d.ts +2 -0
- package/build/react/hooks/use-route.js +8 -0
- package/build/react/hooks/use-stack-navigation.d.ts +4 -0
- package/build/react/hooks/use-stack-navigation.js +14 -0
- package/build/react/hooks/use-tab-navigation.d.ts +4 -0
- package/build/react/hooks/use-tab-navigation.js +12 -0
- package/build/react/index.d.ts +24 -0
- package/build/react/index.js +21 -0
- package/build/react/linking.d.ts +3 -0
- package/build/react/linking.js +47 -0
- package/build/react/navigation-context.d.ts +10 -0
- package/build/react/navigation-context.js +22 -0
- package/build/react/screen.d.ts +22 -0
- package/build/react/screen.js +7 -0
- package/build/react/stack/index.d.ts +13 -0
- package/build/react/stack/index.js +202 -0
- package/build/react/tab-screen.d.ts +15 -0
- package/build/react/tab-screen.js +8 -0
- package/build/react/tabs/index.d.ts +12 -0
- package/build/react/tabs/index.js +116 -0
- package/build/register.d.ts +7 -0
- package/build/register.js +58 -0
- package/build/vue/composables/index.d.ts +12 -0
- package/build/vue/composables/index.js +8 -0
- package/build/vue/composables/use-drawer-navigation.d.ts +5 -0
- package/build/vue/composables/use-drawer-navigation.js +15 -0
- package/build/vue/composables/use-focus-effect.d.ts +1 -0
- package/build/vue/composables/use-focus-effect.js +31 -0
- package/build/vue/composables/use-is-focused.d.ts +2 -0
- package/build/vue/composables/use-is-focused.js +28 -0
- package/build/vue/composables/use-navigation-state.d.ts +3 -0
- package/build/vue/composables/use-navigation-state.js +29 -0
- package/build/vue/composables/use-navigation.d.ts +8 -0
- package/build/vue/composables/use-navigation.js +13 -0
- package/build/vue/composables/use-route.d.ts +3 -0
- package/build/vue/composables/use-route.js +9 -0
- package/build/vue/composables/use-stack-navigation.d.ts +5 -0
- package/build/vue/composables/use-stack-navigation.js +18 -0
- package/build/vue/composables/use-tab-navigation.d.ts +5 -0
- package/build/vue/composables/use-tab-navigation.js +15 -0
- package/build/vue/drawer/index.d.ts +19 -0
- package/build/vue/drawer/index.js +390 -0
- package/build/vue/drawer-screen.d.ts +14 -0
- package/build/vue/drawer-screen.js +12 -0
- package/build/vue/index.d.ts +21 -0
- package/build/vue/index.js +19 -0
- package/build/vue/linking.d.ts +3 -0
- package/build/vue/linking.js +57 -0
- package/build/vue/navigation-context.d.ts +16 -0
- package/build/vue/navigation-context.js +65 -0
- package/build/vue/screen.d.ts +21 -0
- package/build/vue/screen.js +12 -0
- package/build/vue/stack/index.d.ts +9 -0
- package/build/vue/stack/index.js +279 -0
- package/build/vue/tab-screen.d.ts +14 -0
- package/build/vue/tab-screen.js +11 -0
- package/build/vue/tabs/index.d.ts +10 -0
- package/build/vue/tabs/index.js +209 -0
- package/build-ngc/angular/drawer/index.d.ts +79 -0
- package/build-ngc/angular/drawer/index.js +479 -0
- package/build-ngc/angular/drawer/index.js.map +1 -0
- package/build-ngc/angular/drawer-screen.directive.d.ts +17 -0
- package/build-ngc/angular/drawer-screen.directive.js +32 -0
- package/build-ngc/angular/drawer-screen.directive.js.map +1 -0
- package/build-ngc/angular/drawer.d.ts +79 -0
- package/build-ngc/angular/drawer.js +475 -0
- package/build-ngc/angular/drawer.js.map +1 -0
- package/build-ngc/angular/index.d.ts +23 -0
- package/build-ngc/angular/index.js +23 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/angular/injectors/index.d.ts +13 -0
- package/build-ngc/angular/injectors/index.js +9 -0
- package/build-ngc/angular/injectors/index.js.map +1 -0
- package/build-ngc/angular/injectors/inject-drawer-navigation.d.ts +4 -0
- package/build-ngc/angular/injectors/inject-drawer-navigation.js +13 -0
- package/build-ngc/angular/injectors/inject-drawer-navigation.js.map +1 -0
- package/build-ngc/angular/injectors/inject-focus-effect.d.ts +2 -0
- package/build-ngc/angular/injectors/inject-focus-effect.js +30 -0
- package/build-ngc/angular/injectors/inject-focus-effect.js.map +1 -0
- package/build-ngc/angular/injectors/inject-is-focused.d.ts +2 -0
- package/build-ngc/angular/injectors/inject-is-focused.js +22 -0
- package/build-ngc/angular/injectors/inject-is-focused.js.map +1 -0
- package/build-ngc/angular/injectors/inject-navigation-state.d.ts +3 -0
- package/build-ngc/angular/injectors/inject-navigation-state.js +37 -0
- package/build-ngc/angular/injectors/inject-navigation-state.js.map +1 -0
- package/build-ngc/angular/injectors/inject-navigation.d.ts +7 -0
- package/build-ngc/angular/injectors/inject-navigation.js +17 -0
- package/build-ngc/angular/injectors/inject-navigation.js.map +1 -0
- package/build-ngc/angular/injectors/inject-route.d.ts +3 -0
- package/build-ngc/angular/injectors/inject-route.js +21 -0
- package/build-ngc/angular/injectors/inject-route.js.map +1 -0
- package/build-ngc/angular/injectors/inject-stack-navigation.d.ts +4 -0
- package/build-ngc/angular/injectors/inject-stack-navigation.js +16 -0
- package/build-ngc/angular/injectors/inject-stack-navigation.js.map +1 -0
- package/build-ngc/angular/injectors/inject-tab-navigation.d.ts +4 -0
- package/build-ngc/angular/injectors/inject-tab-navigation.js +12 -0
- package/build-ngc/angular/injectors/inject-tab-navigation.js.map +1 -0
- package/build-ngc/angular/linking.d.ts +3 -0
- package/build-ngc/angular/linking.js +44 -0
- package/build-ngc/angular/linking.js.map +1 -0
- package/build-ngc/angular/navigation-context.service.d.ts +16 -0
- package/build-ngc/angular/navigation-context.service.js +63 -0
- package/build-ngc/angular/navigation-context.service.js.map +1 -0
- package/build-ngc/angular/navigation-scope.directive.d.ts +13 -0
- package/build-ngc/angular/navigation-scope.directive.js +42 -0
- package/build-ngc/angular/navigation-scope.directive.js.map +1 -0
- package/build-ngc/angular/screen.directive.d.ts +25 -0
- package/build-ngc/angular/screen.directive.js +35 -0
- package/build-ngc/angular/screen.directive.js.map +1 -0
- package/build-ngc/angular/search-bar-ref.directive.d.ts +13 -0
- package/build-ngc/angular/search-bar-ref.directive.js +44 -0
- package/build-ngc/angular/search-bar-ref.directive.js.map +1 -0
- package/build-ngc/angular/stack/index.d.ts +58 -0
- package/build-ngc/angular/stack/index.js +406 -0
- package/build-ngc/angular/stack/index.js.map +1 -0
- package/build-ngc/angular/stack.d.ts +58 -0
- package/build-ngc/angular/stack.js +402 -0
- package/build-ngc/angular/stack.js.map +1 -0
- package/build-ngc/angular/tab-screen.directive.d.ts +17 -0
- package/build-ngc/angular/tab-screen.directive.js +32 -0
- package/build-ngc/angular/tab-screen.directive.js.map +1 -0
- package/build-ngc/angular/tabs/index.d.ts +45 -0
- package/build-ngc/angular/tabs/index.js +231 -0
- package/build-ngc/angular/tabs/index.js.map +1 -0
- package/build-ngc/angular/tabs.d.ts +45 -0
- package/build-ngc/angular/tabs.js +231 -0
- package/build-ngc/angular/tabs.js.map +1 -0
- package/build-ngc/core/constants.d.ts +27 -0
- package/build-ngc/core/constants.js +62 -0
- package/build-ngc/core/constants.js.map +1 -0
- package/build-ngc/core/drawer-options/index.d.ts +64 -0
- package/build-ngc/core/drawer-options/index.js +201 -0
- package/build-ngc/core/drawer-options/index.js.map +1 -0
- package/build-ngc/core/drawer-options.d.ts +64 -0
- package/build-ngc/core/drawer-options.js +201 -0
- package/build-ngc/core/drawer-options.js.map +1 -0
- package/build-ngc/core/drawer-router-state/index.d.ts +21 -0
- package/build-ngc/core/drawer-router-state/index.js +41 -0
- package/build-ngc/core/drawer-router-state/index.js.map +1 -0
- package/build-ngc/core/drawer-router-state.d.ts +21 -0
- package/build-ngc/core/drawer-router-state.js +41 -0
- package/build-ngc/core/drawer-router-state.js.map +1 -0
- package/build-ngc/core/guards.d.ts +2 -0
- package/build-ngc/core/guards.js +23 -0
- package/build-ngc/core/guards.js.map +1 -0
- package/build-ngc/core/header-bar-buttons.d.ts +9 -0
- package/build-ngc/core/header-bar-buttons.js +164 -0
- package/build-ngc/core/header-bar-buttons.js.map +1 -0
- package/build-ngc/core/href.d.ts +16 -0
- package/build-ngc/core/href.js +55 -0
- package/build-ngc/core/href.js.map +1 -0
- package/build-ngc/core/index.d.ts +29 -0
- package/build-ngc/core/index.js +33 -0
- package/build-ngc/core/index.js.map +1 -0
- package/build-ngc/core/linking-config/index.d.ts +13 -0
- package/build-ngc/core/linking-config/index.js +172 -0
- package/build-ngc/core/linking-config/index.js.map +1 -0
- package/build-ngc/core/linking-config.d.ts +13 -0
- package/build-ngc/core/linking-config.js +172 -0
- package/build-ngc/core/linking-config.js.map +1 -0
- package/build-ngc/core/navigation-events/index.d.ts +16 -0
- package/build-ngc/core/navigation-events/index.js +58 -0
- package/build-ngc/core/navigation-events/index.js.map +1 -0
- package/build-ngc/core/navigation-events.d.ts +16 -0
- package/build-ngc/core/navigation-events.js +58 -0
- package/build-ngc/core/navigation-events.js.map +1 -0
- package/build-ngc/core/navigator-handles/index.d.ts +30 -0
- package/build-ngc/core/navigator-handles/index.js +16 -0
- package/build-ngc/core/navigator-handles/index.js.map +1 -0
- package/build-ngc/core/navigator-handles.d.ts +30 -0
- package/build-ngc/core/navigator-handles.js +16 -0
- package/build-ngc/core/navigator-handles.js.map +1 -0
- package/build-ngc/core/navigator-props.d.ts +216 -0
- package/build-ngc/core/navigator-props.js +8 -0
- package/build-ngc/core/navigator-props.js.map +1 -0
- package/build-ngc/core/navigator-state/index.d.ts +36 -0
- package/build-ngc/core/navigator-state/index.js +82 -0
- package/build-ngc/core/navigator-state/index.js.map +1 -0
- package/build-ngc/core/navigator-state.d.ts +36 -0
- package/build-ngc/core/navigator-state.js +82 -0
- package/build-ngc/core/navigator-state.js.map +1 -0
- package/build-ngc/core/render-drawer.d.ts +13 -0
- package/build-ngc/core/render-drawer.js +89 -0
- package/build-ngc/core/render-drawer.js.map +1 -0
- package/build-ngc/core/render-stack.d.ts +35 -0
- package/build-ngc/core/render-stack.js +295 -0
- package/build-ngc/core/render-stack.js.map +1 -0
- package/build-ngc/core/render-tabs.d.ts +20 -0
- package/build-ngc/core/render-tabs.js +98 -0
- package/build-ngc/core/render-tabs.js.map +1 -0
- package/build-ngc/core/screen-options.d.ts +4 -0
- package/build-ngc/core/screen-options.js +134 -0
- package/build-ngc/core/screen-options.js.map +1 -0
- package/build-ngc/core/search-bar-commands.d.ts +10 -0
- package/build-ngc/core/search-bar-commands.js +43 -0
- package/build-ngc/core/search-bar-commands.js.map +1 -0
- package/build-ngc/core/search-params.d.ts +9 -0
- package/build-ngc/core/search-params.js +60 -0
- package/build-ngc/core/search-params.js.map +1 -0
- package/build-ngc/core/state-persistence/index.d.ts +3 -0
- package/build-ngc/core/state-persistence/index.js +24 -0
- package/build-ngc/core/state-persistence/index.js.map +1 -0
- package/build-ngc/core/state-persistence.d.ts +3 -0
- package/build-ngc/core/state-persistence.js +24 -0
- package/build-ngc/core/state-persistence.js.map +1 -0
- package/build-ngc/core/tab-options.d.ts +13 -0
- package/build-ngc/core/tab-options.js +11 -0
- package/build-ngc/core/tab-options.js.map +1 -0
- package/build-ngc/core/tab-router-state/index.d.ts +19 -0
- package/build-ngc/core/tab-router-state/index.js +52 -0
- package/build-ngc/core/tab-router-state/index.js.map +1 -0
- package/build-ngc/core/tab-router-state.d.ts +19 -0
- package/build-ngc/core/tab-router-state.js +52 -0
- package/build-ngc/core/tab-router-state.js.map +1 -0
- package/build-ngc/register.d.ts +7 -0
- package/build-ngc/register.js +59 -0
- package/build-ngc/register.js.map +1 -0
- package/codegen-specs/FullWindowOverlayNativeComponent.ts +13 -0
- package/codegen-specs/ModalScreenNativeComponent.ts +129 -0
- package/codegen-specs/NativeScreensModule.ts +8 -0
- package/codegen-specs/NativeScreensModule.web.ts +1 -0
- package/codegen-specs/ScreenContainerNativeComponent.ts +8 -0
- package/codegen-specs/ScreenContentWrapperNativeComponent.ts +9 -0
- package/codegen-specs/ScreenFooterNativeComponent.ts +6 -0
- package/codegen-specs/ScreenNativeComponent.ts +133 -0
- package/codegen-specs/ScreenNavigationContainerNativeComponent.ts +11 -0
- package/codegen-specs/ScreenStackHeaderConfigNativeComponent.ts +99 -0
- package/codegen-specs/ScreenStackHeaderSubviewNativeComponent.ts +25 -0
- package/codegen-specs/ScreenStackNativeComponent.ts +17 -0
- package/codegen-specs/SearchBarNativeComponent.ts +101 -0
- package/codegen-specs/codegenUtils.ts +6 -0
- package/codegen-specs/gamma/ScrollViewMarkerNativeComponent.ts +15 -0
- package/codegen-specs/gamma/modals/form-sheet/FormSheetContentWrapperNativeComponent.ts +10 -0
- package/codegen-specs/gamma/modals/form-sheet/FormSheetHostNativeComponent.ts +47 -0
- package/codegen-specs/gamma/split/SplitHostNativeComponent.ts +124 -0
- package/codegen-specs/gamma/split/SplitScreenNativeComponent.ts +24 -0
- package/codegen-specs/gamma/stack/StackHeaderConfigAndroidNativeComponent.ts +144 -0
- package/codegen-specs/gamma/stack/StackHeaderConfigIOSNativeComponent.ts +34 -0
- package/codegen-specs/gamma/stack/StackHeaderItemIOSNativeComponent.ts +47 -0
- package/codegen-specs/gamma/stack/StackHeaderItemSpacerIOSNativeComponent.ts +20 -0
- package/codegen-specs/gamma/stack/StackHeaderSubviewAndroidNativeComponent.ts +27 -0
- package/codegen-specs/gamma/stack/StackHostNativeComponent.ts +8 -0
- package/codegen-specs/gamma/stack/StackScreenNativeComponent.ts +42 -0
- package/codegen-specs/safe-area/SafeAreaViewNativeComponent.ts +24 -0
- package/codegen-specs/tabs/TabsBottomAccessoryContentNativeComponent.ts +15 -0
- package/codegen-specs/tabs/TabsBottomAccessoryNativeComponent.ts +19 -0
- package/codegen-specs/tabs/TabsHostAndroidNativeComponent.ts +69 -0
- package/codegen-specs/tabs/TabsHostIOSNativeComponent.ts +92 -0
- package/codegen-specs/tabs/TabsScreenAndroidNativeComponent.ts +112 -0
- package/codegen-specs/tabs/TabsScreenIOSNativeComponent.ts +171 -0
- package/package.json +201 -0
- package/react-native.config.cjs +58 -0
- package/src/angular/drawer/drawer.test.ts +299 -0
- package/src/angular/drawer/index.ts +546 -0
- package/src/angular/drawer-screen.directive.ts +28 -0
- package/src/angular/index.ts +63 -0
- package/src/angular/injectors/index.ts +13 -0
- package/src/angular/injectors/inject-drawer-navigation.ts +21 -0
- package/src/angular/injectors/inject-focus-effect.ts +37 -0
- package/src/angular/injectors/inject-is-focused.ts +28 -0
- package/src/angular/injectors/inject-navigation-state.ts +46 -0
- package/src/angular/injectors/inject-navigation.ts +26 -0
- package/src/angular/injectors/inject-route.ts +25 -0
- package/src/angular/injectors/inject-stack-navigation.ts +24 -0
- package/src/angular/injectors/inject-tab-navigation.ts +20 -0
- package/src/angular/injectors/injectors.test.ts +247 -0
- package/src/angular/injectors/use-typed-navigation.test.ts +229 -0
- package/src/angular/linking.ts +55 -0
- package/src/angular/navigation-context.service.ts +68 -0
- package/src/angular/navigation-scope.directive.ts +31 -0
- package/src/angular/nested-navigation.test.ts +189 -0
- package/src/angular/screen.directive.ts +48 -0
- package/src/angular/search-bar-ref.directive.ts +38 -0
- package/src/angular/stack/index.ts +401 -0
- package/src/angular/stack/stack.test.ts +419 -0
- package/src/angular/tab-screen.directive.ts +26 -0
- package/src/angular/tabs/index.ts +254 -0
- package/src/angular/tabs/tabs.test.ts +249 -0
- package/src/core/constants.ts +68 -0
- package/src/core/drawer-options/drawer-options.test.ts +415 -0
- package/src/core/drawer-options/index.ts +331 -0
- package/src/core/drawer-router-state/drawer-router-state.test.ts +116 -0
- package/src/core/drawer-router-state/index.ts +71 -0
- package/src/core/guards.ts +23 -0
- package/src/core/header-bar-buttons.ts +212 -0
- package/src/core/index.ts +170 -0
- package/src/core/linking-config/index.ts +209 -0
- package/src/core/linking-config/linking-config.test.ts +109 -0
- package/src/core/navigation-events/index.ts +94 -0
- package/src/core/navigation-events/navigation-events.test.ts +56 -0
- package/src/core/navigator-handles/index.ts +63 -0
- package/src/core/navigator-handles/navigator-handles.test.ts +46 -0
- package/src/core/navigator-props.ts +323 -0
- package/src/core/navigator-state/index.ts +112 -0
- package/src/core/navigator-state/navigator-state.test.ts +80 -0
- package/src/core/render-drawer.ts +123 -0
- package/src/core/render-stack.ts +414 -0
- package/src/core/render-tabs.ts +138 -0
- package/src/core/screen-options.ts +181 -0
- package/src/core/search-bar-commands.ts +57 -0
- package/src/core/state-persistence/index.ts +30 -0
- package/src/core/state-persistence/state-persistence.test.ts +42 -0
- package/src/core/tab-options.ts +25 -0
- package/src/core/tab-router-state/index.ts +75 -0
- package/src/core/tab-router-state/tab-router-state.test.ts +34 -0
- package/src/globals.d.ts +4 -0
- package/src/react/collect-registry.ts +19 -0
- package/src/react/drawer/drawer.test.tsx +472 -0
- package/src/react/drawer/index.ts +451 -0
- package/src/react/drawer-screen.ts +29 -0
- package/src/react/hooks/hooks.test.tsx +199 -0
- package/src/react/hooks/index.ts +12 -0
- package/src/react/hooks/use-drawer-navigation.ts +21 -0
- package/src/react/hooks/use-focus-effect.ts +36 -0
- package/src/react/hooks/use-is-focused.ts +26 -0
- package/src/react/hooks/use-navigation-state/index.ts +47 -0
- package/src/react/hooks/use-navigation-state/use-navigation-state.test.ts +85 -0
- package/src/react/hooks/use-navigation.ts +36 -0
- package/src/react/hooks/use-route.ts +11 -0
- package/src/react/hooks/use-stack-navigation.ts +23 -0
- package/src/react/hooks/use-tab-navigation.ts +21 -0
- package/src/react/hooks/use-typed-navigation.test.tsx +187 -0
- package/src/react/index.ts +52 -0
- package/src/react/linking.ts +59 -0
- package/src/react/navigation-context.ts +40 -0
- package/src/react/nested-navigation.test.tsx +145 -0
- package/src/react/screen.ts +44 -0
- package/src/react/stack/index.ts +323 -0
- package/src/react/stack/stack.test.tsx +514 -0
- package/src/react/tab-screen.ts +30 -0
- package/src/react/tabs/index.ts +204 -0
- package/src/react/tabs/tabs.test.tsx +256 -0
- package/src/register.ts +59 -0
- package/src/vue/composables/composables.test.ts +221 -0
- package/src/vue/composables/index.ts +12 -0
- package/src/vue/composables/use-drawer-navigation.ts +25 -0
- package/src/vue/composables/use-focus-effect.ts +37 -0
- package/src/vue/composables/use-is-focused.ts +34 -0
- package/src/vue/composables/use-navigation-state.ts +38 -0
- package/src/vue/composables/use-navigation.ts +30 -0
- package/src/vue/composables/use-route.ts +13 -0
- package/src/vue/composables/use-stack-navigation.ts +28 -0
- package/src/vue/composables/use-tab-navigation.ts +25 -0
- package/src/vue/composables/use-typed-navigation.test.ts +205 -0
- package/src/vue/drawer/drawer.test.ts +451 -0
- package/src/vue/drawer/index.ts +550 -0
- package/src/vue/drawer-screen.ts +32 -0
- package/src/vue/index.ts +70 -0
- package/src/vue/linking.ts +69 -0
- package/src/vue/navigation-context.ts +87 -0
- package/src/vue/nested-navigation.test.ts +155 -0
- package/src/vue/screen.ts +52 -0
- package/src/vue/stack/index.ts +376 -0
- package/src/vue/stack/stack.test.ts +501 -0
- package/src/vue/tab-screen.ts +29 -0
- package/src/vue/tabs/index.ts +302 -0
- package/src/vue/tabs/tabs.test.ts +278 -0
- package/symbiote-navigation.podspec +84 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { IPanResponderGestureState, ISymbioteEvent } from '@symbiote-native/engine';
|
|
2
|
+
export type IDrawerType = 'front' | 'back' | 'slide' | 'permanent';
|
|
3
|
+
export type IDrawerPosition = 'left' | 'right';
|
|
4
|
+
export interface IDrawerOptions {
|
|
5
|
+
drawerType?: IDrawerType;
|
|
6
|
+
drawerPosition?: IDrawerPosition;
|
|
7
|
+
drawerWidth?: number;
|
|
8
|
+
overlayColor?: string;
|
|
9
|
+
swipeEnabled?: boolean;
|
|
10
|
+
swipeEdgeWidth?: number;
|
|
11
|
+
swipeMinDistance?: number;
|
|
12
|
+
swipeMinVelocity?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface IDrawerScreenOptions {
|
|
15
|
+
title?: string;
|
|
16
|
+
drawerLabel?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const DRAWER_DEFAULT_TYPE: IDrawerType;
|
|
19
|
+
export declare const DRAWER_DEFAULT_POSITION: IDrawerPosition;
|
|
20
|
+
export declare const DRAWER_DEFAULT_WIDTH = 280;
|
|
21
|
+
export declare const DRAWER_DEFAULT_OVERLAY_COLOR = "rgba(0, 0, 0, 0.5)";
|
|
22
|
+
export declare const DRAWER_DEFAULT_SWIPE_ENABLED = true;
|
|
23
|
+
export declare const DRAWER_DEFAULT_SWIPE_EDGE_WIDTH = 32;
|
|
24
|
+
export declare const DRAWER_DEFAULT_SWIPE_MIN_DISTANCE = 60;
|
|
25
|
+
export declare const DRAWER_DEFAULT_SWIPE_MIN_VELOCITY = 0.5;
|
|
26
|
+
export declare function resolveDrawerWidth(options: IDrawerOptions): number;
|
|
27
|
+
export declare function resolveDrawerType(options: IDrawerOptions): IDrawerType;
|
|
28
|
+
export declare function resolveDrawerPosition(options: IDrawerOptions): IDrawerPosition;
|
|
29
|
+
export type IDrawerGeometry = {
|
|
30
|
+
panelTranslateXClosed: number;
|
|
31
|
+
panelTranslateXOpen: number;
|
|
32
|
+
contentTranslateXClosed: number;
|
|
33
|
+
contentTranslateXOpen: number;
|
|
34
|
+
overlayOpacityClosed: number;
|
|
35
|
+
overlayOpacityOpen: number;
|
|
36
|
+
};
|
|
37
|
+
export declare function isDrawerAnimated(options: IDrawerOptions): boolean;
|
|
38
|
+
export declare function isDrawerOverlayVisible(options: IDrawerOptions): boolean;
|
|
39
|
+
export declare function resolveDrawerGeometry(options: IDrawerOptions): IDrawerGeometry;
|
|
40
|
+
export type IDrawerInterpolationRange = {
|
|
41
|
+
inputRange: readonly [number, number];
|
|
42
|
+
outputRange: readonly [number, number];
|
|
43
|
+
};
|
|
44
|
+
export type IDrawerContentSlotInterpolation = {
|
|
45
|
+
translateX: IDrawerInterpolationRange;
|
|
46
|
+
};
|
|
47
|
+
export type IDrawerOverlaySlotInterpolation = {
|
|
48
|
+
opacity: IDrawerInterpolationRange;
|
|
49
|
+
translateX: IDrawerInterpolationRange;
|
|
50
|
+
};
|
|
51
|
+
export type IDrawerPanelSlotInterpolation = {
|
|
52
|
+
translateX: IDrawerInterpolationRange;
|
|
53
|
+
};
|
|
54
|
+
export declare function resolveDrawerSlotInterpolation(geometry: IDrawerGeometry, slot: 'content'): IDrawerContentSlotInterpolation;
|
|
55
|
+
export declare function resolveDrawerSlotInterpolation(geometry: IDrawerGeometry, slot: 'overlay'): IDrawerOverlaySlotInterpolation;
|
|
56
|
+
export declare function resolveDrawerSlotInterpolation(geometry: IDrawerGeometry, slot: 'panel'): IDrawerPanelSlotInterpolation;
|
|
57
|
+
export declare function isSwipeStartInEdge(startX: number, screenWidth: number, isOpen: boolean, options: IDrawerOptions): boolean;
|
|
58
|
+
export declare function isHorizontalDrag(gestureState: IPanResponderGestureState): boolean;
|
|
59
|
+
export type ISwipeIntent = 'open' | 'close';
|
|
60
|
+
export declare function resolveSwipeIntent(gestureState: IPanResponderGestureState, isOpen: boolean, options: IDrawerOptions): ISwipeIntent;
|
|
61
|
+
export declare function clamp01(value: number): number;
|
|
62
|
+
export declare function startPageXOf(event: ISymbioteEvent): number | undefined;
|
|
63
|
+
export declare function resolveDragProgress(gestureState: IPanResponderGestureState, dragStartProgress: number, options: IDrawerOptions): number;
|
|
64
|
+
export declare function shouldClaimDrawerSwipe(event: ISymbioteEvent, gestureState: IPanResponderGestureState, screenWidth: number, isOpen: boolean, options: IDrawerOptions, phase: 'start' | 'move'): boolean;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Drawer option types + the pure swipe/geometry math. Framework-agnostic (numbers and
|
|
2
|
+
// booleans only, per CLAUDE.md <prop_types_split_agnostic_vs_per_adapter>), shared verbatim by
|
|
3
|
+
// every adapter. Mirrors react-navigation's Drawer prop surface (confirmed against the current
|
|
4
|
+
// @react-navigation/drawer docs): drawerType 'front'/'back'/'slide'/'permanent', drawerPosition,
|
|
5
|
+
// drawerWidth, overlayColor, swipeEnabled + the three swipe-tuning knobs. What is NOT ported:
|
|
6
|
+
// `configureGestureHandler` - a react-native-gesture-handler-specific escape hatch with no
|
|
7
|
+
// PanResponder equivalent (see packages/navigation's README / the drawer feasibility note for the
|
|
8
|
+
// full gap list).
|
|
9
|
+
import { isRecord } from '../guards';
|
|
10
|
+
export const DRAWER_DEFAULT_TYPE = 'front';
|
|
11
|
+
export const DRAWER_DEFAULT_POSITION = 'left';
|
|
12
|
+
export const DRAWER_DEFAULT_WIDTH = 280;
|
|
13
|
+
export const DRAWER_DEFAULT_OVERLAY_COLOR = 'rgba(0, 0, 0, 0.5)';
|
|
14
|
+
export const DRAWER_DEFAULT_SWIPE_ENABLED = true;
|
|
15
|
+
export const DRAWER_DEFAULT_SWIPE_EDGE_WIDTH = 32;
|
|
16
|
+
export const DRAWER_DEFAULT_SWIPE_MIN_DISTANCE = 60;
|
|
17
|
+
// react-navigation's 500 is px/second; gestureState.vx is px/ms, so the default converts.
|
|
18
|
+
export const DRAWER_DEFAULT_SWIPE_MIN_VELOCITY = 0.5;
|
|
19
|
+
// Exported so render-drawer.ts and the adapter can resolve the same defaults without
|
|
20
|
+
// re-declaring the `??` fallback (a second copy would drift the instant a default changes).
|
|
21
|
+
export function resolveDrawerWidth(options) {
|
|
22
|
+
return options.drawerWidth ?? DRAWER_DEFAULT_WIDTH;
|
|
23
|
+
}
|
|
24
|
+
export function resolveDrawerType(options) {
|
|
25
|
+
return options.drawerType ?? DRAWER_DEFAULT_TYPE;
|
|
26
|
+
}
|
|
27
|
+
export function resolveDrawerPosition(options) {
|
|
28
|
+
return options.drawerPosition ?? DRAWER_DEFAULT_POSITION;
|
|
29
|
+
}
|
|
30
|
+
export function isDrawerAnimated(options) {
|
|
31
|
+
return resolveDrawerType(options) !== 'permanent';
|
|
32
|
+
}
|
|
33
|
+
export function isDrawerOverlayVisible(options) {
|
|
34
|
+
const type = resolveDrawerType(options);
|
|
35
|
+
return type === 'front' || type === 'slide';
|
|
36
|
+
}
|
|
37
|
+
// front: only the panel moves (-width -> 0), content stays put, overlay fades in.
|
|
38
|
+
// back: only the content moves, away from the position edge, to reveal the stationary panel;
|
|
39
|
+
// no overlay (the panel sits fully behind the content, nothing to dim).
|
|
40
|
+
// slide: panel AND content move together by the same delta, overlay fades in (content still
|
|
41
|
+
// covers the panel partially as they slide in tandem, same as front visually at rest).
|
|
42
|
+
// permanent: static, all zero (isDrawerAnimated() gates callers off this path already).
|
|
43
|
+
export function resolveDrawerGeometry(options) {
|
|
44
|
+
const width = resolveDrawerWidth(options);
|
|
45
|
+
const type = resolveDrawerType(options);
|
|
46
|
+
const sign = resolveDrawerPosition(options) === 'left' ? 1 : -1;
|
|
47
|
+
const closedPanelX = -sign * width;
|
|
48
|
+
const openContentX = sign * width;
|
|
49
|
+
switch (type) {
|
|
50
|
+
case 'back':
|
|
51
|
+
return {
|
|
52
|
+
panelTranslateXClosed: 0,
|
|
53
|
+
panelTranslateXOpen: 0,
|
|
54
|
+
contentTranslateXClosed: 0,
|
|
55
|
+
contentTranslateXOpen: openContentX,
|
|
56
|
+
overlayOpacityClosed: 0,
|
|
57
|
+
overlayOpacityOpen: 0,
|
|
58
|
+
};
|
|
59
|
+
case 'slide':
|
|
60
|
+
return {
|
|
61
|
+
panelTranslateXClosed: closedPanelX,
|
|
62
|
+
panelTranslateXOpen: 0,
|
|
63
|
+
contentTranslateXClosed: 0,
|
|
64
|
+
contentTranslateXOpen: openContentX,
|
|
65
|
+
overlayOpacityClosed: 0,
|
|
66
|
+
overlayOpacityOpen: 1,
|
|
67
|
+
};
|
|
68
|
+
case 'front':
|
|
69
|
+
case 'permanent':
|
|
70
|
+
default:
|
|
71
|
+
return {
|
|
72
|
+
panelTranslateXClosed: closedPanelX,
|
|
73
|
+
panelTranslateXOpen: 0,
|
|
74
|
+
contentTranslateXClosed: 0,
|
|
75
|
+
contentTranslateXOpen: 0,
|
|
76
|
+
overlayOpacityClosed: 0,
|
|
77
|
+
overlayOpacityOpen: 1,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const DRAWER_PROGRESS_INPUT_RANGE = [0, 1];
|
|
82
|
+
export function resolveDrawerSlotInterpolation(geometry, slot) {
|
|
83
|
+
switch (slot) {
|
|
84
|
+
case 'content':
|
|
85
|
+
return {
|
|
86
|
+
translateX: {
|
|
87
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
88
|
+
outputRange: [geometry.contentTranslateXClosed, geometry.contentTranslateXOpen],
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
case 'overlay':
|
|
92
|
+
return {
|
|
93
|
+
opacity: {
|
|
94
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
95
|
+
outputRange: [geometry.overlayOpacityClosed, geometry.overlayOpacityOpen],
|
|
96
|
+
},
|
|
97
|
+
translateX: {
|
|
98
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
99
|
+
outputRange: [geometry.contentTranslateXClosed, geometry.contentTranslateXOpen],
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
case 'panel':
|
|
103
|
+
return {
|
|
104
|
+
translateX: {
|
|
105
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
106
|
+
outputRange: [geometry.panelTranslateXClosed, geometry.panelTranslateXOpen],
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// onStartShouldSetPanResponder gate: while closed, a swipe must START within swipeEdgeWidth of
|
|
112
|
+
// the drawer's position edge (mirrors react-navigation's swipeEdgeWidth). While open, the whole
|
|
113
|
+
// content + overlay area is fair game to drag-close, matching the intuitive "swipe anywhere to
|
|
114
|
+
// dismiss an open drawer" behavior every drawer implementation (including RN's dropped native
|
|
115
|
+
// DrawerLayoutAndroid) shares.
|
|
116
|
+
export function isSwipeStartInEdge(startX, screenWidth, isOpen, options) {
|
|
117
|
+
if (isOpen)
|
|
118
|
+
return true;
|
|
119
|
+
const edgeWidth = options.swipeEdgeWidth ?? DRAWER_DEFAULT_SWIPE_EDGE_WIDTH;
|
|
120
|
+
return resolveDrawerPosition(options) === 'left'
|
|
121
|
+
? startX <= edgeWidth
|
|
122
|
+
: startX >= screenWidth - edgeWidth;
|
|
123
|
+
}
|
|
124
|
+
// onMoveShouldSetPanResponder gate: only claim the gesture once it reads as a horizontal drag
|
|
125
|
+
// (RN's own PanResponder examples use this exact dominant-axis check to stay out of a vertical
|
|
126
|
+
// ScrollView's way).
|
|
127
|
+
const MOVE_CLAIM_THRESHOLD = 5;
|
|
128
|
+
export function isHorizontalDrag(gestureState) {
|
|
129
|
+
return (Math.abs(gestureState.dx) > MOVE_CLAIM_THRESHOLD &&
|
|
130
|
+
Math.abs(gestureState.dx) > Math.abs(gestureState.dy));
|
|
131
|
+
}
|
|
132
|
+
// The release-time decision, structurally the same shape as switch.ts's shouldSnapBack: a pure
|
|
133
|
+
// predicate over the accumulated gesture plus the option thresholds, no framework. Distance OR
|
|
134
|
+
// velocity past its threshold, in the direction that would move the drawer toward the opposite
|
|
135
|
+
// of its current state, snaps it there; anything else snaps back to where it started.
|
|
136
|
+
export function resolveSwipeIntent(gestureState, isOpen, options) {
|
|
137
|
+
const sign = resolveDrawerPosition(options) === 'left' ? 1 : -1;
|
|
138
|
+
// Positive `signedDelta` means "dragging toward open" for a left drawer's rightward drag (and
|
|
139
|
+
// symmetrically for a right drawer's leftward drag).
|
|
140
|
+
const signedDx = sign * gestureState.dx;
|
|
141
|
+
const signedVx = sign * gestureState.vx;
|
|
142
|
+
const minDistance = options.swipeMinDistance ?? DRAWER_DEFAULT_SWIPE_MIN_DISTANCE;
|
|
143
|
+
const minVelocity = options.swipeMinVelocity ?? DRAWER_DEFAULT_SWIPE_MIN_VELOCITY;
|
|
144
|
+
const pastDistance = Math.abs(signedDx) >= minDistance;
|
|
145
|
+
const pastVelocity = Math.abs(signedVx) >= minVelocity;
|
|
146
|
+
if (!pastDistance && !pastVelocity)
|
|
147
|
+
return isOpen ? 'open' : 'close';
|
|
148
|
+
// Velocity wins the direction call when it clears its own threshold (a fast flick can reverse
|
|
149
|
+
// a short drag); otherwise the drag distance's sign decides.
|
|
150
|
+
const towardOpen = pastVelocity ? signedVx > 0 : signedDx > 0;
|
|
151
|
+
return towardOpen ? 'open' : 'close';
|
|
152
|
+
}
|
|
153
|
+
export function clamp01(value) {
|
|
154
|
+
return Math.min(1, Math.max(0, value));
|
|
155
|
+
}
|
|
156
|
+
function toFiniteNumber(value) {
|
|
157
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
158
|
+
}
|
|
159
|
+
// The touch's real starting page-X, read off the raw event rather than gestureState.x0: the
|
|
160
|
+
// engine's capture phase (core/engine/src/pan-responder/index.ts's
|
|
161
|
+
// onStartShouldSetResponderCapture/onMoveShouldSetResponderCapture) resets gestureState before
|
|
162
|
+
// the bubble-phase onStartShouldSetPanResponder/onMoveShouldSetPanResponder gates run, so x0 is
|
|
163
|
+
// only populated later, inside onResponderGrant. Shaped like core/engine/src/events/index.ts's
|
|
164
|
+
// readTouchPoint but not the same function: that one requires both pageX AND pageY and returns
|
|
165
|
+
// an {x, y} pair for touch-history bookkeeping; this only needs pageX and is private to the
|
|
166
|
+
// SET-gate below, so it stays a separate, narrower helper rather than forcing a shared contract
|
|
167
|
+
// onto two callers with different needs.
|
|
168
|
+
export function startPageXOf(event) {
|
|
169
|
+
const { nativeEvent } = event;
|
|
170
|
+
const direct = toFiniteNumber(nativeEvent.pageX);
|
|
171
|
+
if (direct !== undefined)
|
|
172
|
+
return direct;
|
|
173
|
+
const touches = nativeEvent.touches;
|
|
174
|
+
if (Array.isArray(touches) && isRecord(touches[0]))
|
|
175
|
+
return toFiniteNumber(touches[0].pageX);
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
// onPanResponderMove's drag-to-progress math: how far the touch has traveled, in progress units
|
|
179
|
+
// (0..1), added to wherever the drag started from. Mirrors the SAME sign convention as
|
|
180
|
+
// resolveSwipeIntent (left drawer: rightward drag is positive-toward-open).
|
|
181
|
+
export function resolveDragProgress(gestureState, dragStartProgress, options) {
|
|
182
|
+
const width = resolveDrawerWidth(options);
|
|
183
|
+
const sign = resolveDrawerPosition(options) === 'right' ? -1 : 1;
|
|
184
|
+
const delta = (sign * gestureState.dx) / width;
|
|
185
|
+
return clamp01(dragStartProgress + delta);
|
|
186
|
+
}
|
|
187
|
+
// The composed onStartShouldSetPanResponder/onMoveShouldSetPanResponder gate: swipeEnabled ->
|
|
188
|
+
// isDrawerAnimated -> isSwipeStartInEdge, then (move only) isHorizontalDrag on top. The start
|
|
189
|
+
// gate omits the dominant-axis check on purpose (react-navigation's own edge-swipe idiom: claim
|
|
190
|
+
// on entering the edge, confirm direction only once movement exists to measure).
|
|
191
|
+
export function shouldClaimDrawerSwipe(event, gestureState, screenWidth, isOpen, options, phase) {
|
|
192
|
+
if ((options.swipeEnabled ?? DRAWER_DEFAULT_SWIPE_ENABLED) === false)
|
|
193
|
+
return false;
|
|
194
|
+
if (!isDrawerAnimated(options))
|
|
195
|
+
return false;
|
|
196
|
+
const startX = startPageXOf(event) ?? gestureState.x0;
|
|
197
|
+
if (!isSwipeStartInEdge(startX, screenWidth, isOpen, options))
|
|
198
|
+
return false;
|
|
199
|
+
return phase === 'start' ? true : isHorizontalDrag(gestureState);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/drawer-options/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,+FAA+F;AAC/F,+FAA+F;AAC/F,iGAAiG;AACjG,8FAA8F;AAC9F,2FAA2F;AAC3F,kGAAkG;AAClG,kBAAkB;AAGlB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AA+BrC,MAAM,CAAC,MAAM,mBAAm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C,CAAC;AAED,8FAA8F;AAC9F,8FAA8F;AAC9F,gGAAgG;AAChG,iFAAiF;AACjF,MAAM,UAAU,sBAAsB,CACpC,KAAqB,EACrB,YAAuC,EACvC,WAAmB,EACnB,MAAe,EACf,OAAuB,EACvB,KAAuB;IAEvB,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,4BAA4B,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACnF,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,EAAE,CAAC;IACtD,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5E,OAAO,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { IPanResponderGestureState, ISymbioteEvent } from '@symbiote-native/engine';
|
|
2
|
+
export type IDrawerType = 'front' | 'back' | 'slide' | 'permanent';
|
|
3
|
+
export type IDrawerPosition = 'left' | 'right';
|
|
4
|
+
export interface IDrawerOptions {
|
|
5
|
+
drawerType?: IDrawerType;
|
|
6
|
+
drawerPosition?: IDrawerPosition;
|
|
7
|
+
drawerWidth?: number;
|
|
8
|
+
overlayColor?: string;
|
|
9
|
+
swipeEnabled?: boolean;
|
|
10
|
+
swipeEdgeWidth?: number;
|
|
11
|
+
swipeMinDistance?: number;
|
|
12
|
+
swipeMinVelocity?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface IDrawerScreenOptions {
|
|
15
|
+
title?: string;
|
|
16
|
+
drawerLabel?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const DRAWER_DEFAULT_TYPE: IDrawerType;
|
|
19
|
+
export declare const DRAWER_DEFAULT_POSITION: IDrawerPosition;
|
|
20
|
+
export declare const DRAWER_DEFAULT_WIDTH = 280;
|
|
21
|
+
export declare const DRAWER_DEFAULT_OVERLAY_COLOR = "rgba(0, 0, 0, 0.5)";
|
|
22
|
+
export declare const DRAWER_DEFAULT_SWIPE_ENABLED = true;
|
|
23
|
+
export declare const DRAWER_DEFAULT_SWIPE_EDGE_WIDTH = 32;
|
|
24
|
+
export declare const DRAWER_DEFAULT_SWIPE_MIN_DISTANCE = 60;
|
|
25
|
+
export declare const DRAWER_DEFAULT_SWIPE_MIN_VELOCITY = 0.5;
|
|
26
|
+
export declare function resolveDrawerWidth(options: IDrawerOptions): number;
|
|
27
|
+
export declare function resolveDrawerType(options: IDrawerOptions): IDrawerType;
|
|
28
|
+
export declare function resolveDrawerPosition(options: IDrawerOptions): IDrawerPosition;
|
|
29
|
+
export type IDrawerGeometry = {
|
|
30
|
+
panelTranslateXClosed: number;
|
|
31
|
+
panelTranslateXOpen: number;
|
|
32
|
+
contentTranslateXClosed: number;
|
|
33
|
+
contentTranslateXOpen: number;
|
|
34
|
+
overlayOpacityClosed: number;
|
|
35
|
+
overlayOpacityOpen: number;
|
|
36
|
+
};
|
|
37
|
+
export declare function isDrawerAnimated(options: IDrawerOptions): boolean;
|
|
38
|
+
export declare function isDrawerOverlayVisible(options: IDrawerOptions): boolean;
|
|
39
|
+
export declare function resolveDrawerGeometry(options: IDrawerOptions): IDrawerGeometry;
|
|
40
|
+
export type IDrawerInterpolationRange = {
|
|
41
|
+
inputRange: readonly [number, number];
|
|
42
|
+
outputRange: readonly [number, number];
|
|
43
|
+
};
|
|
44
|
+
export type IDrawerContentSlotInterpolation = {
|
|
45
|
+
translateX: IDrawerInterpolationRange;
|
|
46
|
+
};
|
|
47
|
+
export type IDrawerOverlaySlotInterpolation = {
|
|
48
|
+
opacity: IDrawerInterpolationRange;
|
|
49
|
+
translateX: IDrawerInterpolationRange;
|
|
50
|
+
};
|
|
51
|
+
export type IDrawerPanelSlotInterpolation = {
|
|
52
|
+
translateX: IDrawerInterpolationRange;
|
|
53
|
+
};
|
|
54
|
+
export declare function resolveDrawerSlotInterpolation(geometry: IDrawerGeometry, slot: 'content'): IDrawerContentSlotInterpolation;
|
|
55
|
+
export declare function resolveDrawerSlotInterpolation(geometry: IDrawerGeometry, slot: 'overlay'): IDrawerOverlaySlotInterpolation;
|
|
56
|
+
export declare function resolveDrawerSlotInterpolation(geometry: IDrawerGeometry, slot: 'panel'): IDrawerPanelSlotInterpolation;
|
|
57
|
+
export declare function isSwipeStartInEdge(startX: number, screenWidth: number, isOpen: boolean, options: IDrawerOptions): boolean;
|
|
58
|
+
export declare function isHorizontalDrag(gestureState: IPanResponderGestureState): boolean;
|
|
59
|
+
export type ISwipeIntent = 'open' | 'close';
|
|
60
|
+
export declare function resolveSwipeIntent(gestureState: IPanResponderGestureState, isOpen: boolean, options: IDrawerOptions): ISwipeIntent;
|
|
61
|
+
export declare function clamp01(value: number): number;
|
|
62
|
+
export declare function startPageXOf(event: ISymbioteEvent): number | undefined;
|
|
63
|
+
export declare function resolveDragProgress(gestureState: IPanResponderGestureState, dragStartProgress: number, options: IDrawerOptions): number;
|
|
64
|
+
export declare function shouldClaimDrawerSwipe(event: ISymbioteEvent, gestureState: IPanResponderGestureState, screenWidth: number, isOpen: boolean, options: IDrawerOptions, phase: 'start' | 'move'): boolean;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Drawer option types + the pure swipe/geometry math. Framework-agnostic (numbers and
|
|
2
|
+
// booleans only, per CLAUDE.md <prop_types_split_agnostic_vs_per_adapter>), shared verbatim by
|
|
3
|
+
// every adapter. Mirrors react-navigation's Drawer prop surface (confirmed against the current
|
|
4
|
+
// @react-navigation/drawer docs): drawerType 'front'/'back'/'slide'/'permanent', drawerPosition,
|
|
5
|
+
// drawerWidth, overlayColor, swipeEnabled + the three swipe-tuning knobs. What is NOT ported:
|
|
6
|
+
// `configureGestureHandler` — a react-native-gesture-handler-specific escape hatch with no
|
|
7
|
+
// PanResponder equivalent (see packages/navigation's README / the drawer feasibility note for the
|
|
8
|
+
// full gap list).
|
|
9
|
+
import { isRecord } from './guards';
|
|
10
|
+
export const DRAWER_DEFAULT_TYPE = 'front';
|
|
11
|
+
export const DRAWER_DEFAULT_POSITION = 'left';
|
|
12
|
+
export const DRAWER_DEFAULT_WIDTH = 280;
|
|
13
|
+
export const DRAWER_DEFAULT_OVERLAY_COLOR = 'rgba(0, 0, 0, 0.5)';
|
|
14
|
+
export const DRAWER_DEFAULT_SWIPE_ENABLED = true;
|
|
15
|
+
export const DRAWER_DEFAULT_SWIPE_EDGE_WIDTH = 32;
|
|
16
|
+
export const DRAWER_DEFAULT_SWIPE_MIN_DISTANCE = 60;
|
|
17
|
+
// react-navigation's 500 is px/second; gestureState.vx is px/ms, so the default converts.
|
|
18
|
+
export const DRAWER_DEFAULT_SWIPE_MIN_VELOCITY = 0.5;
|
|
19
|
+
// Exported so render-drawer.ts and the adapter can resolve the same defaults without
|
|
20
|
+
// re-declaring the `??` fallback (a second copy would drift the instant a default changes).
|
|
21
|
+
export function resolveDrawerWidth(options) {
|
|
22
|
+
return options.drawerWidth ?? DRAWER_DEFAULT_WIDTH;
|
|
23
|
+
}
|
|
24
|
+
export function resolveDrawerType(options) {
|
|
25
|
+
return options.drawerType ?? DRAWER_DEFAULT_TYPE;
|
|
26
|
+
}
|
|
27
|
+
export function resolveDrawerPosition(options) {
|
|
28
|
+
return options.drawerPosition ?? DRAWER_DEFAULT_POSITION;
|
|
29
|
+
}
|
|
30
|
+
export function isDrawerAnimated(options) {
|
|
31
|
+
return resolveDrawerType(options) !== 'permanent';
|
|
32
|
+
}
|
|
33
|
+
export function isDrawerOverlayVisible(options) {
|
|
34
|
+
const type = resolveDrawerType(options);
|
|
35
|
+
return type === 'front' || type === 'slide';
|
|
36
|
+
}
|
|
37
|
+
// front: only the panel moves (-width -> 0), content stays put, overlay fades in.
|
|
38
|
+
// back: only the content moves, away from the position edge, to reveal the stationary panel;
|
|
39
|
+
// no overlay (the panel sits fully behind the content, nothing to dim).
|
|
40
|
+
// slide: panel AND content move together by the same delta, overlay fades in (content still
|
|
41
|
+
// covers the panel partially as they slide in tandem, same as front visually at rest).
|
|
42
|
+
// permanent: static, all zero (isDrawerAnimated() gates callers off this path already).
|
|
43
|
+
export function resolveDrawerGeometry(options) {
|
|
44
|
+
const width = resolveDrawerWidth(options);
|
|
45
|
+
const type = resolveDrawerType(options);
|
|
46
|
+
const sign = resolveDrawerPosition(options) === 'left' ? 1 : -1;
|
|
47
|
+
const closedPanelX = -sign * width;
|
|
48
|
+
const openContentX = sign * width;
|
|
49
|
+
switch (type) {
|
|
50
|
+
case 'back':
|
|
51
|
+
return {
|
|
52
|
+
panelTranslateXClosed: 0,
|
|
53
|
+
panelTranslateXOpen: 0,
|
|
54
|
+
contentTranslateXClosed: 0,
|
|
55
|
+
contentTranslateXOpen: openContentX,
|
|
56
|
+
overlayOpacityClosed: 0,
|
|
57
|
+
overlayOpacityOpen: 0,
|
|
58
|
+
};
|
|
59
|
+
case 'slide':
|
|
60
|
+
return {
|
|
61
|
+
panelTranslateXClosed: closedPanelX,
|
|
62
|
+
panelTranslateXOpen: 0,
|
|
63
|
+
contentTranslateXClosed: 0,
|
|
64
|
+
contentTranslateXOpen: openContentX,
|
|
65
|
+
overlayOpacityClosed: 0,
|
|
66
|
+
overlayOpacityOpen: 1,
|
|
67
|
+
};
|
|
68
|
+
case 'front':
|
|
69
|
+
case 'permanent':
|
|
70
|
+
default:
|
|
71
|
+
return {
|
|
72
|
+
panelTranslateXClosed: closedPanelX,
|
|
73
|
+
panelTranslateXOpen: 0,
|
|
74
|
+
contentTranslateXClosed: 0,
|
|
75
|
+
contentTranslateXOpen: 0,
|
|
76
|
+
overlayOpacityClosed: 0,
|
|
77
|
+
overlayOpacityOpen: 1,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const DRAWER_PROGRESS_INPUT_RANGE = [0, 1];
|
|
82
|
+
export function resolveDrawerSlotInterpolation(geometry, slot) {
|
|
83
|
+
switch (slot) {
|
|
84
|
+
case 'content':
|
|
85
|
+
return {
|
|
86
|
+
translateX: {
|
|
87
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
88
|
+
outputRange: [geometry.contentTranslateXClosed, geometry.contentTranslateXOpen],
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
case 'overlay':
|
|
92
|
+
return {
|
|
93
|
+
opacity: {
|
|
94
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
95
|
+
outputRange: [geometry.overlayOpacityClosed, geometry.overlayOpacityOpen],
|
|
96
|
+
},
|
|
97
|
+
translateX: {
|
|
98
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
99
|
+
outputRange: [geometry.contentTranslateXClosed, geometry.contentTranslateXOpen],
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
case 'panel':
|
|
103
|
+
return {
|
|
104
|
+
translateX: {
|
|
105
|
+
inputRange: DRAWER_PROGRESS_INPUT_RANGE,
|
|
106
|
+
outputRange: [geometry.panelTranslateXClosed, geometry.panelTranslateXOpen],
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// onStartShouldSetPanResponder gate: while closed, a swipe must START within swipeEdgeWidth of
|
|
112
|
+
// the drawer's position edge (mirrors react-navigation's swipeEdgeWidth). While open, the whole
|
|
113
|
+
// content + overlay area is fair game to drag-close, matching the intuitive "swipe anywhere to
|
|
114
|
+
// dismiss an open drawer" behavior every drawer implementation (including RN's dropped native
|
|
115
|
+
// DrawerLayoutAndroid) shares.
|
|
116
|
+
export function isSwipeStartInEdge(startX, screenWidth, isOpen, options) {
|
|
117
|
+
if (isOpen)
|
|
118
|
+
return true;
|
|
119
|
+
const edgeWidth = options.swipeEdgeWidth ?? DRAWER_DEFAULT_SWIPE_EDGE_WIDTH;
|
|
120
|
+
return resolveDrawerPosition(options) === 'left'
|
|
121
|
+
? startX <= edgeWidth
|
|
122
|
+
: startX >= screenWidth - edgeWidth;
|
|
123
|
+
}
|
|
124
|
+
// onMoveShouldSetPanResponder gate: only claim the gesture once it reads as a horizontal drag
|
|
125
|
+
// (RN's own PanResponder examples use this exact dominant-axis check to stay out of a vertical
|
|
126
|
+
// ScrollView's way).
|
|
127
|
+
const MOVE_CLAIM_THRESHOLD = 5;
|
|
128
|
+
export function isHorizontalDrag(gestureState) {
|
|
129
|
+
return (Math.abs(gestureState.dx) > MOVE_CLAIM_THRESHOLD &&
|
|
130
|
+
Math.abs(gestureState.dx) > Math.abs(gestureState.dy));
|
|
131
|
+
}
|
|
132
|
+
// The release-time decision, structurally the same shape as switch.ts's shouldSnapBack: a pure
|
|
133
|
+
// predicate over the accumulated gesture plus the option thresholds, no framework. Distance OR
|
|
134
|
+
// velocity past its threshold, in the direction that would move the drawer toward the opposite
|
|
135
|
+
// of its current state, snaps it there; anything else snaps back to where it started.
|
|
136
|
+
export function resolveSwipeIntent(gestureState, isOpen, options) {
|
|
137
|
+
const sign = resolveDrawerPosition(options) === 'left' ? 1 : -1;
|
|
138
|
+
// Positive `signedDelta` means "dragging toward open" for a left drawer's rightward drag (and
|
|
139
|
+
// symmetrically for a right drawer's leftward drag).
|
|
140
|
+
const signedDx = sign * gestureState.dx;
|
|
141
|
+
const signedVx = sign * gestureState.vx;
|
|
142
|
+
const minDistance = options.swipeMinDistance ?? DRAWER_DEFAULT_SWIPE_MIN_DISTANCE;
|
|
143
|
+
const minVelocity = options.swipeMinVelocity ?? DRAWER_DEFAULT_SWIPE_MIN_VELOCITY;
|
|
144
|
+
const pastDistance = Math.abs(signedDx) >= minDistance;
|
|
145
|
+
const pastVelocity = Math.abs(signedVx) >= minVelocity;
|
|
146
|
+
if (!pastDistance && !pastVelocity)
|
|
147
|
+
return isOpen ? 'open' : 'close';
|
|
148
|
+
// Velocity wins the direction call when it clears its own threshold (a fast flick can reverse
|
|
149
|
+
// a short drag); otherwise the drag distance's sign decides.
|
|
150
|
+
const towardOpen = pastVelocity ? signedVx > 0 : signedDx > 0;
|
|
151
|
+
return towardOpen ? 'open' : 'close';
|
|
152
|
+
}
|
|
153
|
+
export function clamp01(value) {
|
|
154
|
+
return Math.min(1, Math.max(0, value));
|
|
155
|
+
}
|
|
156
|
+
function toFiniteNumber(value) {
|
|
157
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
158
|
+
}
|
|
159
|
+
// The touch's real starting page-X, read off the raw event rather than gestureState.x0: the
|
|
160
|
+
// engine's capture phase (core/engine/src/pan-responder/index.ts's
|
|
161
|
+
// onStartShouldSetResponderCapture/onMoveShouldSetResponderCapture) resets gestureState before
|
|
162
|
+
// the bubble-phase onStartShouldSetPanResponder/onMoveShouldSetPanResponder gates run, so x0 is
|
|
163
|
+
// only populated later, inside onResponderGrant. Shaped like core/engine/src/events/index.ts's
|
|
164
|
+
// readTouchPoint but not the same function: that one requires both pageX AND pageY and returns
|
|
165
|
+
// an {x, y} pair for touch-history bookkeeping; this only needs pageX and is private to the
|
|
166
|
+
// SET-gate below, so it stays a separate, narrower helper rather than forcing a shared contract
|
|
167
|
+
// onto two callers with different needs.
|
|
168
|
+
export function startPageXOf(event) {
|
|
169
|
+
const { nativeEvent } = event;
|
|
170
|
+
const direct = toFiniteNumber(nativeEvent.pageX);
|
|
171
|
+
if (direct !== undefined)
|
|
172
|
+
return direct;
|
|
173
|
+
const touches = nativeEvent.touches;
|
|
174
|
+
if (Array.isArray(touches) && isRecord(touches[0]))
|
|
175
|
+
return toFiniteNumber(touches[0].pageX);
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
// onPanResponderMove's drag-to-progress math: how far the touch has traveled, in progress units
|
|
179
|
+
// (0..1), added to wherever the drag started from. Mirrors the SAME sign convention as
|
|
180
|
+
// resolveSwipeIntent (left drawer: rightward drag is positive-toward-open).
|
|
181
|
+
export function resolveDragProgress(gestureState, dragStartProgress, options) {
|
|
182
|
+
const width = resolveDrawerWidth(options);
|
|
183
|
+
const sign = resolveDrawerPosition(options) === 'right' ? -1 : 1;
|
|
184
|
+
const delta = (sign * gestureState.dx) / width;
|
|
185
|
+
return clamp01(dragStartProgress + delta);
|
|
186
|
+
}
|
|
187
|
+
// The composed onStartShouldSetPanResponder/onMoveShouldSetPanResponder gate: swipeEnabled ->
|
|
188
|
+
// isDrawerAnimated -> isSwipeStartInEdge, then (move only) isHorizontalDrag on top. The start
|
|
189
|
+
// gate omits the dominant-axis check on purpose (react-navigation's own edge-swipe idiom: claim
|
|
190
|
+
// on entering the edge, confirm direction only once movement exists to measure).
|
|
191
|
+
export function shouldClaimDrawerSwipe(event, gestureState, screenWidth, isOpen, options, phase) {
|
|
192
|
+
if ((options.swipeEnabled ?? DRAWER_DEFAULT_SWIPE_ENABLED) === false)
|
|
193
|
+
return false;
|
|
194
|
+
if (!isDrawerAnimated(options))
|
|
195
|
+
return false;
|
|
196
|
+
const startX = startPageXOf(event) ?? gestureState.x0;
|
|
197
|
+
if (!isSwipeStartInEdge(startX, screenWidth, isOpen, options))
|
|
198
|
+
return false;
|
|
199
|
+
return phase === 'start' ? true : isHorizontalDrag(gestureState);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=drawer-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-options.js","sourceRoot":"","sources":["../../src/core/drawer-options.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,+FAA+F;AAC/F,+FAA+F;AAC/F,iGAAiG;AACjG,8FAA8F;AAC9F,2FAA2F;AAC3F,kGAAkG;AAClG,kBAAkB;AAGlB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AA+BpC,MAAM,CAAC,MAAM,mBAAmB,GAAgB,OAAO,CAAC;AACxD,MAAM,CAAC,MAAM,uBAAuB,GAAoB,MAAM,CAAC;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,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,EACvC,WAAmB,EACnB,MAAe,EACf,OAAuB,EACvB,KAAuB;IAEvB,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,4BAA4B,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACnF,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,EAAE,CAAC;IACtD,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5E,OAAO,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IRoute } from '../navigator-state';
|
|
2
|
+
export type { IRoute } from '../navigator-state';
|
|
3
|
+
type IRouteEntry = IRoute<unknown>;
|
|
4
|
+
export type IDrawerRouterState = Readonly<{
|
|
5
|
+
routes: readonly IRouteEntry[];
|
|
6
|
+
index: number;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
export type IDrawerRouterAction = {
|
|
10
|
+
type: 'jumpTo';
|
|
11
|
+
name: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'openDrawer';
|
|
14
|
+
} | {
|
|
15
|
+
type: 'closeDrawer';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'toggleDrawer';
|
|
18
|
+
};
|
|
19
|
+
export declare function createInitialDrawerRouterState(routes: readonly IRouteEntry[], initialRouteName?: string): IDrawerRouterState;
|
|
20
|
+
export declare function drawerRouterReducer(state: IDrawerRouterState, action: IDrawerRouterAction): IDrawerRouterState;
|
|
21
|
+
export declare function focusedDrawerRoute(state: IDrawerRouterState): IRouteEntry | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// DrawerRouter: the logic half (framework-agnostic, zero render), sibling to navigator-state.ts
|
|
2
|
+
// and tab-router-state.ts. Unlike the stack's push/pop route array, a drawer's route list is
|
|
3
|
+
// FIXED at mount (one entry per declared <Drawer.Screen>, collected by the adapter exactly like
|
|
4
|
+
// Stack's/Tab's collectRegistry) - the reducer only tracks which one is focused (`index`) and
|
|
5
|
+
// whether the drawer panel is open. Route identity/shape is `IRoute`, reused verbatim from
|
|
6
|
+
// navigator-state.ts (same convention tab-router-state.ts follows) so all three navigators share
|
|
7
|
+
// one route shape.
|
|
8
|
+
const INITIAL_FOCUSED_INDEX = 0;
|
|
9
|
+
export function createInitialDrawerRouterState(routes, initialRouteName) {
|
|
10
|
+
if (initialRouteName === undefined) {
|
|
11
|
+
return { routes, index: INITIAL_FOCUSED_INDEX, isOpen: false };
|
|
12
|
+
}
|
|
13
|
+
const index = routes.findIndex(route => route.name === initialRouteName);
|
|
14
|
+
return { routes, index: index === -1 ? INITIAL_FOCUSED_INDEX : index, isOpen: false };
|
|
15
|
+
}
|
|
16
|
+
// Mirrors @react-navigation/drawer's DrawerActions: jumpTo focuses a route by NAME (TabRouter's
|
|
17
|
+
// own convention, not the stack's by-key popTo) AND closes the drawer - selecting a destination
|
|
18
|
+
// is itself the dismissal gesture, so a plain focus without also closing would leave the panel
|
|
19
|
+
// covering the just-selected screen.
|
|
20
|
+
export function drawerRouterReducer(state, action) {
|
|
21
|
+
switch (action.type) {
|
|
22
|
+
case 'jumpTo': {
|
|
23
|
+
const index = state.routes.findIndex(route => route.name === action.name);
|
|
24
|
+
if (index === -1)
|
|
25
|
+
return state;
|
|
26
|
+
return index === state.index && !state.isOpen ? state : { ...state, index, isOpen: false };
|
|
27
|
+
}
|
|
28
|
+
case 'openDrawer':
|
|
29
|
+
return state.isOpen ? state : { ...state, isOpen: true };
|
|
30
|
+
case 'closeDrawer':
|
|
31
|
+
return state.isOpen ? { ...state, isOpen: false } : state;
|
|
32
|
+
case 'toggleDrawer':
|
|
33
|
+
return { ...state, isOpen: !state.isOpen };
|
|
34
|
+
default:
|
|
35
|
+
return state;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function focusedDrawerRoute(state) {
|
|
39
|
+
return state.routes[state.index];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/drawer-router-state/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,6FAA6F;AAC7F,gGAAgG;AAChG,8FAA8F;AAC9F,2FAA2F;AAC3F,iGAAiG;AACjG,mBAAmB;AAoBnB,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,MAAM,UAAU,8BAA8B,CAC5C,MAA8B,EAC9B,gBAAyB;IAEzB,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACjE,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC;IACzE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACxF,CAAC;AAED,gGAAgG;AAChG,gGAAgG;AAChG,+FAA+F;AAC/F,qCAAqC;AACrC,MAAM,UAAU,mBAAmB,CACjC,KAAyB,EACzB,MAA2B;IAE3B,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC;YAC1E,IAAI,KAAK,KAAK,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC/B,OAAO,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC7F,CAAC;QAED,KAAK,YAAY;YACf,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAE3D,KAAK,aAAa;YAChB,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAE5D,KAAK,cAAc;YACjB,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAE7C;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAyB;IAC1D,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IRoute } from './navigator-state';
|
|
2
|
+
export type { IRoute } from './navigator-state';
|
|
3
|
+
type IRouteEntry = IRoute<unknown>;
|
|
4
|
+
export type IDrawerRouterState = Readonly<{
|
|
5
|
+
routes: readonly IRouteEntry[];
|
|
6
|
+
index: number;
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
export type IDrawerRouterAction = {
|
|
10
|
+
type: 'jumpTo';
|
|
11
|
+
name: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'openDrawer';
|
|
14
|
+
} | {
|
|
15
|
+
type: 'closeDrawer';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'toggleDrawer';
|
|
18
|
+
};
|
|
19
|
+
export declare function createInitialDrawerRouterState(routes: readonly IRouteEntry[], initialRouteName?: string): IDrawerRouterState;
|
|
20
|
+
export declare function drawerRouterReducer(state: IDrawerRouterState, action: IDrawerRouterAction): IDrawerRouterState;
|
|
21
|
+
export declare function focusedDrawerRoute(state: IDrawerRouterState): IRouteEntry | undefined;
|