@mwater/visualization 5.1.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 (305) 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/GlobalFilter.d.ts +13 -0
  10. package/lib/GlobalFilter.js +2 -0
  11. package/lib/LocaleContextInjector.d.ts +5 -11
  12. package/lib/LocaleContextInjector.js +4 -12
  13. package/lib/MWaterAddRelatedFormComponent.js +3 -3
  14. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
  15. package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
  16. package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
  17. package/lib/MWaterCompleteTableSelectComponent.js +36 -36
  18. package/lib/MWaterContextComponent.d.ts +19 -9
  19. package/lib/MWaterContextComponent.js +38 -22
  20. package/lib/MWaterCustomTablesetListComponent.js +9 -3
  21. package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
  22. package/lib/MWaterGlobalFiltersComponent.js +4 -4
  23. package/lib/MWaterLoaderComponent.d.ts +15 -3
  24. package/lib/MWaterLoaderComponent.js +11 -2
  25. package/lib/MWaterTableSelectComponent.d.ts +1 -4
  26. package/lib/MWaterTableSelectComponent.js +10 -12
  27. package/lib/UIComponents.d.ts +2 -2
  28. package/lib/UIComponents.js +4 -12
  29. package/lib/axes/Axis.d.ts +20 -25
  30. package/lib/axes/AxisBuilder.d.ts +7 -4
  31. package/lib/axes/AxisBuilder.js +12 -8
  32. package/lib/axes/AxisComponent.d.ts +6 -9
  33. package/lib/axes/AxisComponent.js +1 -2
  34. package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
  35. package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
  36. package/lib/dashboards/DashboardComponent.d.ts +4 -17
  37. package/lib/dashboards/DashboardComponent.js +20 -67
  38. package/lib/dashboards/DashboardDesign.d.ts +5 -20
  39. package/lib/dashboards/DashboardUpgrader.js +36 -1
  40. package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
  41. package/lib/dashboards/DashboardViewComponent.js +112 -136
  42. package/lib/dashboards/FontStyleEditor.d.ts +8 -0
  43. package/lib/dashboards/FontStyleEditor.js +130 -0
  44. package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
  45. package/lib/dashboards/LayoutOptionsComponent.js +209 -39
  46. package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
  47. package/lib/dashboards/ServerDashboardDataSource.js +52 -33
  48. package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
  49. package/lib/dashboards/SettingsModalComponent.js +24 -38
  50. package/lib/dashboards/WidgetComponent.d.ts +3 -3
  51. package/lib/dashboards/WidgetComponent.js +3 -6
  52. package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
  53. package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
  54. package/lib/dashboards/layoutOptions.d.ts +83 -0
  55. package/lib/dashboards/layoutOptions.js +436 -10
  56. package/lib/datagrids/DatagridComponent.d.ts +2 -9
  57. package/lib/datagrids/DatagridDataSource.d.ts +3 -3
  58. package/lib/datagrids/DatagridDataSource.js +0 -14
  59. package/lib/datagrids/DatagridDesign.d.ts +7 -6
  60. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
  61. package/lib/datagrids/DatagridDesignerComponent.js +8 -6
  62. package/lib/datagrids/DatagridViewComponent.js +1 -1
  63. package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
  64. package/lib/datagrids/FindReplaceModalComponent.js +27 -13
  65. package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
  66. package/lib/datagrids/ServerDatagridDataSource.js +88 -36
  67. package/lib/demo.js +4 -4
  68. package/lib/index.css +5 -0
  69. package/lib/index.d.ts +2 -1
  70. package/lib/index.js +0 -1
  71. package/lib/layouts/LayoutManager.d.ts +33 -29
  72. package/lib/layouts/LayoutManager.js +2 -8
  73. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
  74. package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
  75. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
  76. package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
  77. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
  78. package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
  79. package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
  80. package/lib/mWaterLoader.d.ts +2 -0
  81. package/lib/mWaterLoader.js +2 -1
  82. package/lib/maps/AddLayerComponent.d.ts +6 -8
  83. package/lib/maps/AddLayerComponent.js +6 -6
  84. package/lib/maps/BingLayer.js +10 -20
  85. package/lib/maps/BufferLayer.js +5 -2
  86. package/lib/maps/ChoroplethLayer.js +2 -1
  87. package/lib/maps/ClusterLayer.js +3 -1
  88. package/lib/maps/DirectMapDataSource.d.ts +5 -2
  89. package/lib/maps/DirectMapDataSource.js +2 -1
  90. package/lib/maps/EditPopupComponent.js +2 -1
  91. package/lib/maps/GridLayer.js +5 -3
  92. package/lib/maps/GridLayerDesigner.js +0 -1
  93. package/lib/maps/LayerSwitcherComponent.js +1 -1
  94. package/lib/maps/MapComponent.d.ts +3 -11
  95. package/lib/maps/MapComponent.js +3 -3
  96. package/lib/maps/MapDesign.d.ts +2 -13
  97. package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
  98. package/lib/maps/MapFiltersDesignerComponent.js +4 -5
  99. package/lib/maps/MarkersLayer.js +30 -25
  100. package/lib/maps/RasterMapViewComponent.d.ts +3 -13
  101. package/lib/maps/RasterMapViewComponent.js +3 -3
  102. package/lib/maps/RegionSelectComponent.d.ts +2 -1
  103. package/lib/maps/ServerMapDataSource.d.ts +3 -4
  104. package/lib/maps/ServerMapDataSource.js +5 -5
  105. package/lib/maps/VectorMapViewComponent.js +2 -1
  106. package/lib/maps/mapSymbols.js +2 -0
  107. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  108. package/lib/maps/vectorMaps.d.ts +1 -0
  109. package/lib/maps/vectorMaps.js +70 -56
  110. package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
  111. package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
  112. package/lib/quickfilter/QuickfiltersComponent.js +3 -3
  113. package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
  114. package/lib/richtext/DropdownPaletteItem.js +82 -0
  115. package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
  116. package/lib/richtext/FontColorPaletteItem.js +32 -27
  117. package/lib/richtext/ItemsHtmlConverter.js +12 -3
  118. package/lib/richtext/RichTextComponent.d.ts +26 -52
  119. package/lib/richtext/RichTextComponent.js +166 -128
  120. package/lib/valueFormatter.js +6 -1
  121. package/lib/wellknown.d.ts +5 -0
  122. package/lib/wellknown.js +288 -0
  123. package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
  124. package/lib/widgets/DropdownWidgetComponent.js +48 -25
  125. package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
  126. package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
  127. package/lib/widgets/MapWidget.d.ts +4 -7
  128. package/lib/widgets/MapWidget.js +2 -1
  129. package/lib/widgets/MarkdownWidget.d.ts +2 -7
  130. package/lib/widgets/TOCWidget.d.ts +2 -9
  131. package/lib/widgets/TOCWidget.js +2 -1
  132. package/lib/widgets/Widget.d.ts +2 -0
  133. package/lib/widgets/WidgetDataSource.d.ts +3 -1
  134. package/lib/widgets/charts/Chart.d.ts +0 -1
  135. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  136. package/lib/widgets/charts/ChartViewComponent.js +11 -3
  137. package/lib/widgets/charts/ChartWidget.d.ts +1 -74
  138. package/lib/widgets/charts/ChartWidget.js +4 -183
  139. package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
  140. package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
  141. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
  142. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
  143. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
  144. package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
  145. package/lib/widgets/charts/layered/LayeredChart.js +6 -7
  146. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
  147. package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
  148. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
  149. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
  150. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
  151. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
  152. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
  153. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
  154. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
  155. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
  156. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
  157. package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
  158. package/lib/widgets/charts/pivot/PivotChart.js +47 -17
  159. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
  160. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
  161. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
  162. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
  163. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
  164. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
  165. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
  166. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
  167. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
  168. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
  169. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
  170. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
  171. package/lib/widgets/charts/table/TableChart.js +8 -4
  172. package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
  173. package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
  174. package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
  175. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
  176. package/lib/widgets/text/TextComponent.d.ts +5 -12
  177. package/lib/widgets/text/TextComponent.js +19 -39
  178. package/lib/widgets/text/TextWidget.d.ts +2 -1
  179. package/lib/widgets/text/TextWidget.js +5 -1
  180. package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
  181. package/lib/widgets/text/TextWidgetComponent.js +76 -19
  182. package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
  183. package/lib/widgets/text/TextWidgetDesign.js +6 -0
  184. package/package.json +4 -4
  185. package/src/ColorComponent.tsx +177 -0
  186. package/src/ColorSchemeFactory.ts +12 -6
  187. package/src/CustomColorsContext.tsx +8 -0
  188. package/src/FiltersDesignerComponent.ts +3 -4
  189. package/src/GlobalFilter.ts +17 -0
  190. package/src/LocaleContextInjector.tsx +14 -13
  191. package/src/MWaterAddRelatedFormComponent.ts +3 -3
  192. package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
  193. package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
  194. package/src/MWaterContextComponent.tsx +42 -33
  195. package/src/MWaterCustomTablesetListComponent.tsx +21 -3
  196. package/src/MWaterGlobalFiltersComponent.ts +8 -8
  197. package/src/MWaterLoaderComponent.ts +14 -4
  198. package/src/MWaterTableSelectComponent.tsx +11 -12
  199. package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
  200. package/src/axes/Axis.ts +24 -25
  201. package/src/axes/AxisBuilder.ts +16 -13
  202. package/src/axes/AxisComponent.ts +3 -4
  203. package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
  204. package/src/dashboards/DashboardComponent.tsx +73 -147
  205. package/src/dashboards/DashboardDesign.ts +5 -25
  206. package/src/dashboards/DashboardUpgrader.ts +41 -1
  207. package/src/dashboards/DashboardViewComponent.tsx +313 -0
  208. package/src/dashboards/FontStyleEditor.tsx +166 -0
  209. package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
  210. package/src/dashboards/ServerDashboardDataSource.ts +52 -33
  211. package/src/dashboards/SettingsModalComponent.tsx +170 -0
  212. package/src/dashboards/WidgetComponent.tsx +6 -12
  213. package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
  214. package/src/dashboards/layoutOptions.tsx +581 -0
  215. package/src/datagrids/DatagridDataSource.ts +6 -12
  216. package/src/datagrids/DatagridDesign.ts +8 -3
  217. package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
  218. package/src/datagrids/DatagridViewComponent.ts +3 -3
  219. package/src/datagrids/ExprCellComponent.ts +0 -1
  220. package/src/datagrids/FindReplaceModalComponent.ts +39 -22
  221. package/src/datagrids/ServerDatagridDataSource.ts +107 -45
  222. package/src/demo.ts +4 -4
  223. package/src/index.css +5 -0
  224. package/src/index.ts +2 -1
  225. package/src/layouts/LayoutManager.ts +44 -42
  226. package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
  227. package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
  228. package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
  229. package/src/mWaterLoader.ts +4 -1
  230. package/src/maps/AddLayerComponent.ts +9 -9
  231. package/src/maps/BingLayer.ts +16 -26
  232. package/src/maps/BufferLayer.ts +5 -2
  233. package/src/maps/ChoroplethLayer.ts +2 -1
  234. package/src/maps/ClusterLayer.ts +3 -1
  235. package/src/maps/DirectMapDataSource.ts +12 -3
  236. package/src/maps/EditPopupComponent.ts +2 -1
  237. package/src/maps/GridLayer.ts +5 -3
  238. package/src/maps/GridLayerDesigner.tsx +0 -1
  239. package/src/maps/LayerSwitcherComponent.tsx +1 -1
  240. package/src/maps/MapComponent.ts +3 -3
  241. package/src/maps/MapDesign.ts +2 -17
  242. package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
  243. package/src/maps/MarkersLayer.ts +38 -41
  244. package/src/maps/RasterMapViewComponent.ts +3 -3
  245. package/src/maps/ServerMapDataSource.ts +8 -8
  246. package/src/maps/VectorMapViewComponent.tsx +2 -2
  247. package/src/maps/mapSymbols.ts +2 -0
  248. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  249. package/src/maps/vectorMaps.tsx +88 -74
  250. package/src/quickfilter/QuickfilterCompiler.ts +1 -1
  251. package/src/quickfilter/QuickfiltersComponent.ts +3 -3
  252. package/src/richtext/DropdownPaletteItem.tsx +144 -0
  253. package/src/richtext/FontColorPaletteItem.tsx +160 -0
  254. package/src/richtext/ItemsHtmlConverter.ts +15 -5
  255. package/src/richtext/RichTextComponent.tsx +274 -232
  256. package/src/valueFormatter.ts +5 -1
  257. package/src/wellknown.ts +286 -0
  258. package/src/widgets/DropdownWidgetComponent.tsx +75 -0
  259. package/src/widgets/MapWidget.ts +5 -2
  260. package/src/widgets/TOCWidget.ts +2 -1
  261. package/src/widgets/Widget.ts +3 -0
  262. package/src/widgets/WidgetDataSource.ts +3 -1
  263. package/src/widgets/charts/Chart.ts +1 -1
  264. package/src/widgets/charts/ChartViewComponent.ts +16 -3
  265. package/src/widgets/charts/ChartWidget.ts +3 -275
  266. package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
  267. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
  268. package/src/widgets/charts/layered/LayeredChart.ts +4 -6
  269. package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
  270. package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
  271. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
  272. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
  273. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
  274. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
  275. package/src/widgets/charts/pivot/PivotChart.ts +56 -18
  276. package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
  277. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
  278. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
  279. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
  280. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
  281. package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
  282. package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
  283. package/src/widgets/charts/table/TableChart.ts +8 -4
  284. package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
  285. package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
  286. package/src/widgets/text/TextComponent.tsx +47 -49
  287. package/src/widgets/text/TextWidget.ts +8 -3
  288. package/src/widgets/text/TextWidgetComponent.tsx +249 -0
  289. package/src/widgets/text/TextWidgetDesign.ts +26 -2
  290. package/src/ColorComponent.ts +0 -117
  291. package/src/dashboards/DashboardViewComponent.ts +0 -304
  292. package/src/dashboards/SettingsModalComponent.ts +0 -169
  293. package/src/dashboards/layoutOptions.ts +0 -40
  294. package/src/layout-styles.css +0 -263
  295. package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
  296. package/src/layouts/grid/GridLayoutComponent.ts +0 -67
  297. package/src/layouts/grid/GridLayoutManager.ts +0 -185
  298. package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
  299. package/src/layouts/grid/PaletteItemComponent.ts +0 -28
  300. package/src/layouts/grid/README.md +0 -14
  301. package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
  302. package/src/richtext/FontColorPaletteItem.ts +0 -172
  303. package/src/richtext/FontSizePaletteItem.ts +0 -110
  304. package/src/widgets/DropdownWidgetComponent.ts +0 -78
  305. package/src/widgets/text/TextWidgetComponent.ts +0 -120
@@ -0,0 +1,286 @@
1
+ /*
2
+
3
+ https://github.com/mapbox/wellknown
4
+
5
+ Copyright (c) 2016, Mapbox
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
+
19
+ */
20
+
21
+
22
+ const numberRegexp: RegExp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
23
+ // Matches sequences like '100 100' or '100 100 100'.
24
+ const tuples: RegExp = new RegExp('^' + numberRegexp.source + '(\\s' + numberRegexp.source + '){1,}');
25
+
26
+ /*
27
+ * Parse WKT and return GeoJSON.
28
+ *
29
+ * @param {string} _ A WKT geometry
30
+ * @return {?Object} A GeoJSON geometry object
31
+ */
32
+ export function parse(input: string): any {
33
+ let parts: string[] = input.split(';');
34
+ let _: string | undefined = parts.pop();
35
+ let srid: string = (parts.shift() || '').split('=').pop() || '';
36
+
37
+ let i: number = 0;
38
+
39
+ function $(re: RegExp): string | null {
40
+ let match: RegExpMatchArray | null = _!.substring(i).match(re);
41
+ if (!match) return null;
42
+ else {
43
+ i += match[0].length;
44
+ return match[0];
45
+ }
46
+ }
47
+
48
+ function crs(obj: any): any {
49
+ if (obj && srid.match(/\d+/)) {
50
+ obj.crs = {
51
+ type: 'name',
52
+ properties: {
53
+ name: 'urn:ogc:def:crs:EPSG::' + srid
54
+ }
55
+ };
56
+ }
57
+
58
+ return obj;
59
+ }
60
+
61
+ function white(): void { $(/^\s*/); }
62
+
63
+ function multicoords(): any[] | null {
64
+ white();
65
+ let depth: number = 0;
66
+ let rings: any[] = [];
67
+ let stack: any[][] = [rings];
68
+ let pointer: any[] = rings;
69
+ let elem: string | null;
70
+
71
+ while (elem =
72
+ $(/^(\()/) ||
73
+ $(/^(\))/) ||
74
+ $(/^(,)/) ||
75
+ $(tuples)) {
76
+ if (elem === '(') {
77
+ stack.push(pointer);
78
+ pointer = [];
79
+ stack[stack.length - 1].push(pointer);
80
+ depth++;
81
+ } else if (elem === ')') {
82
+ // For the case: Polygon(), ...
83
+ if (pointer.length === 0) return null;
84
+
85
+ pointer = stack.pop() || [];
86
+ // the stack was empty, input was malformed
87
+ if (!pointer) return null;
88
+ depth--;
89
+ if (depth === 0) break;
90
+ } else if (elem === ',') {
91
+ pointer = [];
92
+ stack[stack.length - 1].push(pointer);
93
+ } else if (!elem.split(/\s/g).some(s => isNaN(s as any))) {
94
+ Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat));
95
+ } else {
96
+ return null;
97
+ }
98
+ white();
99
+ }
100
+
101
+ if (depth !== 0) return null;
102
+
103
+ return rings;
104
+ }
105
+
106
+ function coords(): any[] | null {
107
+ let list: any[] = [];
108
+ let item: any[] | undefined;
109
+ let pt: string | null;
110
+ while (pt =
111
+ $(tuples) ||
112
+ $(/^(,)/)) {
113
+ if (pt === ',') {
114
+ list.push(item);
115
+ item = [];
116
+ } else if (!pt.split(/\s/g).some(s => isNaN(s as any))) {
117
+ if (!item) item = [];
118
+ Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat));
119
+ }
120
+ white();
121
+ }
122
+
123
+ if (item) list.push(item);
124
+ else return null;
125
+
126
+ return list.length ? list : null;
127
+ }
128
+
129
+ function point(): any | null {
130
+ if (!$(/^(point(\sz)?)/i)) return null;
131
+ white();
132
+ if (!$(/^(\()/)) return null;
133
+ let c: any[] | null = coords();
134
+ if (!c) return null;
135
+ white();
136
+ if (!$(/^(\))/)) return null;
137
+ return {
138
+ type: 'Point',
139
+ coordinates: c[0]
140
+ };
141
+ }
142
+
143
+ function multipoint(): any | null {
144
+ if (!$(/^(multipoint(\sz)?)/i)) return null;
145
+ white();
146
+ let newCoordsFormat: string = _!
147
+ .substring(_!.indexOf('(') + 1, _!.length - 1)
148
+ .replace(/\(/g, '')
149
+ .replace(/\)/g, '');
150
+ _ = 'MULTIPOINT (' + newCoordsFormat + ')';
151
+ let c: any[] | null = multicoords();
152
+ if (!c) return null;
153
+ white();
154
+ return {
155
+ type: 'MultiPoint',
156
+ coordinates: c
157
+ };
158
+ }
159
+
160
+ function multilinestring(): any | null {
161
+ if (!$(/^(multilinestring(\sz)?)/i)) return null;
162
+ white();
163
+ let c: any[] | null = multicoords();
164
+ if (!c) return null;
165
+ white();
166
+ return {
167
+ type: 'MultiLineString',
168
+ coordinates: c
169
+ };
170
+ }
171
+
172
+ function linestring(): any | null {
173
+ if (!$(/^(linestring(\sz)?)/i)) return null;
174
+ white();
175
+ if (!$(/^(\()/)) return null;
176
+ let c: any[] | null = coords();
177
+ if (!c) return null;
178
+ if (!$(/^(\))/)) return null;
179
+ return {
180
+ type: 'LineString',
181
+ coordinates: c
182
+ };
183
+ }
184
+
185
+ function polygon(): any | null {
186
+ if (!$(/^(polygon(\sz)?)/i)) return null;
187
+ white();
188
+ let c: any[] | null = multicoords();
189
+ if (!c) return null;
190
+ return {
191
+ type: 'Polygon',
192
+ coordinates: c
193
+ };
194
+ }
195
+
196
+ function multipolygon(): any | null {
197
+ if (!$(/^(multipolygon(\sz)?)/i)) return null;
198
+ white();
199
+ let c: any[] | null = multicoords();
200
+ if (!c) return null;
201
+ return {
202
+ type: 'MultiPolygon',
203
+ coordinates: c
204
+ };
205
+ }
206
+
207
+ function geometrycollection(): any | null {
208
+ let geometries: any[] = [];
209
+ let geometry: any | null;
210
+
211
+ if (!$(/^(geometrycollection)/i)) return null;
212
+ white();
213
+
214
+ if (!$(/^(\()/)) return null;
215
+ while (geometry = root()) {
216
+ geometries.push(geometry);
217
+ white();
218
+ $(/^(,)/);
219
+ white();
220
+ }
221
+ if (!$(/^(\))/)) return null;
222
+
223
+ return {
224
+ type: 'GeometryCollection',
225
+ geometries: geometries
226
+ };
227
+ }
228
+
229
+ function root(): any | null {
230
+ return point() ||
231
+ linestring() ||
232
+ polygon() ||
233
+ multipoint() ||
234
+ multilinestring() ||
235
+ multipolygon() ||
236
+ geometrycollection();
237
+ }
238
+
239
+ return crs(root());
240
+ }
241
+
242
+ /**
243
+ * Stringifies a GeoJSON object into WKT
244
+ */
245
+ export function stringify(gj: any): string {
246
+ if (gj.type === 'Feature') {
247
+ gj = gj.geometry;
248
+ }
249
+
250
+ function pairWKT(c: any[]): string {
251
+ return c.join(' ');
252
+ }
253
+
254
+ function ringWKT(r: any[]): string {
255
+ return r.map(pairWKT).join(', ');
256
+ }
257
+
258
+ function ringsWKT(r: any[]): string {
259
+ return r.map(ringWKT).map(wrapParens).join(', ');
260
+ }
261
+
262
+ function multiRingsWKT(r: any[]): string {
263
+ return r.map(ringsWKT).map(wrapParens).join(', ');
264
+ }
265
+
266
+ function wrapParens(s: string): string { return '(' + s + ')'; }
267
+
268
+ switch (gj.type) {
269
+ case 'Point':
270
+ return 'POINT (' + pairWKT(gj.coordinates) + ')';
271
+ case 'LineString':
272
+ return 'LINESTRING (' + ringWKT(gj.coordinates) + ')';
273
+ case 'Polygon':
274
+ return 'POLYGON (' + ringsWKT(gj.coordinates) + ')';
275
+ case 'MultiPoint':
276
+ return 'MULTIPOINT (' + ringWKT(gj.coordinates) + ')';
277
+ case 'MultiPolygon':
278
+ return 'MULTIPOLYGON (' + multiRingsWKT(gj.coordinates) + ')';
279
+ case 'MultiLineString':
280
+ return 'MULTILINESTRING (' + ringsWKT(gj.coordinates) + ')';
281
+ case 'GeometryCollection':
282
+ return 'GEOMETRYCOLLECTION (' + gj.geometries.map(stringify).join(', ') + ')';
283
+ default:
284
+ throw new Error('stringify requires a valid GeoJSON Feature or geometry object as input');
285
+ }
286
+ }
@@ -0,0 +1,75 @@
1
+ import React, { ReactNode, useRef, useCallback } from "react"
2
+
3
+ export interface DropdownWidgetComponentProps {
4
+ /** Width specification */
5
+ width?: any
6
+ /** Height specification */
7
+ height?: any
8
+ dropdownItems: { label: ReactNode; onClick: () => void }[]
9
+ children?: ReactNode
10
+ }
11
+
12
+ // Widget wrapper that adds a dropdown menu in a gear floating
13
+ const DropdownWidgetComponent = (props: DropdownWidgetComponentProps) => {
14
+ const { width, height, dropdownItems, children } = props
15
+ const dropdownRef = useRef<HTMLDivElement>(null)
16
+
17
+ const renderDropdownItem = (item: { label: ReactNode; onClick: () => void }, i: number) => {
18
+ return (
19
+ <li key={`${i}`}>
20
+ <a className="dropdown-item" onClick={item.onClick}>
21
+ {item.label}
22
+ </a>
23
+ </li>
24
+ )
25
+ }
26
+
27
+ const renderDropdown = () => {
28
+ if (dropdownItems.length === 0) {
29
+ return null
30
+ }
31
+
32
+ const dropdownStyle: React.CSSProperties = {
33
+ position: "absolute",
34
+ right: 3,
35
+ top: 3,
36
+ cursor: "pointer",
37
+ zIndex: 1029
38
+ }
39
+
40
+ return (
41
+ <div style={dropdownStyle} ref={dropdownRef}>
42
+ <div style={dropdownStyle} data-bs-toggle="dropdown">
43
+ <div className="mwater-visualization-simple-widget-gear-button">
44
+ <span className="fas fa-cog" />
45
+ </div>
46
+ </div>
47
+ <ul className="dropdown-menu dropdown-menu-end" style={{ top: 25 }}>
48
+ {dropdownItems.map(renderDropdownItem)}
49
+ </ul>
50
+ </div>
51
+ )
52
+ }
53
+
54
+ const closeMenu = useCallback(() => {
55
+ if (dropdownRef.current) {
56
+ const dropdownToggle = dropdownRef.current.querySelector('[data-bs-toggle="dropdown"]')
57
+ if (dropdownToggle) {
58
+ dropdownToggle.parentElement?.classList.remove('open')
59
+ }
60
+ }
61
+ }, [])
62
+
63
+ return (
64
+ <div
65
+ className="mwater-visualization-simple-widget"
66
+ onMouseLeave={closeMenu}
67
+ style={{ width, height }}
68
+ >
69
+ {children}
70
+ {renderDropdown()}
71
+ </div>
72
+ )
73
+ }
74
+
75
+ export default DropdownWidgetComponent
@@ -36,7 +36,8 @@ export default class MapWidget extends Widget {
36
36
  onScopeChange: options.onScopeChange,
37
37
  width: options.width,
38
38
  height: options.height,
39
- onRowClick: options.onRowClick
39
+ onRowClick: options.onRowClick,
40
+ refreshKey: options.refreshKey
40
41
  })
41
42
  }
42
43
 
@@ -66,6 +67,8 @@ interface MapWidgetComponentProps {
66
67
  /** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
67
68
  onScopeChange?: any
68
69
  onRowClick?: any
70
+ /** TODO: implement refreshing */
71
+ refreshKey?: any
69
72
  }
70
73
 
71
74
  interface MapWidgetComponentState {
@@ -178,7 +181,7 @@ class MapWidgetComponent extends React.Component<MapWidgetComponentProps, MapWid
178
181
  schema: this.props.schema,
179
182
  design,
180
183
  dataSource: this.props.dataSource,
181
- mapDataSource: this.props.widgetDataSource.getMapDataSource(design),
184
+ mapDataSource: this.props.widgetDataSource.getMapDataSource!(design),
182
185
  onDesignChange,
183
186
  scope: this.props.scope,
184
187
  onScopeChange: this.props.onScopeChange,
@@ -155,6 +155,7 @@ class TOCWidgetViewComponent extends React.Component {
155
155
  }
156
156
 
157
157
  handleEntryClick = (tocEntry: any) => {
158
+ debugger
158
159
  return this.props.onScrollToTOCEntry?.(tocEntry.widgetId, tocEntry.id)
159
160
  }
160
161
 
@@ -228,7 +229,7 @@ class TOCWidgetViewComponent extends React.Component {
228
229
  }),
229
230
 
230
231
  // Add placeholder if none and editable
231
- this.props.onDesignChange && this.props.tocEntries.length === 0
232
+ this.props.onDesignChange && (this.props.tocEntries || []).length === 0
232
233
  ? R(
233
234
  "div",
234
235
  { className: "text-muted" },
@@ -39,6 +39,9 @@ export interface CreateViewElementOptions {
39
39
 
40
40
  /** called with (widgetId, tocEntryId) to scroll to TOC entry */
41
41
  onScrollToTOCEntry?: (widgetId: string, tocEntryId: string) => void
42
+
43
+ /** A key that changes when the widget should be refreshed */
44
+ refreshKey?: any
42
45
  }
43
46
 
44
47
  export default class Widget {
@@ -11,8 +11,10 @@ export interface WidgetDataSource {
11
11
  * design: design of the widget. Ignored in the case of server-side rendering
12
12
  * filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct
13
13
  * callback: (error, data)
14
+ *
15
+ * Can be aborted by cancelling the AbortController
14
16
  */
15
- getData(design: any, filters: JsonQLFilter[], callback: (error: any, data?: any) => void): void
17
+ getData(design: any, filters: JsonQLFilter[], callback: (error: any, data?: any) => void): AbortController | void | undefined
16
18
 
17
19
  /** For map widgets, the following is required */
18
20
  getMapDataSource?(design: MapDesign): MapDataSource
@@ -119,7 +119,7 @@ export default class Chart {
119
119
  // widgetDataSource: widget data source to use
120
120
  // filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct
121
121
  // Returns an empty list by default
122
- createDropdownItems(design: any, schema: Schema, widgetDataSource: WidgetDataSource, filters: any): { label: ReactNode, icon?: string, onClick: () => void }[] {
122
+ createDropdownItems(design: any, schema: Schema, widgetDataSource: WidgetDataSource, filters: any): { label: ReactNode, onClick: () => void }[] {
123
123
  return []
124
124
  }
125
125
 
@@ -35,6 +35,9 @@ export interface ChartViewComponentProps {
35
35
  onScopeChange?: (scope: WidgetScope | null) => void
36
36
 
37
37
  onRowClick?: (tableId: string, rowId: any) => void
38
+
39
+ /** A key that changes when the widget should be refreshed */
40
+ refreshKey?: any
38
41
  }
39
42
 
40
43
  interface ChartViewComponentState {
@@ -54,6 +57,9 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
54
57
  /** Ordinal of update (0, 1, 2...) to ensure using latest */
55
58
  updateSeq: number
56
59
 
60
+ /** Abort controller for the current data load */
61
+ abortController: AbortController | undefined
62
+
57
63
  constructor(props: ChartViewComponentProps) {
58
64
  super(props)
59
65
 
@@ -77,7 +83,8 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
77
83
  if (
78
84
  !_.isEqual(prevProps.design, this.props.design) ||
79
85
  !_.isEqual(prevProps.filters, this.props.filters) ||
80
- this.props.dataSource.getCacheExpiry() !== this.state.cacheExpiry
86
+ this.props.dataSource.getCacheExpiry() !== this.state.cacheExpiry ||
87
+ prevProps.refreshKey !== this.props.refreshKey
81
88
  ) {
82
89
  // Save new cache expiry
83
90
  this.setState({ cacheExpiry: this.props.dataSource.getCacheExpiry() })
@@ -97,6 +104,9 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
97
104
  }
98
105
 
99
106
  this.updateSeq += 1
107
+ if (this.abortController) {
108
+ this.abortController.abort("Aborting previous data load")
109
+ }
100
110
 
101
111
  // Set loading data after interval to prevent unnecessary refresh
102
112
  const dataLoadingTimeout = setTimeout(() => {
@@ -106,15 +116,18 @@ export default class ChartViewComponent extends React.Component<ChartViewCompone
106
116
  // Store updateSeq to check if latest
107
117
  const loadingUpdateSeq = this.updateSeq
108
118
 
109
- this.props.widgetDataSource.getData(design, this.props.filters || [], (error, data) => {
119
+ this.abortController = this.props.widgetDataSource.getData(design, this.props.filters || [], (error, data) => {
110
120
  // Prevent setting data loading if ready
111
121
  clearTimeout(dataLoadingTimeout)
112
122
 
113
123
  // Only update if latest
114
124
  if (loadingUpdateSeq == this.updateSeq) {
125
+ // Clear the abort controller
126
+ this.abortController = undefined
127
+
115
128
  this.setState({ dataLoading: false, dataError: error, data, validDesign: design })
116
129
  }
117
- })
130
+ }) ?? undefined
118
131
  }
119
132
 
120
133
  renderSpinner() {