-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite in typescript with LitElement
- Loading branch information
1 parent
3e38a25
commit ef7fb87
Showing
53 changed files
with
17,079 additions
and
4,155 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
/bower_components | ||
**/*~ | ||
/node_modules | ||
*.js | ||
*.js.map | ||
*.d.ts | ||
!karma.conf.js |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"files.exclude": { | ||
"**/*.js": {"when": "$(basename).ts"}, | ||
"**/*.d.ts": {"when": "$(basename).ts"}, | ||
"**/*.js.map": true | ||
}, | ||
} |
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,35 @@ | ||
import type { PropertyValues } from 'lit-element'; | ||
import { FireMixin } from '@pwrs/mixins/fire'; | ||
import { LitElement, property } from 'lit-element'; | ||
import { bound } from './bound-decorator'; | ||
|
||
type LeafletFeature = | ||
| null | ||
| L.Circle | ||
| L.GeoJSON | ||
| L.Marker | ||
| L.LayerGroup | ||
| L.Polyline | ||
| L.Polygon | ||
| L.Popup | ||
| L.Point; | ||
|
||
export class LeafletBase extends FireMixin(LitElement) { | ||
_mutationObserver?: MutationObserver; | ||
|
||
feature: LeafletFeature; | ||
|
||
_container: L.Map | L.LayerGroup; | ||
|
||
get container() { | ||
return this._container; | ||
} | ||
|
||
set container(v) { | ||
this._container = v; | ||
} | ||
|
||
@bound onLeafletEvent(e: L.LeafletEvent) { | ||
this.fire(e.type, e); | ||
} | ||
} |
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 @@ | ||
```html | ||
<script src="https://unpkg.com/@webcomponentsjs/webcomponentsjs/webcomponents-loader.js"></script> | ||
<script type="module" src="https://unpkg.com/leaflet-element?module"></script> | ||
<leaflet-map></leaflet-map> | ||
``` |
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,27 @@ | ||
export function bound<T extends Function>( | ||
target: object, | ||
propertyKey: string, | ||
descriptor: TypedPropertyDescriptor<T> | ||
): TypedPropertyDescriptor<T> | void { | ||
if (!descriptor || typeof descriptor.value !== 'function') { | ||
throw new TypeError( | ||
`Only methods can be decorated with @bound. <${propertyKey}> is not a method!` | ||
); | ||
} | ||
|
||
return { | ||
configurable: true, | ||
get(this: T): T { | ||
const f: T = descriptor.value!.bind(this); | ||
// Credits to https://github.com/andreypopp/autobind-decorator for memoizing the result of bind against a symbol on the instance. | ||
Object.defineProperty(this, propertyKey, { | ||
value: f, | ||
configurable: true, | ||
writable: true, | ||
}); | ||
return f; | ||
}, | ||
}; | ||
} | ||
|
||
export default bound; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.