@record-evolution/widget-mapbox 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/widget-mapbox.d.ts +9 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/widget-mapbox.js +395 -356
- package/dist/widget-mapbox.js.map +1 -1
- package/package.json +26 -28
- package/src/default-data.json +2 -0
- package/src/widget-mapbox.ts +68 -17
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "REWidget widget-mapbox",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "widget-mapbox",
|
|
6
|
-
"version": "1.5.
|
|
6
|
+
"version": "1.5.4",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/widget-mapbox.js",
|
|
9
9
|
"types": "dist/src/widget-mapbox.d.ts",
|
|
@@ -13,51 +13,49 @@
|
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"analyze": "cem analyze --litelement",
|
|
16
|
-
"start": "
|
|
16
|
+
"start": "concurrently -k -r \"npm run watch\" \"wds\"",
|
|
17
17
|
"build": "rollup -c rollup.config.js",
|
|
18
18
|
"watch": "rollup -w -c rollup.config.js",
|
|
19
19
|
"link": "npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-mapbox",
|
|
20
20
|
"unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-mapbox && npm i @record-evolution/widget-mapbox",
|
|
21
21
|
"types": "cat src/definition-schema.json | json2ts > src/definition-schema.d.ts",
|
|
22
|
-
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
23
|
-
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
24
22
|
"release": "npm version patch --tag-version-prefix='' && git push && git push --tag",
|
|
25
23
|
"cors": "gcloud storage buckets update gs://reswarm-images --cors-file=src/cors-config.json"
|
|
26
24
|
},
|
|
27
25
|
"dependencies": {
|
|
28
|
-
"@types/geojson": "^7946.0.
|
|
29
|
-
"@types/mapbox-gl": "^3.4.
|
|
30
|
-
"lit": "^3.
|
|
31
|
-
"mapbox-gl": "^3.
|
|
26
|
+
"@types/geojson": "^7946.0.16",
|
|
27
|
+
"@types/mapbox-gl": "^3.4.1",
|
|
28
|
+
"lit": "^3.3.0",
|
|
29
|
+
"mapbox-gl": "^3.13.0",
|
|
32
30
|
"tinycolor2": "^1.6.0"
|
|
33
31
|
},
|
|
34
32
|
"devDependencies": {
|
|
35
|
-
"@babel/plugin-syntax-import-assertions": "^7.
|
|
36
|
-
"@custom-elements-manifest/analyzer": "^0.10.
|
|
33
|
+
"@babel/plugin-syntax-import-assertions": "^7.27.1",
|
|
34
|
+
"@custom-elements-manifest/analyzer": "^0.10.4",
|
|
37
35
|
"@rollup/plugin-babel": "^6.0.4",
|
|
38
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
36
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
39
37
|
"@rollup/plugin-json": "^6.1.0",
|
|
40
|
-
"@rollup/plugin-node-resolve": "^
|
|
41
|
-
"@rollup/plugin-replace": "^6.0.
|
|
42
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
38
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
39
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
40
|
+
"@rollup/plugin-typescript": "^12.1.3",
|
|
43
41
|
"@types/glob": "^8.1.0",
|
|
44
42
|
"@types/tinycolor2": "^1.4.6",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
46
|
-
"@typescript-eslint/parser": "^8.
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
44
|
+
"@typescript-eslint/parser": "^8.34.1",
|
|
47
45
|
"@web/dev-server": "^0.4.6",
|
|
48
|
-
"concurrently": "^9.
|
|
49
|
-
"eslint": "^9.
|
|
50
|
-
"eslint-config-prettier": "^
|
|
51
|
-
"glob": "^11.0.
|
|
52
|
-
"husky": "^9.1.
|
|
53
|
-
"json-schema-to-typescript": "^15.0.
|
|
54
|
-
"lint-staged": "^
|
|
55
|
-
"minimatch": "
|
|
56
|
-
"prettier": "^3.
|
|
57
|
-
"rollup": "^4.
|
|
46
|
+
"concurrently": "^9.1.2",
|
|
47
|
+
"eslint": "^9.29.0",
|
|
48
|
+
"eslint-config-prettier": "^10.1.5",
|
|
49
|
+
"glob": "^11.0.3",
|
|
50
|
+
"husky": "^9.1.7",
|
|
51
|
+
"json-schema-to-typescript": "^15.0.4",
|
|
52
|
+
"lint-staged": "^16.1.2",
|
|
53
|
+
"minimatch": "10.0.3",
|
|
54
|
+
"prettier": "^3.5.3",
|
|
55
|
+
"rollup": "^4.43.0",
|
|
58
56
|
"rollup-plugin-copy": "^3.5.0",
|
|
59
|
-
"tslib": "^2.
|
|
60
|
-
"typescript": "5.3
|
|
57
|
+
"tslib": "^2.8.1",
|
|
58
|
+
"typescript": "5.8.3"
|
|
61
59
|
},
|
|
62
60
|
"repository": {
|
|
63
61
|
"type": "git",
|
package/src/default-data.json
CHANGED
package/src/widget-mapbox.ts
CHANGED
|
@@ -10,10 +10,17 @@ import { LayerBaseColor, InputData } from './definition-schema.js'
|
|
|
10
10
|
|
|
11
11
|
type Dataseries = Exclude<InputData['dataseries'], undefined>[number]
|
|
12
12
|
type Point = Exclude<Dataseries['data'], undefined>[number]
|
|
13
|
-
|
|
13
|
+
type Theme = {
|
|
14
|
+
theme_name: string
|
|
15
|
+
theme_object: any
|
|
16
|
+
}
|
|
14
17
|
export class WidgetMapbox extends LitElement {
|
|
15
18
|
@property({ type: Object })
|
|
16
19
|
inputData?: InputData
|
|
20
|
+
|
|
21
|
+
@property({ type: Object })
|
|
22
|
+
theme?: Theme
|
|
23
|
+
|
|
17
24
|
@state()
|
|
18
25
|
private map: any | undefined = undefined
|
|
19
26
|
|
|
@@ -26,6 +33,10 @@ export class WidgetMapbox extends LitElement {
|
|
|
26
33
|
@state()
|
|
27
34
|
colors: any = new Map()
|
|
28
35
|
|
|
36
|
+
@state() private themeBgColor?: string
|
|
37
|
+
@state() private themeTitleColor?: string
|
|
38
|
+
@state() private themeSubtitleColor?: string
|
|
39
|
+
|
|
29
40
|
public version: string = 'versionplaceholder'
|
|
30
41
|
private mapLoaded: boolean = false
|
|
31
42
|
private resizeObserver: ResizeObserver
|
|
@@ -43,7 +54,7 @@ export class WidgetMapbox extends LitElement {
|
|
|
43
54
|
|
|
44
55
|
disconnectedCallback() {
|
|
45
56
|
super.disconnectedCallback()
|
|
46
|
-
if(this.resizeObserver) {
|
|
57
|
+
if (this.resizeObserver) {
|
|
47
58
|
this.resizeObserver.disconnect()
|
|
48
59
|
}
|
|
49
60
|
}
|
|
@@ -52,6 +63,16 @@ export class WidgetMapbox extends LitElement {
|
|
|
52
63
|
if (changedProperties.has('inputData')) {
|
|
53
64
|
this.transformInputData()
|
|
54
65
|
}
|
|
66
|
+
|
|
67
|
+
if (changedProperties.has('theme')) {
|
|
68
|
+
const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
|
|
69
|
+
const cssBgColor = getComputedStyle(this).getPropertyValue('--re-background-color').trim()
|
|
70
|
+
this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor
|
|
71
|
+
this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color
|
|
72
|
+
this.themeSubtitleColor =
|
|
73
|
+
cssTextColor || this.theme?.theme_object?.title?.subtextStyle?.color || this.themeTitleColor
|
|
74
|
+
}
|
|
75
|
+
|
|
55
76
|
super.update(changedProperties)
|
|
56
77
|
}
|
|
57
78
|
|
|
@@ -67,16 +88,33 @@ export class WidgetMapbox extends LitElement {
|
|
|
67
88
|
|
|
68
89
|
this.customDebounce = setTimeout(() => {
|
|
69
90
|
this.map?.resize()
|
|
70
|
-
this.fitBounds()
|
|
91
|
+
this.fitBounds()
|
|
71
92
|
}, 300)
|
|
72
93
|
}
|
|
73
94
|
|
|
95
|
+
isArrayOfTwoNumbers(v: any) {
|
|
96
|
+
return (
|
|
97
|
+
Array.isArray(v) && // Check if it's an array
|
|
98
|
+
v.length <= 3 && // Check if the array has exactly two elements
|
|
99
|
+
typeof v[0] === 'number' && // Check if the first element is a number
|
|
100
|
+
typeof v[1] === 'number' // Check if the second element is a number
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
74
104
|
fitBounds() {
|
|
75
105
|
const bounds = new mapboxgl.LngLatBounds()
|
|
76
106
|
this.dataSources.forEach((col: GeoJSON.FeatureCollection) => {
|
|
77
107
|
col.features.forEach((f) => {
|
|
78
108
|
// @ts-ignore
|
|
79
|
-
if (
|
|
109
|
+
if (this.isArrayOfTwoNumbers(f.geometry?.coordinates)) {
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
bounds.extend(f.geometry.coordinates)
|
|
112
|
+
} else {
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
for (const lnglat of f.geometry.coordinates) {
|
|
115
|
+
if (this.isArrayOfTwoNumbers(lnglat)) bounds.extend(lnglat)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
80
118
|
})
|
|
81
119
|
})
|
|
82
120
|
if (bounds.isEmpty()) {
|
|
@@ -129,7 +167,7 @@ export class WidgetMapbox extends LitElement {
|
|
|
129
167
|
// Filter for latest Values
|
|
130
168
|
this.dataSets.forEach((ds) => {
|
|
131
169
|
if (ds?.latestValues && ds?.latestValues > 0) {
|
|
132
|
-
ds.data = ds?.data?.slice(
|
|
170
|
+
ds.data = ds?.data?.slice(-ds.latestValues || -1) ?? []
|
|
133
171
|
}
|
|
134
172
|
})
|
|
135
173
|
|
|
@@ -522,9 +560,7 @@ export class WidgetMapbox extends LitElement {
|
|
|
522
560
|
static styles = css`
|
|
523
561
|
:host {
|
|
524
562
|
display: block;
|
|
525
|
-
color: var(--re-bar-text-color, #000);
|
|
526
563
|
font-family: sans-serif;
|
|
527
|
-
padding: 16px;
|
|
528
564
|
box-sizing: border-box;
|
|
529
565
|
margin: auto;
|
|
530
566
|
}
|
|
@@ -559,6 +595,8 @@ export class WidgetMapbox extends LitElement {
|
|
|
559
595
|
.wrapper {
|
|
560
596
|
display: flex;
|
|
561
597
|
flex-direction: column;
|
|
598
|
+
box-sizing: border-box;
|
|
599
|
+
padding: 16px;
|
|
562
600
|
height: 100%;
|
|
563
601
|
width: 100%;
|
|
564
602
|
}
|
|
@@ -586,6 +624,16 @@ export class WidgetMapbox extends LitElement {
|
|
|
586
624
|
a.mapboxgl-ctrl-logo {
|
|
587
625
|
display: none;
|
|
588
626
|
}
|
|
627
|
+
|
|
628
|
+
.no-data {
|
|
629
|
+
font-size: 20px;
|
|
630
|
+
display: flex;
|
|
631
|
+
height: 100%;
|
|
632
|
+
width: 100%;
|
|
633
|
+
text-align: center;
|
|
634
|
+
align-items: center;
|
|
635
|
+
justify-content: center;
|
|
636
|
+
}
|
|
589
637
|
`
|
|
590
638
|
|
|
591
639
|
render() {
|
|
@@ -594,16 +642,18 @@ export class WidgetMapbox extends LitElement {
|
|
|
594
642
|
href="https://api.mapbox.com/mapbox-gl-js/v${mapboxgl.version}/mapbox-gl.css"
|
|
595
643
|
rel="stylesheet"
|
|
596
644
|
/>
|
|
597
|
-
<div
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
>
|
|
645
|
+
<div
|
|
646
|
+
class="wrapper"
|
|
647
|
+
style="background-color: ${this.themeBgColor}; color: ${this.themeTitleColor}"
|
|
648
|
+
>
|
|
649
|
+
<header class="paging" ?active=${this.inputData?.title || this.inputData?.subTitle}>
|
|
602
650
|
<div class="title">
|
|
603
|
-
<h3 class="paging" ?active=${this.inputData?.title}>
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
651
|
+
<h3 class="paging" ?active=${this.inputData?.title}>${this.inputData?.title}</h3>
|
|
652
|
+
<p
|
|
653
|
+
class="paging"
|
|
654
|
+
?active=${this.inputData?.subTitle}
|
|
655
|
+
style="color: ${this.themeSubtitleColor}"
|
|
656
|
+
>
|
|
607
657
|
${this.inputData?.subTitle}
|
|
608
658
|
</p>
|
|
609
659
|
</div>
|
|
@@ -624,7 +674,8 @@ export class WidgetMapbox extends LitElement {
|
|
|
624
674
|
)}
|
|
625
675
|
</div>
|
|
626
676
|
</header>
|
|
627
|
-
<div
|
|
677
|
+
<div class="paging no-data" ?active=${!this.dataSets.length}>No Data</div>
|
|
678
|
+
<div id="map" class="paging" ?active=${this.dataSets.length}></div>
|
|
628
679
|
</div>
|
|
629
680
|
`
|
|
630
681
|
}
|