Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit addce20

Browse files
bc022699bc022699
authored andcommitted
Update to support new routing code in F7 Vue
1 parent e102654 commit addce20

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

framework7-react-component-gen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const generateTypeScriptInterfaceFromProps = (props, componentName, eventList, s
8989
};
9090

9191
const getEventList = (vueComponentString) => {
92-
const regex = new RegExp(/\$emit\(["']([A-Za-z0-9-:]+)["'],/, 'g');
92+
const regex = new RegExp(/\$emit\(["']([A-Za-z0-9-:]+)["'],?/, 'g');
9393
let match;
9494
const events = [];
9595

src/components/Framework7App.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22

33
import Framework7Router from '../../framework7-vue/router';
4-
import {Framework7, IFramework7Params} from '../Framework7';
4+
import {Framework7, IFramework7Params, Dom7} from '../Framework7';
55
import {applyOverscrollFix} from '../utils/OverscrollFix';
66

77
export type ThemeTypeEnum = 'ios' | 'material';
@@ -34,6 +34,7 @@ export interface IFramework7AppContext {
3434
onRouteChange: (componentId: number, callback: (route: IFramework7Route) => void) => void;
3535
unregisterRouteChange: (callback: (componentId: number) => void) => void;
3636
getCurrentRoute: () => any;
37+
getRouter: () => any;
3738
}
3839

3940
export interface IFramework7AppProps extends IFramework7Params, React.Props<any> {
@@ -49,6 +50,7 @@ export class Framework7App extends React.Component<IFramework7AppProps, Framewor
4950
private framework7InitCallbacks: ((framework7: Framework7) => void)[] = [];
5051
private routeChangeCallbacks: any = {};
5152
private currentRoute;
53+
private router;
5254

5355
public static childContextTypes = {
5456
framework7AppContext: React.PropTypes.object
@@ -65,7 +67,8 @@ export class Framework7App extends React.Component<IFramework7AppProps, Framewor
6567
},
6668
onRouteChange: this.onRouteChange.bind(this),
6769
unregisterRouteChange: this.unregisterRouteChange.bind(this),
68-
getCurrentRoute: () => this.currentRoute
70+
getCurrentRoute: () => this.currentRoute,
71+
getRouter: () => this.router
6972
}
7073
};
7174
}
@@ -88,7 +91,7 @@ export class Framework7App extends React.Component<IFramework7AppProps, Framewor
8891
private initFramework7() {
8992
this.framework7 = new Framework7(this.props);
9093

91-
const router = new Framework7Router(this.props.routes, this.framework7);
94+
const router = this.router = new Framework7Router(this.props.routes, this.framework7, Dom7);
9295

9396
router.setRouteChangeHandler(route => {
9497
this.currentRoute = route;

src/utils/ReactifyF7Vue.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const reactifyF7Vue = <TProps>(args: IReactifyF7VueArgs) => {
3232
args: {
3333
...args.args,
3434
$$: Dom7,
35-
$t7: Template7
35+
$t7: Template7
3636
},
3737
mixin: args.mixin
3838
});
@@ -45,6 +45,12 @@ export const reactifyF7Vue = <TProps>(args: IReactifyF7VueArgs) => {
4545
this.framework7 = f7;
4646
});
4747

48+
Object.defineProperty(args.component, '$router', {
49+
get: framework7AppContext.getRouter,
50+
enumerable: true,
51+
configurable: true
52+
});
53+
4854
Object.defineProperty(args.component, '$route', {
4955
get: framework7AppContext.getCurrentRoute,
5056
enumerable: true,

0 commit comments

Comments
 (0)