@mwater/visualization 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/lib/ColorComponent.d.ts +10 -11
  2. package/lib/ColorComponent.js +78 -29
  3. package/lib/ColorSchemeFactory.d.ts +13 -2
  4. package/lib/ColorSchemeFactory.js +7 -5
  5. package/lib/CustomColorsContext.d.ts +6 -0
  6. package/lib/CustomColorsContext.js +6 -0
  7. package/lib/FiltersDesignerComponent.d.ts +1 -4
  8. package/lib/FiltersDesignerComponent.js +2 -3
  9. package/lib/GlobalFilter.d.ts +13 -0
  10. package/lib/GlobalFilter.js +2 -0
  11. package/lib/LocaleContextInjector.d.ts +5 -11
  12. package/lib/LocaleContextInjector.js +4 -12
  13. package/lib/MWaterAddRelatedFormComponent.js +3 -3
  14. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
  15. package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
  16. package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
  17. package/lib/MWaterCompleteTableSelectComponent.js +36 -36
  18. package/lib/MWaterContextComponent.d.ts +19 -9
  19. package/lib/MWaterContextComponent.js +38 -22
  20. package/lib/MWaterCustomTablesetListComponent.js +9 -3
  21. package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
  22. package/lib/MWaterGlobalFiltersComponent.js +4 -4
  23. package/lib/MWaterLoaderComponent.d.ts +15 -3
  24. package/lib/MWaterLoaderComponent.js +11 -2
  25. package/lib/MWaterTableSelectComponent.d.ts +1 -4
  26. package/lib/MWaterTableSelectComponent.js +10 -12
  27. package/lib/UIComponents.d.ts +2 -2
  28. package/lib/UIComponents.js +4 -12
  29. package/lib/axes/Axis.d.ts +20 -25
  30. package/lib/axes/AxisBuilder.d.ts +7 -4
  31. package/lib/axes/AxisBuilder.js +12 -8
  32. package/lib/axes/AxisComponent.d.ts +6 -9
  33. package/lib/axes/AxisComponent.js +1 -2
  34. package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
  35. package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
  36. package/lib/dashboards/DashboardComponent.d.ts +4 -17
  37. package/lib/dashboards/DashboardComponent.js +20 -67
  38. package/lib/dashboards/DashboardDesign.d.ts +5 -20
  39. package/lib/dashboards/DashboardUpgrader.js +36 -1
  40. package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
  41. package/lib/dashboards/DashboardViewComponent.js +112 -136
  42. package/lib/dashboards/FontStyleEditor.d.ts +8 -0
  43. package/lib/dashboards/FontStyleEditor.js +130 -0
  44. package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
  45. package/lib/dashboards/LayoutOptionsComponent.js +209 -39
  46. package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
  47. package/lib/dashboards/ServerDashboardDataSource.js +52 -33
  48. package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
  49. package/lib/dashboards/SettingsModalComponent.js +24 -38
  50. package/lib/dashboards/WidgetComponent.d.ts +3 -3
  51. package/lib/dashboards/WidgetComponent.js +3 -6
  52. package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
  53. package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
  54. package/lib/dashboards/layoutOptions.d.ts +83 -0
  55. package/lib/dashboards/layoutOptions.js +436 -10
  56. package/lib/datagrids/DatagridComponent.d.ts +2 -9
  57. package/lib/datagrids/DatagridDataSource.d.ts +3 -3
  58. package/lib/datagrids/DatagridDataSource.js +0 -14
  59. package/lib/datagrids/DatagridDesign.d.ts +7 -6
  60. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
  61. package/lib/datagrids/DatagridDesignerComponent.js +8 -6
  62. package/lib/datagrids/DatagridViewComponent.js +1 -1
  63. package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
  64. package/lib/datagrids/FindReplaceModalComponent.js +27 -13
  65. package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
  66. package/lib/datagrids/ServerDatagridDataSource.js +88 -36
  67. package/lib/demo.js +4 -4
  68. package/lib/index.css +5 -0
  69. package/lib/index.d.ts +2 -1
  70. package/lib/index.js +0 -1
  71. package/lib/layouts/LayoutManager.d.ts +33 -29
  72. package/lib/layouts/LayoutManager.js +2 -8
  73. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
  74. package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
  75. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
  76. package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
  77. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
  78. package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
  79. package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
  80. package/lib/mWaterLoader.d.ts +2 -0
  81. package/lib/mWaterLoader.js +2 -1
  82. package/lib/maps/AddLayerComponent.d.ts +6 -8
  83. package/lib/maps/AddLayerComponent.js +6 -6
  84. package/lib/maps/BingLayer.js +10 -20
  85. package/lib/maps/BufferLayer.js +5 -2
  86. package/lib/maps/ChoroplethLayer.js +2 -1
  87. package/lib/maps/ClusterLayer.js +3 -1
  88. package/lib/maps/DirectMapDataSource.d.ts +5 -2
  89. package/lib/maps/DirectMapDataSource.js +2 -1
  90. package/lib/maps/EditPopupComponent.js +2 -1
  91. package/lib/maps/GridLayer.js +5 -3
  92. package/lib/maps/GridLayerDesigner.js +0 -1
  93. package/lib/maps/LayerSwitcherComponent.js +1 -1
  94. package/lib/maps/MapComponent.d.ts +3 -11
  95. package/lib/maps/MapComponent.js +3 -3
  96. package/lib/maps/MapDesign.d.ts +2 -13
  97. package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
  98. package/lib/maps/MapFiltersDesignerComponent.js +4 -5
  99. package/lib/maps/MarkersLayer.js +30 -25
  100. package/lib/maps/RasterMapViewComponent.d.ts +3 -13
  101. package/lib/maps/RasterMapViewComponent.js +3 -3
  102. package/lib/maps/RegionSelectComponent.d.ts +2 -1
  103. package/lib/maps/ServerMapDataSource.d.ts +3 -4
  104. package/lib/maps/ServerMapDataSource.js +5 -5
  105. package/lib/maps/VectorMapViewComponent.js +2 -1
  106. package/lib/maps/mapSymbols.js +2 -0
  107. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  108. package/lib/maps/vectorMaps.d.ts +1 -0
  109. package/lib/maps/vectorMaps.js +70 -56
  110. package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
  111. package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
  112. package/lib/quickfilter/QuickfiltersComponent.js +3 -3
  113. package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
  114. package/lib/richtext/DropdownPaletteItem.js +82 -0
  115. package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
  116. package/lib/richtext/FontColorPaletteItem.js +32 -27
  117. package/lib/richtext/ItemsHtmlConverter.js +12 -3
  118. package/lib/richtext/RichTextComponent.d.ts +26 -52
  119. package/lib/richtext/RichTextComponent.js +166 -128
  120. package/lib/valueFormatter.js +6 -1
  121. package/lib/wellknown.d.ts +5 -0
  122. package/lib/wellknown.js +288 -0
  123. package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
  124. package/lib/widgets/DropdownWidgetComponent.js +48 -25
  125. package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
  126. package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
  127. package/lib/widgets/MapWidget.d.ts +4 -7
  128. package/lib/widgets/MapWidget.js +2 -1
  129. package/lib/widgets/MarkdownWidget.d.ts +2 -7
  130. package/lib/widgets/TOCWidget.d.ts +2 -9
  131. package/lib/widgets/TOCWidget.js +2 -1
  132. package/lib/widgets/Widget.d.ts +2 -0
  133. package/lib/widgets/WidgetDataSource.d.ts +3 -1
  134. package/lib/widgets/charts/Chart.d.ts +0 -1
  135. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  136. package/lib/widgets/charts/ChartViewComponent.js +11 -3
  137. package/lib/widgets/charts/ChartWidget.d.ts +1 -74
  138. package/lib/widgets/charts/ChartWidget.js +4 -183
  139. package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
  140. package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
  141. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
  142. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
  143. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
  144. package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
  145. package/lib/widgets/charts/layered/LayeredChart.js +6 -7
  146. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
  147. package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
  148. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
  149. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
  150. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
  151. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
  152. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
  153. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
  154. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
  155. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
  156. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
  157. package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
  158. package/lib/widgets/charts/pivot/PivotChart.js +47 -17
  159. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
  160. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
  161. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
  162. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
  163. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
  164. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
  165. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
  166. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
  167. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
  168. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
  169. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
  170. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
  171. package/lib/widgets/charts/table/TableChart.js +8 -4
  172. package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
  173. package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
  174. package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
  175. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
  176. package/lib/widgets/text/TextComponent.d.ts +5 -12
  177. package/lib/widgets/text/TextComponent.js +19 -39
  178. package/lib/widgets/text/TextWidget.d.ts +2 -1
  179. package/lib/widgets/text/TextWidget.js +5 -1
  180. package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
  181. package/lib/widgets/text/TextWidgetComponent.js +76 -19
  182. package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
  183. package/lib/widgets/text/TextWidgetDesign.js +6 -0
  184. package/package.json +4 -4
  185. package/src/ColorComponent.tsx +177 -0
  186. package/src/ColorSchemeFactory.ts +12 -6
  187. package/src/CustomColorsContext.tsx +8 -0
  188. package/src/FiltersDesignerComponent.ts +3 -4
  189. package/src/GlobalFilter.ts +17 -0
  190. package/src/LocaleContextInjector.tsx +14 -13
  191. package/src/MWaterAddRelatedFormComponent.ts +3 -3
  192. package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
  193. package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
  194. package/src/MWaterContextComponent.tsx +42 -33
  195. package/src/MWaterCustomTablesetListComponent.tsx +21 -3
  196. package/src/MWaterGlobalFiltersComponent.ts +8 -8
  197. package/src/MWaterLoaderComponent.ts +14 -4
  198. package/src/MWaterTableSelectComponent.tsx +11 -12
  199. package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
  200. package/src/axes/Axis.ts +24 -25
  201. package/src/axes/AxisBuilder.ts +16 -13
  202. package/src/axes/AxisComponent.ts +3 -4
  203. package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
  204. package/src/dashboards/DashboardComponent.tsx +73 -147
  205. package/src/dashboards/DashboardDesign.ts +5 -25
  206. package/src/dashboards/DashboardUpgrader.ts +41 -1
  207. package/src/dashboards/DashboardViewComponent.tsx +313 -0
  208. package/src/dashboards/FontStyleEditor.tsx +166 -0
  209. package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
  210. package/src/dashboards/ServerDashboardDataSource.ts +52 -33
  211. package/src/dashboards/SettingsModalComponent.tsx +170 -0
  212. package/src/dashboards/WidgetComponent.tsx +6 -12
  213. package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
  214. package/src/dashboards/layoutOptions.tsx +581 -0
  215. package/src/datagrids/DatagridDataSource.ts +6 -12
  216. package/src/datagrids/DatagridDesign.ts +8 -3
  217. package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
  218. package/src/datagrids/DatagridViewComponent.ts +3 -3
  219. package/src/datagrids/ExprCellComponent.ts +0 -1
  220. package/src/datagrids/FindReplaceModalComponent.ts +39 -22
  221. package/src/datagrids/ServerDatagridDataSource.ts +107 -45
  222. package/src/demo.ts +4 -4
  223. package/src/index.css +5 -0
  224. package/src/index.ts +2 -1
  225. package/src/layouts/LayoutManager.ts +44 -42
  226. package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
  227. package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
  228. package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
  229. package/src/mWaterLoader.ts +4 -1
  230. package/src/maps/AddLayerComponent.ts +9 -9
  231. package/src/maps/BingLayer.ts +16 -26
  232. package/src/maps/BufferLayer.ts +5 -2
  233. package/src/maps/ChoroplethLayer.ts +2 -1
  234. package/src/maps/ClusterLayer.ts +3 -1
  235. package/src/maps/DirectMapDataSource.ts +12 -3
  236. package/src/maps/EditPopupComponent.ts +2 -1
  237. package/src/maps/GridLayer.ts +5 -3
  238. package/src/maps/GridLayerDesigner.tsx +0 -1
  239. package/src/maps/LayerSwitcherComponent.tsx +1 -1
  240. package/src/maps/MapComponent.ts +3 -3
  241. package/src/maps/MapDesign.ts +2 -17
  242. package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
  243. package/src/maps/MarkersLayer.ts +38 -41
  244. package/src/maps/RasterMapViewComponent.ts +3 -3
  245. package/src/maps/ServerMapDataSource.ts +8 -8
  246. package/src/maps/VectorMapViewComponent.tsx +2 -2
  247. package/src/maps/mapSymbols.ts +2 -0
  248. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  249. package/src/maps/vectorMaps.tsx +88 -74
  250. package/src/quickfilter/QuickfilterCompiler.ts +1 -1
  251. package/src/quickfilter/QuickfiltersComponent.ts +3 -3
  252. package/src/richtext/DropdownPaletteItem.tsx +144 -0
  253. package/src/richtext/FontColorPaletteItem.tsx +160 -0
  254. package/src/richtext/ItemsHtmlConverter.ts +15 -5
  255. package/src/richtext/RichTextComponent.tsx +274 -232
  256. package/src/valueFormatter.ts +5 -1
  257. package/src/wellknown.ts +286 -0
  258. package/src/widgets/DropdownWidgetComponent.tsx +75 -0
  259. package/src/widgets/MapWidget.ts +5 -2
  260. package/src/widgets/TOCWidget.ts +2 -1
  261. package/src/widgets/Widget.ts +3 -0
  262. package/src/widgets/WidgetDataSource.ts +3 -1
  263. package/src/widgets/charts/Chart.ts +1 -1
  264. package/src/widgets/charts/ChartViewComponent.ts +16 -3
  265. package/src/widgets/charts/ChartWidget.ts +3 -275
  266. package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
  267. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
  268. package/src/widgets/charts/layered/LayeredChart.ts +4 -6
  269. package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
  270. package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
  271. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
  272. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
  273. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
  274. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
  275. package/src/widgets/charts/pivot/PivotChart.ts +56 -18
  276. package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
  277. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
  278. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
  279. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
  280. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
  281. package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
  282. package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
  283. package/src/widgets/charts/table/TableChart.ts +8 -4
  284. package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
  285. package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
  286. package/src/widgets/text/TextComponent.tsx +47 -49
  287. package/src/widgets/text/TextWidget.ts +8 -3
  288. package/src/widgets/text/TextWidgetComponent.tsx +249 -0
  289. package/src/widgets/text/TextWidgetDesign.ts +26 -2
  290. package/src/ColorComponent.ts +0 -117
  291. package/src/dashboards/DashboardViewComponent.ts +0 -304
  292. package/src/dashboards/SettingsModalComponent.ts +0 -169
  293. package/src/dashboards/layoutOptions.ts +0 -40
  294. package/src/layout-styles.css +0 -263
  295. package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
  296. package/src/layouts/grid/GridLayoutComponent.ts +0 -67
  297. package/src/layouts/grid/GridLayoutManager.ts +0 -185
  298. package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
  299. package/src/layouts/grid/PaletteItemComponent.ts +0 -28
  300. package/src/layouts/grid/README.md +0 -14
  301. package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
  302. package/src/richtext/FontColorPaletteItem.ts +0 -172
  303. package/src/richtext/FontSizePaletteItem.ts +0 -110
  304. package/src/widgets/DropdownWidgetComponent.ts +0 -78
  305. package/src/widgets/text/TextWidgetComponent.ts +0 -120
@@ -41,7 +41,8 @@ class TextWidget extends Widget_1.default {
41
41
  height: options.height,
42
42
  singleRowTable: options.singleRowTable,
43
43
  namedStrings: options.namedStrings,
44
- ref: options.widgetRef
44
+ ref: options.widgetRef,
45
+ refreshKey: options.refreshKey
45
46
  });
46
47
  }
47
48
  // Get the data that the widget needs. This will be called on the server, typically.
@@ -189,6 +190,9 @@ class TextWidget extends Widget_1.default {
189
190
  }
190
191
  // Get a list of table ids that can be filtered on
191
192
  getFilterableTables(design, schema) {
193
+ if (!design) {
194
+ return [];
195
+ }
192
196
  const exprItems = this.getExprItems(design.items);
193
197
  let filterableTables = lodash_1.default.map(exprItems, (exprItem) => exprItem.expr?.table);
194
198
  filterableTables = lodash_1.default.uniq(lodash_1.default.compact(filterableTables));
@@ -17,17 +17,29 @@ export interface TextWidgetComponentProps {
17
17
  /** Table that is filtered to have one row */
18
18
  singleRowTable?: string;
19
19
  namedStrings?: any;
20
+ /** A key that changes when the widget should be refreshed */
21
+ refreshKey?: any;
20
22
  }
21
23
  export default class TextWidgetComponent extends AsyncLoadComponent<TextWidgetComponentProps, {
22
24
  loading: boolean;
23
25
  exprValues: any;
24
26
  error: any;
25
27
  cacheExpiry: any;
28
+ editModalOpen: boolean;
26
29
  }> {
27
30
  divComp: HTMLElement | null;
28
- constructor(props: any);
31
+ constructor(props: TextWidgetComponentProps);
29
32
  isLoadNeeded(newProps: any, oldProps: any): boolean;
30
- load(props: any, prevProps: any, callback: any): void;
33
+ load(props: TextWidgetComponentProps, prevProps: TextWidgetComponentProps, callback: any): void;
31
34
  scrollToTOCEntry(entryId: any): void;
32
- render(): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
35
+ handleEditClick: () => void;
36
+ handleEditModalClose: () => void;
37
+ handleBackgroundColorChange: (color: string | null) => void;
38
+ handleSpacingChange: (spacing: number | null) => void;
39
+ handleBorderColorChange: (color: string | null) => void;
40
+ handleBorderThicknessChange: (thickness: number | null) => void;
41
+ handleBorderRadiusChange: (radius: number | null) => void;
42
+ renderEditModal(): React.JSX.Element | null;
43
+ renderTextComponent(): React.JSX.Element;
44
+ render(): React.JSX.Element;
33
45
  }
@@ -4,11 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const R = react_1.default.createElement;
8
7
  const lodash_1 = __importDefault(require("lodash"));
9
8
  const TextComponent_1 = __importDefault(require("./TextComponent"));
10
9
  const TextWidget_1 = __importDefault(require("./TextWidget"));
11
10
  const AsyncLoadComponent_1 = __importDefault(require("@mwater/react-library/lib/AsyncLoadComponent"));
11
+ const DropdownWidgetComponent_1 = __importDefault(require("../DropdownWidgetComponent"));
12
+ const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
13
+ const bootstrap_1 = require("@mwater/react-library/lib/bootstrap");
14
+ const ColorComponent_1 = __importDefault(require("../../ColorComponent"));
15
+ const bootstrap_2 = require("@mwater/react-library/lib/bootstrap");
12
16
  // Widget which displays styled text with embedded expressions
13
17
  class TextWidgetComponent extends AsyncLoadComponent_1.default {
14
18
  divComp;
@@ -19,7 +23,8 @@ class TextWidgetComponent extends AsyncLoadComponent_1.default {
19
23
  // Map of expression id to expression value
20
24
  exprValues: {},
21
25
  error: null,
22
- cacheExpiry: props.dataSource.getCacheExpiry() // Save cache expiry to see if changes
26
+ cacheExpiry: props.dataSource.getCacheExpiry(),
27
+ editModalOpen: false
23
28
  };
24
29
  }
25
30
  // Override to determine if a load is needed. Not called on mounting
@@ -42,7 +47,8 @@ class TextWidgetComponent extends AsyncLoadComponent_1.default {
42
47
  // Reload if filters or expressions have changed or cache expiry
43
48
  return (!lodash_1.default.isEqual(newProps.filters, oldProps.filters) ||
44
49
  !lodash_1.default.isEqual(getExprItems(newProps.design.items), getExprItems(oldProps.design.items)) ||
45
- newProps.dataSource.getCacheExpiry() !== this.state.cacheExpiry);
50
+ newProps.dataSource.getCacheExpiry() !== this.state.cacheExpiry ||
51
+ newProps.refreshKey !== oldProps.refreshKey);
46
52
  }
47
53
  // Call callback with state changes
48
54
  load(props, prevProps, callback) {
@@ -65,24 +71,75 @@ class TextWidgetComponent extends AsyncLoadComponent_1.default {
65
71
  return entry.scrollIntoView(true);
66
72
  }
67
73
  }
68
- render() {
74
+ handleEditClick = () => {
75
+ this.setState({ editModalOpen: true });
76
+ };
77
+ handleEditModalClose = () => {
78
+ this.setState({ editModalOpen: false });
79
+ };
80
+ handleBackgroundColorChange = (color) => {
81
+ const newDesign = { ...this.props.design, backgroundColor: color };
82
+ this.props.onDesignChange(newDesign);
83
+ };
84
+ handleSpacingChange = (spacing) => {
85
+ const newDesign = { ...this.props.design, padding: spacing ?? undefined };
86
+ this.props.onDesignChange(newDesign);
87
+ };
88
+ handleBorderColorChange = (color) => {
89
+ const newDesign = { ...this.props.design, borderColor: color };
90
+ this.props.onDesignChange(newDesign);
91
+ };
92
+ handleBorderThicknessChange = (thickness) => {
93
+ const newDesign = { ...this.props.design, borderThickness: thickness };
94
+ this.props.onDesignChange(newDesign);
95
+ };
96
+ handleBorderRadiusChange = (radius) => {
97
+ const newDesign = { ...this.props.design, borderRadius: radius };
98
+ this.props.onDesignChange(newDesign);
99
+ };
100
+ renderEditModal() {
101
+ if (!this.state.editModalOpen) {
102
+ return null;
103
+ }
104
+ const spacingOptions = [0, 5, 10, 15, 20, 25, 30, 35, 40].map(value => ({ value, label: `${value}px` }));
105
+ const borderThicknessOptions = [0, 1, 2, 3, 4, 5].map(value => ({ value, label: value === 0 ? "None" : `${value}px` }));
106
+ return (react_1.default.createElement(ActionCancelModalComponent_1.default, { title: "Edit Text Widget", onCancel: this.handleEditModalClose, onAction: this.handleEditModalClose },
107
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Background Color" },
108
+ react_1.default.createElement(ColorComponent_1.default, { color: this.props.design.backgroundColor || null, onChange: this.handleBackgroundColorChange }),
109
+ react_1.default.createElement("div", { className: "text-muted" }, "Choose a background color for the text widget")),
110
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Padding" },
111
+ react_1.default.createElement(bootstrap_2.Select, { value: this.props.design.padding ?? 0, onChange: this.handleSpacingChange, options: spacingOptions }),
112
+ react_1.default.createElement("div", { className: "text-muted" }, "Choose extra padding for the text widget")),
113
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Border Thickness", help: "Choose the border thickness for the text widget" },
114
+ react_1.default.createElement(bootstrap_2.Select, { value: this.props.design.borderThickness ?? 0, onChange: this.handleBorderThicknessChange, options: borderThicknessOptions })),
115
+ this.props.design.borderThickness &&
116
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Border Color", help: "Choose the border color for the text widget" },
117
+ react_1.default.createElement(ColorComponent_1.default, { color: this.props.design.borderColor || null, onChange: this.handleBorderColorChange })),
118
+ this.props.design.borderThickness &&
119
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Border Radius", help: "Choose the border radius for the text widget" },
120
+ react_1.default.createElement(bootstrap_2.Select, { value: this.props.design.borderRadius ?? 0, onChange: this.handleBorderRadiusChange, options: spacingOptions }))));
121
+ }
122
+ renderTextComponent() {
69
123
  // If loading, don't display old values
70
124
  const exprValues = !this.state.loading ? this.state.exprValues : {};
71
- return R("div", {
72
- ref: (c) => {
73
- this.divComp = c;
74
- }
75
- }, R(TextComponent_1.default, {
76
- design: this.props.design,
77
- onDesignChange: this.props.onDesignChange,
78
- schema: this.props.schema,
79
- dataSource: this.props.dataSource,
80
- exprValues,
81
- width: this.props.width,
82
- height: this.props.height,
83
- singleRowTable: this.props.singleRowTable,
84
- namedStrings: this.props.namedStrings
85
- }));
125
+ const padding = this.props.design.padding ?? 0;
126
+ return (react_1.default.createElement(TextComponent_1.default, { design: this.props.design, onDesignChange: this.props.onDesignChange, schema: this.props.schema, dataSource: this.props.dataSource, exprValues: exprValues, width: this.props.width ? this.props.width - padding * 2 : undefined, height: this.props.height ? this.props.height - padding * 2 : undefined, singleRowTable: this.props.singleRowTable, namedStrings: this.props.namedStrings }));
127
+ }
128
+ render() {
129
+ const borderStyle = this.props.design.borderThickness && this.props.design.borderColor
130
+ ? `${this.props.design.borderThickness}px solid ${this.props.design.borderColor}`
131
+ : undefined;
132
+ return (react_1.default.createElement("div", { style: {
133
+ backgroundColor: this.props.design.backgroundColor ?? undefined,
134
+ padding: this.props.design.padding != null ? `${this.props.design.padding}px` : undefined,
135
+ border: borderStyle,
136
+ borderRadius: this.props.design.borderRadius != null ? `${this.props.design.borderRadius}px` : undefined
137
+ }, ref: comp => this.divComp = comp },
138
+ this.props.onDesignChange ? (react_1.default.createElement(DropdownWidgetComponent_1.default, { dropdownItems: [{
139
+ label: "Edit",
140
+ onClick: this.handleEditClick
141
+ }] }, this.renderTextComponent())) : (this.renderTextComponent()),
142
+ this.renderEditModal()));
86
143
  }
87
144
  }
88
145
  exports.default = TextWidgetComponent;
@@ -1,6 +1,20 @@
1
+ import { HtmlItemExpr } from "../../richtext/ExprItemsHtmlConverter";
2
+ import { HtmlItem } from "../../richtext/ItemsHtmlConverter";
1
3
  export interface TextWidgetDesign {
2
4
  /** Text widget stores its content as array of items. See ItemsHtmlConverter TODO */
3
- items: any[];
5
+ items: (HtmlItem | HtmlItemExpr)[];
4
6
  /** "title" for title block. default is "default" */
5
- style?: "title" | "default";
7
+ style?: "title" | "default" | "header" | "footer";
8
+ /** Background color of the text widget (optional) */
9
+ backgroundColor?: string | null;
10
+ /** Extra padding for the text widget */
11
+ padding?: number;
12
+ /** Border color of the text widget (optional) */
13
+ borderColor?: string | null;
14
+ /** Border thickness of the text widget (optional) */
15
+ borderThickness?: number | null;
16
+ /** Border radius of the text widget (optional) */
17
+ borderRadius?: number | null;
6
18
  }
19
+ /** Returns true if the text widget design is empty. */
20
+ export declare function isEmptyTextWidgetDesign(design: TextWidgetDesign | undefined): boolean;
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmptyTextWidgetDesign = void 0;
4
+ /** Returns true if the text widget design is empty. */
5
+ function isEmptyTextWidgetDesign(design) {
6
+ return design == null || design.items.length === 0;
7
+ }
8
+ exports.isEmptyTextWidgetDesign = isEmptyTextWidgetDesign;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mwater/visualization",
3
- "version": "5.1.0",
3
+ "version": "5.3.0",
4
4
  "description": "Visualization library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  "async": "^1.2.1",
30
30
  "async-latest": "^1.0.0",
31
31
  "backbone": "~1.1.2",
32
- "billboard.js": "^3.6.3",
32
+ "billboard.js": "^3.13.0",
33
33
  "canonical-json": "0.0.4",
34
34
  "classnames": "^2.3.1",
35
35
  "color": "^3.2.1",
@@ -54,6 +54,7 @@
54
54
  "maplibre-gl": "^3.3.1",
55
55
  "markdown-it": "^12.0.4",
56
56
  "moment": "^2.29.1",
57
+ "p-queue": "^8.0.1",
57
58
  "pako": "^1.0.11",
58
59
  "prop-types": "^15.7.2",
59
60
  "querystring": "^0.2.0",
@@ -70,7 +71,7 @@
70
71
  "react-linkify": "^0.2.2",
71
72
  "react-motion": "^0.5.2",
72
73
  "react-onclickout": "^2.0.4",
73
- "react-select": "^5.1.0",
74
+ "react-select": "^5.8.0",
74
75
  "save-svg-as-png": "^1.4.17",
75
76
  "shallowequal": "^0.2.2",
76
77
  "update-object": "^1.0.0",
@@ -94,7 +95,6 @@
94
95
  "@types/react-color": "^2.17.6",
95
96
  "@types/react-datepicker": "^1.8.0",
96
97
  "@types/react-dropzone": "^5.1.0",
97
- "@types/react-select": "^3.0.27",
98
98
  "@types/uuid": "^3.4.10",
99
99
  "build-library": "github:mWater/build-library",
100
100
  "chai": "~2.0.0",
@@ -0,0 +1,177 @@
1
+ import React, { CSSProperties, useContext } from "react"
2
+ import ReactDOM from "react-dom"
3
+ import ClickOutHandler from "react-onclickout"
4
+ import { ColorState, SketchPicker, SwatchesPicker } from "react-color"
5
+ import { CustomColorsContext } from "./CustomColorsContext"
6
+
7
+ export interface ColorComponentProps {
8
+ color: string | null | undefined
9
+ onChange: (value: string | null) => void
10
+ disableReset?: boolean
11
+ }
12
+
13
+ interface ColorComponentState {
14
+ open: boolean
15
+ advanced: boolean
16
+ }
17
+
18
+ // Simple color well with popup
19
+ export default class ColorComponent extends React.Component<ColorComponentProps, ColorComponentState> {
20
+ constructor(props: ColorComponentProps) {
21
+ super(props)
22
+ this.state = { open: false, advanced: false }
23
+ }
24
+
25
+ handleClick = () => {
26
+ return this.setState({ open: !this.state.open, advanced: false })
27
+ }
28
+
29
+ handleColor = (color: ColorState) => {
30
+ return this.props.onChange(color.hex)
31
+ }
32
+
33
+ handleReset = () => {
34
+ this.setState({ open: false })
35
+ return this.props.onChange(null)
36
+ }
37
+
38
+ handleTransparent = () => {
39
+ this.setState({ open: false })
40
+ return this.props.onChange("transparent")
41
+ }
42
+
43
+ handleAdvanced = () => {
44
+ return this.setState({ advanced: !this.state.advanced })
45
+ }
46
+
47
+ renderPopup() {
48
+ if (!this.state.open || !this.colorWellRef) return null
49
+
50
+ const rect = this.colorWellRef.getBoundingClientRect()
51
+
52
+ const popupPosition: CSSProperties = {
53
+ position: "fixed",
54
+ top: `${rect.bottom + window.scrollY}px`,
55
+ left: `${rect.left + window.scrollX}px`,
56
+ zIndex: 1070,
57
+ backgroundColor: "white",
58
+ border: "solid 1px #DDD",
59
+ borderRadius: 3
60
+ }
61
+
62
+ return ReactDOM.createPortal(
63
+ <ClickOutHandler onClickOut={() => this.setState({ open: false })}>
64
+ <div style={popupPosition}>
65
+ {!this.props.disableReset && (
66
+ <button type="button" className="btn btn-link btn-sm" onClick={this.handleReset}>
67
+ <i className="fa fa-undo" />
68
+ {" Reset Color"}
69
+ </button>
70
+ )}
71
+ <button type="button" className="btn btn-link btn-sm" onClick={this.handleAdvanced}>
72
+ {this.state.advanced ? "Basic" : "Advanced"}
73
+ </button>
74
+
75
+ <CustomColors
76
+ color={this.props.color}
77
+ onChange={this.props.onChange}
78
+ />
79
+ {this.state.advanced ? (
80
+ <SketchPicker
81
+ color={this.props.color || undefined}
82
+ disableAlpha={true}
83
+ onChangeComplete={this.handleColor}
84
+ />
85
+ ) : (
86
+ <SwatchesPicker
87
+ color={this.props.color || undefined}
88
+ onChangeComplete={this.handleColor}
89
+ />
90
+ )}
91
+ </div>
92
+ </ClickOutHandler>,
93
+ document.body
94
+ )
95
+ }
96
+
97
+ colorWellRef: HTMLDivElement | null = null
98
+
99
+ render() {
100
+ const style: CSSProperties = {
101
+ height: 20,
102
+ width: 20,
103
+ border: "solid 2px #888",
104
+ borderRadius: 4,
105
+ backgroundColor: this.props.color || undefined,
106
+ cursor: "pointer",
107
+ display: "inline-block"
108
+ }
109
+
110
+ if (!this.props.color) {
111
+ // http://lea.verou.me/css3patterns/#diagonal-stripes
112
+ style.backgroundColor = "#AAA"
113
+ style.backgroundImage =
114
+ "repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,.7) 2px, rgba(255,255,255,.7) 4px)"
115
+ }
116
+
117
+ return (
118
+ <div style={{ position: "relative", display: "inline-block" }}>
119
+ <div
120
+ style={style}
121
+ onClick={this.handleClick}
122
+ ref={ref => this.colorWellRef = ref}
123
+ />
124
+ {this.renderPopup()}
125
+ </div>
126
+ )
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Custom colors component for the color picker that allows the user to select from a set of custom colors
132
+ * that are defined in CSS variables.
133
+ * @param props
134
+ * @returns
135
+ */
136
+ function CustomColors(props: {
137
+ color: string | null | undefined
138
+ onChange: (value: string | null) => void
139
+ }) {
140
+ const customColors = useContext(CustomColorsContext)
141
+
142
+ return (
143
+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 42px)', gap: 8, margin: 5, marginLeft: 16 }}>
144
+ {customColors?.customColors.filter(color => color != null).map((color) => {
145
+ const isSelected = props.color === color
146
+
147
+ return (
148
+ <div
149
+ key={color}
150
+ title={color}
151
+ tabIndex={0}
152
+ onClick={() => props.onChange(color)}
153
+ style={{
154
+ background: color,
155
+ height: '24px',
156
+ width: '40px',
157
+ cursor: 'pointer',
158
+ position: 'relative',
159
+ outline: 'none',
160
+ marginBottom: '1px',
161
+ overflow: 'hidden',
162
+ boxShadow: isSelected ? `${color} 0 0 4px` : 'none'
163
+ }}
164
+ >
165
+ {isSelected && (
166
+ <div style={{ color: '#FFFFFF', marginLeft: '8px' }}>
167
+ <svg viewBox="0 0 24 24" style={{ fill: 'currentcolor', width: '24px', height: '24px' }}>
168
+ <path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path>
169
+ </svg>
170
+ </div>
171
+ )}
172
+ </div>
173
+ )
174
+ })}
175
+ </div>
176
+ )
177
+ }
@@ -27,12 +27,18 @@ function generateSequentialSet(set: any, number: any, reversed: any) {
27
27
  }
28
28
 
29
29
  export default class ColorSchemeFactory {
30
- // creates a color scheme
31
- // options:
32
- // type: string (type of the color scheme)
33
- // number: int (number of colors to be generated)
34
- // reversed: true to reversed
35
- static createColorScheme(options: any) {
30
+ /**
31
+ * Creates a color scheme
32
+ * @param options
33
+ * @param options.type - type of the color scheme
34
+ * @param options.number - number of colors to be generated
35
+ * @param options.reversed - true to reversed
36
+ */
37
+ static createColorScheme(options: {
38
+ type: string
39
+ number: number
40
+ reversed: boolean
41
+ }): string[] {
36
42
  switch (options.type) {
37
43
  case "schemeAccent":
38
44
  return generateCategoricalSet(brewer.schemeAccent, options.number, options.reversed)
@@ -0,0 +1,8 @@
1
+ import { createContext } from "react"
2
+
3
+ export interface CustomColorsContextType {
4
+ customColors: (string | null)[]
5
+ }
6
+
7
+ /** Context for custom colors */
8
+ export const CustomColorsContext = createContext<CustomColorsContextType | null>(null)
@@ -1,8 +1,7 @@
1
1
  import _ from "lodash"
2
- import PropTypes from "prop-types"
3
2
  import React from "react"
4
3
  const R = React.createElement
5
- import { FilterExprComponent } from "@mwater/expressions-ui"
4
+ import { FilterExprComponent, LocaleContext } from "@mwater/expressions-ui"
6
5
  import { DataSource, Expr, ExprCleaner, Schema } from "@mwater/expressions"
7
6
  import { ExprUtils } from "@mwater/expressions"
8
7
 
@@ -20,7 +19,7 @@ export interface FiltersDesignerComponentProps {
20
19
  // Designer for filters of multiple tables. Used for maps and dashboards
21
20
  // Filters are in format mwater-expression filter expression indexed by table. e.g. { sometable: logical expression, etc. }
22
21
  export default class FiltersDesignerComponent extends React.Component<FiltersDesignerComponentProps> {
23
- static contextTypes = { locale: PropTypes.string }
22
+ static contextType = LocaleContext
24
23
 
25
24
  handleFilterChange = (table: any, expr: any) => {
26
25
  // Clean filter
@@ -33,7 +32,7 @@ export default class FiltersDesignerComponent extends React.Component<FiltersDes
33
32
  }
34
33
 
35
34
  renderFilterableTable = (table: any) => {
36
- const name = ExprUtils.localizeString(this.props.schema.getTable(table)!.name, this.context.locale)
35
+ const name = ExprUtils.localizeString(this.props.schema.getTable(table)!.name, this.context)
37
36
 
38
37
  return R(
39
38
  "div",
@@ -0,0 +1,17 @@
1
+ import { Expr, LiteralType } from "@mwater/expressions"
2
+
3
+ /** Global filters apply to multiple tables at once if a certain column is present. User-interface to set them
4
+ * is application-specific and the default (non-mWater) dashboard applies them but does not allow editing. */
5
+ export interface GlobalFilter {
6
+ /** id of column to filter */
7
+ columnId: string
8
+
9
+ /** type of column to filter (to ensure that consistent) */
10
+ columnType: LiteralType
11
+
12
+ /** op of expression for filtering */
13
+ op: string
14
+
15
+ /** array of expressions to use for filtering. field expression for column will be injected as expression 0 in the resulting filter expression */
16
+ exprs: Expr[]
17
+ }
@@ -1,17 +1,18 @@
1
1
  import React from "react"
2
- import PropTypes from "prop-types"
2
+ import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
3
3
 
4
- /** Adds the locale to the context */
5
- export default class LocaleContextInjector extends React.Component<{ locale: string }> {
6
- static childContextTypes = {
7
- locale: PropTypes.string
8
- }
9
-
10
- getChildContext() {
11
- return { locale: this.props.locale }
12
- }
4
+ export interface LocaleContextProps {
5
+ locale: string
6
+ children: React.ReactNode
7
+ }
13
8
 
14
- render() {
15
- return this.props.children
16
- }
9
+ /** Adds the locale to the context */
10
+ const LocaleContextInjector: React.FC<LocaleContextProps> = ({ locale, children }) => {
11
+ return (
12
+ <LocaleContext.Provider value={locale}>
13
+ {children}
14
+ </LocaleContext.Provider>
15
+ )
17
16
  }
17
+
18
+ export default LocaleContextInjector
@@ -1,5 +1,4 @@
1
1
  import $ from "jquery"
2
- import PropTypes from "prop-types"
3
2
  import _ from "lodash"
4
3
  import React from "react"
5
4
  const R = React.createElement
@@ -11,6 +10,7 @@ import { ExprUtils, Schema } from "@mwater/expressions"
11
10
  import * as ui from "./UIComponents"
12
11
  import * as formUtils from "@mwater/forms/lib/formUtils" // TODO requireing this directly because of bizarre backbone issue
13
12
  import { Form, FormDesign } from "@mwater/forms"
13
+ import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
14
14
 
15
15
  export interface MWaterAddRelatedFormComponentProps {
16
16
  /** Entities table id */
@@ -115,7 +115,7 @@ class AddRelatedFormModalComponent extends React.Component<
115
115
  AddRelatedFormModalComponentProps,
116
116
  AddRelatedFormModalComponentState
117
117
  > {
118
- static contextTypes = { locale: PropTypes.string }
118
+ static contextType = LocaleContext
119
119
 
120
120
  constructor(props: any) {
121
121
  super(props)
@@ -149,7 +149,7 @@ class AddRelatedFormModalComponent extends React.Component<
149
149
 
150
150
  // Get _id, name, and description
151
151
  const items = _.map(forms, (form) => ({
152
- name: ExprUtils.localizeString(form.design.name, this.context.locale),
152
+ name: ExprUtils.localizeString(form.design.name, this.context),
153
153
  desc: `Modified ${moment(form.modified!.on, moment.ISO_8601).format("ll")}`,
154
154
  onClick: this.props.onSelect.bind(null, "responses:" + form._id)
155
155
  }))
@@ -1,11 +1,11 @@
1
1
  import $ from "jquery"
2
- import PropTypes from "prop-types"
3
2
  import _ from "lodash"
4
3
  import React from "react"
5
4
  const R = React.createElement
6
5
 
7
6
  import querystring from "querystring"
8
7
  import { ExprUtils, Schema } from "@mwater/expressions"
8
+ import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
9
9
 
10
10
  export interface MWaterAddRelatedIndicatorComponentProps {
11
11
  table: string
@@ -30,7 +30,7 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
30
30
  MWaterAddRelatedIndicatorComponentProps,
31
31
  MWaterAddRelatedIndicatorComponentState
32
32
  > {
33
- static contextTypes = { locale: PropTypes.string }
33
+ static contextType = LocaleContext
34
34
 
35
35
  constructor(props: any) {
36
36
  super(props)
@@ -69,7 +69,7 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
69
69
  indicators,
70
70
  [
71
71
  (indicator) => (indicator.design.recommended ? 0 : 1),
72
- (indicator) => ExprUtils.localizeString(indicator.design.name, this.context.locale)
72
+ (indicator) => ExprUtils.localizeString(indicator.design.name, this.context)
73
73
  ],
74
74
  ["asc", "asc"]
75
75
  )
@@ -112,7 +112,7 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
112
112
  // Filter by search
113
113
  if (this.props.filter) {
114
114
  indicators = _.filter(indicators, (indicator) =>
115
- filterMatches(this.props.filter, ExprUtils.localizeString(indicator.design.name, this.context.locale))
115
+ filterMatches(this.props.filter, ExprUtils.localizeString(indicator.design.name, this.context))
116
116
  )
117
117
  }
118
118
 
@@ -134,8 +134,8 @@ export default class MWaterAddRelatedIndicatorComponent extends React.Component<
134
134
  "div",
135
135
  { style: { paddingLeft: 10 } },
136
136
  _.map(indicators, (indicator) => {
137
- const name = ExprUtils.localizeString(indicator.design.name, this.context.locale)
138
- const desc = ExprUtils.localizeString(indicator.design.desc, this.context.locale)
137
+ const name = ExprUtils.localizeString(indicator.design.name, this.context)
138
+ const desc = ExprUtils.localizeString(indicator.design.desc, this.context)
139
139
 
140
140
  // If added, put special message
141
141
  if (this.props.schema.getTable(`indicator_values:${indicator._id}`)) {