@mwater/visualization 5.4.1 → 5.4.2

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 (269) hide show
  1. package/lib/ColorComponent.js +2 -1
  2. package/lib/IdSelection.d.ts +16 -0
  3. package/lib/IdSelection.js +59 -0
  4. package/lib/MWaterAddRelatedIndicatorComponent.js +2 -2
  5. package/lib/MWaterCompleteTableSelectComponent.d.ts +3 -8
  6. package/lib/MWaterCompleteTableSelectComponent.js +36 -42
  7. package/lib/MWaterLoaderComponent.d.ts +11 -10
  8. package/lib/MWaterLoaderComponent.js +1 -1
  9. package/lib/MWaterResponsesFilterComponent.js +1 -1
  10. package/lib/MWaterTableSelectComponent.d.ts +0 -1
  11. package/lib/MWaterTableSelectComponent.js +4 -6
  12. package/lib/autotranslate.d.ts +20 -0
  13. package/lib/autotranslate.js +122 -0
  14. package/lib/axes/AxisBuilder.js +3 -3
  15. package/lib/axes/AxisColorEditorComponent.js +4 -0
  16. package/lib/axes/AxisComponent.d.ts +8 -12
  17. package/lib/axes/AxisComponent.js +32 -80
  18. package/lib/axes/CategoryMapComponent.js +4 -4
  19. package/lib/axes/RangesComponent.js +2 -2
  20. package/lib/dashboards/DashboardComponent.d.ts +6 -0
  21. package/lib/dashboards/DashboardComponent.js +44 -12
  22. package/lib/dashboards/DashboardDesign.d.ts +11 -2
  23. package/lib/dashboards/DashboardUtils.d.ts +5 -0
  24. package/lib/dashboards/DashboardUtils.js +30 -0
  25. package/lib/dashboards/DashboardViewComponent.d.ts +2 -0
  26. package/lib/dashboards/DashboardViewComponent.js +16 -3
  27. package/lib/dashboards/ServerDashboardDataSource.js +2 -1
  28. package/lib/dashboards/SettingsModalComponent.d.ts +1 -1
  29. package/lib/dashboards/SettingsModalComponent.js +256 -19
  30. package/lib/dashboards/WidgetComponent.d.ts +6 -3
  31. package/lib/dashboards/WidgetComponent.js +3 -1
  32. package/lib/datagrids/CellEditor.d.ts +19 -0
  33. package/lib/datagrids/CellEditor.js +223 -0
  34. package/lib/datagrids/DatagridComponent.d.ts +18 -87
  35. package/lib/datagrids/DatagridComponent.js +304 -222
  36. package/lib/datagrids/DatagridViewComponent.d.ts +15 -53
  37. package/lib/datagrids/DatagridViewComponent.js +256 -257
  38. package/lib/datagrids/DirectDatagridDataSource.js +2 -3
  39. package/lib/datagrids/ExprCellComponent.d.ts +8 -15
  40. package/lib/datagrids/ExprCellComponent.js +11 -15
  41. package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -6
  42. package/lib/datagrids/FindReplaceModalComponent.js +38 -75
  43. package/lib/index.css +1 -1
  44. package/lib/index.d.ts +0 -1
  45. package/lib/index.js +0 -1
  46. package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
  47. package/lib/mWaterLoader.d.ts +1 -1
  48. package/lib/maps/BufferLayer.d.ts +7 -5
  49. package/lib/maps/BufferLayer.js +69 -48
  50. package/lib/maps/BufferLayerDesign.d.ts +21 -14
  51. package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
  52. package/lib/maps/BufferLayerDesignerComponent.js +68 -102
  53. package/lib/maps/ChoroplethLayer.d.ts +5 -4
  54. package/lib/maps/ChoroplethLayer.js +32 -9
  55. package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
  56. package/lib/maps/ChoroplethLayerDesigner.js +4 -2
  57. package/lib/maps/ClusterLayer.d.ts +3 -4
  58. package/lib/maps/ClusterLayer.js +2 -1
  59. package/lib/maps/DetailLevelSelectComponent.js +1 -1
  60. package/lib/maps/DirectMapDataSource.js +2 -1
  61. package/lib/maps/EditPopupComponent.js +5 -3
  62. package/lib/maps/GridLayer.d.ts +3 -4
  63. package/lib/maps/GridLayer.js +2 -1
  64. package/lib/maps/GridLayerDesigner.js +5 -3
  65. package/lib/maps/HoverContent.d.ts +11 -3
  66. package/lib/maps/HoverContent.js +25 -9
  67. package/lib/maps/Layer.d.ts +24 -3
  68. package/lib/maps/Layer.js +5 -1
  69. package/lib/maps/LayerFactory.js +0 -8
  70. package/lib/maps/LayerLegendComponent.js +0 -1
  71. package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
  72. package/lib/maps/LayerSwitcherComponent.js +1 -1
  73. package/lib/maps/LeafletMapComponent.js +3 -1
  74. package/lib/maps/LegendComponent.d.ts +1 -0
  75. package/lib/maps/LegendComponent.js +9 -1
  76. package/lib/maps/MWaterServerLayer.d.ts +2 -2
  77. package/lib/maps/MWaterServerLayer.js +2 -2
  78. package/lib/maps/MapComponent.js +3 -3
  79. package/lib/maps/MapDesign.d.ts +2 -0
  80. package/lib/maps/MapDesignerComponent.d.ts +4 -3
  81. package/lib/maps/MapDesignerComponent.js +68 -74
  82. package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
  83. package/lib/maps/MapUtils.d.ts +4 -0
  84. package/lib/maps/MapUtils.js +19 -0
  85. package/lib/maps/MapViewComponent.d.ts +8 -3
  86. package/lib/maps/MarkersLayer.d.ts +5 -4
  87. package/lib/maps/MarkersLayer.js +33 -7
  88. package/lib/maps/MarkersLayerDesign.d.ts +19 -16
  89. package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
  90. package/lib/maps/PopupFilterJoinsUtils.js +0 -6
  91. package/lib/maps/RasterMapViewComponent.d.ts +3 -31
  92. package/lib/maps/RasterMapViewComponent.js +7 -2
  93. package/lib/maps/ServerMapDataSource.js +2 -1
  94. package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
  95. package/lib/maps/SwitchableTileUrlLayer.js +2 -1
  96. package/lib/maps/TileUrlLayer.d.ts +4 -5
  97. package/lib/maps/TileUrlLayer.js +2 -1
  98. package/lib/maps/VectorMapViewComponent.d.ts +5 -37
  99. package/lib/maps/VectorMapViewComponent.js +19 -8
  100. package/lib/maps/maps.d.ts +3 -0
  101. package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
  102. package/lib/quickfilter/QuickfiltersComponent.js +9 -7
  103. package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +1 -1
  104. package/lib/quickfilter/QuickfiltersDesignComponent.js +19 -35
  105. package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
  106. package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
  107. package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
  108. package/lib/richtext/ExprItemsTranslator.js +149 -0
  109. package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
  110. package/lib/richtext/ItemsHtmlConverter.js +31 -15
  111. package/lib/wellknown.js +12 -9
  112. package/lib/widgets/IFrameWidget.d.ts +4 -4
  113. package/lib/widgets/ImageWidget.d.ts +7 -4
  114. package/lib/widgets/ImageWidget.js +9 -1
  115. package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
  116. package/lib/widgets/ImageWidgetComponent.js +1 -1
  117. package/lib/widgets/MapWidget.d.ts +5 -48
  118. package/lib/widgets/MapWidget.js +26 -63
  119. package/lib/widgets/MarkdownWidget.d.ts +3 -0
  120. package/lib/widgets/MarkdownWidget.js +3 -0
  121. package/lib/widgets/TOCWidget.d.ts +15 -27
  122. package/lib/widgets/TOCWidget.js +107 -183
  123. package/lib/widgets/Widget.d.ts +18 -7
  124. package/lib/widgets/Widget.js +4 -0
  125. package/lib/widgets/WidgetScopesViewComponent.js +1 -1
  126. package/lib/widgets/charts/Chart.d.ts +10 -1
  127. package/lib/widgets/charts/Chart.js +22 -11
  128. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  129. package/lib/widgets/charts/ChartViewComponent.js +6 -3
  130. package/lib/widgets/charts/ChartWidget.d.ts +2 -0
  131. package/lib/widgets/charts/ChartWidget.js +9 -1
  132. package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
  133. package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
  134. package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
  135. package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
  136. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
  137. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
  138. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
  139. package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
  140. package/lib/widgets/charts/layered/LayeredChart.js +63 -3
  141. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
  142. package/lib/widgets/charts/layered/LayeredChartCompiler.js +1 -1
  143. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
  144. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
  145. package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
  146. package/lib/widgets/charts/pivot/PivotChart.js +63 -0
  147. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
  148. package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
  149. package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
  150. package/lib/widgets/charts/table/TableChart.d.ts +1 -0
  151. package/lib/widgets/charts/table/TableChart.js +15 -0
  152. package/lib/widgets/text/TextComponent.d.ts +11 -4
  153. package/lib/widgets/text/TextComponent.js +11 -8
  154. package/lib/widgets/text/TextWidget.d.ts +6 -3
  155. package/lib/widgets/text/TextWidget.js +7 -1
  156. package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
  157. package/lib/widgets/text/TextWidgetComponent.js +7 -1
  158. package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
  159. package/lib/widgets/text/TextWidgetDesign.js +1 -1
  160. package/package.json +7 -8
  161. package/src/ColorComponent.tsx +1 -2
  162. package/src/IdSelection.ts +62 -0
  163. package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
  164. package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
  165. package/src/MWaterLoaderComponent.ts +28 -26
  166. package/src/MWaterResponsesFilterComponent.ts +5 -2
  167. package/src/MWaterTableSelectComponent.tsx +5 -9
  168. package/src/autotranslate.ts +141 -0
  169. package/src/axes/AxisBuilder.ts +3 -3
  170. package/src/axes/AxisColorEditorComponent.tsx +5 -0
  171. package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
  172. package/src/axes/CategoryMapComponent.ts +4 -4
  173. package/src/axes/RangesComponent.ts +3 -2
  174. package/src/dashboards/DashboardComponent.tsx +79 -14
  175. package/src/dashboards/DashboardDesign.ts +9 -2
  176. package/src/dashboards/DashboardUtils.ts +39 -0
  177. package/src/dashboards/DashboardViewComponent.tsx +22 -3
  178. package/src/dashboards/ServerDashboardDataSource.ts +2 -1
  179. package/src/dashboards/SettingsModalComponent.tsx +450 -35
  180. package/src/dashboards/WidgetComponent.tsx +12 -6
  181. package/src/datagrids/CellEditor.tsx +354 -0
  182. package/src/datagrids/DatagridComponent.tsx +646 -0
  183. package/src/datagrids/DatagridViewComponent.tsx +539 -0
  184. package/src/datagrids/DirectDatagridDataSource.ts +2 -3
  185. package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
  186. package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
  187. package/src/index.css +1 -1
  188. package/src/index.ts +0 -1
  189. package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
  190. package/src/mWaterLoader.ts +1 -1
  191. package/src/maps/BufferLayer.ts +83 -60
  192. package/src/maps/BufferLayerDesign.ts +20 -14
  193. package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
  194. package/src/maps/ChoroplethLayer.ts +40 -19
  195. package/src/maps/ChoroplethLayerDesign.ts +4 -2
  196. package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
  197. package/src/maps/ClusterLayer.ts +4 -10
  198. package/src/maps/DetailLevelSelectComponent.ts +1 -1
  199. package/src/maps/DirectMapDataSource.ts +2 -1
  200. package/src/maps/EditPopupComponent.ts +7 -3
  201. package/src/maps/GridLayer.ts +4 -10
  202. package/src/maps/GridLayerDesigner.tsx +5 -3
  203. package/src/maps/HoverContent.tsx +40 -16
  204. package/src/maps/Layer.ts +28 -10
  205. package/src/maps/LayerFactory.ts +0 -8
  206. package/src/maps/LayerLegendComponent.ts +2 -4
  207. package/src/maps/LayerSwitcherComponent.tsx +6 -2
  208. package/src/maps/LeafletMapComponent.tsx +3 -1
  209. package/src/maps/LegendComponent.tsx +10 -1
  210. package/src/maps/MWaterServerLayer.ts +3 -3
  211. package/src/maps/MapComponent.ts +3 -3
  212. package/src/maps/MapDesign.ts +3 -0
  213. package/src/maps/MapDesignerComponent.tsx +165 -162
  214. package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
  215. package/src/maps/MapUtils.ts +24 -0
  216. package/src/maps/MapViewComponent.tsx +11 -3
  217. package/src/maps/MarkersLayer.ts +44 -18
  218. package/src/maps/MarkersLayerDesign.ts +19 -16
  219. package/src/maps/PopupFilterJoinsUtils.ts +6 -2
  220. package/src/maps/RasterMapViewComponent.ts +9 -45
  221. package/src/maps/ServerMapDataSource.ts +2 -2
  222. package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
  223. package/src/maps/TileUrlLayer.tsx +4 -10
  224. package/src/maps/VectorMapViewComponent.tsx +28 -55
  225. package/src/maps/maps.ts +3 -0
  226. package/src/quickfilter/QuickfiltersComponent.ts +13 -7
  227. package/src/quickfilter/QuickfiltersDesignComponent.tsx +56 -74
  228. package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
  229. package/src/richtext/ExprItemsTranslator.ts +176 -0
  230. package/src/richtext/ItemsHtmlConverter.ts +33 -18
  231. package/src/wellknown.ts +33 -30
  232. package/src/widgets/ImageWidget.ts +10 -1
  233. package/src/widgets/ImageWidgetComponent.ts +3 -2
  234. package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
  235. package/src/widgets/MarkdownWidget.ts +3 -0
  236. package/src/widgets/TOCWidget.tsx +281 -0
  237. package/src/widgets/Widget.ts +25 -5
  238. package/src/widgets/WidgetScopesViewComponent.ts +2 -1
  239. package/src/widgets/charts/Chart.ts +31 -12
  240. package/src/widgets/charts/ChartViewComponent.ts +13 -3
  241. package/src/widgets/charts/ChartWidget.ts +11 -1
  242. package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
  243. package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
  244. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
  245. package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
  246. package/src/widgets/charts/layered/LayeredChart.ts +71 -3
  247. package/src/widgets/charts/layered/LayeredChartCompiler.ts +2 -2
  248. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
  249. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
  250. package/src/widgets/charts/pivot/PivotChart.ts +73 -0
  251. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
  252. package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
  253. package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
  254. package/src/widgets/charts/table/TableChart.ts +17 -0
  255. package/src/widgets/text/TextComponent.tsx +22 -12
  256. package/src/widgets/text/TextWidget.ts +9 -2
  257. package/src/widgets/text/TextWidgetComponent.tsx +16 -1
  258. package/src/widgets/text/TextWidgetDesign.ts +4 -7
  259. package/test/IdSelectionTests.ts +54 -0
  260. package/test/LayeredChartCompilerTests.ts +0 -2
  261. package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
  262. package/test/wellknownTests.ts +144 -0
  263. package/src/datagrids/DatagridComponent.ts +0 -478
  264. package/src/datagrids/DatagridViewComponent.ts +0 -464
  265. package/src/datagrids/EditExprCellComponent.tsx +0 -305
  266. package/src/datagrids/README.md +0 -3
  267. package/src/maps/BufferLayerDesignerComponent.ts +0 -311
  268. package/src/widgets/TOCWidget.ts +0 -326
  269. package/test/LegoLayoutEngineTests.ts +0 -69
@@ -1,54 +1,57 @@
1
1
  import { Expr } from "@mwater/expressions"
2
2
  import { Axis } from "../axes/Axis"
3
3
  import { HoverOverItem } from "./maps"
4
+ import { LayoutBlock } from "../layouts/blocks/blockUtils"
5
+ import { PopupFilterJoins } from "./PopupFilterJoinsUtils"
4
6
 
5
7
  /** Design for a markers layer */
6
8
  export interface MarkersLayerDesign {
7
9
  /** table to get data from */
8
10
  table: string
9
11
 
10
- /** axes (see below) */
12
+ /** Axes */
11
13
  axes: {
12
- /** where to place markers */
14
+ /** Where to place markers */
13
15
  geometry: Axis
14
16
 
15
- /** color axis (to split into series based on a color) */
17
+ /** Color axis (to split into series based on a color) */
16
18
  color?: Axis
17
19
  }
18
20
 
19
- /** optional logical expression to filter by */
21
+ /** Optional logical expression to filter by */
20
22
  filter?: Expr
21
23
 
22
- /** color of layer (e.g. #FF8800). Color axis overrides */
24
+ /** Color of layer (e.g. #FF8800). Color axis overrides */
23
25
  color?: string
24
26
 
25
- /** symbol to use for layer. e.g. "font-awesome/bell". Will be converted on server to proper uri. */
27
+ /** Symbol to use for layer. e.g. "font-awesome/bell". Will be converted on server to proper uri. */
26
28
  symbol?: string
27
29
 
28
- /** size in pixels of the markers. Default 10. */
30
+ /** Size in pixels of the markers. Default 10. */
29
31
  markerSize?: number
30
32
 
31
- /** size of the lines in pixels. Default 3 */
33
+ /** Size of the lines in pixels. Default 3 */
32
34
  lineWidth?: number
33
35
 
34
- /** opacity of polygon fill (0-1). Default is 0.25 */
36
+ /** Opacity of polygon fill (0-1). Default is 0.25 */
35
37
  polygonFillOpacity?: number
36
38
 
37
- /** color of polygon borders (defaults to color of fill) */
39
+ /** Color of polygon borders (defaults to color of fill) */
38
40
  polygonBorderColor?: string
39
41
 
40
- /** contains items: which is BlocksLayoutManager items. Will be displayed when the marker is clicked TODO */
41
- popup: { items: any }
42
+ /** Contains items: which is BlocksLayoutManager items. Will be displayed when the marker is clicked */
43
+ popup: { items: LayoutBlock }
42
44
 
45
+ /** Contains items to display when hovering over the layer */
43
46
  hoverOver: { items: HoverOverItem[] }
44
47
 
45
- /** customizable filtering for popup. See PopupFilterJoins.md TODO */
46
- popupFilterJoins: any
48
+ /** Customizable filtering for popup */
49
+ popupFilterJoins: PopupFilterJoins
47
50
 
48
- /** minimum zoom level */
51
+ /** Minimum zoom level */
49
52
  minZoom?: number
50
53
 
51
- /** maximum zoom level */
54
+ /** Maximum zoom level */
52
55
  maxZoom?: number
53
56
 
54
57
  /** @deprecated LEGACY sublayers array that contains above design */
@@ -3,7 +3,6 @@ import { ExprUtils } from "@mwater/expressions"
3
3
  import { JsonQLFilter } from ".."
4
4
 
5
5
  /**
6
- * Utilities for popup filter joins.
7
6
  * Object keyed by table name that has expressions as values.
8
7
  * Each value is an expression for its key's table that is a type `id` or `idTable` of the layer's table.
9
8
  * This is used to filter the popup so that the rows are scoped to the item clicked on.
@@ -11,8 +10,13 @@ import { JsonQLFilter } from ".."
11
10
  * However, it could also filter to only water points that are related to the water system by adding the following key-value:
12
11
  * entities.water_point: { table: "entities.water_point", type: "field", column: "water_system" }
13
12
  */
13
+ export type PopupFilterJoins = { [tableId: string]: Expr }
14
+
15
+ /**
16
+ * Utilities for popup filter joins.
17
+ */
14
18
  export function createPopupFilters(
15
- popupFilterJoins: { [tableId: string]: Expr },
19
+ popupFilterJoins: PopupFilterJoins,
16
20
  schema: Schema,
17
21
  layerTable: any,
18
22
  rowId: any,
@@ -10,53 +10,12 @@ import { LayerSwitcherComponent } from "./LayerSwitcherComponent"
10
10
  import { default as LegendComponent } from "./LegendComponent"
11
11
  import { JsonQLFilter } from "../JsonQLFilter"
12
12
  import { MapDesign } from "./MapDesign"
13
- import { MapDataSource } from "./MapDataSource"
14
- import { MapScope } from "./MapUtils"
15
13
  import { LocaleContext } from "@mwater/expressions-ui"
14
+ import { MapViewComponentProps } from "./MapViewComponent"
16
15
 
17
- export interface RasterMapViewComponentProps {
18
- schema: Schema
19
- dataSource: DataSource
20
- mapDataSource: MapDataSource
21
-
22
- design: MapDesign
23
- onDesignChange?: (design: MapDesign) => void
24
-
25
- /** Width in pixels */
26
- width: number
27
-
28
- /** Height in pixels */
29
- height: number
30
-
31
- /** Called with (tableId, rowId) when item is clicked */
32
- onRowClick?: (tableId: string, rowId: any) => void
33
-
34
- /** Extra filters to apply to view */
35
- extraFilters?: JsonQLFilter[]
36
-
37
- /** scope of the map (when a layer self-selects a particular scope) */
38
- scope?: MapScope
39
-
40
- /** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
41
- onScopeChange?: (scope: MapScope | null) => void
42
-
43
- /** Whether the map be draggable with mouse/touch or not. Default true */
44
- dragging?: boolean
45
-
46
- /** Whether the map can be zoomed by touch-dragging with two fingers. Default true */
47
- touchZoom?: boolean
48
-
49
- /** Whether the map can be zoomed by using the mouse wheel. Default true */
50
- scrollWheelZoom?: boolean
51
-
52
- /** Whether changes to zoom level should be persisted. Default false */
53
- zoomLocked?: boolean
54
-
16
+ export interface RasterMapViewComponentProps extends MapViewComponentProps {
55
17
  /** Called with underlying leaflet map component */
56
18
  leafletMapRef?: (map: LeafletMapComponent | null) => void
57
-
58
- /** Whether to disable interaction or not. Default false (implemented for printing to reduce number of tiles request) */
59
- disableInteraction?: boolean
60
19
  }
61
20
 
62
21
  /** Component that displays just the map, using raster tile technology */
@@ -154,13 +113,16 @@ export default class RasterMapViewComponent extends React.Component<
154
113
  const design = layer.cleanDesign(layerView.design, this.props.schema)
155
114
 
156
115
  // Handle click of layer
116
+ // TODO not translated
157
117
  const results = layer.onGridClick(ev, {
158
118
  design,
159
119
  schema: this.props.schema,
160
120
  dataSource: this.props.dataSource,
161
121
  layerDataSource: this.props.mapDataSource.getLayerDataSource(layerViewId),
162
122
  scopeData: this.props.scope?.data?.layerViewId === layerViewId ? this.props.scope!.data.data : undefined,
163
- filters: this.getCompiledFilters()
123
+ filters: this.getCompiledFilters(),
124
+ locale: this.context,
125
+ translate: (input: string) => input
164
126
  })
165
127
 
166
128
  if (!results) {
@@ -216,6 +178,7 @@ export default class RasterMapViewComponent extends React.Component<
216
178
  filters: this.getCompiledFilters(),
217
179
  dataSource: this.props.dataSource,
218
180
  locale: this.context,
181
+ translate: this.props.translate ?? (() => ""),
219
182
  onHide: () => this.setState({ legendHidden: true }),
220
183
  zoom: null
221
184
  })
@@ -322,7 +285,8 @@ export default class RasterMapViewComponent extends React.Component<
322
285
  this.props.onDesignChange && this.props.design.showLayerSwitcher
323
286
  ? R(LayerSwitcherComponent, {
324
287
  design: this.props.design,
325
- onDesignChange: this.props.onDesignChange
288
+ onDesignChange: this.props.onDesignChange,
289
+ translate: this.props.translate ?? (() => "")
326
290
  })
327
291
  : undefined
328
292
  )
@@ -184,8 +184,8 @@ class ServerLayerDataSource implements MapLayerDataSource {
184
184
  throw new Error("Error getting tiles token")
185
185
  }
186
186
  const { token, expires } = await response.json()
187
-
188
- return { url: this.options.apiUrl + `vector_tiles/tiles/{z}/{x}/{y}?token=${token}`, expires }
187
+ // Client isn't necessary, but allows tracking of usage easier
188
+ return { url: this.options.apiUrl + `vector_tiles/tiles/{z}/{x}/{y}?token=${token}&client=${this.options.client ?? ""}`, expires }
189
189
  }
190
190
 
191
191
  // Gets widget data source for a popup widget
@@ -1,8 +1,8 @@
1
1
  import _ from "lodash"
2
- import Layer from "./Layer"
2
+ import Layer, { LegendOptions } from "./Layer"
3
3
  import { LocalizedString, Schema, DataSource } from "@mwater/expressions"
4
4
  import { JsonQLFilter } from "../index"
5
- import React from "react"
5
+ import React, { ReactNode } from "react"
6
6
  import { HtmlUrlLegend } from "./HtmlUrlLegend"
7
7
 
8
8
  /**
@@ -79,14 +79,8 @@ export default class SwitchableTileUrlLayer extends Layer<SwitchableTileUrlLayer
79
79
  return option.utfGridUrl || null
80
80
  }
81
81
 
82
- getLegend(
83
- design: SwitchableTileUrlLayerDesign,
84
- schema: Schema,
85
- name: string,
86
- dataSource: DataSource,
87
- locale: string,
88
- filters: JsonQLFilter[]
89
- ) {
82
+ getLegend(options: LegendOptions<SwitchableTileUrlLayerDesign>): ReactNode {
83
+ const { design, name } = options
90
84
  // Find active option
91
85
  const option = design.options.find((d) => d.id === design.activeOption)
92
86
  if (!option || !option.legendUrl) {
@@ -1,8 +1,8 @@
1
1
  import _ from "lodash"
2
- import React from "react"
2
+ import React, { ReactNode } from "react"
3
3
  const R = React.createElement
4
4
 
5
- import Layer from "./Layer"
5
+ import Layer, { LegendOptions } from "./Layer"
6
6
  import { DataSource, ExprCompiler, Schema } from "@mwater/expressions"
7
7
  import { JsonQLFilter } from "../JsonQLFilter"
8
8
  import { HtmlUrlLegend } from "./HtmlUrlLegend"
@@ -64,14 +64,8 @@ export default class TileUrlLayer extends Layer<TileUrlLayerDesign> {
64
64
  return this.validateDesign(this.cleanDesign(design, schema), schema) != null
65
65
  }
66
66
 
67
- getLegend(
68
- design: TileUrlLayerDesign,
69
- schema: Schema,
70
- name: string,
71
- dataSource: DataSource,
72
- locale: string,
73
- filters: JsonQLFilter[]
74
- ) {
67
+ getLegend(options: LegendOptions<TileUrlLayerDesign>): ReactNode {
68
+ const { design } = options
75
69
  // Find active option
76
70
  if (!design.legendUrl) {
77
71
  return null
@@ -26,57 +26,17 @@ import {
26
26
  useStyleMap,
27
27
  useVectorMap
28
28
  } from "./vectorMaps"
29
+ import { MapViewComponentProps } from "./MapViewComponent"
29
30
 
30
- /** Component that displays just the map, using vector tile technology */
31
- export function VectorMapViewComponent(props: {
32
- schema: Schema
33
- dataSource: DataSource
34
- mapDataSource: MapDataSource
35
-
36
- design: MapDesign
37
- onDesignChange?: (design: MapDesign) => void
38
-
39
- /** Width in pixels */
40
- width: number
41
-
42
- /** Height in pixels */
43
- height: number
44
-
45
- /** Called with (tableId, rowId) when item is clicked */
46
- onRowClick?: (tableId: string, rowId: any) => void
47
-
48
- /** Extra filters to apply to view */
49
- extraFilters?: JsonQLFilter[]
50
-
51
- /** scope of the map (when a layer self-selects a particular scope) */
52
- scope?: MapScope
53
-
54
- /** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
55
- onScopeChange?: (scope: MapScope | null) => void
56
-
57
- /** Whether the map be draggable with mouse/touch or not. Default true */
58
- dragging?: boolean
59
-
60
- /** Whether the map can be zoomed by touch-dragging with two fingers. Default true */
61
- touchZoom?: boolean
62
-
63
- /** Whether the map can be zoomed by using the mouse wheel. Default true */
64
- scrollWheelZoom?: boolean
65
-
66
- /** Whether changes to zoom level should be persisted. Default false */
67
- zoomLocked?: boolean
68
-
69
- /** Locale to use. Overrides map design locale */
70
- locale?: string
71
-
72
- /** Increment to force refresh */
73
- refreshTrigger?: number
74
-
31
+ export interface VectorMapViewComponentProps extends MapViewComponentProps {
75
32
  /** Optional callback that gets updated MapLibre map each render. Used to allow
76
33
  * external zooming/panning.
77
34
  */
78
35
  onMapUpdate?: (map: maplibregl.Map) => void
79
- }) {
36
+ }
37
+
38
+ /** Component that displays just the map, using vector tile technology */
39
+ export function VectorMapViewComponent(props: VectorMapViewComponentProps) {
80
40
  const [mapDiv, setMapDiv] = useState<HTMLDivElement | null>(null)
81
41
 
82
42
  /** Last published bounds, to avoid recentering when self-changed bounds */
@@ -113,6 +73,12 @@ export function VectorMapViewComponent(props: {
113
73
  initialLegendDisplay == "closed" || (props.width < 500 && initialLegendDisplay == "closedIfSmall")
114
74
  )
115
75
 
76
+ // Locale to use
77
+ const locale = props.locale || props.design.locale || "en"
78
+
79
+ // Translate function to use TODO
80
+ const translate = props.translate || ((input: string) => input)
81
+
116
82
  // Last feature that mouse entered
117
83
  const lastFeature = useRef<string>()
118
84
 
@@ -145,11 +111,11 @@ export function VectorMapViewComponent(props: {
145
111
  const layer = LayerFactory.createLayer(layerView.type)
146
112
 
147
113
  // Clean design (prevent ever displaying invalid/legacy designs)
148
- const design = layer.cleanDesign(layerView.design, props.schema)
114
+ const layerDesign = layer.cleanDesign(layerView.design, props.schema)
149
115
 
150
116
  // Handle click of layer
151
117
  const results = layer.onGridHoverOver(ev, {
152
- design: design,
118
+ design: layerDesign,
153
119
  schema: props.schema,
154
120
  dataSource: props.dataSource,
155
121
  layerDataSource: props.mapDataSource.getLayerDataSource(layerViewId),
@@ -157,7 +123,9 @@ export function VectorMapViewComponent(props: {
157
123
  props.scope && props.scope.data && props.scope.data.layerViewId == layerViewId
158
124
  ? props.scope.data.data
159
125
  : undefined,
160
- filters: getCompiledFilters()
126
+ filters: getCompiledFilters(),
127
+ locale: locale,
128
+ translate: translate
161
129
  })
162
130
 
163
131
  if (!results) {
@@ -191,7 +159,9 @@ export function VectorMapViewComponent(props: {
191
159
  props.scope && props.scope.data && props.scope.data.layerViewId == layerViewId
192
160
  ? props.scope.data.data
193
161
  : undefined,
194
- filters: getCompiledFilters()
162
+ filters: getCompiledFilters(),
163
+ locale: locale,
164
+ translate: translate
195
165
  })
196
166
 
197
167
  if (!results) {
@@ -505,7 +475,10 @@ export function VectorMapViewComponent(props: {
505
475
  setBusy(b => b - 1)
506
476
 
507
477
  if (bounds) {
508
- map!.fitBounds([bounds.w, bounds.s, bounds.e, bounds.n], { padding: 30, duration: 2500 })
478
+ map!.fitBounds([bounds.w, bounds.s, bounds.e, bounds.n], {
479
+ padding: 30,
480
+ duration: (props.design.animateAutoBounds ?? true) ? 2500 : 0
481
+ })
509
482
 
510
483
  // Also record if editable as part of bounds
511
484
  setBounds(bounds)
@@ -590,7 +563,6 @@ export function VectorMapViewComponent(props: {
590
563
  return
591
564
  }
592
565
 
593
-
594
566
  const layers = layerClickHandlers.map(clickHandler => clickHandler.mapLayerId)
595
567
 
596
568
  const onEnter = (ev: MapLayerMouseEvent) => {
@@ -634,7 +606,8 @@ export function VectorMapViewComponent(props: {
634
606
  filters={getCompiledFilters()}
635
607
  zoom={map ? map.getZoom() : null}
636
608
  dataSource={props.dataSource}
637
- locale={props.locale || props.design.locale || "en"}
609
+ locale={locale}
610
+ translate={translate}
638
611
  onHide={() => setLegendHidden(true)}
639
612
  />
640
613
  )
@@ -676,7 +649,7 @@ export function VectorMapViewComponent(props: {
676
649
  maxWidth: 250
677
650
  }
678
651
 
679
- return <div style={style}>{hoverContents ?? "asdksjdbfskajf"}</div>
652
+ return <div style={style}>{hoverContents}</div>
680
653
  }
681
654
 
682
655
  // Overflow hidden because of problem of exceeding div
@@ -687,7 +660,7 @@ export function VectorMapViewComponent(props: {
687
660
  <div style={{ position: "absolute", maxWidth: 250, top: 10, right: 10, zIndex: 999, userSelect: "none" }}>
688
661
  <div style={{ display: "flex", gap: 6, position: "relative", flexDirection: "column", alignItems: "right" }}>
689
662
  {props.onDesignChange != null && props.design.showLayerSwitcher ? (
690
- <LayerSwitcherComponent design={props.design} onDesignChange={props.onDesignChange} />
663
+ <LayerSwitcherComponent design={props.design} onDesignChange={props.onDesignChange} translate={translate} />
691
664
  ) : null}
692
665
  {renderHoverContent()}
693
666
  </div>
package/src/maps/maps.ts CHANGED
@@ -31,8 +31,11 @@ export type OnGridHoverResults = {
31
31
  hoverOver?: React.ReactElement<{}>
32
32
  } | null
33
33
 
34
+ /** Item in hover over */
34
35
  export interface HoverOverItem {
35
36
  id: string
36
37
  label: string
37
38
  value?: Expr
39
+ /** See valueFormatter.ts */
40
+ format?: string
38
41
  }
@@ -38,6 +38,9 @@ export interface QuickfiltersComponentProps {
38
38
 
39
39
  /** Called when user hides the quickfilter bar */
40
40
  onHide?: () => void
41
+
42
+ /** Translate function to use for display */
43
+ translate?: (input: string) => string
41
44
  }
42
45
 
43
46
  /** Displays quick filters and allows their value to be modified */
@@ -52,6 +55,9 @@ export default class QuickfiltersComponent extends React.Component<QuickfiltersC
52
55
  let values = this.props.values || []
53
56
  let itemValue = values[index]
54
57
 
58
+ // Translate label
59
+ const label = this.props.translate?.(item.label) ?? item.label
60
+
55
61
  // Clean expression first
56
62
  const expr = new ExprCleaner(this.props.schema).cleanExpr(item.expr)
57
63
 
@@ -106,7 +112,7 @@ export default class QuickfiltersComponent extends React.Component<QuickfiltersC
106
112
  if (["enum", "enumset"].includes(type)) {
107
113
  return R(EnumQuickfilterComponent, {
108
114
  key: JSON.stringify(item),
109
- label: item.label,
115
+ label,
110
116
  schema: this.props.schema,
111
117
  options: new ExprUtils(this.props.schema).getExprEnumValues(expr)!,
112
118
  value: itemValue,
@@ -119,7 +125,7 @@ export default class QuickfiltersComponent extends React.Component<QuickfiltersC
119
125
  return R(TextQuickfilterComponent, {
120
126
  key: JSON.stringify(item),
121
127
  index,
122
- label: item.label,
128
+ label,
123
129
  expr,
124
130
  schema: this.props.schema,
125
131
  quickfiltersDataSource: this.props.quickfiltersDataSource,
@@ -133,7 +139,7 @@ export default class QuickfiltersComponent extends React.Component<QuickfiltersC
133
139
  if (["date", "datetime"].includes(type)) {
134
140
  return R(DateQuickfilterComponent, {
135
141
  key: JSON.stringify(item),
136
- label: item.label,
142
+ label,
137
143
  expr,
138
144
  schema: this.props.schema,
139
145
  value: itemValue,
@@ -145,7 +151,7 @@ export default class QuickfiltersComponent extends React.Component<QuickfiltersC
145
151
  return R(IdArrayQuickfilterComponent, {
146
152
  key: JSON.stringify(item),
147
153
  index,
148
- label: item.label,
154
+ label,
149
155
  expr,
150
156
  schema: this.props.schema,
151
157
  dataSource: this.props.dataSource,
@@ -160,7 +166,7 @@ export default class QuickfiltersComponent extends React.Component<QuickfiltersC
160
166
  return R(TextArrayQuickfilterComponent, {
161
167
  key: JSON.stringify(item),
162
168
  index,
163
- label: item.label,
169
+ label,
164
170
  expr,
165
171
  schema: this.props.schema,
166
172
  quickfiltersDataSource: this.props.quickfiltersDataSource,
@@ -239,7 +245,7 @@ class EnumQuickfilterComponent extends React.Component<EnumQuickfilterComponentP
239
245
 
240
246
  renderSingleSelect(options: any[]) {
241
247
  return R(ReactSelect, {
242
- placeholder: "All",
248
+ placeholder: T`All`,
243
249
  value: _.findWhere(options, { value: this.props.value }) || null,
244
250
  options,
245
251
  isClearable: true,
@@ -258,7 +264,7 @@ class EnumQuickfilterComponent extends React.Component<EnumQuickfilterComponentP
258
264
 
259
265
  renderMultiSelect(options: any[]) {
260
266
  return R(ReactSelect, {
261
- placeholder: "All",
267
+ placeholder: T`All`,
262
268
  value: _.map(this.props.value, (v) => _.find(options, (o) => o.value === v)),
263
269
  isClearable: true,
264
270
  isMulti: true,
@@ -117,7 +117,7 @@ export default class QuickfiltersDesignComponent extends React.Component<Quickfi
117
117
  ? R(
118
118
  "button",
119
119
  { type: "button", className: "btn btn-sm btn-link", onClick: this.handleAdd },
120
- R("span", { className: "fas fa-plus" }),
120
+ R("span", { className: "fas fa-plus me-1" }),
121
121
  T`Add Quick Filter`
122
122
  )
123
123
  : undefined
@@ -175,83 +175,65 @@ class QuickfilterDesignComponent extends React.Component<
175
175
  handleMultiChange = (multi: any) => {
176
176
  return this.props.onChange(update(this.props.design, { multi: { $set: multi } }))
177
177
  }
178
-
179
178
  render() {
180
179
  // Determine type of expression
181
180
  const exprType = new ExprUtils(this.props.schema).getExprType(this.props.design.expr)
182
181
 
183
- return R(
184
- "div", {},
185
- R(
186
- "div",
187
- { className: "mb-3 mt-1", key: "table" },
188
- R("label", { className: "text-muted" }, T`Data Source`),
189
- R(ui.Select, {
190
- value: this.state.table,
191
- options: _.map(this.props.tables, (table) => ({
192
- value: table,
193
- label: ExprUtils.localizeString(this.props.schema.getTable(table)!.name)
194
- })),
195
- onChange: this.handleTableChange,
196
- nullLabel: T`Select...`
197
- })
198
- ),
199
-
200
- R(
201
- "div",
202
- { className: "mb-3", key: "expr" },
203
- R("label", { className: "text-muted" }, T`Filter By`),
204
- R(
205
- "div",
206
- null,
207
- R(ExprComponent, {
208
- schema: this.props.schema,
209
- dataSource: this.props.dataSource,
210
- table: this.state.table,
211
- value: this.props.design.expr,
212
- onChange: this.handleExprChange,
213
- types: ["enum", "text", "enumset", "date", "datetime", "id[]", "text[]"],
214
- })
215
- )
216
- ),
217
-
218
- this.props.design.expr
219
- ? R(
220
- "div",
221
- { className: "mb-3", key: "label" },
222
- R("label", { className: "text-muted" }, T`Label`),
223
- R("input", {
224
- type: "text",
225
- className: "form-control form-control-sm",
226
- value: this.props.design.label || "",
227
- onChange: this.handleLabelChange,
228
- placeholder: T`Optional Label`
229
- })
230
- )
231
- : undefined,
232
-
233
- this.props.mergeable
234
- ? R(
235
- ui.Checkbox,
236
- {
237
- value: this.props.design.merged,
238
- onChange: this.handleMergedChange
239
- },
240
- T`Merge with previous quickfilter `,
241
- R("span", { className: "text-muted" }, T`- displays as one single control that filters both`)
242
- )
243
- : undefined,
244
-
245
- ["enum", "text", "enumset", "id[]", "text[]"].includes(exprType!)
246
- ? R(
247
- ui.Checkbox,
248
- {
249
- value: this.props.design.multi,
250
- onChange: this.handleMultiChange
251
- },
252
- T`Allow multiple selections`
253
- )
254
- : undefined
182
+ return (
183
+ <div>
184
+ <div className="mb-3 mt-1" key="table">
185
+ <label className="text-muted">{T`Data Source`}</label>
186
+ <ui.Select
187
+ value={this.state.table}
188
+ options={_.map(this.props.tables, (table) => ({
189
+ value: table,
190
+ label: ExprUtils.localizeString(this.props.schema.getTable(table)!.name)
191
+ }))}
192
+ onChange={this.handleTableChange}
193
+ nullLabel={T`Select...`}
194
+ />
195
+ </div>
196
+
197
+ <div className="mb-3" key="expr">
198
+ <label className="text-muted">{T`Filter By`}</label>
199
+ <div>
200
+ <ExprComponent
201
+ schema={this.props.schema}
202
+ dataSource={this.props.dataSource}
203
+ table={this.state.table}
204
+ value={this.props.design.expr}
205
+ onChange={this.handleExprChange}
206
+ types={["enum", "text", "enumset", "date", "datetime", "id[]", "text[]"]}
207
+ />
208
+ </div>
209
+ </div>
210
+
211
+ {this.props.design.expr ? (
212
+ <div className="mb-3" key="label">
213
+ <label className="text-muted">{T`Label`}</label>
214
+ <input
215
+ type="text"
216
+ className="form-control form-control-sm"
217
+ value={this.props.design.label || ""}
218
+ onChange={this.handleLabelChange}
219
+ placeholder={T`Optional Label`}
220
+ />
221
+ </div>
222
+ ) : undefined}
223
+
224
+ {this.props.mergeable ? (
225
+ <ui.Checkbox value={this.props.design.merged} onChange={this.handleMergedChange}>
226
+ {T`Merge with previous quickfilter `}
227
+ <span className="text-muted">{`- ${T`displays as one single control that filters both`}`}</span>
228
+ </ui.Checkbox>
229
+ ) : undefined}
230
+
231
+ {["enum", "text", "enumset", "id[]", "text[]"].includes(exprType!) ? (
232
+ <ui.Checkbox value={this.props.design.multi} onChange={this.handleMultiChange}>
233
+ {T`Allow multiple selections`}
234
+ </ui.Checkbox>
235
+ ) : undefined}
236
+ </div>
255
237
  )
256
238
  }
257
239
  }