-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e79abe3
commit 035ef67
Showing
6 changed files
with
34 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 25 additions & 5 deletions
30
packages/stencil-xstate-router/src/components/xstate-router/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
import { h } from '@stencil/core'; | ||
import { EventObject, StateSchema } from 'xstate'; | ||
import { RouterProps } from './types'; | ||
import { EventObject, StateMachine, StateSchema } from 'xstate'; | ||
import { | ||
ComponentRenderer, | ||
NavigationHandler, | ||
RouteHandler, | ||
RouterInterpreterOptions, | ||
StateRenderer | ||
} from './types'; | ||
|
||
export * from './types'; | ||
export * from './utils'; | ||
|
||
export interface XstateRouterProps< | ||
TContext, | ||
TSchema extends StateSchema, | ||
TEvent extends EventObject | ||
> { | ||
machine: StateMachine<TContext, TSchema, TEvent>; | ||
options?: RouterInterpreterOptions; | ||
stateRenderer?: StateRenderer<TContext, TSchema, TEvent>; | ||
componentRenderer?: ComponentRenderer<TContext, TSchema, TEvent>; | ||
route?: RouteHandler; | ||
routes?: Record<string, string>; | ||
navigate?: NavigationHandler; | ||
} | ||
|
||
/** | ||
* Functional component wrapper for XstateRouter | ||
* @param props Component props | ||
* @param children Component children | ||
*/ | ||
export const Router: < | ||
export const XstateRouter: < | ||
TContext, | ||
TSchema extends StateSchema, | ||
TEvent extends EventObject | ||
>( | ||
props: RouterProps<TContext, TSchema, TEvent>, | ||
props: XstateRouterProps<TContext, TSchema, TEvent>, | ||
children?: Element[] | ||
) => Element = (props, children) => ( | ||
<xstate-router {...props}>{children}</xstate-router> | ||
); | ||
|
||
export default Router; | ||
export default XstateRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters