Skip to content

Commit

Permalink
fix: export functional components
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Jul 4, 2019
1 parent e79abe3 commit 035ef67
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { h, Component, State } from '@stencil/core';
import { Machine, assign } from 'xstate';
import 'stencil-xstate-router';
import { DemoContext, DemoEvent, DemoSchema } from '../types';

import { XstateRouterNavigo } from 'stencil-xstate-router';

@Component({
tag: 'xstate-router-test',
Expand Down Expand Up @@ -94,7 +94,7 @@ export class XStateRouterTest {

render() {
return (
<xstate-router-navigo
<XstateRouterNavigo
machine={this.machine}
routes={{
WOOT: '/woot',
Expand Down
2 changes: 1 addition & 1 deletion packages/stencil-xstate-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"module": "dist/index.mjs",
"es2015": "dist/esm/index.mjs",
"es2017": "dist/esm/index.mjs",
"types": "dist/types/components.d.ts",
"types": "dist/types/index.d.ts",
"unpkg": "dist/stencil-xstate-router/xstate.js",
"collection:main": "dist/collection/index.js",
"collection": "dist/collection/collection-manifest.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
StateRenderer
} from '../xstate-router/types';

export interface RouterNavigoProps<
export interface XstateRouterNavigoProps<
TContext,
TSchema extends StateSchema,
TEvent extends EventObject
Expand All @@ -27,10 +27,12 @@ export interface RouterNavigoProps<
* @param props Component props
* @param children Component children
*/
export const RouterNavigo: <
export const XstateRouterNavigo: <
TContext,
TSchema extends StateSchema,
TEvent extends EventObject
>(
props: RouterNavigoProps<TContext, TSchema, TEvent>
props: XstateRouterNavigoProps<TContext, TSchema, TEvent>
) => Element = props => <xstate-router-navigo {...props} />;

export default XstateRouterNavigo;
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;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Interpreter,
InterpreterOptions,
State as RouterState,
StateMachine,
StateSchema
} from 'xstate';

Expand Down Expand Up @@ -74,20 +73,6 @@ export type NavigationEvent = RouterEvent & {
path: string;
};

export interface RouterProps<
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;
}

export interface ComponentProps<
TContext,
TSchema extends StateSchema,
Expand Down

0 comments on commit 035ef67

Please sign in to comment.