77import * as React from 'react' ;
88import { findNodeHandle } from 'react-native' ;
99
10+ import type { UseSlots } from '@fluentui-react-native/framework' ;
11+ import { compose , mergeProps } from '@fluentui-react-native/framework' ;
1012import { useViewCommandFocus } from '@fluentui-react-native/interactive-hooks' ;
11- import type { IUseStyling } from '@uifabricshared/foundation-composable' ;
12- import { composable } from '@uifabricshared/foundation-composable' ;
13- import { mergeSettings } from '@uifabricshared/foundation-settings' ;
1413
15- import type { FocusZoneProps , FocusZoneSlotProps , FocusZoneType } from './FocusZone.types' ;
14+ import type { FocusZoneProps , FocusZoneState , FocusZoneTokens } from './FocusZone.types' ;
15+ import { focusZoneName } from './FocusZone.types' ;
1616import RCTFocusZone from './FocusZoneNativeComponent' ;
17-
18- const filterOutComponentRef = ( propName ) => propName !== 'componentRef' ;
19-
20- export const FocusZone = composable < FocusZoneType > ( {
21- usePrepareProps : ( userProps : FocusZoneProps , useStyling : IUseStyling < FocusZoneType > ) => {
17+ import type { NativeProps } from './FocusZoneNativeComponent' ;
18+
19+ interface FocusZoneTypeInternal {
20+ props : FocusZoneProps ;
21+ tokens : FocusZoneTokens ;
22+ slotProps : { root : React . PropsWithRef < NativeProps > } ;
23+ state : FocusZoneState ;
24+ }
25+
26+ export const FocusZone = compose < FocusZoneTypeInternal > ( {
27+ displayName : focusZoneName ,
28+ slots : { root : RCTFocusZone } ,
29+ useRender : ( userProps : FocusZoneProps , useSlots : UseSlots < FocusZoneTypeInternal > ) => {
2230 const { componentRef, defaultTabbableElement, isCircularNavigation, ...rest } = userProps ;
2331
2432 const ftzRef = useViewCommandFocus ( componentRef ) ;
@@ -34,18 +42,18 @@ export const FocusZone = composable<FocusZoneType>({
3442 }
3543 } , [ defaultTabbableElement ] ) ;
3644
37- return {
38- slotProps : mergeSettings < FocusZoneSlotProps > ( useStyling ( userProps ) , {
39- root : {
40- navigateAtEnd : isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' , // let rest override
41- ...rest ,
42- defaultTabbableElement : targetFirstFocus ,
43- ref : ftzRef ,
44- } ,
45- } ) ,
45+ const rootProps = {
46+ navigateAtEnd : isCircularNavigation ? 'NavigateWrap' : 'NavigateStopAtEnds' ,
47+ ...rest ,
48+ } as NativeProps ;
49+
50+ const Root = useSlots ( userProps ) . root ;
51+ return ( restProps : FocusZoneProps ) => {
52+ return React . createElement ( Root , {
53+ ...mergeProps ( rootProps , restProps as NativeProps ) ,
54+ defaultTabbableElement : targetFirstFocus ,
55+ ref : ftzRef ,
56+ } ) ;
4657 } ;
4758 } ,
48- slots : {
49- root : { slotType : RCTFocusZone , filter : filterOutComponentRef } ,
50- } ,
5159} ) ;
0 commit comments