@mwater/visualization 5.2.0 → 5.3.1

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 (254) 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/LocaleContextInjector.d.ts +5 -11
  10. package/lib/LocaleContextInjector.js +4 -12
  11. package/lib/MWaterAddRelatedFormComponent.js +3 -3
  12. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
  13. package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
  14. package/lib/MWaterCompleteTableSelectComponent.d.ts +5 -16
  15. package/lib/MWaterCompleteTableSelectComponent.js +36 -36
  16. package/lib/MWaterContextComponent.d.ts +4 -6
  17. package/lib/MWaterContextComponent.js +4 -13
  18. package/lib/MWaterLoaderComponent.d.ts +5 -3
  19. package/lib/MWaterLoaderComponent.js +2 -1
  20. package/lib/MWaterTableSelectComponent.d.ts +1 -4
  21. package/lib/MWaterTableSelectComponent.js +10 -12
  22. package/lib/UIComponents.d.ts +2 -2
  23. package/lib/UIComponents.js +4 -12
  24. package/lib/axes/AxisBuilder.d.ts +7 -4
  25. package/lib/axes/AxisBuilder.js +3 -1
  26. package/lib/axes/AxisComponent.d.ts +2 -5
  27. package/lib/axes/AxisComponent.js +1 -2
  28. package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
  29. package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
  30. package/lib/dashboards/DashboardComponent.d.ts +4 -12
  31. package/lib/dashboards/DashboardComponent.js +18 -38
  32. package/lib/dashboards/DashboardDesign.d.ts +3 -3
  33. package/lib/dashboards/DashboardUpgrader.js +36 -1
  34. package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
  35. package/lib/dashboards/DashboardViewComponent.js +109 -132
  36. package/lib/dashboards/FontStyleEditor.d.ts +8 -0
  37. package/lib/dashboards/FontStyleEditor.js +130 -0
  38. package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
  39. package/lib/dashboards/LayoutOptionsComponent.js +211 -42
  40. package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
  41. package/lib/dashboards/ServerDashboardDataSource.js +52 -33
  42. package/lib/dashboards/WidgetComponent.d.ts +3 -3
  43. package/lib/dashboards/WidgetComponent.js +3 -6
  44. package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
  45. package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
  46. package/lib/dashboards/layoutOptions.d.ts +83 -0
  47. package/lib/dashboards/layoutOptions.js +436 -10
  48. package/lib/datagrids/DatagridDesign.d.ts +7 -6
  49. package/lib/datagrids/ServerDatagridDataSource.d.ts +7 -6
  50. package/lib/datagrids/ServerDatagridDataSource.js +87 -33
  51. package/lib/demo.js +3 -3
  52. package/lib/index.css +5 -0
  53. package/lib/index.d.ts +1 -1
  54. package/lib/index.js +0 -1
  55. package/lib/layouts/LayoutManager.d.ts +33 -29
  56. package/lib/layouts/LayoutManager.js +2 -8
  57. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -57
  58. package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
  59. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
  60. package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
  61. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
  62. package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
  63. package/lib/mWaterLoader.d.ts +2 -0
  64. package/lib/mWaterLoader.js +2 -1
  65. package/lib/maps/AddLayerComponent.d.ts +6 -8
  66. package/lib/maps/AddLayerComponent.js +6 -6
  67. package/lib/maps/BingLayer.js +10 -20
  68. package/lib/maps/BufferLayer.js +2 -1
  69. package/lib/maps/ChoroplethLayer.js +2 -1
  70. package/lib/maps/DirectMapDataSource.d.ts +5 -2
  71. package/lib/maps/DirectMapDataSource.js +2 -1
  72. package/lib/maps/EditPopupComponent.js +2 -1
  73. package/lib/maps/MapComponent.d.ts +1 -4
  74. package/lib/maps/MapComponent.js +3 -3
  75. package/lib/maps/MarkersLayer.js +30 -25
  76. package/lib/maps/RasterMapViewComponent.d.ts +1 -4
  77. package/lib/maps/RasterMapViewComponent.js +3 -3
  78. package/lib/maps/ServerMapDataSource.d.ts +2 -3
  79. package/lib/maps/ServerMapDataSource.js +5 -5
  80. package/lib/maps/VectorMapViewComponent.js +2 -1
  81. package/lib/maps/mapSymbols.js +2 -0
  82. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  83. package/lib/maps/vectorMaps.js +61 -55
  84. package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
  85. package/lib/quickfilter/QuickfiltersComponent.js +3 -3
  86. package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
  87. package/lib/richtext/DropdownPaletteItem.js +82 -0
  88. package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
  89. package/lib/richtext/FontColorPaletteItem.js +32 -27
  90. package/lib/richtext/ItemsHtmlConverter.js +12 -3
  91. package/lib/richtext/RichTextComponent.d.ts +26 -52
  92. package/lib/richtext/RichTextComponent.js +166 -128
  93. package/lib/valueFormatter.js +6 -1
  94. package/lib/wellknown.d.ts +5 -0
  95. package/lib/wellknown.js +288 -0
  96. package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
  97. package/lib/widgets/DropdownWidgetComponent.js +48 -25
  98. package/lib/widgets/IFrameWidgetComponent.d.ts +1 -2
  99. package/lib/widgets/ImageWidgetComponent.d.ts +2 -3
  100. package/lib/widgets/MapWidget.d.ts +2 -0
  101. package/lib/widgets/MapWidget.js +2 -1
  102. package/lib/widgets/TOCWidget.js +2 -1
  103. package/lib/widgets/Widget.d.ts +2 -0
  104. package/lib/widgets/WidgetDataSource.d.ts +3 -1
  105. package/lib/widgets/charts/Chart.d.ts +0 -1
  106. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  107. package/lib/widgets/charts/ChartViewComponent.js +11 -3
  108. package/lib/widgets/charts/ChartWidget.d.ts +1 -62
  109. package/lib/widgets/charts/ChartWidget.js +4 -183
  110. package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
  111. package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
  112. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
  113. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
  114. package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
  115. package/lib/widgets/charts/layered/LayeredChart.js +6 -7
  116. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
  117. package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
  118. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
  119. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +3 -0
  120. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
  121. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -2
  122. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
  123. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
  124. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
  125. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -112
  126. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
  127. package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
  128. package/lib/widgets/charts/pivot/PivotChart.js +47 -17
  129. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
  130. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -1
  131. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
  132. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
  133. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
  134. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
  135. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
  136. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
  137. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
  138. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -28
  139. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
  140. package/lib/widgets/charts/table/TableChart.js +8 -4
  141. package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
  142. package/lib/widgets/charts/table/TableChartViewComponent.js +11 -11
  143. package/lib/widgets/text/TextComponent.d.ts +5 -12
  144. package/lib/widgets/text/TextComponent.js +19 -39
  145. package/lib/widgets/text/TextWidget.d.ts +2 -1
  146. package/lib/widgets/text/TextWidget.js +5 -1
  147. package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
  148. package/lib/widgets/text/TextWidgetComponent.js +76 -19
  149. package/lib/widgets/text/TextWidgetDesign.d.ts +13 -1
  150. package/lib/widgets/text/TextWidgetDesign.js +6 -0
  151. package/package.json +4 -4
  152. package/src/ColorComponent.tsx +177 -0
  153. package/src/ColorSchemeFactory.ts +12 -6
  154. package/src/CustomColorsContext.tsx +9 -0
  155. package/src/FiltersDesignerComponent.ts +3 -4
  156. package/src/LocaleContextInjector.tsx +14 -13
  157. package/src/MWaterAddRelatedFormComponent.ts +3 -3
  158. package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
  159. package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
  160. package/src/MWaterContextComponent.tsx +8 -17
  161. package/src/MWaterLoaderComponent.ts +6 -3
  162. package/src/MWaterTableSelectComponent.tsx +11 -12
  163. package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
  164. package/src/axes/AxisBuilder.ts +7 -5
  165. package/src/axes/AxisComponent.ts +3 -4
  166. package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
  167. package/src/dashboards/DashboardComponent.tsx +71 -107
  168. package/src/dashboards/DashboardDesign.ts +3 -3
  169. package/src/dashboards/DashboardUpgrader.ts +41 -1
  170. package/src/dashboards/DashboardViewComponent.tsx +313 -0
  171. package/src/dashboards/FontStyleEditor.tsx +166 -0
  172. package/src/dashboards/LayoutOptionsComponent.tsx +380 -75
  173. package/src/dashboards/ServerDashboardDataSource.ts +52 -33
  174. package/src/dashboards/WidgetComponent.tsx +6 -12
  175. package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
  176. package/src/dashboards/layoutOptions.tsx +581 -0
  177. package/src/datagrids/DatagridDesign.ts +8 -3
  178. package/src/datagrids/ServerDatagridDataSource.ts +106 -43
  179. package/src/demo.ts +3 -3
  180. package/src/index.css +5 -0
  181. package/src/index.ts +1 -1
  182. package/src/layouts/LayoutManager.ts +44 -42
  183. package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
  184. package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
  185. package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
  186. package/src/mWaterLoader.ts +4 -1
  187. package/src/maps/AddLayerComponent.ts +9 -9
  188. package/src/maps/BingLayer.ts +16 -26
  189. package/src/maps/BufferLayer.ts +2 -1
  190. package/src/maps/ChoroplethLayer.ts +2 -1
  191. package/src/maps/DirectMapDataSource.ts +12 -3
  192. package/src/maps/EditPopupComponent.ts +2 -1
  193. package/src/maps/MapComponent.ts +3 -3
  194. package/src/maps/MarkersLayer.ts +38 -41
  195. package/src/maps/RasterMapViewComponent.ts +3 -3
  196. package/src/maps/ServerMapDataSource.ts +7 -7
  197. package/src/maps/VectorMapViewComponent.tsx +2 -1
  198. package/src/maps/mapSymbols.ts +2 -0
  199. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  200. package/src/maps/vectorMaps.tsx +79 -74
  201. package/src/quickfilter/QuickfiltersComponent.ts +3 -3
  202. package/src/richtext/DropdownPaletteItem.tsx +144 -0
  203. package/src/richtext/FontColorPaletteItem.tsx +160 -0
  204. package/src/richtext/ItemsHtmlConverter.ts +15 -5
  205. package/src/richtext/RichTextComponent.tsx +274 -232
  206. package/src/valueFormatter.ts +5 -1
  207. package/src/wellknown.ts +286 -0
  208. package/src/widgets/DropdownWidgetComponent.tsx +75 -0
  209. package/src/widgets/MapWidget.ts +5 -2
  210. package/src/widgets/TOCWidget.ts +2 -1
  211. package/src/widgets/Widget.ts +3 -0
  212. package/src/widgets/WidgetDataSource.ts +3 -1
  213. package/src/widgets/charts/Chart.ts +1 -1
  214. package/src/widgets/charts/ChartViewComponent.ts +16 -3
  215. package/src/widgets/charts/ChartWidget.ts +3 -275
  216. package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
  217. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
  218. package/src/widgets/charts/layered/LayeredChart.ts +4 -6
  219. package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
  220. package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
  221. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
  222. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
  223. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
  224. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
  225. package/src/widgets/charts/pivot/PivotChart.ts +56 -18
  226. package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
  227. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
  228. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
  229. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
  230. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
  231. package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
  232. package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
  233. package/src/widgets/charts/table/TableChart.ts +8 -4
  234. package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
  235. package/src/widgets/charts/table/TableChartViewComponent.ts +13 -14
  236. package/src/widgets/text/TextComponent.tsx +47 -49
  237. package/src/widgets/text/TextWidget.ts +8 -3
  238. package/src/widgets/text/TextWidgetComponent.tsx +249 -0
  239. package/src/widgets/text/TextWidgetDesign.ts +22 -1
  240. package/src/ColorComponent.ts +0 -117
  241. package/src/dashboards/DashboardViewComponent.ts +0 -303
  242. package/src/dashboards/layoutOptions.ts +0 -40
  243. package/src/layout-styles.css +0 -263
  244. package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
  245. package/src/layouts/grid/GridLayoutComponent.ts +0 -67
  246. package/src/layouts/grid/GridLayoutManager.ts +0 -185
  247. package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
  248. package/src/layouts/grid/PaletteItemComponent.ts +0 -28
  249. package/src/layouts/grid/README.md +0 -14
  250. package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
  251. package/src/richtext/FontColorPaletteItem.ts +0 -172
  252. package/src/richtext/FontSizePaletteItem.ts +0 -110
  253. package/src/widgets/DropdownWidgetComponent.ts +0 -78
  254. package/src/widgets/text/TextWidgetComponent.ts +0 -120
@@ -27,9 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const lodash_1 = __importDefault(require("lodash"));
30
- const prop_types_1 = __importDefault(require("prop-types"));
31
- const react_1 = __importDefault(require("react"));
32
- const R = react_1.default.createElement;
30
+ const react_1 = __importStar(require("react"));
33
31
  const ImplicitFilterBuilder_1 = __importDefault(require("../ImplicitFilterBuilder"));
34
32
  const DashboardUtils = __importStar(require("./DashboardUtils"));
35
33
  const WidgetFactory_1 = __importDefault(require("../widgets/WidgetFactory"));
@@ -40,85 +38,85 @@ const WidgetScopesViewComponent_1 = __importDefault(require("../widgets/WidgetSc
40
38
  const layoutOptions_1 = require("./layoutOptions");
41
39
  const WidgetComponent_1 = require("./WidgetComponent");
42
40
  const vectorMaps_1 = require("../maps/vectorMaps");
41
+ const WidgetDataSourcePrioritizer_1 = require("./WidgetDataSourcePrioritizer");
42
+ const contexts_1 = require("@mwater/expressions-ui/lib/contexts");
43
43
  /**
44
44
  * Displays a dashboard, handling removing of widgets. No title bar or other decorations.
45
45
  * Handles scoping and stores the state of scope
46
46
  */
47
- class DashboardViewComponent extends react_1.default.Component {
48
- static childContextTypes = { locale: prop_types_1.default.string };
49
- widgetComps;
50
- // Pass locale down. Both here and DashboardViewComponent to ensure that quickfilters also get context
51
- getChildContext() {
52
- return { locale: this.props.design.locale };
53
- }
54
- constructor(props) {
55
- super(props);
56
- this.state = {
57
- widgetScoper: new WidgetScoper_1.default() // Empty scoping
47
+ const DashboardViewComponent = react_1.default.forwardRef((props, ref) => {
48
+ const [widgetScoper, setWidgetScoper] = (0, react_1.useState)(new WidgetScoper_1.default());
49
+ const widgetComps = (0, react_1.useRef)({});
50
+ const [forceUpdate, setForceUpdate] = (0, react_1.useState)(0);
51
+ const widgetDataSourcePrioritizer = (0, react_1.useMemo)(() => {
52
+ return new WidgetDataSourcePrioritizer_1.WidgetDataSourcePrioritizer(props.dashboardDataSource, 10);
53
+ }, [props.dashboardDataSource]);
54
+ (0, react_1.useEffect)(() => {
55
+ return () => {
56
+ // Clear queue on component unmount
57
+ widgetDataSourcePrioritizer.cancel();
58
58
  };
59
- this.widgetComps = {}; // Lookup of widget components by id
60
- }
61
- componentDidMount() {
62
- if (this.props.initialTOCEntryScroll) {
59
+ }, [widgetDataSourcePrioritizer]);
60
+ (0, react_1.useEffect)(() => {
61
+ if (props.initialTOCEntryScroll) {
63
62
  // Getting heights of widgets properly requires a 0 length timeout
64
63
  setTimeout(() => {
65
- return this.handleScrollToTOCEntry(this.props.initialTOCEntryScroll.widgetId, this.props.initialTOCEntryScroll.entryId);
64
+ handleScrollToTOCEntry(props.initialTOCEntryScroll.widgetId, props.initialTOCEntryScroll.entryId);
66
65
  }, 0);
67
66
  }
68
67
  // Add listener to localstorage to update clipboard display
69
- return window.addEventListener("storage", this.handleStorageChange);
70
- }
71
- componentWillUnmount() {
72
- // Remove listener
73
- return window.addEventListener("storage", this.handleStorageChange);
74
- }
75
- handleStorageChange = () => {
76
- return this.forceUpdate();
68
+ window.addEventListener("storage", handleStorageChange);
69
+ return () => {
70
+ // Remove listener
71
+ window.removeEventListener("storage", handleStorageChange);
72
+ };
73
+ }, [props.initialTOCEntryScroll]);
74
+ const handleStorageChange = () => {
75
+ setForceUpdate(forceUpdate + 1);
77
76
  };
78
- handleScopeChange = (id, scope) => {
79
- return this.setState({ widgetScoper: this.state.widgetScoper.applyScope(id, scope) });
77
+ const handleScopeChange = (id, scope) => {
78
+ setWidgetScoper(widgetScoper.applyScope(id, scope));
80
79
  };
81
- handleRemoveScope = (id) => {
82
- return this.setState({ widgetScoper: this.state.widgetScoper.applyScope(id, null) });
80
+ const handleRemoveScope = (id) => {
81
+ setWidgetScoper(widgetScoper.applyScope(id, null));
83
82
  };
84
- handleItemsChange = (items) => {
85
- const design = lodash_1.default.extend({}, this.props.design, { items });
86
- return this.props.onDesignChange(design);
83
+ const handleItemsChange = (items) => {
84
+ const design = lodash_1.default.extend({}, props.design, { items });
85
+ props.onDesignChange(design);
87
86
  };
88
- // Handle a change of the clipboard and determine which tables the clipboard block uses
89
- handleClipboardChange = (block) => {
87
+ const handleClipboardChange = (block) => {
90
88
  try {
91
89
  // If empty, just set it
92
90
  if (!block) {
93
91
  window.localStorage.removeItem("DashboardViewComponent.clipboard");
94
- this.forceUpdate();
92
+ setForceUpdate(forceUpdate + 1);
95
93
  return;
96
94
  }
97
95
  // Determine which tables are used (just peek for any uses of the table name. Not ideal, but easy)
98
- const tables = lodash_1.default.pluck(lodash_1.default.filter(this.props.schema.getTables(), (table) => JSON.stringify(block).includes(JSON.stringify(table.id))), "id");
96
+ const tables = lodash_1.default.pluck(lodash_1.default.filter(props.schema.getTables(), (table) => JSON.stringify(block).includes(JSON.stringify(table.id))), "id");
99
97
  // Store in clipboard
100
98
  window.localStorage.setItem("DashboardViewComponent.clipboard", JSON.stringify({ block, tables }));
101
- return this.forceUpdate();
99
+ setForceUpdate(forceUpdate + 1);
102
100
  }
103
101
  catch (err) {
104
102
  return alert("Clipboard not available");
105
103
  }
106
104
  };
107
- getClipboardContents() {
105
+ const getClipboardContents = () => {
108
106
  try {
109
107
  return JSON.parse(window.localStorage.getItem("DashboardViewComponent.clipboard") || "null");
110
108
  }
111
109
  catch (err) {
112
110
  return null;
113
111
  }
114
- }
115
- // Call to print the dashboard
116
- print = async () => {
112
+ };
113
+ const print = async () => {
117
114
  // Temporarily enable print mode for vector maps
118
115
  try {
119
116
  (0, vectorMaps_1.setPrintingModeEnabled)(true);
120
117
  // Create element at 1080 wide (use as standard printing width)
121
- const elem = R("div", { style: { width: 1080 } }, R(DashboardViewComponent, lodash_1.default.extend({}, this.props, { onDesignChange: null, printMode: true })));
118
+ const elem = (react_1.default.createElement("div", { style: { width: 1080 } },
119
+ react_1.default.createElement(DashboardViewComponent, { ...props, onDesignChange: undefined, printMode: true })));
122
120
  const printer = new ReactElementPrinter_1.default();
123
121
  await printer.print(elem, { delay: 5000 });
124
122
  }
@@ -126,109 +124,88 @@ class DashboardViewComponent extends react_1.default.Component {
126
124
  (0, vectorMaps_1.setPrintingModeEnabled)(false);
127
125
  }
128
126
  };
129
- // Get filters from props filters combined with dashboard filters
130
- getCompiledFilters() {
131
- let compiledFilters = DashboardUtils.getCompiledFilters(this.props.design, this.props.schema, DashboardUtils.getFilterableTables(this.props.design, this.props.schema));
132
- compiledFilters = compiledFilters.concat(this.props.filters || []);
127
+ (0, react_1.useImperativeHandle)(ref, () => ({
128
+ print
129
+ }));
130
+ const getCompiledFilters = () => {
131
+ let compiledFilters = DashboardUtils.getCompiledFilters(props.design, props.schema, DashboardUtils.getFilterableTables(props.design, props.schema));
132
+ compiledFilters = compiledFilters.concat(props.filters || []);
133
133
  return compiledFilters;
134
- }
135
- // Get list of TOC entries
136
- getTOCEntries(layoutManager) {
134
+ };
135
+ const getTOCEntries = (layoutManager) => {
137
136
  const entries = [];
138
- for (let { id, type, design } of layoutManager.getAllWidgets(this.props.design.items)) {
137
+ for (let { id, type, design } of layoutManager.getAllWidgets(props.design.items)) {
139
138
  const widget = WidgetFactory_1.default.createWidget(type);
140
139
  // Add widgetId to each one
141
- for (let entry of widget.getTOCEntries(design, this.props.namedStrings)) {
140
+ for (let entry of widget.getTOCEntries(design, props.namedStrings)) {
142
141
  entries.push(lodash_1.default.extend({}, entry, { widgetId: id }));
143
142
  }
144
143
  }
145
144
  return entries;
146
- }
147
- handleScrollToTOCEntry = (widgetId, entryId) => {
148
- const widgetComp = this.widgetComps[widgetId];
145
+ };
146
+ const handleScrollToTOCEntry = (widgetId, entryId) => {
147
+ const widgetComp = widgetComps.current[widgetId];
149
148
  if (!widgetComp) {
150
149
  return;
151
150
  }
152
151
  // Call scrollToTOCEntry if present
153
152
  return widgetComp.scrollToTOCEntry?.(entryId);
154
153
  };
155
- renderScopes() {
156
- return R(WidgetScopesViewComponent_1.default, {
157
- scopes: this.state.widgetScoper.getScopes(),
158
- onRemoveScope: this.handleRemoveScope
159
- });
160
- }
161
- compRef = (widgetId, comp) => {
162
- return (this.widgetComps[widgetId] = comp);
154
+ const renderScopes = () => {
155
+ return (react_1.default.createElement(WidgetScopesViewComponent_1.default, { scopes: widgetScoper.getScopes(), onRemoveScope: handleRemoveScope }));
163
156
  };
164
- render() {
165
- let cantPasteMessage = "";
166
- const layoutManager = LayoutManager_1.default.createLayoutManager(this.props.design.layout);
167
- const compiledFilters = this.getCompiledFilters();
168
- // Get filterable tables
169
- const filterableTables = DashboardUtils.getFilterableTables(this.props.design, this.props.schema);
170
- // Determine toc entries
171
- const tocEntries = this.getTOCEntries(layoutManager);
172
- // Get clipboard contents
173
- const clipboardContents = this.getClipboardContents();
174
- // Check if can't paste because of missing table
175
- if (clipboardContents && !lodash_1.default.all(clipboardContents.tables, (table) => this.props.schema.getTable(table))) {
176
- cantPasteMessage = "Dashboard is missing one or more data sources needed for the copied item.";
177
- }
178
- const renderWidget = (options) => {
179
- const widget = WidgetFactory_1.default.createWidget(options.type);
180
- // Get filters (passed in plus dashboard widget scoper filters)
181
- let filters = compiledFilters.concat(this.state.widgetScoper.getFilters(options.id));
182
- // Extend the filters to include implicit filters (filter children in 1-n relationships)
183
- if (this.props.design.implicitFiltersEnabled || this.props.design.implicitFiltersEnabled == null) {
184
- // Default is true
185
- const implicitFilterBuilder = new ImplicitFilterBuilder_1.default(this.props.schema);
186
- filters = implicitFilterBuilder.extendFilters(filterableTables, filters);
187
- }
188
- const widgetElem = R(WidgetComponent_1.WidgetComponent, {
189
- key: options.id,
190
- id: options.id,
191
- type: options.type,
192
- schema: this.props.schema,
193
- dataSource: this.props.dataSource,
194
- dashboardDataSource: this.props.dashboardDataSource,
195
- design: options.design,
196
- scope: this.state.widgetScoper.getScope(options.id),
197
- filters,
198
- onScopeChange: this.handleScopeChange.bind(null, options.id),
199
- onDesignChange: options.onDesignChange,
200
- width: options.width,
201
- height: options.height,
202
- onRowClick: this.props.onRowClick,
203
- namedStrings: this.props.namedStrings,
204
- tocEntries,
205
- onScrollToTOCEntry: this.handleScrollToTOCEntry,
206
- // Keep references to widget elements
207
- widgetRef: this.compRef.bind(null, options.id),
208
- refreshKey: this.props.refreshKey
209
- });
210
- return widgetElem;
211
- };
212
- const style = {
213
- height: "100%",
214
- position: "relative"
215
- };
216
- if (!this.props.printMode) {
217
- // Prevent this block from taking up too much space. Scrolling handled by layout manager.
218
- // Setting overflow-x stops the inner div from becoming too tall
219
- style.overflowX = "auto";
157
+ const compRef = (widgetId, comp) => {
158
+ return (widgetComps.current[widgetId] = comp);
159
+ };
160
+ let cantPasteMessage = "";
161
+ const layoutManager = LayoutManager_1.default.createLayoutManager(props.design.layout);
162
+ const compiledFilters = getCompiledFilters();
163
+ // Get filterable tables
164
+ const filterableTables = DashboardUtils.getFilterableTables(props.design, props.schema);
165
+ // Determine toc entries
166
+ const tocEntries = getTOCEntries(layoutManager);
167
+ // Get clipboard contents
168
+ const clipboardContents = getClipboardContents();
169
+ // Check if can't paste because of missing table
170
+ if (clipboardContents && !lodash_1.default.all(clipboardContents.tables, (table) => props.schema.getTable(table))) {
171
+ cantPasteMessage = "Dashboard is missing one or more data sources needed for the copied item.";
172
+ }
173
+ const renderWidget = (options) => {
174
+ const widgetDataSource = widgetDataSourcePrioritizer.getWidgetDataSource(options.type, options.id, options.priority ?? 0);
175
+ // Get filters (passed in plus dashboard widget scoper filters)
176
+ let filters = compiledFilters.concat(widgetScoper.getFilters(options.id));
177
+ // Extend the filters to include implicit filters (filter children in 1-n relationships)
178
+ if (props.design.implicitFiltersEnabled || props.design.implicitFiltersEnabled == null) {
179
+ // Default is true
180
+ const implicitFilterBuilder = new ImplicitFilterBuilder_1.default(props.schema);
181
+ filters = implicitFilterBuilder.extendFilters(filterableTables, filters);
220
182
  }
221
- // Render widget container
222
- return R("div", { style }, !this.props.hideScopes ? this.renderScopes() : undefined, layoutManager.renderLayout({
223
- items: this.props.design.items,
224
- onItemsChange: this.props.onDesignChange != null ? this.handleItemsChange : undefined,
225
- style: this.props.design.style || null,
226
- layoutOptions: (0, layoutOptions_1.getLayoutOptions)(this.props.design),
227
- renderWidget,
228
- clipboard: clipboardContents?.block,
229
- onClipboardChange: this.handleClipboardChange,
230
- cantPasteMessage
231
- }));
183
+ const widgetElem = (react_1.default.createElement(WidgetComponent_1.WidgetComponent, { key: options.id, id: options.id, type: options.type, schema: props.schema, dataSource: props.dataSource, widgetDataSource: widgetDataSource, design: options.design, scope: widgetScoper.getScope(options.id), filters: filters, onScopeChange: handleScopeChange.bind(null, options.id), onDesignChange: options.onDesignChange, width: options.width, height: options.height, onRowClick: props.onRowClick, namedStrings: props.namedStrings, tocEntries: tocEntries, onScrollToTOCEntry: handleScrollToTOCEntry,
184
+ // Keep references to widget elements
185
+ widgetRef: compRef.bind(null, options.id), refreshKey: props.refreshKey }));
186
+ return widgetElem;
187
+ };
188
+ const style = {
189
+ height: "100%",
190
+ position: "relative"
191
+ };
192
+ if (!props.printMode) {
193
+ // Prevent this block from taking up too much space. Scrolling handled by layout manager.
194
+ // Setting overflow-x stops the inner div from becoming too tall
195
+ style.overflowX = "auto";
232
196
  }
233
- }
197
+ // Render widget container
198
+ return (react_1.default.createElement(contexts_1.LocaleContext.Provider, { value: props.design.locale ?? "en" },
199
+ react_1.default.createElement("div", { style: style },
200
+ !props.hideScopes ? renderScopes() : undefined,
201
+ layoutManager.renderLayout({
202
+ items: props.design.items,
203
+ onItemsChange: props.onDesignChange != null ? handleItemsChange : undefined,
204
+ layoutOptions: (0, layoutOptions_1.getLayoutOptions)(props.design),
205
+ renderWidget,
206
+ clipboard: clipboardContents?.block,
207
+ onClipboardChange: handleClipboardChange,
208
+ cantPasteMessage
209
+ }))));
210
+ });
234
211
  exports.default = DashboardViewComponent;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { FontStyle } from "./layoutOptions";
3
+ interface FontStyleEditorProps {
4
+ value: FontStyle;
5
+ onChange: (value: FontStyle) => void;
6
+ }
7
+ export declare const FontStyleEditor: ({ value, onChange }: FontStyleEditorProps) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.FontStyleEditor = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
32
+ const layoutOptions_1 = require("./layoutOptions");
33
+ const react_select_1 = __importDefault(require("react-select"));
34
+ const bootstrap_1 = require("@mwater/react-library/lib/bootstrap");
35
+ const ColorComponent_1 = __importDefault(require("../ColorComponent"));
36
+ const FontStyleEditor = ({ value, onChange }) => {
37
+ const [isModalOpen, setIsModalOpen] = (0, react_1.useState)(false);
38
+ const handleOpenModal = () => setIsModalOpen(true);
39
+ const handleCloseModal = () => setIsModalOpen(false);
40
+ const handleSave = (newValue) => {
41
+ onChange(newValue);
42
+ handleCloseModal();
43
+ };
44
+ return react_1.default.createElement(react_1.default.Fragment, null,
45
+ react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center', cursor: 'pointer', border: 'solid 1px #DDD', padding: '4px', borderRadius: '6px', justifyContent: 'space-between' }, onClick: handleOpenModal },
46
+ react_1.default.createElement("div", { style: {
47
+ fontFamily: (0, layoutOptions_1.expandFontFamily)(value.family),
48
+ fontSize: `${value.size}px`,
49
+ fontWeight: value.weight,
50
+ color: value.color
51
+ } }, "Sample"),
52
+ react_1.default.createElement("div", { style: { fontSize: '10px', color: '#888', marginTop: '2px' } },
53
+ value.family,
54
+ ", ",
55
+ value.size,
56
+ "px")),
57
+ isModalOpen && (react_1.default.createElement(FontEditorModal, { initialValue: value, onSave: handleSave, onCancel: handleCloseModal })));
58
+ };
59
+ exports.FontStyleEditor = FontStyleEditor;
60
+ const FontEditorModal = ({ initialValue, onSave, onCancel }) => {
61
+ const [currentValue, setCurrentValue] = (0, react_1.useState)(initialValue);
62
+ const handleChange = (field, value) => {
63
+ if (field == "family") {
64
+ setCurrentValue(prev => ({ ...prev, [field]: value, weight: "400" }));
65
+ }
66
+ else {
67
+ setCurrentValue(prev => ({ ...prev, [field]: value }));
68
+ }
69
+ };
70
+ // Generate font size options from 5 to 48
71
+ const fontSizeOptions = Array.from({ length: 44 }, (_, i) => i + 5).map(size => ({
72
+ value: size,
73
+ label: `${size}px`
74
+ }));
75
+ // If the font is variable, then the font weight options are much wider
76
+ const fontWeightOptions = [];
77
+ if (currentValue.family === "Roboto") {
78
+ fontWeightOptions.push("100", "300", "400", "500", "700", "900");
79
+ }
80
+ else if (currentValue.family === "Lora") {
81
+ fontWeightOptions.push("400", "500", "600", "700");
82
+ }
83
+ else if (currentValue.family === "Inter") {
84
+ fontWeightOptions.push("100", "200", "300", "400", "500", "600", "700", "800", "900");
85
+ }
86
+ else if (currentValue.family === "Merriweather") {
87
+ fontWeightOptions.push("300", "400", "700", "900");
88
+ }
89
+ else if (currentValue.family === "Lato") {
90
+ fontWeightOptions.push("100", "300", "400", "700", "900");
91
+ }
92
+ else {
93
+ fontWeightOptions.push("400", "700");
94
+ }
95
+ return (react_1.default.createElement(ActionCancelModalComponent_1.default, { title: "Edit Font", onAction: () => onSave(currentValue), onCancel: onCancel },
96
+ react_1.default.createElement("div", { style: {
97
+ border: '1px solid #ccc',
98
+ padding: '10px',
99
+ marginBottom: '15px',
100
+ borderRadius: '4px'
101
+ } },
102
+ react_1.default.createElement("div", { style: {
103
+ marginBottom: '10px',
104
+ fontSize: '14px',
105
+ fontWeight: 'bold'
106
+ } }, "Sample Text:"),
107
+ react_1.default.createElement("div", { style: {
108
+ fontFamily: (0, layoutOptions_1.expandFontFamily)(currentValue.family),
109
+ fontSize: `${currentValue.size}px`,
110
+ fontWeight: currentValue.weight,
111
+ color: currentValue.color
112
+ } }, "The quick brown fox jumps over the lazy dog.")),
113
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Font Family" },
114
+ react_1.default.createElement(react_select_1.default, { value: { value: currentValue.family, label: currentValue.family }, onChange: (option) => handleChange('family', option?.value || ''), options: [
115
+ { value: 'Helvetica Neue', label: 'Helvetica Neue' },
116
+ { value: 'Georgia', label: 'Georgia' },
117
+ { value: 'Inter', label: 'Inter' },
118
+ { value: 'Lato', label: 'Lato' },
119
+ { value: 'Lora', label: 'Lora' },
120
+ { value: 'Lucida Grande', label: 'Lucida Grande' },
121
+ { value: 'Merriweather', label: 'Merriweather' },
122
+ { value: 'Roboto', label: 'Roboto' },
123
+ ], formatOptionLabel: (option) => (react_1.default.createElement("span", { style: { fontFamily: (0, layoutOptions_1.expandFontFamily)(option.value) } }, option.label)), isClearable: false, menuPortalTarget: document.body, styles: { menuPortal: (style) => ({ ...style, zIndex: 2000 }) } })),
124
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Font Size:", horizontal: true },
125
+ react_1.default.createElement(bootstrap_1.Select, { value: currentValue.size, onChange: (value) => handleChange('size', value || 12), options: fontSizeOptions })),
126
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Font Weight:", horizontal: true },
127
+ react_1.default.createElement(bootstrap_1.Select, { value: currentValue.weight, onChange: (value) => handleChange('weight', value), options: fontWeightOptions.map(weight => ({ value: weight, label: weight })) })),
128
+ react_1.default.createElement(bootstrap_1.FormGroup, { label: "Font Color:", horizontal: true },
129
+ react_1.default.createElement(ColorComponent_1.default, { color: currentValue.color, onChange: (value) => handleChange('color', value), disableReset: true }))));
130
+ };
@@ -3,7 +3,6 @@ import { DashboardDesign } from "./DashboardDesign";
3
3
  export declare function LayoutOptionsComponent(props: {
4
4
  design: DashboardDesign;
5
5
  onDesignChange: (design: DashboardDesign) => void;
6
- onClose: () => void;
7
6
  /** Dashboard view to preview*/
8
7
  dashboardView: ReactNode;
9
8
  /** Quickfilters to preview */