@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,6 +1,5 @@
1
1
  import _ from "lodash"
2
2
  import React from "react"
3
- const R = React.createElement
4
3
  import { default as ReactSelect } from "react-select"
5
4
  import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent"
6
5
  import DatagridViewComponent, { RowUpdate } from "./DatagridViewComponent"
@@ -47,14 +46,14 @@ export default class FindReplaceModalComponent extends React.Component<
47
46
  FindReplaceModalComponentProps,
48
47
  FindReplaceModalComponentState
49
48
  > {
50
- constructor(props: any) {
49
+ constructor(props: FindReplaceModalComponentProps) {
51
50
  super(props)
52
51
 
53
52
  this.state = {
54
- open: false, // True if modal is open
55
- replaceColumn: null, // Column id to replace
56
- withExpr: null, // Replace with expression
57
- conditionExpr: null, // Condition expr
53
+ open: false,
54
+ replaceColumn: null,
55
+ withExpr: null,
56
+ conditionExpr: null,
58
57
  busy: false
59
58
  }
60
59
  }
@@ -222,24 +221,27 @@ export default class FindReplaceModalComponent extends React.Component<
222
221
  }
223
222
  })
224
223
 
225
- return R(AutoSizeComponent, { injectWidth: true } as any, (size: any) => {
226
- return R(DatagridViewComponent, {
227
- width: size.width,
228
- height: 400,
229
- schema: this.props.schema,
230
- dataSource: this.props.dataSource,
231
- datagridDataSource: new DirectDatagridDataSource({
232
- schema: this.props.schema,
233
- dataSource: this.props.dataSource
234
- }),
235
- design,
236
- filters: this.props.filters
237
- })
238
- })
224
+ return (
225
+ <AutoSizeComponent injectWidth={true}>
226
+ {(size: any) => {
227
+ return <DatagridViewComponent
228
+ width={size.width}
229
+ height={400}
230
+ schema={this.props.schema}
231
+ dataSource={this.props.dataSource}
232
+ datagridDataSource={new DirectDatagridDataSource({
233
+ schema: this.props.schema,
234
+ dataSource: this.props.dataSource
235
+ })}
236
+ design={design}
237
+ filters={this.props.filters}
238
+ />
239
+ }}
240
+ </AutoSizeComponent>
241
+ )
239
242
  }
240
243
 
241
244
  renderContents() {
242
- let value
243
245
  const exprUtils = new ExprUtils(this.props.schema)
244
246
 
245
247
  // Determine which columns are replace-able. Excludes subtables and aggregates
@@ -254,80 +256,69 @@ export default class FindReplaceModalComponent extends React.Component<
254
256
 
255
257
  // Show progress
256
258
  if (this.state.busy) {
257
- return R(
258
- "div",
259
- null,
260
- R("h3", null, T`Working...`),
261
- R(
262
- "div",
263
- { className: "progress" },
264
- R("div", { className: "progress-bar progress-bar-striped progress-bar-animated", style: { width: `100%` } })
265
- )
259
+ return (
260
+ <div>
261
+ <h3>{T`Working...`}</h3>
262
+ <div className="progress">
263
+ <div className="progress-bar progress-bar-striped progress-bar-animated" style={{ width: "100%" }} />
264
+ </div>
265
+ </div>
266
266
  )
267
267
  }
268
268
 
269
- return R(
270
- "div",
271
- null,
272
- R(
273
- "div",
274
- { key: "replace", className: "mb-3" },
275
- R("label", null, T`Column with data to replace` + ": "),
276
- R(ReactSelect, {
277
- options: replaceColumnOptions,
278
- value: _.findWhere(replaceColumnOptions, { value: this.state.replaceColumn }) || null,
279
- onChange: (opt: any) => this.setState({ replaceColumn: opt.value }),
280
- placeholder: T`Select Column...`,
281
- styles: {
282
- // Keep menu above fixed data table headers
283
- menu: style => _.extend({}, style, { zIndex: 2 })
284
- }
285
- })
286
- ),
287
-
288
- (() => {
289
- if (this.state.replaceColumn) {
290
- // Get expr of replace column
291
- const replaceExpr = _.findWhere(this.props.design.columns, { id: this.state.replaceColumn })!.expr
292
-
293
- return R(
294
- "div",
295
- { key: "with", className: "mb-3" },
296
- R("label", null, T`Value to replace data with` + ": "),
297
- R(ExprComponent, {
298
- schema: this.props.schema,
299
- dataSource: this.props.dataSource,
300
- table: this.props.design.table!,
301
- value: this.state.withExpr,
302
- onChange: value => this.setState({ withExpr: value }),
303
- types: [exprUtils.getExprType(replaceExpr)!],
304
- enumValues: exprUtils.getExprEnumValues(replaceExpr) || undefined,
305
- idTable: exprUtils.getExprIdTable(replaceExpr) || undefined,
306
- preferLiteral: true,
307
- placeholder: T`(Blank)`,
308
- refExpr: replaceExpr
309
- })
310
- )
311
- }
312
- return null
313
- })(),
314
-
315
- R(
316
- "div",
317
- { key: "condition", className: "mb-3" },
318
- R("label", null, T`Only in rows that (optional)` + ":"),
319
- R(ExprComponent, {
320
- schema: this.props.schema,
321
- dataSource: this.props.dataSource,
322
- table: this.props.design.table!,
323
- value: this.state.conditionExpr,
324
- onChange: value => this.setState({ conditionExpr: value }),
325
- types: ["boolean"],
326
- placeholder: T`All Rows`
327
- })
328
- ),
329
-
330
- R("div", { key: "preview" }, R("h4", null, T`Preview`), this.renderPreview())
269
+ return (
270
+ <div>
271
+ <div key="replace" className="mb-3">
272
+ <label>{T`Column with data to replace`}: </label>
273
+ <ReactSelect
274
+ options={replaceColumnOptions}
275
+ value={_.findWhere(replaceColumnOptions, { value: this.state.replaceColumn }) || null}
276
+ onChange={(opt: any) => this.setState({ replaceColumn: opt.value })}
277
+ placeholder={T`Select Column...`}
278
+ styles={{
279
+ // Keep menu above fixed data table headers
280
+ menu: style => _.extend({}, style, { zIndex: 2 })
281
+ }}
282
+ />
283
+ </div>
284
+
285
+ {this.state.replaceColumn ? (
286
+ <div key="with" className="mb-3">
287
+ <label>{T`Value to replace data with`}: </label>
288
+ <ExprComponent
289
+ schema={this.props.schema}
290
+ dataSource={this.props.dataSource}
291
+ table={this.props.design.table!}
292
+ value={this.state.withExpr}
293
+ onChange={value => this.setState({ withExpr: value })}
294
+ types={[exprUtils.getExprType(_.findWhere(this.props.design.columns, { id: this.state.replaceColumn })!.expr)!]}
295
+ enumValues={exprUtils.getExprEnumValues(_.findWhere(this.props.design.columns, { id: this.state.replaceColumn })!.expr) || undefined}
296
+ idTable={exprUtils.getExprIdTable(_.findWhere(this.props.design.columns, { id: this.state.replaceColumn })!.expr) || undefined}
297
+ preferLiteral={true}
298
+ placeholder={T`(Blank)`}
299
+ refExpr={_.findWhere(this.props.design.columns, { id: this.state.replaceColumn })!.expr}
300
+ />
301
+ </div>
302
+ ) : null}
303
+
304
+ <div key="condition" className="mb-3">
305
+ <label>{T`Only in rows that (optional)`}:</label>
306
+ <ExprComponent
307
+ schema={this.props.schema}
308
+ dataSource={this.props.dataSource}
309
+ table={this.props.design.table!}
310
+ value={this.state.conditionExpr}
311
+ onChange={value => this.setState({ conditionExpr: value })}
312
+ types={["boolean"]}
313
+ placeholder={T`All Rows`}
314
+ />
315
+ </div>
316
+
317
+ <div key="preview">
318
+ <h4>{T`Preview`}</h4>
319
+ {this.renderPreview()}
320
+ </div>
321
+ </div>
331
322
  )
332
323
  }
333
324
 
@@ -336,36 +327,32 @@ export default class FindReplaceModalComponent extends React.Component<
336
327
  return null
337
328
  }
338
329
 
339
- return R(
340
- ModalPopupComponent,
341
- {
342
- size: "large",
343
- header: T`Find/Replace`,
344
- footer: [
345
- R(
346
- "button",
347
- {
348
- key: "cancel",
349
- type: "button",
350
- onClick: () => this.setState({ open: false }),
351
- className: "btn btn-secondary"
352
- },
353
- T`Cancel`
354
- ),
355
- R(
356
- "button",
357
- {
358
- key: "apply",
359
- type: "button",
360
- disabled: !this.state.replaceColumn || this.state.busy,
361
- onClick: () => this.performReplace(),
362
- className: "btn btn-primary"
363
- },
364
- T`Apply`
365
- )
366
- ]
367
- },
368
- this.renderContents()
330
+ return (
331
+ <ModalPopupComponent
332
+ size="large"
333
+ header={T`Find/Replace`}
334
+ footer={[
335
+ <button
336
+ key="cancel"
337
+ type="button"
338
+ onClick={() => this.setState({ open: false })}
339
+ className="btn btn-secondary"
340
+ >
341
+ {T`Cancel`}
342
+ </button>,
343
+ <button
344
+ key="apply"
345
+ type="button"
346
+ disabled={!this.state.replaceColumn || this.state.busy}
347
+ onClick={() => this.performReplace()}
348
+ className="btn btn-primary"
349
+ >
350
+ {T`Apply`}
351
+ </button>
352
+ ]}
353
+ >
354
+ {this.renderContents()}
355
+ </ModalPopupComponent>
369
356
  )
370
357
  }
371
358
  }
package/src/index.css CHANGED
@@ -434,7 +434,7 @@ Lato, Lora, Inter, Merriweather, Roboto
434
434
  .dropzone {
435
435
  width: 100%;
436
436
  padding: 80px 40px;
437
- border: 2px dashed rgb(102, 102, 102);
437
+ border: 2px dashed var(--bs-border-color);
438
438
  border-radius: 5px;
439
439
  text-align: center;
440
440
  vertical-align: middle;
package/src/index.ts CHANGED
@@ -45,7 +45,6 @@ export { WidgetDataSource } from "./widgets/WidgetDataSource"
45
45
  export { default as DirectWidgetDataSource } from "./widgets/DirectWidgetDataSource"
46
46
 
47
47
  import "leaflet/dist/leaflet.css"
48
- import "fixed-data-table-2/dist/fixed-data-table.min.css"
49
48
  import "rc-slider/assets/index.css"
50
49
  import "./layouts/decorated-block.css"
51
50
  import "react-datepicker/dist/react-datepicker.css"
@@ -84,7 +84,7 @@ export default class HorizontalBlockComponent extends React.Component<
84
84
  dragXOffset = this.state.rightSize - 100
85
85
  }
86
86
 
87
- return this.setState({ dragXOffset })
87
+ this.setState({ dragXOffset })
88
88
  }
89
89
 
90
90
  handleMouseUp = (ev: any) => {
@@ -93,7 +93,7 @@ export default class HorizontalBlockComponent extends React.Component<
93
93
  document.removeEventListener("mouseup", this.handleMouseUp)
94
94
 
95
95
  // Determine weights of two blocks
96
- const weights = this.props.block.weights || []
96
+ const weights = [...(this.props.block.weights || [])]
97
97
  const newLeftSize = this.state.leftSize + this.state.dragXOffset
98
98
  const newRightSize = this.state.rightSize - this.state.dragXOffset
99
99
 
@@ -14,7 +14,7 @@ export interface MWaterLoaderOptions {
14
14
  /** Load schema as a specific user (for shared dashboards, etc). optional */
15
15
  asUser?: string
16
16
  /** Extra tables to load in schema. Forms are not loaded by default as they are too many */
17
- extraTables: string[]
17
+ extraTables?: string[]
18
18
  /** False to disable local caching of queries. Default true */
19
19
  localCaching?: boolean
20
20
  /** Locales of the schema to load. Default is all. */
@@ -2,42 +2,24 @@ import _ from "lodash"
2
2
  import produce, { original } from "immer"
3
3
  import { JsonQLExpr, JsonQLQuery, JsonQLScalar, JsonQLSelect } from "@mwater/jsonql"
4
4
  import { DataSource, ExprCleaner, ExprCompiler, ExprValidator, injectTableAlias, Schema } from "@mwater/expressions"
5
- import React from "react"
5
+ import React, { ReactNode } from "react"
6
6
  import { JsonQLFilter } from "../JsonQLFilter"
7
7
  import AxisBuilder from "../axes/AxisBuilder"
8
8
  import { BufferLayerDesign } from "./BufferLayerDesign"
9
- import Layer, { OnGridClickOptions, OnGridHoverOptions, VectorTileDef } from "./Layer"
9
+ import Layer, { OnGridClickOptions, OnGridHoverOptions, VectorTileDef, LegendOptions } from "./Layer"
10
10
  import { OnGridClickResults, OnGridHoverResults } from "./maps"
11
11
  import { compileColorMapToMapbox } from "./mapboxUtils"
12
12
 
13
- import LegendGroup from "./LegendGroup"
14
13
  import LayerLegendComponent from "./LayerLegendComponent"
15
14
  import * as PopupFilterJoinsUtils from "./PopupFilterJoinsUtils"
16
15
  import { LayerSpecification } from "maplibre-gl"
17
16
  import HoverContent from "./HoverContent"
18
17
  import { getDefaultLayoutOptions } from "../dashboards/layoutOptions"
18
+ import Widget from "../widgets/Widget"
19
+ import BlocksLayoutManager from "../layouts/blocks/BlocksLayoutManager"
20
+ import { getTranslatableStringsFromLayoutManager } from "../dashboards/DashboardUtils"
19
21
 
20
- /*
21
- Layer which draws a buffer around geometries (i.e. a radius circle around points)
22
-
23
- Design is:
24
- table: table to get data from
25
- axes: axes (see below)
26
- filter: optional logical expression to filter by
27
- color: color of layer (e.g. #FF8800). Color axis overrides
28
- fillOpacity: Opacity to fill the circles (0-1)
29
- radius: radius to draw in meters
30
- minZoom: minimum zoom level
31
- maxZoom: maximum zoom level
32
-
33
- popup: contains items: which is BlocksLayoutManager items. Will be displayed when the circle is clicked
34
- popupFilterJoins: customizable filtering for popup. See PopupFilterJoins.md
35
-
36
- axes:
37
- geometry: where to draw buffers around
38
- color: color axis
39
-
40
- */
22
+ /** Layer which draws a buffer around geometries (i.e. a radius circle around points) */
41
23
  export default class BufferLayer extends Layer<BufferLayerDesign> {
42
24
  /** Gets the type of layer definition */
43
25
  getLayerDefinitionType(): "VectorTile" {
@@ -51,7 +33,7 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
51
33
  filters: JsonQLFilter[],
52
34
  opacity: number
53
35
  ): VectorTileDef {
54
- const jsonql = this.createJsonQL(design, schema, filters)
36
+ const jsonql = this.createVectorJsonQL(design, schema, filters)
55
37
 
56
38
  const mapLayers: LayerSpecification[] = []
57
39
 
@@ -95,7 +77,7 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
95
77
  }
96
78
  }
97
79
 
98
- createJsonQL(design: BufferLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLQuery {
80
+ createVectorJsonQL(design: BufferLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLQuery {
99
81
  let colorExpr: JsonQLExpr
100
82
  const axisBuilder = new AxisBuilder({ schema })
101
83
  const exprCompiler = new ExprCompiler(schema)
@@ -144,8 +126,15 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
144
126
  // ST_Expand(ST_MakeEnvelope(-180, -85, 180, 85, 4326), -<radius in degrees>))
145
127
  // , <radius in degrees>})
146
128
  // , 3857)
147
- // TODO document how we compute this
148
- const radiusDeg = design.radius / 100000
129
+
130
+ // Get radius expression
131
+ const radiusCompiledExpr: JsonQLExpr = exprCompiler.compileExpr({
132
+ expr: design.radiusExpr ?? { type: "literal", valueType: "number", value: design.radius },
133
+ tableAlias: "main"
134
+ })
135
+
136
+ // Convert radius in meters to a maximum number of degrees latitude
137
+ const radiusDegCompiledExpr: JsonQLExpr = { type: "op", op: "/", exprs: [radiusCompiledExpr, 100000] }
149
138
 
150
139
  const boundingBox: JsonQLExpr = {
151
140
  type: "op",
@@ -163,11 +152,14 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
163
152
  {
164
153
  type: "op",
165
154
  op: "ST_Expand",
166
- exprs: [{ type: "op", op: "ST_MakeEnvelope", exprs: [-180, -85, 180, 85, 4326] }, -radiusDeg]
155
+ exprs: [
156
+ { type: "op", op: "ST_MakeEnvelope", exprs: [-180, -85, 180, 85, 4326] },
157
+ { type: "op", op: "*", exprs: [radiusDegCompiledExpr, -1] }
158
+ ]
167
159
  }
168
160
  ]
169
161
  },
170
- radiusDeg
162
+ radiusDegCompiledExpr
171
163
  ]
172
164
  },
173
165
  3857
@@ -211,7 +203,7 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
211
203
  type: "op",
212
204
  op: "/",
213
205
  exprs: [
214
- design.radius,
206
+ radiusCompiledExpr,
215
207
  {
216
208
  type: "op",
217
209
  op: "cos",
@@ -349,6 +341,15 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
349
341
  const axisBuilder = new AxisBuilder({ schema })
350
342
  const exprCompiler = new ExprCompiler(schema)
351
343
 
344
+ // Get radius expression
345
+ const radiusCompiledExpr: JsonQLExpr = exprCompiler.compileExpr({
346
+ expr: design.radiusExpr ?? { type: "literal", valueType: "number", value: design.radius },
347
+ tableAlias: "main"
348
+ })
349
+
350
+ // Convert radius in meters to a maximum number of degrees latitude
351
+ const radiusDegCompiledExpr: JsonQLExpr = { type: "op", op: "/", exprs: [radiusCompiledExpr, 100000] }
352
+
352
353
  /*
353
354
  Query:
354
355
  select
@@ -383,7 +384,7 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
383
384
  type: "op",
384
385
  op: "/",
385
386
  exprs: [
386
- { type: "op", op: "*", exprs: [design.radius, 2] },
387
+ { type: "op", op: "*", exprs: [radiusCompiledExpr, 2] },
387
388
  {
388
389
  type: "op",
389
390
  op: "*",
@@ -438,16 +439,6 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
438
439
  from: exprCompiler.compileTable(design.table, "main")
439
440
  }
440
441
 
441
- // ST_Transform(ST_Expand(
442
- // # Prevent 3857 overflow (i.e. > 85 degrees lat)
443
- // ST_Intersection(
444
- // ST_Transform(!bbox!, 4326),
445
- // ST_Expand(ST_MakeEnvelope(-180, -85, 180, 85, 4326), -<radius in degrees>))
446
- // , <radius in degrees>})
447
- // , 3857)
448
- // TODO document how we compute this
449
- const radiusDeg = design.radius / 100000
450
-
451
442
  const boundingBox: JsonQLExpr = {
452
443
  type: "op",
453
444
  op: "ST_Transform",
@@ -464,11 +455,14 @@ export default class BufferLayer extends Layer<BufferLayerDesign> {
464
455
  {
465
456
  type: "op",
466
457
  op: "ST_Expand",
467
- exprs: [{ type: "op", op: "ST_MakeEnvelope", exprs: [-180, -85, 180, 85, 4326] }, -radiusDeg]
458
+ exprs: [
459
+ { type: "op", op: "ST_MakeEnvelope", exprs: [-180, -85, 180, 85, 4326] },
460
+ { type: "op", op: "*", exprs: [radiusDegCompiledExpr, -1] }
461
+ ]
468
462
  }
469
463
  ]
470
464
  },
471
- radiusDeg
465
+ radiusDegCompiledExpr
472
466
  ]
473
467
  },
474
468
  3857
@@ -662,7 +656,7 @@ marker-fill: ` +
662
656
  items: clickOptions.design.popup.items,
663
657
  layoutOptions: getDefaultLayoutOptions("default"),
664
658
  renderWidget: (options: any) => {
665
- const widget = WidgetFactory.createWidget(options.type)
659
+ const widget = WidgetFactory.createWidget(options.type) as Widget
666
660
 
667
661
  const filters = clickOptions.filters.concat(popupFilters)
668
662
 
@@ -679,10 +673,11 @@ marker-fill: ` +
679
673
  design: options.design,
680
674
  scope: null,
681
675
  filters,
682
- onScopeChange: null,
683
- onDesignChange: null,
676
+ onDesignChange: undefined,
684
677
  width: options.width,
685
- height: options.height
678
+ height: options.height,
679
+ locale: clickOptions.locale,
680
+ translate: clickOptions.translate
686
681
  })
687
682
  }
688
683
  })
@@ -721,8 +716,11 @@ marker-fill: ` +
721
716
  key: ev.data.id,
722
717
  schema: hoverOptions.schema,
723
718
  dataSource: hoverOptions.dataSource,
724
- design: hoverOptions.design,
725
- filters: popupFilters
719
+ table,
720
+ items: hoverOptions.design.hoverOver.items,
721
+ filters: popupFilters,
722
+ locale: hoverOptions.locale,
723
+ translate: hoverOptions.translate
726
724
  })
727
725
  }
728
726
 
@@ -773,14 +771,8 @@ marker-fill: ` +
773
771
 
774
772
  // Get the legend to be optionally displayed on the map. Returns
775
773
  // a React element
776
- getLegend(
777
- design: BufferLayerDesign,
778
- schema: Schema,
779
- name: string,
780
- dataSource: DataSource,
781
- locale: string,
782
- filters: JsonQLFilter[]
783
- ) {
774
+ getLegend(options: LegendOptions<BufferLayerDesign>): ReactNode {
775
+ const { design, schema, name, dataSource, locale, filters } = options
784
776
  const _filters = filters.slice()
785
777
  if (design.filter != null) {
786
778
  const exprCompiler = new ExprCompiler(schema)
@@ -865,7 +857,14 @@ marker-fill: ` +
865
857
  draft.color = design.color || "#0088FF"
866
858
 
867
859
  draft.axes = design.axes || {}
868
- draft.radius = design.radius || 1000
860
+
861
+ // Default radius if both radius and radiusExpr are not specified
862
+ if (design.radius == null && design.radiusExpr == null) {
863
+ draft.radius = 1000
864
+ draft.radiusExpr = { type: "literal", valueType: "number", value: 1000 }
865
+ }
866
+
867
+ // Default fill opacity
869
868
  draft.fillOpacity = design.fillOpacity != null ? design.fillOpacity : 0.5
870
869
 
871
870
  draft.axes.geometry = axisBuilder.cleanAxis({
@@ -896,7 +895,7 @@ marker-fill: ` +
896
895
  return T`Missing table`
897
896
  }
898
897
 
899
- if (design.radius == null) {
898
+ if (design.radius == null && design.radiusExpr == null) {
900
899
  return T`Missing radius`
901
900
  }
902
901
 
@@ -927,4 +926,28 @@ marker-fill: ` +
927
926
 
928
927
  return null
929
928
  }
929
+
930
+ /** Get strings to be translated */
931
+ getTranslatableStrings(design: BufferLayerDesign, schema: Schema): string[] {
932
+ const strings: string[] = []
933
+
934
+ // Add strings from hoverOver items
935
+ if (design.hoverOver && design.hoverOver.items) {
936
+ for (const item of design.hoverOver.items) {
937
+ if (item.label) {
938
+ strings.push(item.label)
939
+ }
940
+ }
941
+ }
942
+
943
+ // Add strings from popup items using a layout manager approach
944
+ if (design.popup && design.popup.items) {
945
+ const layoutManager = new BlocksLayoutManager()
946
+ const popupStrings = getTranslatableStringsFromLayoutManager(layoutManager, design.popup.items, schema)
947
+ strings.push(...popupStrings)
948
+ }
949
+
950
+ // Remove duplicates
951
+ return _.uniq(strings)
952
+ }
930
953
  }
@@ -1,48 +1,54 @@
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
  /** Layer which draws a buffer around geometries (i.e. a radius circle around points) */
6
8
  export interface BufferLayerDesign {
7
- /** table to get data from */
9
+ /** Table to get data from */
8
10
  table: string
9
11
 
10
- /** axes (see below) */
12
+ /** Axes (see below) */
11
13
  axes: {
12
- /** where to draw buffers around */
14
+ /** Where to draw buffers around */
13
15
  geometry: Axis | null
14
16
 
15
- /** color axis */
17
+ /** Color axis */
16
18
  color: Axis | null
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
27
  /** Opacity to fill the circles (0-1) */
26
28
  fillOpacity: number
27
29
 
28
- /** radius to draw in meters */
29
- radius: number
30
+ /** Radius to draw in meters @deprecated use radiusExpr instead */
31
+ radius?: number
30
32
 
31
- /** minimum zoom level */
33
+ /** Expression to get radius in meters */
34
+ radiusExpr?: Expr
35
+
36
+ /** Minimum zoom level */
32
37
  minZoom?: number
33
38
 
34
- /** maximum zoom level */
39
+ /** Maximum zoom level */
35
40
  maxZoom?: number
36
41
 
37
42
  /** True to union circles together. Makes ids unavailable as geometries are combined.
38
43
  * Only implemented for vector tiles */
39
44
  unionShapes?: boolean
40
45
 
41
- /** contains items: which is BlocksLayoutManager items. Will be displayed when the circle is clicked */
42
- popup: any
46
+ /** Contains items: which is BlocksLayoutManager items. Will be displayed when the circle is clicked */
47
+ popup: { items: LayoutBlock }
43
48
 
49
+ /** Contains items: which is HoverOverItem[] */
44
50
  hoverOver: { items: HoverOverItem[] }
45
51
 
46
- /** customizable filtering for popup. See PopupFilterJoins.md */
47
- popupFilterJoins: any
52
+ /** Customizable filtering for popup. See PopupFilterJoins.md */
53
+ popupFilterJoins: PopupFilterJoins
48
54
  }