@mwater/visualization 5.4.5 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/lib/MWaterContextComponent.d.ts +1 -1
  2. package/lib/MWaterContextComponent.js +1 -1
  3. package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
  4. package/lib/MWaterGlobalFiltersComponent.js +11 -20
  5. package/lib/MWaterLoaderComponent.d.ts +5 -14
  6. package/lib/MWaterLoaderComponent.js +2 -11
  7. package/lib/UndoStack.d.ts +2 -1
  8. package/lib/UndoStack.js +12 -6
  9. package/lib/dashboards/DashboardComponent.js +7 -5
  10. package/lib/dashboards/DashboardDesign.d.ts +1 -1
  11. package/lib/dashboards/LayoutOptionsComponent.js +18 -11
  12. package/lib/dashboards/ServerDashboardDataSource.d.ts +10 -1
  13. package/lib/dashboards/ServerDashboardDataSource.js +29 -10
  14. package/lib/dashboards/SettingsModalComponent.js +1 -1
  15. package/lib/dashboards/layoutOptions.d.ts +5 -1
  16. package/lib/datagrids/DatagridComponent.js +23 -3
  17. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
  18. package/lib/datagrids/DatagridDesignerComponent.js +108 -120
  19. package/lib/datagrids/DatagridViewComponent.js +3 -2
  20. package/lib/datagrids/ExprCellComponent.d.ts +1 -0
  21. package/lib/datagrids/ExprCellComponent.js +22 -20
  22. package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
  23. package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
  24. package/lib/index.css +45 -2
  25. package/lib/index.d.ts +5 -5
  26. package/lib/index.js +2 -3
  27. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
  28. package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
  29. package/lib/maps/BufferLayer.d.ts +18 -0
  30. package/lib/maps/BufferLayer.js +36 -14
  31. package/lib/maps/BufferLayerDesign.d.ts +1 -1
  32. package/lib/maps/BufferLayerDesignerComponent.js +2 -2
  33. package/lib/maps/ChoroplethLayer.d.ts +18 -0
  34. package/lib/maps/ChoroplethLayer.js +46 -25
  35. package/lib/maps/ChoroplethLayerDesign.d.ts +7 -3
  36. package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -22
  37. package/lib/maps/ChoroplethLayerDesigner.js +58 -89
  38. package/lib/maps/DirectMapDataSource.js +17 -10
  39. package/lib/maps/EditHoverOver.d.ts +4 -3
  40. package/lib/maps/EditHoverOver.js +64 -35
  41. package/lib/maps/HoverContent.d.ts +10 -5
  42. package/lib/maps/HoverContent.js +7 -36
  43. package/lib/maps/Layer.d.ts +37 -0
  44. package/lib/maps/Layer.js +30 -4
  45. package/lib/maps/LeafletMapComponent.js +10 -19
  46. package/lib/maps/MWaterServerLayer.d.ts +2 -2
  47. package/lib/maps/MWaterServerLayer.js +6 -6
  48. package/lib/maps/MapComponent.js +0 -1
  49. package/lib/maps/MapLayerDataSource.d.ts +9 -0
  50. package/lib/maps/MapUtils.d.ts +19 -1
  51. package/lib/maps/MapUtils.js +80 -1
  52. package/lib/maps/MarkersLayer.d.ts +18 -0
  53. package/lib/maps/MarkersLayer.js +42 -26
  54. package/lib/maps/MarkersLayerDesign.d.ts +1 -1
  55. package/lib/maps/MarkersLayerDesignerComponent.d.ts +12 -28
  56. package/lib/maps/MarkersLayerDesignerComponent.js +81 -111
  57. package/lib/maps/RasterMapViewComponent.js +1 -1
  58. package/lib/maps/ServerMapDataSource.d.ts +9 -0
  59. package/lib/maps/ServerMapDataSource.js +29 -10
  60. package/lib/maps/VectorMapViewComponent.js +7 -15
  61. package/lib/maps/maps.d.ts +4 -2
  62. package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
  63. package/lib/maps/symbols/font-awesome/ban.png +0 -0
  64. package/lib/maps/symbols/font-awesome/beer.png +0 -0
  65. package/lib/maps/symbols/font-awesome/bell.png +0 -0
  66. package/lib/maps/symbols/font-awesome/bolt.png +0 -0
  67. package/lib/maps/symbols/font-awesome/building.png +0 -0
  68. package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
  69. package/lib/maps/symbols/font-awesome/bus.png +0 -0
  70. package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
  71. package/lib/maps/symbols/font-awesome/certificate.png +0 -0
  72. package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
  73. package/lib/maps/symbols/font-awesome/check.png +0 -0
  74. package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  75. package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  76. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  77. package/lib/maps/symbols/font-awesome/cloud.png +0 -0
  78. package/lib/maps/symbols/font-awesome/comment.png +0 -0
  79. package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
  80. package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  81. package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  82. package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  83. package/lib/maps/symbols/font-awesome/female.png +0 -0
  84. package/lib/maps/symbols/font-awesome/file.png +0 -0
  85. package/lib/maps/symbols/font-awesome/flag.png +0 -0
  86. package/lib/maps/symbols/font-awesome/flask.png +0 -0
  87. package/lib/maps/symbols/font-awesome/h-square.png +0 -0
  88. package/lib/maps/symbols/font-awesome/home.png +0 -0
  89. package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
  90. package/lib/maps/symbols/font-awesome/male.png +0 -0
  91. package/lib/maps/symbols/font-awesome/medkit.png +0 -0
  92. package/lib/maps/symbols/font-awesome/mobile.png +0 -0
  93. package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
  94. package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
  95. package/lib/maps/symbols/font-awesome/plus.png +0 -0
  96. package/lib/maps/symbols/font-awesome/square.png +0 -0
  97. package/lib/maps/symbols/font-awesome/star.png +0 -0
  98. package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
  99. package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
  100. package/lib/maps/symbols/font-awesome/ticket.png +0 -0
  101. package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
  102. package/lib/maps/symbols/font-awesome/times.png +0 -0
  103. package/lib/maps/symbols/font-awesome/tint.png +0 -0
  104. package/lib/maps/symbols/font-awesome/tree.png +0 -0
  105. package/lib/maps/symbols/font-awesome/university.png +0 -0
  106. package/lib/maps/symbols/font-awesome/usd.png +0 -0
  107. package/lib/maps/symbols/font-awesome/user.png +0 -0
  108. package/lib/maps/symbols/font-awesome/users.png +0 -0
  109. package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
  110. package/lib/maps/symbols/sdf-ize.sh +93 -0
  111. package/lib/maps/vectorMaps.d.ts +1 -0
  112. package/lib/maps/vectorMaps.js +20 -36
  113. package/lib/mwater_table_selection/FormsListComponent.d.ts +33 -0
  114. package/lib/mwater_table_selection/FormsListComponent.js +141 -0
  115. package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +49 -0
  116. package/lib/mwater_table_selection/IndicatorsListComponent.js +251 -0
  117. package/lib/mwater_table_selection/IssuesListComponent.d.ts +29 -0
  118. package/lib/mwater_table_selection/IssuesListComponent.js +123 -0
  119. package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.d.ts +20 -0
  120. package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.js +157 -0
  121. package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.d.ts +17 -0
  122. package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.js +79 -0
  123. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
  124. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
  125. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +63 -0
  126. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +461 -0
  127. package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.d.ts +17 -0
  128. package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.js +94 -0
  129. package/lib/mwater_table_selection/MWaterMetricsTableListComponent.d.ts +17 -0
  130. package/lib/mwater_table_selection/MWaterMetricsTableListComponent.js +80 -0
  131. package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +32 -0
  132. package/lib/mwater_table_selection/MWaterTableSelectComponent.js +163 -0
  133. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
  134. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
  135. package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
  136. package/lib/quickfilter/QuickfiltersComponent.js +53 -110
  137. package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
  138. package/lib/quickfilter/TextLiteralComponent.js +85 -82
  139. package/lib/widgets/MapWidget.js +4 -2
  140. package/lib/widgets/charts/Chart.d.ts +11 -0
  141. package/lib/widgets/charts/Chart.js +15 -0
  142. package/lib/widgets/charts/ChartWidgetComponent.d.ts +1 -0
  143. package/lib/widgets/charts/ChartWidgetComponent.js +27 -1
  144. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +1 -1
  145. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +1 -1
  146. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +5 -12
  147. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +43 -57
  148. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +113 -110
  149. package/lib/widgets/charts/layered/LayeredChartUtils.d.ts +2 -1
  150. package/lib/widgets/charts/layered/LayeredChartUtils.js +0 -2
  151. package/lib/widgets/charts/pivot/PivotChart.d.ts +2 -0
  152. package/lib/widgets/charts/pivot/PivotChart.js +156 -0
  153. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +5 -20
  154. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +31 -61
  155. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +4 -0
  156. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +4 -2
  157. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.d.ts +5 -44
  158. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +38 -63
  159. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +7 -68
  160. package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +58 -106
  161. package/lib/widgets/charts/table/TableChart.d.ts +2 -0
  162. package/lib/widgets/charts/table/TableChart.js +172 -1
  163. package/lib/widgets/charts/table/TableChartDesignerComponent.d.ts +7 -17
  164. package/lib/widgets/charts/table/TableChartDesignerComponent.js +79 -95
  165. package/lib/widgets/charts/table/TableChartViewComponent.d.ts +1 -7
  166. package/lib/widgets/charts/table/TableChartViewComponent.js +19 -27
  167. package/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
  168. package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
  169. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
  170. package/package.json +4 -10
  171. package/src/MWaterContextComponent.tsx +2 -2
  172. package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
  173. package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +18 -19
  174. package/src/UndoStack.ts +14 -6
  175. package/src/dashboards/DashboardComponent.tsx +7 -5
  176. package/src/dashboards/DashboardDesign.ts +1 -1
  177. package/src/dashboards/LayoutOptionsComponent.tsx +22 -10
  178. package/src/dashboards/ServerDashboardDataSource.ts +36 -13
  179. package/src/dashboards/SettingsModalComponent.tsx +1 -1
  180. package/src/dashboards/layoutOptions.tsx +5 -1
  181. package/src/datagrids/DatagridComponent.tsx +31 -3
  182. package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
  183. package/src/datagrids/DatagridViewComponent.tsx +3 -2
  184. package/src/datagrids/ExprCellComponent.tsx +23 -20
  185. package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
  186. package/src/index.css +45 -2
  187. package/src/index.ts +5 -11
  188. package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
  189. package/src/maps/BufferLayer.ts +48 -20
  190. package/src/maps/BufferLayerDesign.ts +1 -1
  191. package/src/maps/BufferLayerDesignerComponent.tsx +2 -1
  192. package/src/maps/ChoroplethLayer.ts +70 -39
  193. package/src/maps/ChoroplethLayerDesign.ts +6 -2
  194. package/src/maps/ChoroplethLayerDesigner.tsx +171 -167
  195. package/src/maps/DirectMapDataSource.ts +21 -13
  196. package/src/maps/EditHoverOver.tsx +98 -54
  197. package/src/maps/HoverContent.tsx +17 -48
  198. package/src/maps/Layer.ts +42 -4
  199. package/src/maps/LeafletMapComponent.tsx +10 -19
  200. package/src/maps/MWaterServerLayer.ts +6 -6
  201. package/src/maps/MapComponent.ts +0 -1
  202. package/src/maps/MapLayerDataSource.ts +8 -0
  203. package/src/maps/MapUtils.ts +82 -3
  204. package/src/maps/MarkersLayer.ts +54 -27
  205. package/src/maps/MarkersLayerDesign.ts +1 -1
  206. package/src/maps/MarkersLayerDesignerComponent.tsx +360 -0
  207. package/src/maps/RasterMapViewComponent.ts +1 -1
  208. package/src/maps/ServerMapDataSource.ts +35 -12
  209. package/src/maps/VectorMapViewComponent.tsx +8 -19
  210. package/src/maps/maps.ts +4 -2
  211. package/src/maps/symbols/font-awesome/asterisk.png +0 -0
  212. package/src/maps/symbols/font-awesome/ban.png +0 -0
  213. package/src/maps/symbols/font-awesome/beer.png +0 -0
  214. package/src/maps/symbols/font-awesome/bell.png +0 -0
  215. package/src/maps/symbols/font-awesome/bolt.png +0 -0
  216. package/src/maps/symbols/font-awesome/building.png +0 -0
  217. package/src/maps/symbols/font-awesome/bullseye.png +0 -0
  218. package/src/maps/symbols/font-awesome/bus.png +0 -0
  219. package/src/maps/symbols/font-awesome/caret-up.png +0 -0
  220. package/src/maps/symbols/font-awesome/certificate.png +0 -0
  221. package/src/maps/symbols/font-awesome/check-circle.png +0 -0
  222. package/src/maps/symbols/font-awesome/check.png +0 -0
  223. package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  224. package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  225. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  226. package/src/maps/symbols/font-awesome/cloud.png +0 -0
  227. package/src/maps/symbols/font-awesome/comment.png +0 -0
  228. package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
  229. package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  230. package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  231. package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  232. package/src/maps/symbols/font-awesome/female.png +0 -0
  233. package/src/maps/symbols/font-awesome/file.png +0 -0
  234. package/src/maps/symbols/font-awesome/flag.png +0 -0
  235. package/src/maps/symbols/font-awesome/flask.png +0 -0
  236. package/src/maps/symbols/font-awesome/h-square.png +0 -0
  237. package/src/maps/symbols/font-awesome/home.png +0 -0
  238. package/src/maps/symbols/font-awesome/info-circle.png +0 -0
  239. package/src/maps/symbols/font-awesome/male.png +0 -0
  240. package/src/maps/symbols/font-awesome/medkit.png +0 -0
  241. package/src/maps/symbols/font-awesome/mobile.png +0 -0
  242. package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
  243. package/src/maps/symbols/font-awesome/plus-square.png +0 -0
  244. package/src/maps/symbols/font-awesome/plus.png +0 -0
  245. package/src/maps/symbols/font-awesome/square.png +0 -0
  246. package/src/maps/symbols/font-awesome/star.png +0 -0
  247. package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
  248. package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
  249. package/src/maps/symbols/font-awesome/ticket.png +0 -0
  250. package/src/maps/symbols/font-awesome/times-circle.png +0 -0
  251. package/src/maps/symbols/font-awesome/times.png +0 -0
  252. package/src/maps/symbols/font-awesome/tint.png +0 -0
  253. package/src/maps/symbols/font-awesome/tree.png +0 -0
  254. package/src/maps/symbols/font-awesome/university.png +0 -0
  255. package/src/maps/symbols/font-awesome/usd.png +0 -0
  256. package/src/maps/symbols/font-awesome/user.png +0 -0
  257. package/src/maps/symbols/font-awesome/users.png +0 -0
  258. package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
  259. package/src/maps/symbols/sdf-ize.sh +93 -0
  260. package/src/maps/vectorMaps.tsx +20 -44
  261. package/src/mwater_table_selection/FormsListComponent.tsx +188 -0
  262. package/src/mwater_table_selection/IndicatorsListComponent.tsx +411 -0
  263. package/src/mwater_table_selection/IssuesListComponent.tsx +167 -0
  264. package/src/mwater_table_selection/MWaterAccountingSystemListComponent.tsx +225 -0
  265. package/src/{MWaterAssetSystemsListComponent.tsx → mwater_table_selection/MWaterAssetSystemsListComponent.tsx} +2 -2
  266. package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
  267. package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +713 -0
  268. package/src/{MWaterCustomTablesetListComponent.tsx → mwater_table_selection/MWaterCustomTablesetListComponent.tsx} +1 -1
  269. package/src/{MWaterMetricsTableListComponent.tsx → mwater_table_selection/MWaterMetricsTableListComponent.tsx} +1 -1
  270. package/src/{MWaterTableSelectComponent.tsx → mwater_table_selection/MWaterTableSelectComponent.tsx} +91 -90
  271. package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
  272. package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
  273. package/src/quickfilter/TextLiteralComponent.tsx +197 -0
  274. package/src/widgets/MapWidget.tsx +9 -1
  275. package/src/widgets/charts/Chart.ts +17 -0
  276. package/src/widgets/charts/ChartWidgetComponent.tsx +36 -1
  277. package/src/widgets/charts/layered/LayeredChartDesign.ts +1 -1
  278. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +23 -24
  279. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +260 -211
  280. package/src/widgets/charts/layered/LayeredChartUtils.ts +7 -7
  281. package/src/widgets/charts/pivot/PivotChart.ts +191 -0
  282. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +124 -129
  283. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +4 -2
  284. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +120 -149
  285. package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +178 -198
  286. package/src/widgets/charts/table/TableChart.ts +177 -1
  287. package/src/widgets/charts/table/TableChartDesignerComponent.tsx +422 -0
  288. package/src/widgets/charts/table/{TableChartViewComponent.ts → TableChartViewComponent.tsx} +65 -60
  289. package/src/widgets/text/ExprItemEditorComponent.tsx +83 -77
  290. package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
  291. package/test/UndoStackTests.ts +52 -1
  292. package/.storybook/config.js +0 -7
  293. package/.storybook/head.html +0 -4
  294. package/.storybook/webpack.config.js +0 -15
  295. package/src/MWaterCompleteTableSelectComponent.tsx +0 -975
  296. package/src/maps/BingLayer.ts +0 -146
  297. package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
  298. package/src/quickfilter/TextLiteralComponent.ts +0 -165
  299. package/src/widgets/charts/table/TableChartDesignerComponent.ts +0 -441
  300. package/stories/UpdateableComponent.js +0 -29
  301. package/stories/consoles.js +0 -202
  302. package/stories/dashboards.js +0 -217
  303. package/stories/datagridDesign.js +0 -114
  304. package/stories/datagrids.js +0 -69
  305. package/stories/dates.js +0 -80
  306. package/stories/exprcomponent.js +0 -43
  307. package/stories/index.js +0 -18
  308. package/stories/leaflet.js +0 -59
  309. package/stories/maps.js +0 -24
  310. package/stories/pivotChart.js +0 -235
@@ -0,0 +1,422 @@
1
+ import _ from "lodash"
2
+ import React from "react"
3
+ import uuid from "uuid"
4
+ import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
5
+ import AxisBuilder from "../../../axes/AxisBuilder"
6
+ import { ExprComponent } from "@mwater/expressions-ui"
7
+ import { FilterExprComponent } from "@mwater/expressions-ui"
8
+ import OrderingsComponent from "./OrderingsComponent"
9
+ import { TableSelectComponent } from "@mwater/expressions-ui"
10
+ import ReorderableListComponent from "@mwater/react-library/lib/reorderable/ReorderableListComponent"
11
+ import * as ui from "@mwater/react-library/lib/bootstrap"
12
+ import { getFormatOptions } from "../../../valueFormatter"
13
+ import { getDefaultFormat } from "../../../valueFormatter"
14
+ import { TableChartColumn, TableChartDesign } from "./TableChart"
15
+ import AxisComponent from "../../../axes/AxisComponent"
16
+ import { Axis } from "../../../axes/Axis"
17
+
18
+ import { LocaleContext } from "@mwater/expressions-ui"
19
+
20
+ export interface TableChartDesignerComponentProps {
21
+ design: TableChartDesign
22
+ schema: Schema
23
+ dataSource: DataSource
24
+ onDesignChange: (design: TableChartDesign) => void
25
+ }
26
+
27
+ export default class TableChartDesignerComponent extends React.Component<TableChartDesignerComponentProps> {
28
+ // Updates design with the specified changes
29
+ updateDesign(changes: Partial<TableChartDesign>) {
30
+ const design = _.extend({}, this.props.design, changes) as TableChartDesign
31
+ this.props.onDesignChange(design)
32
+ }
33
+
34
+ handleTitleTextChange = (ev: any) => {
35
+ this.updateDesign({ titleText: ev.target.value })
36
+ }
37
+ handleTableChange = (table: any) => {
38
+ this.updateDesign({ table })
39
+ }
40
+ handleFilterChange = (filter: any) => {
41
+ this.updateDesign({ filter })
42
+ }
43
+ handleOrderingsChange = (orderings: any) => {
44
+ this.updateDesign({ orderings })
45
+ }
46
+ handleLimitChange = (limit: any) => {
47
+ this.updateDesign({ limit })
48
+ }
49
+
50
+ handleColumnChange = (index: any, column: any) => {
51
+ const columns = this.props.design.columns.slice()
52
+ columns[index] = column
53
+ this.updateDesign({ columns })
54
+ }
55
+
56
+ handleRemoveColumn = (index: any) => {
57
+ const columns = this.props.design.columns.slice()
58
+ columns.splice(index, 1)
59
+ this.updateDesign({ columns })
60
+ }
61
+
62
+ handleAddColumn = () => {
63
+ const columns = this.props.design.columns.slice()
64
+ columns.push({ id: uuid() })
65
+ this.updateDesign({ columns })
66
+ }
67
+
68
+ renderTable() {
69
+ return (
70
+ <div className="mb-3">
71
+ <label className="text-muted"><i className="fa fa-database" /> {T`Data Source`}</label>
72
+ : <TableSelectComponent
73
+ schema={this.props.schema}
74
+ value={this.props.design.table}
75
+ onChange={this.handleTableChange}
76
+ filter={this.props.design.filter}
77
+ onFilterChange={this.handleFilterChange}
78
+ />
79
+ </div>
80
+ )
81
+ }
82
+
83
+ renderTitle() {
84
+ return (
85
+ <div className="mb-3">
86
+ <label className="text-muted">{T`Title`}</label>
87
+ <input
88
+ type="text"
89
+ className="form-control form-control-sm"
90
+ value={this.props.design.titleText}
91
+ onChange={this.handleTitleTextChange}
92
+ placeholder={T`Untitled`}
93
+ />
94
+ </div>
95
+ )
96
+ }
97
+
98
+ renderColumn = (column: any, index: any, connectDragSource: any, connectDragPreview: any, connectDropTarget: any) => {
99
+ const style = {
100
+ borderTop: "solid 1px #EEE",
101
+ paddingTop: 10,
102
+ paddingBottom: 10
103
+ }
104
+
105
+ return connectDragPreview(
106
+ connectDropTarget(
107
+ <div key={index} style={style}>
108
+ <TableChartColumnDesignerComponent
109
+ design={this.props.design}
110
+ schema={this.props.schema}
111
+ dataSource={this.props.dataSource}
112
+ index={index}
113
+ onChange={this.handleColumnChange.bind(null, index)}
114
+ onRemove={this.handleRemoveColumn.bind(null, index)}
115
+ connectDragSource={connectDragSource}
116
+ />
117
+ </div>
118
+ )
119
+ )
120
+ }
121
+
122
+ handleReorder = (map: any) => {
123
+ return this.updateDesign({ columns: map })
124
+ }
125
+
126
+ renderColumns() {
127
+ if (!this.props.design.table) {
128
+ return
129
+ }
130
+
131
+ return (
132
+ <div>
133
+ <ReorderableListComponent
134
+ items={this.props.design.columns}
135
+ onReorder={this.handleReorder}
136
+ renderItem={this.renderColumn}
137
+ getItemId={(item: TableChartColumn) => item.id}
138
+ />
139
+ <button className="btn btn-secondary btn-sm" type="button" onClick={this.handleAddColumn}>
140
+ <span className="fas fa-plus" /> {T`Add Column`}
141
+ </button>
142
+ </div>
143
+ )
144
+ }
145
+ // return R 'div', className: "form-group",
146
+ // _.map(@props.design.columns, (column, i) => @renderColumn(i))
147
+ //
148
+
149
+ renderOrderings() {
150
+ // If no table, hide
151
+ if (!this.props.design.table) {
152
+ return null
153
+ }
154
+
155
+ return (
156
+ <div className="mb-3">
157
+ <label className="text-muted"><span className="fas fa-sort-amount-down" /> {T`Ordering`}</label>
158
+ <div style={{ marginLeft: 8 }}>
159
+ <OrderingsComponent
160
+ schema={this.props.schema}
161
+ dataSource={this.props.dataSource}
162
+ orderings={this.props.design.orderings}
163
+ onOrderingsChange={this.handleOrderingsChange}
164
+ table={this.props.design.table}
165
+ />
166
+ </div>
167
+ </div>
168
+ )
169
+ }
170
+
171
+ renderFilter() {
172
+ // If no table, hide
173
+ if (!this.props.design.table) {
174
+ return null
175
+ }
176
+
177
+ return (
178
+ <div className="mb-3">
179
+ <label className="text-muted"><span className="fas fa-filter" /> {T`Filters`}</label>
180
+ <div style={{ marginLeft: 8 }}>
181
+ <FilterExprComponent
182
+ schema={this.props.schema}
183
+ dataSource={this.props.dataSource}
184
+ onChange={this.handleFilterChange}
185
+ table={this.props.design.table}
186
+ value={this.props.design.filter}
187
+ />
188
+ </div>
189
+ </div>
190
+ )
191
+ }
192
+
193
+ renderLimit() {
194
+ // If no table, hide
195
+ if (!this.props.design.table) {
196
+ return null
197
+ }
198
+
199
+ return (
200
+ <div className="mb-3">
201
+ <label className="text-muted">{T`Maximum Number of Rows (up to 1000)`}</label>
202
+ <div style={{ marginLeft: 8 }}>
203
+ <ui.NumberInput
204
+ value={this.props.design.limit}
205
+ onChange={this.handleLimitChange}
206
+ decimal={false}
207
+ placeholder="1000"
208
+ />
209
+ </div>
210
+ </div>
211
+ )
212
+ }
213
+
214
+ render() {
215
+ return (
216
+ <div>
217
+ {this.renderTable()}
218
+ {this.renderColumns()}
219
+ {this.props.design.table ? <hr /> : undefined}
220
+ {this.renderOrderings()}
221
+ {this.renderFilter()}
222
+ {this.renderLimit()}
223
+ <hr />
224
+ {this.renderTitle()}
225
+ </div>
226
+ )
227
+ }
228
+ }
229
+
230
+ export interface TableChartColumnDesignerComponentProps {
231
+ design: TableChartDesign
232
+ schema: Schema
233
+ dataSource: DataSource
234
+ index: number
235
+ onChange: any
236
+ onRemove: any
237
+ connectDragSource: any
238
+ }
239
+
240
+ class TableChartColumnDesignerComponent extends React.Component<TableChartColumnDesignerComponentProps> {
241
+ static contextType = LocaleContext
242
+
243
+ // Updates column with the specified changes
244
+ updateColumn(changes: any) {
245
+ const column = _.extend({}, this.props.design.columns[this.props.index], changes)
246
+ return this.props.onChange(column)
247
+ }
248
+
249
+ updateTextAxis(changes: any) {
250
+ const textAxis = _.extend({}, this.props.design.columns[this.props.index].textAxis, changes)
251
+ return this.updateColumn({ textAxis })
252
+ }
253
+
254
+ handleExprChange = (expr: any) => {
255
+ return this.updateTextAxis({ expr })
256
+ }
257
+ handleHeaderTextChange = (ev: any) => {
258
+ return this.updateColumn({ headerText: ev.target.value })
259
+ }
260
+ handleAggrChange = (aggr: any) => {
261
+ return this.updateTextAxis({ aggr })
262
+ }
263
+ handleFormatChange = (ev: any) => {
264
+ return this.updateColumn({ format: ev.target.value })
265
+ }
266
+
267
+ renderRemove() {
268
+ if (this.props.design.columns.length > 1) {
269
+ return (
270
+ <button className="btn btn-sm btn-link float-end" type="button" onClick={this.props.onRemove}>
271
+ <span className="fas fa-times" />
272
+ </button>
273
+ )
274
+ }
275
+ return null
276
+ }
277
+
278
+ renderExpr() {
279
+ const column = this.props.design.columns[this.props.index]
280
+
281
+ const title = T`Value`
282
+
283
+ return (
284
+ <div>
285
+ <label className="text-muted">{title}</label>
286
+ : <ExprComponent
287
+ schema={this.props.schema}
288
+ dataSource={this.props.dataSource}
289
+ table={this.props.design.table}
290
+ value={column.textAxis ? column.textAxis.expr : null}
291
+ onChange={this.handleExprChange}
292
+ aggrStatuses={["literal", "individual", "aggregate"]}
293
+ />
294
+ </div>
295
+ )
296
+ }
297
+
298
+ renderFormat() {
299
+ const column = this.props.design.columns[this.props.index]
300
+
301
+ // Get type
302
+ const exprUtils = new ExprUtils(this.props.schema)
303
+ const exprType = exprUtils.getExprType(column.textAxis?.expr ?? null)
304
+ if (!exprType) {
305
+ return null
306
+ }
307
+
308
+ const formats = getFormatOptions(exprType)
309
+ if (!formats) {
310
+ return null
311
+ }
312
+
313
+ return (
314
+ <div className="mb-3">
315
+ <label className="text-muted">{T`Format`}</label>
316
+ : <select
317
+ value={column.format != null ? column.format : getDefaultFormat(exprType)}
318
+ className="form-select"
319
+ style={{ width: "auto", display: "inline-block" }}
320
+ onChange={this.handleFormatChange}
321
+ >
322
+ {_.map(formats, (format) => <option key={format.value} value={format.value}>{format.label}</option>)}
323
+ </select>
324
+ </div>
325
+ )
326
+ }
327
+
328
+ renderHeader() {
329
+ const column = this.props.design.columns[this.props.index]
330
+
331
+ const axisBuilder = new AxisBuilder({ schema: this.props.schema })
332
+ const placeholder = column.textAxis ? axisBuilder.summarizeAxis(column.textAxis ?? null, this.context): ""
333
+
334
+ return (
335
+ <div>
336
+ <label className="text-muted">{T`Header`}</label>
337
+ : <input
338
+ type="text"
339
+ className="form-control form-control-sm"
340
+ style={{ display: "inline-block", width: "15em" }}
341
+ value={column.headerText}
342
+ onChange={this.handleHeaderTextChange}
343
+ placeholder={placeholder}
344
+ />
345
+ </div>
346
+ )
347
+ }
348
+
349
+ renderSummarize() {
350
+ const column = this.props.design.columns[this.props.index]
351
+ const exprUtils = new ExprUtils(this.props.schema)
352
+ const exprType = exprUtils.getExprType(column.textAxis?.expr ?? null)
353
+ if (!exprType || exprType !== 'number') {
354
+ return null
355
+ }
356
+
357
+ return (
358
+ <div>
359
+ <ui.Checkbox value={column.summarize} inline={true} onChange={(summarize) => this.updateColumn({ summarize, summaryType: column.summaryType ?? 'sum' })}>{T`Summarize`}</ui.Checkbox>
360
+ {column.summarize ?
361
+ <div>
362
+ <label className="text-muted">{T`Summary Type`}</label>
363
+ : <ui.Select
364
+ inline={true}
365
+ value={column.summaryType}
366
+ onChange={(summaryType) => this.updateColumn({ summaryType })}
367
+ options={[{value: 'avg', label: T`Average`}, {value: 'sum', label: T`Sum`}, {value: 'min', label: T`Minimum`}, {value: 'max', label: T`Maximum`}]}
368
+ />
369
+ </div>
370
+ : undefined}
371
+ </div>
372
+ )
373
+ }
374
+
375
+ renderBackgroundColorAxis() {
376
+ const column = this.props.design.columns[this.props.index]
377
+
378
+ if(!column.textAxis) return null
379
+
380
+ return (
381
+ <ui.CollapsibleSection
382
+ label={T`Background color by data`}
383
+ labelMuted={true}
384
+ >
385
+ <AxisComponent
386
+ schema={this.props.schema}
387
+ dataSource={this.props.dataSource}
388
+ table={this.props.design.table}
389
+ types={["enum", "text", "boolean", "date"]}
390
+ value={column.backgroundColorAxis}
391
+ onChange={(backgroundColorAxis: Axis | null) => this.updateColumn({ backgroundColorAxis })}
392
+ showColorMap={true}
393
+ aggrNeed="optional"
394
+ />
395
+ </ui.CollapsibleSection>
396
+ )
397
+ }
398
+
399
+ render() {
400
+ const iconStyle = {
401
+ cursor: "move",
402
+ marginRight: 8,
403
+ opacity: 0.5,
404
+ fontSize: 12,
405
+ height: 20
406
+ }
407
+ return (
408
+ <div>
409
+ {this.props.connectDragSource(<i className="fa fa-bars" style={iconStyle} />)}
410
+ {this.renderRemove()}
411
+ <label>{T`Column ${this.props.index + 1}`}</label>
412
+ <div style={{ marginLeft: 5 }}>
413
+ {this.renderExpr()}
414
+ {this.renderFormat()}
415
+ {this.renderHeader()}
416
+ {this.renderSummarize()}
417
+ {this.renderBackgroundColorAxis()}
418
+ </div>
419
+ </div>
420
+ )
421
+ }
422
+ }
@@ -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 Linkify } from "react-linkify"
5
4
  import AxisBuilder from "../../../axes/AxisBuilder"
6
5
  import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
@@ -38,18 +37,18 @@ export default class TableChartViewComponent extends React.Component<TableChartV
38
37
  height: this.props.height
39
38
  }
40
39
 
41
- return R(
42
- "div",
43
- { style, className: "overflow-auto-except-print" },
44
- R("div", { style: { fontWeight: "bold", textAlign: "center" } }, this.props.design.titleText),
45
- R(TableContentsComponent, {
46
- columns: this.props.design.columns,
47
- table: this.props.design.table,
48
- data: this.props.data,
49
- schema: this.props.schema,
50
- dataSource: this.props.dataSource,
51
- onRowClick: this.props.onRowClick
52
- })
40
+ return (
41
+ <div style={style} className="overflow-auto-except-print">
42
+ <div style={{ fontWeight: "bold", textAlign: "center" }}>{this.props.design.titleText}</div>
43
+ <TableContentsComponent
44
+ columns={this.props.design.columns}
45
+ table={this.props.design.table}
46
+ data={this.props.data}
47
+ schema={this.props.schema}
48
+ dataSource={this.props.dataSource}
49
+ onRowClick={this.props.onRowClick}
50
+ />
51
+ </div>
53
52
  )
54
53
  }
55
54
  }
@@ -155,32 +154,30 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
155
154
  //(this.state.sort?.direction === 'asc' ? "":"")
156
155
  const text =
157
156
  column.headerText ?? (column.textAxis ? axisBuilder.summarizeAxis(column.textAxis, this.context) : "")
158
- return R(
159
- "th",
160
- {
161
- key: index,
162
- style: { cursor: "pointer" },
163
- onClick: () => this.handleSort(index)
164
- },
165
- text,
166
- this.state.sort?.column === index
167
- ? R("span", {
168
- style: { marginLeft: 10 },
169
- className: `fa ${this.state.sort?.direction === "asc" ? "fa-sort-asc" : "fa-sort-desc"}`
170
- })
171
- : undefined
157
+ return (
158
+ <th
159
+ key={index}
160
+ style={{ cursor: "pointer" }}
161
+ onClick={() => this.handleSort(index)}
162
+ >
163
+ {text}
164
+ {this.state.sort?.column === index ? (
165
+ <span
166
+ style={{ marginLeft: 10 }}
167
+ className={`fa ${this.state.sort?.direction === "asc" ? "fa-sort-asc" : "fa-sort-desc"}`}
168
+ />
169
+ ) : undefined}
170
+ </th>
172
171
  )
173
172
  }
174
173
 
175
174
  renderHeader() {
176
- return R(
177
- "thead",
178
- { key: "head" },
179
- R(
180
- "tr",
181
- { key: "head" },
182
- _.map(this.props.columns, (column, i) => this.renderHeaderCell(i))
183
- )
175
+ return (
176
+ <thead key="head">
177
+ <tr key="head">
178
+ {_.map(this.props.columns, (column, i) => this.renderHeaderCell(i))}
179
+ </tr>
180
+ </thead>
184
181
  )
185
182
  }
186
183
 
@@ -209,20 +206,28 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
209
206
  return null
210
207
  }
211
208
 
212
- return R(
213
- "tfoot",
214
- { key: "foot" },
215
- R(
216
- "tr",
217
- { key: "foot" },
218
- _.map(this.props.columns, (column, i) => R("th", { key: i }, this.renderFooterCell(i)))
219
- )
209
+ return (
210
+ <tfoot key="foot">
211
+ <tr key="foot">
212
+ {_.map(this.props.columns, (column, i) => <th key={i}>{this.renderFooterCell(i)}</th>)}
213
+ </tr>
214
+ </tfoot>
220
215
  )
221
216
  }
222
217
 
223
218
  renderImage(id: any) {
224
219
  const url = this.props.dataSource.getImageUrl(id)
225
- return R("a", { href: url, onClick: (e) => {e.stopPropagation()}, key: id, target: "_blank", style: { paddingLeft: 5, paddingRight: 5 } }, T`Image`)
220
+ return (
221
+ <a
222
+ href={url}
223
+ onClick={(e) => {e.stopPropagation()}}
224
+ key={id}
225
+ target="_blank"
226
+ style={{ paddingLeft: 5, paddingRight: 5 }}
227
+ >
228
+ {T`Image`}
229
+ </a>
230
+ )
226
231
  }
227
232
 
228
233
  renderCell(rowIndex: any, columnIndex: any) {
@@ -264,7 +269,7 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
264
269
  switch (exprType) {
265
270
  case "text":
266
271
  if (_.isString(value)) {
267
- node = R(Linkify, { properties: { target: "_blank" } }, value)
272
+ node = <Linkify properties={{ target: "_blank" }}>{value}</Linkify>
268
273
  }
269
274
  break
270
275
  case "number":
@@ -314,32 +319,32 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
314
319
  textColor = lightness < 0.3 ? "rgb(204,204,204)" : "inherit"
315
320
  }
316
321
 
317
- return R("td", { key: columnIndex, style: { backgroundColor, color: textColor } }, node)
322
+ return <td key={columnIndex} style={{ backgroundColor, color: textColor }}>{node}</td>
318
323
  }
319
324
 
320
325
  renderRow(index: any) {
321
- return R(
322
- "tr",
323
- { key: index, onClick: this.handleRowClick.bind(null, index) },
324
- _.map(this.props.columns, (column, i) => this.renderCell(index, i))
326
+ return (
327
+ <tr key={index} onClick={this.handleRowClick.bind(null, index)}>
328
+ {_.map(this.props.columns, (column, i) => this.renderCell(index, i))}
329
+ </tr>
325
330
  )
326
331
  }
327
332
 
328
333
  renderBody() {
329
- return R(
330
- "tbody",
331
- { key: "body" },
332
- _.map(this.state.data, (row, i) => this.renderRow(i))
334
+ return (
335
+ <tbody key="body">
336
+ {_.map(this.state.data, (row, i) => this.renderRow(i))}
337
+ </tbody>
333
338
  )
334
339
  }
335
340
 
336
341
  render() {
337
- return R(
338
- "table",
339
- { className: "mwater-visualization-table", style: { marginBottom: 0 } },
340
- this.renderHeader(),
341
- this.renderBody(),
342
- this.renderFooter()
342
+ return (
343
+ <table className="mwater-visualization-table" style={{ marginBottom: 0 }}>
344
+ {this.renderHeader()}
345
+ {this.renderBody()}
346
+ {this.renderFooter()}
347
+ </table>
343
348
  )
344
349
  }
345
350
  }