-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from Banno/ts-mixins
Add typescript friendly mixins
- Loading branch information
Showing
7 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import animatedRouteMixin from './animated-routing-mixin.js'; | ||
function animatedRoutingMixin(Superclass, className) { | ||
return animatedRouteMixin(Superclass, className); | ||
} | ||
export default animatedRoutingMixin; |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {type LitElement} from 'lit'; | ||
import {type Constructor, type RoutingMixinInterface} from './routing.mixin.js'; | ||
import animatedRouteMixin from './animated-routing-mixin.js'; | ||
|
||
function animatedRoutingMixin<T extends Constructor<LitElement>>(Superclass:T, className:string) { | ||
return animatedRouteMixin(Superclass, className) as unknown as Constructor<RoutingMixinInterface> & T; | ||
} | ||
|
||
export default animatedRoutingMixin; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import BasicRoutingInterface from './routing-interface.js'; | ||
import routingMixin from './routing-mixin.js'; | ||
const RoutingMixin = (superclass) => { | ||
return routingMixin(superclass); | ||
}; | ||
//exporting BasicRoutingInterface for backward compatibility - don't break consumer imports | ||
export { RoutingMixin, BasicRoutingInterface }; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import BasicRoutingInterface from './routing-interface.js'; | ||
import type { Context } from './page.js'; | ||
import type RouteTreeNode from './route-tree-node.js'; | ||
import type { LitElement } from 'lit'; | ||
import routingMixin from './routing-mixin.js'; | ||
export type Constructor<T = {}> = new (...args: any[]) => T; | ||
export declare class RoutingMixinInterface { | ||
routeEnter(currentNode: RouteTreeNode, nextNodeIfExists: RouteTreeNode | undefined, routeId: string, context: Context): Promise<boolean | void>; | ||
routeExit(currentNode: RouteTreeNode, nextNode: RouteTreeNode | undefined, routeId: string, context: Context): Promise<boolean | void>; | ||
} | ||
const RoutingMixin = <T extends Constructor<LitElement>>(superclass: T) => { | ||
return routingMixin(superclass) as unknown as Constructor<RoutingMixinInterface> & T; | ||
}; | ||
|
||
//exporting BasicRoutingInterface for backward compatibility - don't break consumer imports | ||
export { RoutingMixin, BasicRoutingInterface }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": false, | ||
"emitDeclarationOnly": false, | ||
}, | ||
"include": ["lib/routing.mixin.ts", "lib/animated-routing.mixin.ts"], | ||
} |
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