@mwater/visualization 5.4.1 → 5.4.3

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 (273) 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 +12 -20
  21. package/lib/dashboards/DashboardComponent.js +109 -69
  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/languages.js +6 -1
  47. package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
  48. package/lib/mWaterLoader.d.ts +1 -1
  49. package/lib/maps/BufferLayer.d.ts +7 -5
  50. package/lib/maps/BufferLayer.js +69 -48
  51. package/lib/maps/BufferLayerDesign.d.ts +21 -14
  52. package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
  53. package/lib/maps/BufferLayerDesignerComponent.js +68 -102
  54. package/lib/maps/ChoroplethLayer.d.ts +5 -4
  55. package/lib/maps/ChoroplethLayer.js +32 -9
  56. package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
  57. package/lib/maps/ChoroplethLayerDesigner.js +4 -2
  58. package/lib/maps/ClusterLayer.d.ts +3 -4
  59. package/lib/maps/ClusterLayer.js +2 -1
  60. package/lib/maps/DetailLevelSelectComponent.js +1 -1
  61. package/lib/maps/DirectMapDataSource.js +2 -1
  62. package/lib/maps/EditPopupComponent.js +5 -3
  63. package/lib/maps/GridLayer.d.ts +3 -4
  64. package/lib/maps/GridLayer.js +2 -1
  65. package/lib/maps/GridLayerDesigner.js +5 -3
  66. package/lib/maps/HoverContent.d.ts +11 -3
  67. package/lib/maps/HoverContent.js +25 -9
  68. package/lib/maps/Layer.d.ts +24 -3
  69. package/lib/maps/Layer.js +5 -1
  70. package/lib/maps/LayerFactory.js +0 -8
  71. package/lib/maps/LayerLegendComponent.js +0 -1
  72. package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
  73. package/lib/maps/LayerSwitcherComponent.js +1 -1
  74. package/lib/maps/LeafletMapComponent.js +3 -1
  75. package/lib/maps/LegendComponent.d.ts +1 -0
  76. package/lib/maps/LegendComponent.js +9 -1
  77. package/lib/maps/MWaterServerLayer.d.ts +2 -2
  78. package/lib/maps/MWaterServerLayer.js +2 -2
  79. package/lib/maps/MapComponent.js +3 -3
  80. package/lib/maps/MapDesign.d.ts +2 -0
  81. package/lib/maps/MapDesignerComponent.d.ts +4 -3
  82. package/lib/maps/MapDesignerComponent.js +68 -74
  83. package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
  84. package/lib/maps/MapUtils.d.ts +4 -0
  85. package/lib/maps/MapUtils.js +19 -0
  86. package/lib/maps/MapViewComponent.d.ts +8 -3
  87. package/lib/maps/MarkersLayer.d.ts +5 -4
  88. package/lib/maps/MarkersLayer.js +33 -7
  89. package/lib/maps/MarkersLayerDesign.d.ts +19 -16
  90. package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
  91. package/lib/maps/PopupFilterJoinsUtils.js +0 -6
  92. package/lib/maps/RasterMapViewComponent.d.ts +3 -31
  93. package/lib/maps/RasterMapViewComponent.js +7 -2
  94. package/lib/maps/ServerMapDataSource.js +2 -1
  95. package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
  96. package/lib/maps/SwitchableTileUrlLayer.js +2 -1
  97. package/lib/maps/TileUrlLayer.d.ts +4 -5
  98. package/lib/maps/TileUrlLayer.js +2 -1
  99. package/lib/maps/VectorMapViewComponent.d.ts +5 -37
  100. package/lib/maps/VectorMapViewComponent.js +19 -8
  101. package/lib/maps/maps.d.ts +3 -0
  102. package/lib/quickfilter/Quickfilter.d.ts +2 -0
  103. package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
  104. package/lib/quickfilter/QuickfiltersComponent.js +9 -7
  105. package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +5 -30
  106. package/lib/quickfilter/QuickfiltersDesignComponent.js +56 -63
  107. package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
  108. package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
  109. package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
  110. package/lib/richtext/ExprItemsTranslator.js +149 -0
  111. package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
  112. package/lib/richtext/ItemsHtmlConverter.js +31 -15
  113. package/lib/wellknown.js +12 -9
  114. package/lib/widgets/IFrameWidget.d.ts +4 -4
  115. package/lib/widgets/ImageWidget.d.ts +7 -4
  116. package/lib/widgets/ImageWidget.js +9 -1
  117. package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
  118. package/lib/widgets/ImageWidgetComponent.js +1 -1
  119. package/lib/widgets/MapWidget.d.ts +5 -48
  120. package/lib/widgets/MapWidget.js +26 -63
  121. package/lib/widgets/MarkdownWidget.d.ts +3 -0
  122. package/lib/widgets/MarkdownWidget.js +3 -0
  123. package/lib/widgets/TOCWidget.d.ts +15 -27
  124. package/lib/widgets/TOCWidget.js +107 -183
  125. package/lib/widgets/Widget.d.ts +18 -7
  126. package/lib/widgets/Widget.js +4 -0
  127. package/lib/widgets/WidgetScopesViewComponent.js +1 -1
  128. package/lib/widgets/charts/Chart.d.ts +10 -1
  129. package/lib/widgets/charts/Chart.js +22 -11
  130. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  131. package/lib/widgets/charts/ChartViewComponent.js +6 -3
  132. package/lib/widgets/charts/ChartWidget.d.ts +2 -0
  133. package/lib/widgets/charts/ChartWidget.js +9 -1
  134. package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
  135. package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
  136. package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
  137. package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
  138. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
  139. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
  140. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
  141. package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
  142. package/lib/widgets/charts/layered/LayeredChart.js +63 -3
  143. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
  144. package/lib/widgets/charts/layered/LayeredChartCompiler.js +1 -1
  145. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
  146. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
  147. package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
  148. package/lib/widgets/charts/pivot/PivotChart.js +63 -0
  149. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
  150. package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
  151. package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
  152. package/lib/widgets/charts/table/TableChart.d.ts +1 -0
  153. package/lib/widgets/charts/table/TableChart.js +15 -0
  154. package/lib/widgets/text/TextComponent.d.ts +11 -4
  155. package/lib/widgets/text/TextComponent.js +11 -8
  156. package/lib/widgets/text/TextWidget.d.ts +6 -3
  157. package/lib/widgets/text/TextWidget.js +7 -1
  158. package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
  159. package/lib/widgets/text/TextWidgetComponent.js +7 -1
  160. package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
  161. package/lib/widgets/text/TextWidgetDesign.js +1 -1
  162. package/package.json +7 -8
  163. package/src/ColorComponent.tsx +1 -2
  164. package/src/IdSelection.ts +62 -0
  165. package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
  166. package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
  167. package/src/MWaterLoaderComponent.ts +28 -26
  168. package/src/MWaterResponsesFilterComponent.ts +5 -2
  169. package/src/MWaterTableSelectComponent.tsx +5 -9
  170. package/src/autotranslate.ts +141 -0
  171. package/src/axes/AxisBuilder.ts +3 -3
  172. package/src/axes/AxisColorEditorComponent.tsx +5 -0
  173. package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
  174. package/src/axes/CategoryMapComponent.ts +4 -4
  175. package/src/axes/RangesComponent.ts +3 -2
  176. package/src/dashboards/DashboardComponent.tsx +189 -125
  177. package/src/dashboards/DashboardDesign.ts +9 -2
  178. package/src/dashboards/DashboardUtils.ts +39 -0
  179. package/src/dashboards/DashboardViewComponent.tsx +22 -3
  180. package/src/dashboards/ServerDashboardDataSource.ts +2 -1
  181. package/src/dashboards/SettingsModalComponent.tsx +450 -35
  182. package/src/dashboards/WidgetComponent.tsx +12 -6
  183. package/src/datagrids/CellEditor.tsx +354 -0
  184. package/src/datagrids/DatagridComponent.tsx +646 -0
  185. package/src/datagrids/DatagridViewComponent.tsx +539 -0
  186. package/src/datagrids/DirectDatagridDataSource.ts +2 -3
  187. package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
  188. package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
  189. package/src/index.css +1 -1
  190. package/src/index.ts +0 -1
  191. package/src/languages.ts +6 -1
  192. package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
  193. package/src/mWaterLoader.ts +1 -1
  194. package/src/maps/BufferLayer.ts +83 -60
  195. package/src/maps/BufferLayerDesign.ts +20 -14
  196. package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
  197. package/src/maps/ChoroplethLayer.ts +40 -19
  198. package/src/maps/ChoroplethLayerDesign.ts +4 -2
  199. package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
  200. package/src/maps/ClusterLayer.ts +4 -10
  201. package/src/maps/DetailLevelSelectComponent.ts +1 -1
  202. package/src/maps/DirectMapDataSource.ts +2 -1
  203. package/src/maps/EditPopupComponent.ts +7 -3
  204. package/src/maps/GridLayer.ts +4 -10
  205. package/src/maps/GridLayerDesigner.tsx +5 -3
  206. package/src/maps/HoverContent.tsx +40 -16
  207. package/src/maps/Layer.ts +28 -10
  208. package/src/maps/LayerFactory.ts +0 -8
  209. package/src/maps/LayerLegendComponent.ts +2 -4
  210. package/src/maps/LayerSwitcherComponent.tsx +6 -2
  211. package/src/maps/LeafletMapComponent.tsx +3 -1
  212. package/src/maps/LegendComponent.tsx +10 -1
  213. package/src/maps/MWaterServerLayer.ts +3 -3
  214. package/src/maps/MapComponent.ts +3 -3
  215. package/src/maps/MapDesign.ts +3 -0
  216. package/src/maps/MapDesignerComponent.tsx +165 -162
  217. package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
  218. package/src/maps/MapUtils.ts +24 -0
  219. package/src/maps/MapViewComponent.tsx +11 -3
  220. package/src/maps/MarkersLayer.ts +44 -18
  221. package/src/maps/MarkersLayerDesign.ts +19 -16
  222. package/src/maps/PopupFilterJoinsUtils.ts +6 -2
  223. package/src/maps/RasterMapViewComponent.ts +9 -45
  224. package/src/maps/ServerMapDataSource.ts +2 -2
  225. package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
  226. package/src/maps/TileUrlLayer.tsx +4 -10
  227. package/src/maps/VectorMapViewComponent.tsx +28 -55
  228. package/src/maps/maps.ts +3 -0
  229. package/src/quickfilter/Quickfilter.ts +3 -0
  230. package/src/quickfilter/QuickfiltersComponent.ts +13 -7
  231. package/src/quickfilter/QuickfiltersDesignComponent.tsx +127 -128
  232. package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
  233. package/src/richtext/ExprItemsTranslator.ts +176 -0
  234. package/src/richtext/ItemsHtmlConverter.ts +33 -18
  235. package/src/wellknown.ts +33 -30
  236. package/src/widgets/ImageWidget.ts +10 -1
  237. package/src/widgets/ImageWidgetComponent.ts +3 -2
  238. package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
  239. package/src/widgets/MarkdownWidget.ts +3 -0
  240. package/src/widgets/TOCWidget.tsx +281 -0
  241. package/src/widgets/Widget.ts +25 -5
  242. package/src/widgets/WidgetScopesViewComponent.ts +2 -1
  243. package/src/widgets/charts/Chart.ts +31 -12
  244. package/src/widgets/charts/ChartViewComponent.ts +13 -3
  245. package/src/widgets/charts/ChartWidget.ts +11 -1
  246. package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
  247. package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
  248. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
  249. package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
  250. package/src/widgets/charts/layered/LayeredChart.ts +71 -3
  251. package/src/widgets/charts/layered/LayeredChartCompiler.ts +2 -2
  252. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
  253. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
  254. package/src/widgets/charts/pivot/PivotChart.ts +73 -0
  255. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
  256. package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
  257. package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
  258. package/src/widgets/charts/table/TableChart.ts +17 -0
  259. package/src/widgets/text/TextComponent.tsx +22 -12
  260. package/src/widgets/text/TextWidget.ts +9 -2
  261. package/src/widgets/text/TextWidgetComponent.tsx +16 -1
  262. package/src/widgets/text/TextWidgetDesign.ts +4 -7
  263. package/test/IdSelectionTests.ts +54 -0
  264. package/test/LayeredChartCompilerTests.ts +0 -2
  265. package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
  266. package/test/wellknownTests.ts +144 -0
  267. package/src/datagrids/DatagridComponent.ts +0 -478
  268. package/src/datagrids/DatagridViewComponent.ts +0 -464
  269. package/src/datagrids/EditExprCellComponent.tsx +0 -305
  270. package/src/datagrids/README.md +0 -3
  271. package/src/maps/BufferLayerDesignerComponent.ts +0 -311
  272. package/src/widgets/TOCWidget.ts +0 -326
  273. package/test/LegoLayoutEngineTests.ts +0 -69
@@ -1,6 +1,6 @@
1
1
  import _ from "lodash"
2
2
  import PropTypes from "prop-types"
3
- import React, { ReactElement } from "react"
3
+ import React, { ReactElement, ReactNode } from "react"
4
4
  const R = React.createElement
5
5
 
6
6
  import TabbedComponent, { TabbedComponentTab } from "@mwater/react-library/lib/TabbedComponent"
@@ -37,16 +37,21 @@ export interface MapDesignerComponentProps {
37
37
  }
38
38
 
39
39
  export default class MapDesignerComponent extends React.Component<MapDesignerComponentProps> {
40
- handleAttributionChange = (text: any) => {
40
+ handleAttributionChange = (text: string | undefined) => {
41
41
  const design = { ...this.props.design, attribution: text }
42
42
  return this.props.onDesignChange(design)
43
43
  }
44
44
 
45
- handleAutoBoundsChange = (value: any) => {
45
+ handleAutoBoundsChange = (value: boolean) => {
46
46
  const design = { ...this.props.design, autoBounds: value }
47
47
  return this.props.onDesignChange(design)
48
48
  }
49
49
 
50
+ handleAnimateAutoBoundsChange = (value: boolean) => {
51
+ const design = { ...this.props.design, animateAutoBounds: value }
52
+ return this.props.onDesignChange(design)
53
+ }
54
+
50
55
  handleShowLayerSwitcherChange = (value: any) => {
51
56
  const design = { ...this.props.design, showLayerSwitcher: value }
52
57
  return this.props.onDesignChange(design)
@@ -66,96 +71,90 @@ export default class MapDesignerComponent extends React.Component<MapDesignerCom
66
71
  }
67
72
 
68
73
  renderOptionsTab() {
69
- return R(
70
- "div",
71
- null,
72
- R(BaseLayerDesignerComponent, {
73
- design: this.props.design,
74
- onDesignChange: this.props.onDesignChange
75
- }),
76
-
77
- R(
78
- CheckboxComponent,
79
- {
80
- checked: this.props.design.autoBounds,
81
- onChange: this.handleAutoBoundsChange
82
- },
83
- R(
84
- "span",
85
- { className: "text-muted" },
86
- T`Automatic zoom `,
87
- R(
88
- PopoverHelpComponent,
89
- { placement: "left" },
90
- T`Automatically zoom to the complete data whenever the map is loaded or the filters change`
91
- )
92
- )
93
- ),
94
-
95
- R(
96
- CheckboxComponent,
97
- {
98
- checked: this.props.design.showLayerSwitcher,
99
- onChange: this.handleShowLayerSwitcherChange
100
- },
101
- R(
102
- "span",
103
- { className: "text-muted" },
104
- T`Show Layer Switcher `,
105
- R(PopoverHelpComponent, { placement: "left" }, T`Show a control in the map allowing switching layers`)
106
- )
107
- ),
108
-
109
- R(
110
- ui.FormGroup,
111
- { label: T`Initial Legend Display`, labelMuted: true },
112
- R(ui.Select, {
113
- value: this.props.design.initialLegendDisplay || "open",
114
- onChange: this.handleInitialLegendDisplayChange,
115
- options: [
116
- { value: "open", label: T`Open` },
117
- { value: "closed", label: T`Closed` },
118
- { value: "closedIfSmall", label: T`Open if wide enough` }
119
- ],
120
- style: { width: "auto" }
121
- })
122
- ),
123
-
124
- MapUtils.canConvertToClusterMap(this.props.design)
125
- ? R(
126
- "div",
127
- { key: "tocluster" },
128
- R(
129
- "a",
130
- { onClick: this.handleConvertToClusterMap, className: "btn btn-link btn-sm" },
131
- T`Convert to cluster map`
132
- )
133
- )
134
- : undefined,
135
-
136
- MapUtils.canConvertToMarkersMap(this.props.design)
137
- ? R(
138
- "div",
139
- { key: "toMarker" },
140
- R(
141
- "a",
142
- { onClick: this.handleConvertToMarkersMap, className: "btn btn-link btn-sm" },
143
- T`Convert to markers map`
144
- )
145
- )
146
- : undefined,
147
-
148
- R(AttributionComponent, {
149
- text: this.props.design.attribution,
150
- onTextChange: this.handleAttributionChange
151
- }),
152
-
153
- R("br"),
154
-
155
- R(AdvancedOptionsComponent, {
156
- design: this.props.design,
157
- onDesignChange: this.props.onDesignChange
158
- })
74
+ return (
75
+ <div>
76
+ <BaseLayerDesignerComponent
77
+ design={this.props.design}
78
+ onDesignChange={this.props.onDesignChange}
79
+ />
80
+
81
+ <CheckboxComponent
82
+ checked={this.props.design.autoBounds}
83
+ onChange={this.handleAutoBoundsChange}
84
+ >
85
+ <span className="text-muted">
86
+ {T`Automatic zoom`}
87
+ {" "}
88
+ <PopoverHelpComponent placement="left">
89
+ {T`Automatically zoom to the complete data whenever the map is loaded or the filters change`}
90
+ </PopoverHelpComponent>
91
+ </span>
92
+ </CheckboxComponent>
93
+
94
+ {this.props.design.autoBounds && (
95
+ <CheckboxComponent
96
+ checked={this.props.design.animateAutoBounds ?? true}
97
+ onChange={this.handleAnimateAutoBoundsChange}
98
+ >
99
+ <span className="text-muted">
100
+ {T`Animate automatic zoom`}
101
+ </span>
102
+ </CheckboxComponent>
103
+ )}
104
+
105
+ <CheckboxComponent
106
+ checked={this.props.design.showLayerSwitcher}
107
+ onChange={this.handleShowLayerSwitcherChange}
108
+ >
109
+ <span className="text-muted">
110
+ {T`Show Layer Switcher `}
111
+ <PopoverHelpComponent placement="left">
112
+ {T`Show a control in the map allowing switching layers`}
113
+ </PopoverHelpComponent>
114
+ </span>
115
+ </CheckboxComponent>
116
+
117
+ <ui.FormGroup label={T`Initial Legend Display`} labelMuted>
118
+ <ui.Select
119
+ value={this.props.design.initialLegendDisplay || "open"}
120
+ onChange={this.handleInitialLegendDisplayChange}
121
+ options={[
122
+ { value: "open", label: T`Open|adjective` },
123
+ { value: "closed", label: T`Closed` },
124
+ { value: "closedIfSmall", label: T`Open if wide enough` }
125
+ ]}
126
+ style={{ width: "auto" }}
127
+ />
128
+ </ui.FormGroup>
129
+
130
+ {MapUtils.canConvertToClusterMap(this.props.design) ? (
131
+ <div key="tocluster">
132
+ <a onClick={this.handleConvertToClusterMap} className="btn btn-link btn-sm">
133
+ {T`Convert to cluster map`}
134
+ </a>
135
+ </div>
136
+ ) : undefined}
137
+
138
+ {MapUtils.canConvertToMarkersMap(this.props.design) ? (
139
+ <div key="toMarker">
140
+ <a onClick={this.handleConvertToMarkersMap} className="btn btn-link btn-sm">
141
+ {T`Convert to markers map`}
142
+ </a>
143
+ </div>
144
+ ) : undefined}
145
+
146
+ <AttributionComponent
147
+ text={this.props.design.attribution}
148
+ onTextChange={this.handleAttributionChange}
149
+ />
150
+
151
+ <br />
152
+
153
+ <AdvancedOptionsComponent
154
+ design={this.props.design}
155
+ onDesignChange={this.props.onDesignChange}
156
+ />
157
+ </div>
159
158
  )
160
159
  }
161
160
 
@@ -172,29 +171,29 @@ export default class MapDesignerComponent extends React.Component<MapDesignerCom
172
171
  const tabs: TabbedComponentTab[] = [
173
172
  {
174
173
  id: "layers",
175
- label: [R("i", { className: "fa fa-bars" }), T` Layers`],
176
- elem: R(MapLayersDesignerComponent, {
177
- schema: this.props.schema,
178
- dataSource: this.props.dataSource,
179
- design: this.props.design,
180
- onDesignChange: this.props.onDesignChange,
181
- allowEditingLayers: true,
182
- filters: _.compact(filters)
183
- })
174
+ label: <><i className="fa fa-bars" /> {T`Layers`}</>,
175
+ elem: <MapLayersDesignerComponent
176
+ schema={this.props.schema}
177
+ dataSource={this.props.dataSource}
178
+ design={this.props.design}
179
+ onDesignChange={this.props.onDesignChange}
180
+ allowEditingLayers={true}
181
+ filters={_.compact(filters)}
182
+ />
184
183
  },
185
184
  {
186
185
  id: "filters",
187
- label: [R("i", { className: "fa fa-filter" }), T` Filters`],
188
- elem: R(MapFiltersDesignerComponent, {
189
- schema: this.props.schema,
190
- dataSource: this.props.dataSource,
191
- design: this.props.design,
192
- onDesignChange: this.props.onDesignChange
193
- })
186
+ label: <><i className="fa fa-filter" /> {T`Filters`}</>,
187
+ elem: <MapFiltersDesignerComponent
188
+ schema={this.props.schema}
189
+ dataSource={this.props.dataSource}
190
+ design={this.props.design}
191
+ onDesignChange={this.props.onDesignChange}
192
+ />
194
193
  },
195
194
  {
196
195
  id: "options",
197
- label: [R("i", { className: "fa fa-cog" }), T` Options`],
196
+ label: <><i className="fa fa-cog" /> {T`Options`}</>,
198
197
  elem: this.renderOptionsTab()
199
198
  }
200
199
  ]
@@ -202,22 +201,20 @@ export default class MapDesignerComponent extends React.Component<MapDesignerCom
202
201
  if (this.props.enableQuickfilters) {
203
202
  tabs.splice(2, 0, {
204
203
  id: "quickfilters",
205
- label: [R("i", { className: "fa fa-bolt" }), " ", T`Quickfilters`],
206
- elem: R(
207
- "div",
208
- { style: { marginBottom: 200 } },
209
- R(QuickfiltersDesignComponent, {
210
- design: this.props.design.quickfilters || [],
211
- onDesignChange: (qfDesign) => {
204
+ label: <><i className="fa fa-bolt" /> {T`Quickfilters`}</>,
205
+ elem: <div style={{ marginBottom: 200 }}>
206
+ <QuickfiltersDesignComponent
207
+ design={this.props.design.quickfilters || []}
208
+ onDesignChange={(qfDesign) => {
212
209
  this.props.onDesignChange(produce(this.props.design, (draft) => {
213
210
  draft.quickfilters = qfDesign
214
211
  }))
215
- },
216
- schema: this.props.schema,
217
- dataSource: this.props.dataSource,
218
- tables: filterableTables
219
- })
220
- )
212
+ }}
213
+ schema={this.props.schema}
214
+ dataSource={this.props.dataSource}
215
+ tables={filterableTables}
216
+ />
217
+ </div>
221
218
  })
222
219
  }
223
220
 
@@ -263,10 +260,10 @@ class AttributionComponent extends React.Component<AttributionComponentProps, At
263
260
  }
264
261
 
265
262
  renderEditor() {
266
- return R(
267
- ClickOutHandler,
268
- { onClickOut: this.handleClickOut },
269
- R("input", { onChange: this.handleTextChange, value: this.props.text, className: "form-control" })
263
+ return (
264
+ <ClickOutHandler onClickOut={this.handleClickOut}>
265
+ <input onChange={this.handleTextChange} value={this.props.text} className="form-control" />
266
+ </ClickOutHandler>
270
267
  )
271
268
  }
272
269
 
@@ -275,18 +272,29 @@ class AttributionComponent extends React.Component<AttributionComponentProps, At
275
272
  }
276
273
 
277
274
  render() {
278
- let elem: ReactElement = R(
279
- "div",
280
- { style: { marginLeft: 5 } },
281
- this.state.editing
282
- ? this.renderEditor()
283
- : this.props.text
284
- ? R("span", { onClick: this.handleTextClick, style: { cursor: "pointer" } }, this.props.text)
285
- : R("a", { onClick: this.handleTextClick, className: "btn btn-link btn-sm" }, T`+ Add attribution`)
275
+ let elem = (
276
+ <div style={{ marginLeft: 5 }}>
277
+ {this.state.editing ? (
278
+ this.renderEditor()
279
+ ) : this.props.text ? (
280
+ <span onClick={this.handleTextClick} style={{ cursor: "pointer" }}>
281
+ {this.props.text}
282
+ </span>
283
+ ) : (
284
+ <a onClick={this.handleTextClick} className="btn btn-link btn-sm">
285
+ {T`+ Add attribution`}
286
+ </a>
287
+ )}
288
+ </div>
286
289
  )
287
290
 
288
291
  if (this.props.text || this.state.editing) {
289
- elem = R("div", { className: "mb-3" }, R("label", { className: "text-muted" }, T`Attribution`), elem)
292
+ elem = (
293
+ <div className="mb-3">
294
+ <label className="text-muted">{T`Attribution`}</label>
295
+ {elem}
296
+ </div>
297
+ )
290
298
  }
291
299
 
292
300
  return elem
@@ -314,35 +322,30 @@ class AdvancedOptionsComponent extends React.Component<AdvancedOptionsComponentP
314
322
 
315
323
  render() {
316
324
  if (!this.state.expanded) {
317
- return R(
318
- "div",
319
- null,
320
- R(
321
- "a",
322
- { className: "btn btn-link btn-sm", onClick: () => this.setState({ expanded: true }) },
323
- T`Advanced options...`
324
- )
325
+ return (
326
+ <div>
327
+ <a className="btn btn-link btn-sm" onClick={() => this.setState({ expanded: true })}>
328
+ {T`Advanced options...`}
329
+ </a>
330
+ </div>
325
331
  )
326
332
  }
327
333
 
328
- return R(
329
- "div",
330
- { className: "mb-3" },
331
- R("label", { className: "text-muted" }, T`Advanced`),
332
-
333
- R(
334
- "div",
335
- null,
336
- R("span", { className: "text-muted" }, T`Maximum Zoom Level: `),
337
- " ",
338
- R(NumberInputComponent, {
339
- small: true,
340
- style: { display: "inline-block" },
341
- placeholder: T`None`,
342
- value: this.props.design.maxZoom,
343
- onChange: (v: any) => this.props.onDesignChange(_.extend({}, this.props.design, { maxZoom: v }))
344
- })
345
- )
334
+ return (
335
+ <div className="mb-3">
336
+ <label className="text-muted">{T`Advanced`}</label>
337
+ <div>
338
+ <span className="text-muted">{T`Maximum Zoom Level: `}</span>{" "}
339
+ <ui.NumberInput
340
+ decimal={false}
341
+ size="sm"
342
+ style={{ display: "inline-block" }}
343
+ placeholder={T`None`}
344
+ value={this.props.design.maxZoom}
345
+ onChange={(v: any) => this.props.onDesignChange(_.extend({}, this.props.design, { maxZoom: v }))}
346
+ />
347
+ </div>
348
+ </div>
346
349
  )
347
350
  }
348
351
  }
@@ -161,8 +161,8 @@ export default class MapLayerViewDesignerComponent extends React.Component<
161
161
  "a",
162
162
  { className: "link-plain", onClick: this.handleToggleEditing, style: { fontSize: 12 } },
163
163
  this.state.editing
164
- ? [R("i", { className: "fa fa-caret-up" }), T` Close`]
165
- : [R("i", { className: "fa fa-cog" }), T` Customize...`]
164
+ ? [R("i", { className: "fa fa-caret-up" }), " ", T`Close`]
165
+ : [R("i", { className: "fa fa-cog" }), " ", T`Customize...`]
166
166
  )
167
167
  )
168
168
  }
@@ -6,6 +6,7 @@ import { Expr, ExprCleaner, ExprCompiler, ExprUtils, FieldExpr, Schema } from "@
6
6
  import { JsonQLFilter } from "../JsonQLFilter"
7
7
  import LayerFactory from "./LayerFactory"
8
8
  import { MapDesign } from "./MapDesign"
9
+ import { produce } from "immer"
9
10
 
10
11
  export interface MapScope {
11
12
  name: string
@@ -146,3 +147,26 @@ export function getCompiledFilters(
146
147
 
147
148
  return compiledFilters
148
149
  }
150
+
151
+ /**
152
+ * Get a list of translatable strings in the map design
153
+ */
154
+ export function getTranslatableStrings(design: MapDesign, schema: Schema): string[] {
155
+ const strings: string[] = []
156
+
157
+ // Iterate through each layer view in the design
158
+ for (const layerView of design.layerViews) {
159
+ // Name of the layer is translatable
160
+ strings.push(layerView.name)
161
+
162
+ // Create the layer using the LayerFactory
163
+ const layer = LayerFactory.createLayer(layerView.type)
164
+
165
+ // Get the translatable strings from the layer design
166
+ const layerStrings = layer.getTranslatableStrings(layerView.design, schema)
167
+ strings.push(...layerStrings)
168
+ }
169
+
170
+ // Remove duplicates
171
+ return _.uniq(strings)
172
+ }
@@ -9,8 +9,7 @@ import { MapScope } from "./MapUtils"
9
9
  import RasterMapViewComponent from "./RasterMapViewComponent"
10
10
  import { areVectorMapsEnabled } from "./vectorMaps"
11
11
 
12
- /** Component that displays just the map */
13
- export function MapViewComponent(props: {
12
+ export interface MapViewComponentProps {
14
13
  schema: Schema
15
14
  dataSource: DataSource
16
15
  mapDataSource: MapDataSource
@@ -51,9 +50,18 @@ export function MapViewComponent(props: {
51
50
  /** Locale to use. Overrides map design locale */
52
51
  locale?: string
53
52
 
53
+ /** Translate function to use for display. TODO: implement this */
54
+ translate?: (input: string) => string
55
+
56
+ /** Increment to force refresh */
57
+ refreshTrigger?: number
58
+
54
59
  /** Whether to disable interaction or not. Default false (implemented for printing to reduce number of tiles request) */
55
60
  disableInteraction?: boolean
56
- }) {
61
+ }
62
+
63
+ /** Component that displays just the map */
64
+ export function MapViewComponent(props: MapViewComponentProps) {
57
65
  if (areVectorMapsEnabled()) {
58
66
  return <VectorMapViewComponent {...props} />
59
67
  } else {
@@ -1,9 +1,9 @@
1
1
  import _ from "lodash"
2
- import React from "react"
2
+ import React, { ReactNode } from "react"
3
3
 
4
4
  import { original, produce } from "immer"
5
5
 
6
- import Layer, { OnGridClickOptions, OnGridHoverOptions, VectorTileDef } from "./Layer"
6
+ import Layer, { OnGridClickOptions, OnGridHoverOptions, VectorTileDef, LegendOptions } from "./Layer"
7
7
  import { ExprCompiler, ExprCleaner, injectTableAlias, Schema, DataSource, ExprValidator } from "@mwater/expressions"
8
8
  import AxisBuilder from "../axes/AxisBuilder"
9
9
  import { OnGridClickResults, OnGridHoverResults } from "./maps"
@@ -16,6 +16,10 @@ import * as PopupFilterJoinsUtils from "./PopupFilterJoinsUtils"
16
16
  import { ExpressionSpecification, FilterSpecification, LayerSpecification } from "maplibre-gl"
17
17
  import HoverContent from "./HoverContent"
18
18
  import { getDefaultLayoutOptions } from "../dashboards/layoutOptions"
19
+ import Widget from "../widgets/Widget"
20
+ import { WidgetDataSource } from "../widgets/WidgetDataSource"
21
+ import BlocksLayoutManager from "../layouts/blocks/BlocksLayoutManager"
22
+ import { getTranslatableStringsFromLayoutManager } from "../dashboards/DashboardUtils"
19
23
 
20
24
  export default class MarkersLayer extends Layer<MarkersLayerDesign> {
21
25
  /** Gets the type of layer definition */
@@ -479,7 +483,8 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
479
483
  key: ev.data.id,
480
484
  schema: hoverOptions.schema,
481
485
  dataSource: hoverOptions.dataSource,
482
- design: hoverOptions.design,
486
+ table,
487
+ items: hoverOptions.design.hoverOver.items,
483
488
  filters: [
484
489
  {
485
490
  table,
@@ -492,7 +497,9 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
492
497
  ]
493
498
  }
494
499
  }
495
- ]
500
+ ],
501
+ locale: hoverOptions.locale,
502
+ translate: hoverOptions.translate
496
503
  })
497
504
  }
498
505
 
@@ -581,12 +588,12 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
581
588
  items: clickOptions.design.popup.items,
582
589
  layoutOptions: getDefaultLayoutOptions("default"),
583
590
  renderWidget: (options: any) => {
584
- const widget = WidgetFactory.createWidget(options.type)
591
+ const widget = WidgetFactory.createWidget(options.type) as Widget
585
592
 
586
593
  const filters = clickOptions.filters.concat(popupFilters)
587
594
 
588
595
  // Get data source for widget
589
- const widgetDataSource = clickOptions.layerDataSource.getPopupWidgetDataSource(
596
+ const widgetDataSource: WidgetDataSource = clickOptions.layerDataSource.getPopupWidgetDataSource(
590
597
  clickOptions.design,
591
598
  options.id
592
599
  )
@@ -598,10 +605,10 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
598
605
  design: options.design,
599
606
  scope: null,
600
607
  filters,
601
- onScopeChange: null,
602
- onDesignChange: null,
603
608
  width: options.width,
604
- height: options.height
609
+ height: options.height,
610
+ locale: clickOptions.locale,
611
+ translate: clickOptions.translate
605
612
  })
606
613
  }
607
614
  })
@@ -644,14 +651,8 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
644
651
 
645
652
  // Get the legend to be optionally displayed on the map. Returns
646
653
  // a React element
647
- getLegend(
648
- design: MarkersLayerDesign,
649
- schema: Schema,
650
- name: string,
651
- dataSource: DataSource,
652
- locale: string,
653
- filters: JsonQLFilter[]
654
- ) {
654
+ getLegend(options: LegendOptions<MarkersLayerDesign>): ReactNode {
655
+ const { design, schema, name, dataSource, locale, filters, translate } = options
655
656
  const _filters = filters.slice()
656
657
  if (design.filter != null) {
657
658
  const exprCompiler = new ExprCompiler(schema)
@@ -667,7 +668,7 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
667
668
  defaultColor: design.color,
668
669
  symbol: design.symbol || "font-awesome/circle",
669
670
  markerSize: design.markerSize,
670
- name,
671
+ name: translate(name),
671
672
  filters: _.compact(_filters),
672
673
  axis: axisBuilder.cleanAxis({
673
674
  axis: design.axes.color || null,
@@ -793,6 +794,30 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
793
794
 
794
795
  return null
795
796
  }
797
+
798
+ /** Get strings to be translated */
799
+ getTranslatableStrings(design: MarkersLayerDesign, schema: Schema): string[] {
800
+ const strings: string[] = []
801
+
802
+ // Add strings from hoverOver items
803
+ if (design.hoverOver && design.hoverOver.items) {
804
+ for (const item of design.hoverOver.items) {
805
+ if (item.label) {
806
+ strings.push(item.label)
807
+ }
808
+ }
809
+ }
810
+
811
+ // Add strings from popup items using a layout manager approach
812
+ if (design.popup && design.popup.items) {
813
+ const layoutManager = new BlocksLayoutManager()
814
+ const popupStrings = getTranslatableStringsFromLayoutManager(layoutManager, design.popup.items, schema)
815
+ strings.push(...popupStrings)
816
+ }
817
+
818
+ // Remove duplicates
819
+ return _.uniq(strings)
820
+ }
796
821
  }
797
822
 
798
823
  /**
@@ -936,3 +961,4 @@ export function createMarkersVectorQuery(baseQuery: JsonQLSelectQuery) {
936
961
 
937
962
  return outerquery
938
963
  }
964
+