@mwater/visualization 5.2.0 → 5.3.0

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.
Files changed (254) hide show
  1. package/lib/ColorComponent.d.ts +10 -11
  2. package/lib/ColorComponent.js +78 -29
  3. package/lib/ColorSchemeFactory.d.ts +13 -2
  4. package/lib/ColorSchemeFactory.js +7 -5
  5. package/lib/CustomColorsContext.d.ts +6 -0
  6. package/lib/CustomColorsContext.js +6 -0
  7. package/lib/FiltersDesignerComponent.d.ts +1 -4
  8. package/lib/FiltersDesignerComponent.js +2 -3
  9. package/lib/LocaleContextInjector.d.ts +5 -11
  10. package/lib/LocaleContextInjector.js +4 -12
  11. package/lib/MWaterAddRelatedFormComponent.js +3 -3
  12. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
  13. package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
  14. package/lib/MWaterCompleteTableSelectComponent.d.ts +5 -16
  15. package/lib/MWaterCompleteTableSelectComponent.js +36 -36
  16. package/lib/MWaterContextComponent.d.ts +4 -6
  17. package/lib/MWaterContextComponent.js +4 -13
  18. package/lib/MWaterLoaderComponent.d.ts +5 -3
  19. package/lib/MWaterLoaderComponent.js +2 -1
  20. package/lib/MWaterTableSelectComponent.d.ts +1 -4
  21. package/lib/MWaterTableSelectComponent.js +10 -12
  22. package/lib/UIComponents.d.ts +2 -2
  23. package/lib/UIComponents.js +4 -12
  24. package/lib/axes/AxisBuilder.d.ts +7 -4
  25. package/lib/axes/AxisBuilder.js +3 -1
  26. package/lib/axes/AxisComponent.d.ts +2 -5
  27. package/lib/axes/AxisComponent.js +1 -2
  28. package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
  29. package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
  30. package/lib/dashboards/DashboardComponent.d.ts +4 -12
  31. package/lib/dashboards/DashboardComponent.js +18 -38
  32. package/lib/dashboards/DashboardDesign.d.ts +3 -3
  33. package/lib/dashboards/DashboardUpgrader.js +36 -1
  34. package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
  35. package/lib/dashboards/DashboardViewComponent.js +109 -132
  36. package/lib/dashboards/FontStyleEditor.d.ts +8 -0
  37. package/lib/dashboards/FontStyleEditor.js +130 -0
  38. package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
  39. package/lib/dashboards/LayoutOptionsComponent.js +211 -42
  40. package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
  41. package/lib/dashboards/ServerDashboardDataSource.js +52 -33
  42. package/lib/dashboards/WidgetComponent.d.ts +3 -3
  43. package/lib/dashboards/WidgetComponent.js +3 -6
  44. package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
  45. package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
  46. package/lib/dashboards/layoutOptions.d.ts +83 -0
  47. package/lib/dashboards/layoutOptions.js +436 -10
  48. package/lib/datagrids/DatagridDesign.d.ts +7 -6
  49. package/lib/datagrids/ServerDatagridDataSource.d.ts +7 -6
  50. package/lib/datagrids/ServerDatagridDataSource.js +87 -33
  51. package/lib/demo.js +3 -3
  52. package/lib/index.css +5 -0
  53. package/lib/index.d.ts +1 -1
  54. package/lib/index.js +0 -1
  55. package/lib/layouts/LayoutManager.d.ts +33 -29
  56. package/lib/layouts/LayoutManager.js +2 -8
  57. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -57
  58. package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
  59. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
  60. package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
  61. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
  62. package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
  63. package/lib/mWaterLoader.d.ts +2 -0
  64. package/lib/mWaterLoader.js +2 -1
  65. package/lib/maps/AddLayerComponent.d.ts +6 -8
  66. package/lib/maps/AddLayerComponent.js +6 -6
  67. package/lib/maps/BingLayer.js +10 -20
  68. package/lib/maps/BufferLayer.js +2 -1
  69. package/lib/maps/ChoroplethLayer.js +2 -1
  70. package/lib/maps/DirectMapDataSource.d.ts +5 -2
  71. package/lib/maps/DirectMapDataSource.js +2 -1
  72. package/lib/maps/EditPopupComponent.js +2 -1
  73. package/lib/maps/MapComponent.d.ts +1 -4
  74. package/lib/maps/MapComponent.js +3 -3
  75. package/lib/maps/MarkersLayer.js +30 -25
  76. package/lib/maps/RasterMapViewComponent.d.ts +1 -4
  77. package/lib/maps/RasterMapViewComponent.js +3 -3
  78. package/lib/maps/ServerMapDataSource.d.ts +2 -3
  79. package/lib/maps/ServerMapDataSource.js +5 -5
  80. package/lib/maps/VectorMapViewComponent.js +2 -1
  81. package/lib/maps/mapSymbols.js +2 -0
  82. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  83. package/lib/maps/vectorMaps.js +61 -55
  84. package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
  85. package/lib/quickfilter/QuickfiltersComponent.js +3 -3
  86. package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
  87. package/lib/richtext/DropdownPaletteItem.js +82 -0
  88. package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
  89. package/lib/richtext/FontColorPaletteItem.js +32 -27
  90. package/lib/richtext/ItemsHtmlConverter.js +12 -3
  91. package/lib/richtext/RichTextComponent.d.ts +26 -52
  92. package/lib/richtext/RichTextComponent.js +166 -128
  93. package/lib/valueFormatter.js +6 -1
  94. package/lib/wellknown.d.ts +5 -0
  95. package/lib/wellknown.js +288 -0
  96. package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
  97. package/lib/widgets/DropdownWidgetComponent.js +48 -25
  98. package/lib/widgets/IFrameWidgetComponent.d.ts +1 -2
  99. package/lib/widgets/ImageWidgetComponent.d.ts +2 -3
  100. package/lib/widgets/MapWidget.d.ts +2 -0
  101. package/lib/widgets/MapWidget.js +2 -1
  102. package/lib/widgets/TOCWidget.js +2 -1
  103. package/lib/widgets/Widget.d.ts +2 -0
  104. package/lib/widgets/WidgetDataSource.d.ts +3 -1
  105. package/lib/widgets/charts/Chart.d.ts +0 -1
  106. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  107. package/lib/widgets/charts/ChartViewComponent.js +11 -3
  108. package/lib/widgets/charts/ChartWidget.d.ts +1 -62
  109. package/lib/widgets/charts/ChartWidget.js +4 -183
  110. package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
  111. package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
  112. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
  113. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
  114. package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
  115. package/lib/widgets/charts/layered/LayeredChart.js +6 -7
  116. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
  117. package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
  118. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
  119. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +3 -0
  120. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
  121. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -2
  122. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
  123. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
  124. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
  125. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -112
  126. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
  127. package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
  128. package/lib/widgets/charts/pivot/PivotChart.js +47 -17
  129. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
  130. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -1
  131. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
  132. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
  133. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
  134. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
  135. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
  136. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
  137. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
  138. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -28
  139. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
  140. package/lib/widgets/charts/table/TableChart.js +8 -4
  141. package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
  142. package/lib/widgets/charts/table/TableChartViewComponent.js +11 -11
  143. package/lib/widgets/text/TextComponent.d.ts +5 -12
  144. package/lib/widgets/text/TextComponent.js +19 -39
  145. package/lib/widgets/text/TextWidget.d.ts +2 -1
  146. package/lib/widgets/text/TextWidget.js +5 -1
  147. package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
  148. package/lib/widgets/text/TextWidgetComponent.js +76 -19
  149. package/lib/widgets/text/TextWidgetDesign.d.ts +13 -1
  150. package/lib/widgets/text/TextWidgetDesign.js +6 -0
  151. package/package.json +4 -4
  152. package/src/ColorComponent.tsx +177 -0
  153. package/src/ColorSchemeFactory.ts +12 -6
  154. package/src/CustomColorsContext.tsx +8 -0
  155. package/src/FiltersDesignerComponent.ts +3 -4
  156. package/src/LocaleContextInjector.tsx +14 -13
  157. package/src/MWaterAddRelatedFormComponent.ts +3 -3
  158. package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
  159. package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
  160. package/src/MWaterContextComponent.tsx +8 -17
  161. package/src/MWaterLoaderComponent.ts +6 -3
  162. package/src/MWaterTableSelectComponent.tsx +11 -12
  163. package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
  164. package/src/axes/AxisBuilder.ts +7 -5
  165. package/src/axes/AxisComponent.ts +3 -4
  166. package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
  167. package/src/dashboards/DashboardComponent.tsx +71 -107
  168. package/src/dashboards/DashboardDesign.ts +3 -3
  169. package/src/dashboards/DashboardUpgrader.ts +41 -1
  170. package/src/dashboards/DashboardViewComponent.tsx +313 -0
  171. package/src/dashboards/FontStyleEditor.tsx +166 -0
  172. package/src/dashboards/LayoutOptionsComponent.tsx +379 -75
  173. package/src/dashboards/ServerDashboardDataSource.ts +52 -33
  174. package/src/dashboards/WidgetComponent.tsx +6 -12
  175. package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
  176. package/src/dashboards/layoutOptions.tsx +581 -0
  177. package/src/datagrids/DatagridDesign.ts +8 -3
  178. package/src/datagrids/ServerDatagridDataSource.ts +106 -43
  179. package/src/demo.ts +3 -3
  180. package/src/index.css +5 -0
  181. package/src/index.ts +1 -1
  182. package/src/layouts/LayoutManager.ts +44 -42
  183. package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
  184. package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
  185. package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
  186. package/src/mWaterLoader.ts +4 -1
  187. package/src/maps/AddLayerComponent.ts +9 -9
  188. package/src/maps/BingLayer.ts +16 -26
  189. package/src/maps/BufferLayer.ts +2 -1
  190. package/src/maps/ChoroplethLayer.ts +2 -1
  191. package/src/maps/DirectMapDataSource.ts +12 -3
  192. package/src/maps/EditPopupComponent.ts +2 -1
  193. package/src/maps/MapComponent.ts +3 -3
  194. package/src/maps/MarkersLayer.ts +38 -41
  195. package/src/maps/RasterMapViewComponent.ts +3 -3
  196. package/src/maps/ServerMapDataSource.ts +7 -7
  197. package/src/maps/VectorMapViewComponent.tsx +2 -1
  198. package/src/maps/mapSymbols.ts +2 -0
  199. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  200. package/src/maps/vectorMaps.tsx +79 -74
  201. package/src/quickfilter/QuickfiltersComponent.ts +3 -3
  202. package/src/richtext/DropdownPaletteItem.tsx +144 -0
  203. package/src/richtext/FontColorPaletteItem.tsx +160 -0
  204. package/src/richtext/ItemsHtmlConverter.ts +15 -5
  205. package/src/richtext/RichTextComponent.tsx +274 -232
  206. package/src/valueFormatter.ts +5 -1
  207. package/src/wellknown.ts +286 -0
  208. package/src/widgets/DropdownWidgetComponent.tsx +75 -0
  209. package/src/widgets/MapWidget.ts +5 -2
  210. package/src/widgets/TOCWidget.ts +2 -1
  211. package/src/widgets/Widget.ts +3 -0
  212. package/src/widgets/WidgetDataSource.ts +3 -1
  213. package/src/widgets/charts/Chart.ts +1 -1
  214. package/src/widgets/charts/ChartViewComponent.ts +16 -3
  215. package/src/widgets/charts/ChartWidget.ts +3 -275
  216. package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
  217. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
  218. package/src/widgets/charts/layered/LayeredChart.ts +4 -6
  219. package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
  220. package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
  221. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
  222. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
  223. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
  224. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
  225. package/src/widgets/charts/pivot/PivotChart.ts +56 -18
  226. package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
  227. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
  228. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
  229. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
  230. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
  231. package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
  232. package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
  233. package/src/widgets/charts/table/TableChart.ts +8 -4
  234. package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
  235. package/src/widgets/charts/table/TableChartViewComponent.ts +13 -14
  236. package/src/widgets/text/TextComponent.tsx +47 -49
  237. package/src/widgets/text/TextWidget.ts +8 -3
  238. package/src/widgets/text/TextWidgetComponent.tsx +249 -0
  239. package/src/widgets/text/TextWidgetDesign.ts +22 -1
  240. package/src/ColorComponent.ts +0 -117
  241. package/src/dashboards/DashboardViewComponent.ts +0 -303
  242. package/src/dashboards/layoutOptions.ts +0 -40
  243. package/src/layout-styles.css +0 -263
  244. package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
  245. package/src/layouts/grid/GridLayoutComponent.ts +0 -67
  246. package/src/layouts/grid/GridLayoutManager.ts +0 -185
  247. package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
  248. package/src/layouts/grid/PaletteItemComponent.ts +0 -28
  249. package/src/layouts/grid/README.md +0 -14
  250. package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
  251. package/src/richtext/FontColorPaletteItem.ts +0 -172
  252. package/src/richtext/FontSizePaletteItem.ts +0 -110
  253. package/src/widgets/DropdownWidgetComponent.ts +0 -78
  254. package/src/widgets/text/TextWidgetComponent.ts +0 -120
@@ -63,8 +63,8 @@ export function useVectorMap(options: {
63
63
  if (!divRef) {
64
64
  return
65
65
  }
66
-
67
- const observer = new IntersectionObserver(function(entries) {
66
+
67
+ const observer = new IntersectionObserver(function (entries) {
68
68
  // When in printing mode, always visible as we need to render the map
69
69
  setMapDivVisible(entries[0].isIntersecting || printingModeEnabled)
70
70
  })
@@ -88,65 +88,70 @@ export function useVectorMap(options: {
88
88
  return
89
89
  }
90
90
 
91
- const m = new maplibregl.Map({
92
- container: divRef,
93
- bounds: bounds,
94
- scrollZoom: scrollZoom === false ? false : true,
95
- dragPan: dragPan === false ? false : true,
96
- touchZoomRotate: touchZoomRotate === false ? false : true,
97
- attributionControl: false,
98
- boxZoom: false,
99
- style: {
100
- version: 8,
101
- layers: [],
102
- sources: {}
103
- },
104
- // Prevent scrolling outside of world bounds
105
- maxBounds: [
106
- [-179.9, -85], // Southwest coordinates
107
- [179.9, 85] // Northeast coordinates
108
- ],
109
- preserveDrawingBuffer: printingModeEnabled
110
- })
91
+ try {
92
+ const m = new maplibregl.Map({
93
+ container: divRef,
94
+ bounds: bounds,
95
+ scrollZoom: scrollZoom === false ? false : true,
96
+ dragPan: dragPan === false ? false : true,
97
+ touchZoomRotate: touchZoomRotate === false ? false : true,
98
+ attributionControl: false,
99
+ boxZoom: false,
100
+ style: {
101
+ version: 8,
102
+ layers: [],
103
+ sources: {}
104
+ },
105
+ // Prevent scrolling outside of world bounds
106
+ maxBounds: [
107
+ [-179.9, -85], // Southwest coordinates
108
+ [179.9, 85] // Northeast coordinates
109
+ ],
110
+ preserveDrawingBuffer: printingModeEnabled
111
+ })
111
112
 
112
- setHasWebGLContext(true)
113
+ setHasWebGLContext(true)
113
114
 
114
- // Add listener for losing context
115
- m.on("webglcontextlost", () => {
116
- console.warn("Lost WebGL context")
117
- setHasWebGLContext(false)
118
- })
115
+ // Add listener for losing context
116
+ m.on("webglcontextlost", () => {
117
+ console.warn("Lost WebGL context")
118
+ setHasWebGLContext(false)
119
+ })
119
120
 
120
- // Add zoom controls to the map.
121
- m.addControl(new maplibregl.NavigationControl({}), "top-left")
121
+ // Add zoom controls to the map.
122
+ m.addControl(new maplibregl.NavigationControl({}), "top-left")
122
123
 
123
- // Add scale control
124
- const scale = new maplibregl.ScaleControl({
125
- unit: "metric"
126
- })
127
- m.addControl(scale)
128
-
129
- // Speed up wheel scrolling
130
- m.scrollZoom.setWheelZoomRate(1 / 250)
131
-
132
- // Dynamically load symbols
133
- m.on("styleimagemissing" as any, function (ev: { id: string }) {
134
- // Check if known
135
- const mapSymbol = mapSymbols.find((s) => s.value == ev.id)
136
- if (mapSymbol) {
137
- m.loadImage(mapSymbol.url, (err: any, image: any) => {
138
- if (image && !m.hasImage(mapSymbol.value)) {
139
- m.addImage(mapSymbol.value, image, { sdf: true })
140
- }
141
- })
142
- }
143
- })
124
+ // Add scale control
125
+ const scale = new maplibregl.ScaleControl({
126
+ unit: "metric"
127
+ })
128
+ m.addControl(scale)
129
+
130
+ // Speed up wheel scrolling
131
+ m.scrollZoom.setWheelZoomRate(1 / 250)
132
+
133
+ // Dynamically load symbols
134
+ m.on("styleimagemissing" as any, function (ev: { id: string }) {
135
+ // Check if known
136
+ const mapSymbol = mapSymbols.find((s) => s.value == ev.id)
137
+ if (mapSymbol) {
138
+ m.loadImage(mapSymbol.url, (err: any, image: any) => {
139
+ if (image && !m.hasImage(mapSymbol.value)) {
140
+ m.addImage(mapSymbol.value, image, { sdf: true })
141
+ }
142
+ })
143
+ }
144
+ })
144
145
 
145
- setMap(m)
146
+ setMap(m)
146
147
 
147
- return () => {
148
- m.remove()
149
- setHasWebGLContext(false)
148
+ return () => {
149
+ m.remove()
150
+ setHasWebGLContext(false)
151
+ }
152
+ } catch (e) {
153
+ console.error("Error loading map", e)
154
+ alert(T`Error loading map. Please check that your browser and drivers are updated.`)
150
155
  }
151
156
  }, [mapReloadCount])
152
157
 
@@ -187,10 +192,10 @@ export function useHoverCursor(map: maplibregl.Map | undefined, layerIds: string
187
192
 
188
193
  /** Apply user style to a map with base style */
189
194
  export function useStyleMap(options: {
190
- map: maplibregl.Map | undefined,
195
+ map: maplibregl.Map | undefined,
191
196
  baseLayer: BaseLayer,
192
197
  baseLayerOpacity?: number | null,
193
- userStyle: maplibregl.StyleSpecification | null | undefined,
198
+ userStyle: maplibregl.StyleSpecification | null | undefined,
194
199
  }) {
195
200
  const { map, baseLayer, baseLayerOpacity, userStyle } = options
196
201
 
@@ -229,11 +234,11 @@ export function useBaseStyle(baseLayer: BaseLayer) {
229
234
  }
230
235
 
231
236
  if (baseLayer == "cartodb_positron") {
232
- loadStyle(`https://api.maptiler.com/maps/positron/style.json?key=${mapTilerApiKey}`)
237
+ loadStyle(`https://api.maptiler.com/maps/5f972163-6078-4341-982a-5c8bc4447e68/style.json?key=${mapTilerApiKey}`)
233
238
  } else if (baseLayer == "cartodb_dark_matter") {
234
- loadStyle(`https://api.maptiler.com/maps/darkmatter/style.json?key=${mapTilerApiKey}`)
239
+ loadStyle(`https://api.maptiler.com/maps/1d3e957b-c546-4791-b9de-dce203538429/style.json?key=${mapTilerApiKey}`)
235
240
  } else if (baseLayer == "bing_road") {
236
- loadStyle(`https://api.maptiler.com/maps/streets/style.json?key=${mapTilerApiKey}`)
241
+ loadStyle(`https://api.maptiler.com/maps/streets-v2/style.json?key=${mapTilerApiKey}`)
237
242
  } else if (baseLayer == "bing_aerial") {
238
243
  // Switched to Bing for superior aerial imagery
239
244
  loadBingBasemap("AerialWithLabels", 1).then(setBaseStyle)
@@ -252,8 +257,8 @@ export function useBaseStyle(baseLayer: BaseLayer) {
252
257
 
253
258
  /** Combines a base style and a user style */
254
259
  export function mergeBaseAndUserStyle(
255
- baseStyle: maplibregl.StyleSpecification | null | undefined,
256
- userStyle: maplibregl.StyleSpecification | null | undefined,
260
+ baseStyle: maplibregl.StyleSpecification | null | undefined,
261
+ userStyle: maplibregl.StyleSpecification | null | undefined,
257
262
  baseLayerOpacity?: number | null) {
258
263
  // Merge until baseStyle and userStyle are present
259
264
  if (!baseStyle || !userStyle) {
@@ -292,9 +297,9 @@ export function mergeBaseAndUserStyle(
292
297
  return style
293
298
  }
294
299
 
295
- export function AttributionControl(props: {
300
+ export function AttributionControl(props: {
296
301
  baseLayer: BaseLayer
297
- extraText?: string
302
+ extraText?: string
298
303
  }) {
299
304
  if (props.baseLayer == "blank") {
300
305
  return <div className="newmap-attribution-control">
@@ -315,7 +320,7 @@ export function AttributionControl(props: {
315
320
  <div className="newmap-attribution-control">
316
321
  <a href="https://www.maptiler.com/copyright/" target="_blank">
317
322
  &copy; MapTiler
318
- </a>
323
+ </a>
319
324
  {" "}
320
325
  <a href="https://www.openstreetmap.org/about/" target="_blank">
321
326
  © OpenStreetMap
@@ -333,15 +338,15 @@ export function VectorMapLogo(props: {
333
338
  }
334
339
 
335
340
  if (props.baseLayer == "bing_aerial") {
336
- return <img
337
- src="https://dev.virtualearth.net/Branding/logo_powered_by.png"
338
- style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
341
+ return <img
342
+ src="https://dev.virtualearth.net/Branding/logo_powered_by.png"
343
+ style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
339
344
  />
340
345
  }
341
346
 
342
- return <img
343
- src={require("./Maptiler-logo.png").default}
344
- style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
347
+ return <img
348
+ src={require("./Maptiler-logo.png").default}
349
+ style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
345
350
  />
346
351
  }
347
352
 
@@ -351,12 +356,12 @@ async function loadBingBasemap(basemapType: "AerialWithLabels", opacity: number)
351
356
 
352
357
  const metadata = await fetch(`https://dev.virtualearth.net/REST/v1/Imagery/Metadata/${basemapType}?key=${bingApiKey}`).then((response) => response.json())
353
358
  const resource = metadata.resourceSets[0].resources[0]
354
-
359
+
355
360
  return {
356
361
  sources: {
357
362
  "bing_raster": {
358
363
  type: "raster",
359
- tiles: resource.imageUrlSubdomains.map((subdomain: string) =>
364
+ tiles: resource.imageUrlSubdomains.map((subdomain: string) =>
360
365
  resource.imageUrl.replace("{subdomain}", subdomain).replace("{culture}", "").replace("http:", "https:")),
361
366
  tileSize: resource.imageHeight,
362
367
  }
@@ -416,4 +421,4 @@ export function usePersistedMapBounds(map: Map | undefined, localStorageKey: str
416
421
  }
417
422
  }, [map])
418
423
  }
419
-
424
+
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash"
2
- import PropTypes from "prop-types"
3
2
  import React from "react"
4
3
  const R = React.createElement
5
4
  import { default as ReactSelect } from "react-select"
@@ -12,6 +11,7 @@ import IdArrayQuickfilterComponent from "./IdArrayQuickfilterComponent"
12
11
  import { Quickfilter, QuickfilterLock } from "./Quickfilter"
13
12
  import { QuickfiltersDataSource } from "./QuickfiltersDataSource"
14
13
  import { JsonQLFilter } from ".."
14
+ import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
15
15
 
16
16
  export interface QuickfiltersComponentProps {
17
17
  /** Design of quickfilters. See README.md */
@@ -219,7 +219,7 @@ interface EnumQuickfilterComponentProps {
219
219
 
220
220
  /** Quickfilter for an enum */
221
221
  class EnumQuickfilterComponent extends React.Component<EnumQuickfilterComponentProps> {
222
- static contextTypes = { locale: PropTypes.string }
222
+ static contextType = LocaleContext
223
223
 
224
224
  handleSingleChange = (val: any) => {
225
225
  if (val) {
@@ -275,7 +275,7 @@ class EnumQuickfilterComponent extends React.Component<EnumQuickfilterComponentP
275
275
  render() {
276
276
  const options = _.map(this.props.options, (opt) => ({
277
277
  value: opt.id,
278
- label: ExprUtils.localizeString(opt.name, this.context.locale)
278
+ label: ExprUtils.localizeString(opt.name, this.context)
279
279
  }))
280
280
 
281
281
  // Determine width, estimating about 8 px per letter with 120px padding
@@ -0,0 +1,144 @@
1
+ import React, { ReactNode } from "react"
2
+ import _ from "lodash"
3
+ import ClickOutHandler from "react-onclickout"
4
+
5
+ export interface DropdownItem {
6
+ label: ReactNode
7
+ value: string
8
+ /** If true, this item will be rendered only when "More..." is clicked. */
9
+ more?: boolean
10
+ }
11
+
12
+ export interface DropdownPaletteItemProps {
13
+ label: ReactNode
14
+
15
+ items: DropdownItem[]
16
+
17
+ /** Called with clicked item */
18
+ onSelect: (value: string) => void
19
+
20
+ /** should the popup be under or over? */
21
+ position?: "under" | "over"
22
+ }
23
+
24
+ interface DropdownPaletteItemState {
25
+ open: boolean
26
+ moreOpen: boolean
27
+ }
28
+
29
+ /** Palette item that allows picking from dropdown */
30
+ export default class DropdownPaletteItem extends React.Component<DropdownPaletteItemProps, DropdownPaletteItemState> {
31
+ static defaultProps = { position: "under" }
32
+
33
+ constructor(props: DropdownPaletteItemProps) {
34
+ super(props)
35
+ this.state = {
36
+ open: false,
37
+ moreOpen: false
38
+ }
39
+ }
40
+
41
+ handleMouseDown = (ev: React.MouseEvent) => {
42
+ // Ignore if clicking on menu
43
+ if ((ev.target as HTMLElement).className === "dropdown-palette-menu-item") {
44
+ return
45
+ }
46
+
47
+ // Don't lose focus from editor
48
+ ev.preventDefault()
49
+ this.setState({ open: !this.state.open })
50
+ }
51
+
52
+ handleMoreClick = (ev: React.MouseEvent) => {
53
+ ev.preventDefault()
54
+ this.setState({ moreOpen: true })
55
+ }
56
+
57
+ renderItem(item: DropdownItem) {
58
+ return (
59
+ <div
60
+ className="dropdown-palette-menu-item"
61
+ onMouseDown={(ev: React.MouseEvent) => {
62
+ ev.preventDefault()
63
+ this.props.onSelect(item.value)
64
+ this.setState({ open: false })
65
+ }}
66
+ key={item.value}
67
+ >
68
+ {item.label}
69
+ </div>
70
+ )
71
+ }
72
+
73
+ renderItems() {
74
+ const visibleItems = this.state.moreOpen ? this.props.items : this.props.items.filter(item => !item.more)
75
+ const halfLength = Math.ceil(visibleItems.length / 2)
76
+ const leftColumn = visibleItems.slice(0, halfLength)
77
+ const rightColumn = visibleItems.slice(halfLength)
78
+
79
+ return (
80
+ <div className="dropdown-palette-menu">
81
+ <div style={{ display: 'flex' }}>
82
+ <div style={{ flex: 1 }}>
83
+ {leftColumn.map(item => this.renderItem(item))}
84
+ </div>
85
+ <div style={{ flex: 1 }}>
86
+ {rightColumn.map(item => this.renderItem(item))}
87
+ </div>
88
+ </div>
89
+ {this.props.items.some(item => item.more) && !this.state.moreOpen && (
90
+ <div
91
+ className="dropdown-palette-menu-item"
92
+ onMouseDown={this.handleMoreClick}
93
+ >
94
+ More...
95
+ </div>
96
+ )}
97
+ </div>
98
+ )
99
+ }
100
+
101
+ render() {
102
+ const popupPosition: React.CSSProperties = {
103
+ position: "absolute",
104
+ left: 0,
105
+ zIndex: 1000,
106
+ backgroundColor: "white",
107
+ border: "solid 1px #AAA",
108
+ borderRadius: 3
109
+ }
110
+
111
+ if (this.props.position === "under") {
112
+ popupPosition.top = 26
113
+ } else {
114
+ popupPosition.bottom = 26
115
+ }
116
+
117
+ return (
118
+ <ClickOutHandler onClickOut={() => this.setState({ open: false, moreOpen: false })}>
119
+ <div
120
+ className="mwater-visualization-text-palette-item"
121
+ style={{ position: "relative" }}
122
+ onMouseDown={this.handleMouseDown}
123
+ >
124
+ <style>
125
+ {`
126
+ .dropdown-palette-menu-item {
127
+ color: black;
128
+ background-color: white;
129
+ text-align: left;
130
+ padding: 5px 15px 5px 15px;
131
+ cursor: pointer;
132
+ }
133
+ .dropdown-palette-menu-item:hover {
134
+ background-color: #DDD;
135
+ }
136
+ `}
137
+ </style>
138
+ {this.state.open ? <div style={popupPosition}>{this.renderItems()}</div> : undefined}
139
+ {this.props.label}
140
+ </div>
141
+ </ClickOutHandler>
142
+ )
143
+ }
144
+ }
@@ -0,0 +1,160 @@
1
+ import React from "react"
2
+ import _ from "lodash"
3
+ import ClickOutHandler from "react-onclickout"
4
+ import Color from "color"
5
+ import { CustomColorsContext } from "../CustomColorsContext"
6
+
7
+ export interface FontColorPaletteItemProps {
8
+ /** Called with "#FF8800", etc. */
9
+ onSetColor: any
10
+ /** should the popup be under or over? */
11
+ position?: string
12
+ }
13
+
14
+ interface FontColorPaletteItemState {
15
+ open: any
16
+ }
17
+
18
+ // Palette item that allows picking a color
19
+ export default class FontColorPaletteItem extends React.Component<
20
+ FontColorPaletteItemProps,
21
+ FontColorPaletteItemState
22
+ > {
23
+ static defaultProps = { position: "under" }
24
+
25
+ constructor(props: any) {
26
+ super(props)
27
+ this.state = {
28
+ open: false
29
+ }
30
+ }
31
+
32
+ handleMouseDown = (ev: any) => {
33
+ // Don't lose focus from editor
34
+ ev.preventDefault()
35
+ return this.setState({ open: !this.state.open })
36
+ }
37
+
38
+ render() {
39
+ const popupPosition: React.CSSProperties = {
40
+ position: "absolute",
41
+ left: 0,
42
+ zIndex: 1000,
43
+ backgroundColor: "white",
44
+ border: "solid 1px #AAA",
45
+ borderRadius: 3
46
+ }
47
+
48
+ if (this.props.position === "under") {
49
+ popupPosition["top"] = 26
50
+ } else {
51
+ popupPosition["bottom"] = 26
52
+ }
53
+
54
+ return (
55
+ <ClickOutHandler onClickOut={() => this.setState({ open: false })}>
56
+ <div
57
+ className="mwater-visualization-text-palette-item"
58
+ onMouseDown={this.handleMouseDown}
59
+ style={{ position: "relative" }}
60
+ >
61
+ {this.state.open ? (
62
+ <div style={popupPosition}>
63
+ <ColorPaletteComponent
64
+ onSetColor={(color: any) => {
65
+ this.props.onSetColor(color)
66
+ return this.setState({ open: false })
67
+ }}
68
+ />
69
+ </div>
70
+ ) : undefined}
71
+
72
+ <i className="fas fa-palette" />
73
+ </div>
74
+ </ClickOutHandler>
75
+ )
76
+ }
77
+ }
78
+
79
+ interface ColorPaletteComponentProps {
80
+ onSetColor: any
81
+ }
82
+
83
+ class ColorPaletteComponent extends React.Component<ColorPaletteComponentProps> {
84
+ static contextType = CustomColorsContext
85
+ declare context: React.ContextType<typeof CustomColorsContext>
86
+
87
+ renderColor(color: any) {
88
+ return (
89
+ <td>
90
+ <div
91
+ style={{ width: 16, height: 15, backgroundColor: color, margin: 1 }}
92
+ onMouseDown={(ev: any) => {
93
+ ev.preventDefault()
94
+ this.props.onSetColor(color)
95
+ }}
96
+ />
97
+ </td>
98
+ )
99
+ }
100
+
101
+ render() {
102
+ const baseColors = [
103
+ "#FF0000", // red
104
+ "#FFAA00", // orange
105
+ "#FFFF00", // yellow
106
+ "#00FF00", // green
107
+ "#00FFFF", // cyan
108
+ "#0000FF", // blue
109
+ "#9900FF", // purple
110
+ "#FF00FF" // magenta
111
+ ]
112
+
113
+ const customColors = this.context?.customColors || []
114
+
115
+ return (
116
+ <div style={{ padding: 5 }}>
117
+ <table>
118
+ <tbody>
119
+ {/* Custom colors */}
120
+ {_.chunk(customColors.filter(color => color != null), 8).map((colorGroup, index) => (
121
+ <tr key={index}>
122
+ {colorGroup.map((color) => this.renderColor(color))}
123
+ </tr>
124
+ ))}
125
+ {/* Grey shades */}
126
+ <tr>
127
+ {_.map(_.range(0, 8), (i) => {
128
+ return this.renderColor(Color({ r: (i * 255) / 7, g: (i * 255) / 7, b: (i * 255) / 7 }).hex())
129
+ })}
130
+ </tr>
131
+ <tr style={{ height: 5 }} />
132
+ {/* Base colors */}
133
+ <tr>
134
+ {_.map(baseColors, (c) => this.renderColor(c))}
135
+ </tr>
136
+ <tr style={{ height: 5 }} />
137
+ <tr>
138
+ {_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.7).hex()))}
139
+ </tr>
140
+ <tr>
141
+ {_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.5).hex()))}
142
+ </tr>
143
+ <tr>
144
+ {_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.3).hex()))}
145
+ </tr>
146
+ <tr>
147
+ {_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.3).hex()))}
148
+ </tr>
149
+ <tr>
150
+ {_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.5).hex()))}
151
+ </tr>
152
+ <tr>
153
+ {_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.7).hex()))}
154
+ </tr>
155
+ </tbody>
156
+ </table>
157
+ </div>
158
+ )
159
+ }
160
+ }
@@ -82,6 +82,9 @@ export default class ItemsHtmlConverter {
82
82
  if (!allowedStyles[key]) {
83
83
  continue
84
84
  }
85
+ if (value == null || value === "") {
86
+ continue
87
+ }
85
88
 
86
89
  if (!first) {
87
90
  attrs += " "
@@ -163,14 +166,21 @@ export default class ItemsHtmlConverter {
163
166
  const item: HtmlItemElement = { type: "element", tag, items: this.convertElemToItems((node as HTMLElement)) }
164
167
 
165
168
  // Add style
166
- if ((node as HTMLElement).style != null) {
167
- for (style of (node as HTMLElement).style) {
168
- if (!allowedStyles[style]) {
169
+ const nodeElement = node as HTMLElement
170
+ if (nodeElement.style != null) {
171
+ const styleDeclaration = nodeElement.style
172
+ for (const style of styleDeclaration) {
173
+ if (!allowedStyles[style as string]) {
174
+ continue
175
+ }
176
+
177
+ const value = styleDeclaration[style as any]
178
+ if (value == null || value === "") {
169
179
  continue
170
180
  }
171
181
 
172
182
  item.style = item.style || {}
173
- item.style[style] = (node as HTMLElement).style[style]
183
+ item.style[style] = value
174
184
  }
175
185
  }
176
186
 
@@ -243,4 +253,4 @@ var allowedStyles: { [style: string]: number } = {
243
253
  "text-decoration": 1,
244
254
  color: 1,
245
255
  "font-size": 1
246
- }
256
+ }