@mwater/visualization 5.2.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 (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 +8 -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 +379 -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
@@ -1,14 +1,37 @@
1
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
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  const lodash_1 = __importDefault(require("lodash"));
7
- const react_1 = __importDefault(require("react"));
8
- const R = react_1.default.createElement;
30
+ const react_1 = __importStar(require("react"));
9
31
  const ColorSchemeFactory_1 = __importDefault(require("../ColorSchemeFactory"));
10
- class ColorPaletteCollectionComponent extends react_1.default.Component {
11
- static palettes = [
32
+ const CustomColorsContext_1 = require("../CustomColorsContext");
33
+ function ColorPaletteCollectionComponent(props) {
34
+ const palettes = [
12
35
  { type: "schemeSet1", reversed: false },
13
36
  { type: "schemeSet2", reversed: false },
14
37
  { type: "schemeSet3", reversed: false },
@@ -72,59 +95,67 @@ class ColorPaletteCollectionComponent extends react_1.default.Component {
72
95
  { type: "interpolateRdYlGn", reversed: false },
73
96
  { type: "interpolateRdYlGn", reversed: true }
74
97
  ];
75
- onPaletteSelected = (index) => {
76
- // Generate color map
77
- const scheme = ColorSchemeFactory_1.default.createColorScheme({
78
- type: ColorPaletteCollectionComponent.palettes[index].type,
79
- // Null doesn't count to length
80
- number: lodash_1.default.any(this.props.categories, (c) => c.value == null)
81
- ? this.props.categories.length - 1
82
- : this.props.categories.length,
83
- reversed: ColorPaletteCollectionComponent.palettes[index].reversed
98
+ // Get custom colors
99
+ const customColorsContext = (0, react_1.useContext)(CustomColorsContext_1.CustomColorsContext);
100
+ // Number of colors needed. Null doesn't count to length
101
+ const numColors = props.categories.filter((c) => c.value != null).length;
102
+ if (customColorsContext && customColorsContext.customColors.filter((c) => c != null).length > 0) {
103
+ const filteredCustomColors = customColorsContext.customColors.filter((c) => c != null);
104
+ const customPalettes = [];
105
+ for (let i = 0; i < filteredCustomColors.length; i += 6) {
106
+ const customPalette = filteredCustomColors.slice(i, i + 6);
107
+ customPalettes.push({ type: "custom", reversed: false, colors: customPalette });
108
+ }
109
+ palettes.unshift(...customPalettes);
110
+ }
111
+ function generatePaletteColors(palette, numColors) {
112
+ if (palette.type === "custom") {
113
+ return palette.colors;
114
+ }
115
+ return ColorSchemeFactory_1.default.createColorScheme({
116
+ type: palette.type,
117
+ number: numColors,
118
+ reversed: palette.reversed
84
119
  });
85
- const colorMap = lodash_1.default.map(this.props.categories, (category, i) => ({
120
+ }
121
+ const onPaletteSelected = (index) => {
122
+ // Generate color map
123
+ const scheme = generatePaletteColors(palettes[index], Math.min(numColors, 6));
124
+ const colorMap = lodash_1.default.map(props.categories, (category, i) => ({
86
125
  value: category.value,
87
126
  color: category.value === null ? "#aaaaaa" : scheme[i % scheme.length]
88
127
  }));
89
- return this.props.onPaletteSelected(colorMap);
128
+ return props.onPaletteSelected(colorMap);
90
129
  };
91
- renderCancel = () => {
92
- if (this.props.axis.colorMap) {
93
- return R("div", null, R("a", { className: "link-plain", onClick: this.props.onCancel, key: "cancel-customize" }, "Cancel"));
130
+ const renderCancel = () => {
131
+ if (props.axis.colorMap) {
132
+ return (react_1.default.createElement("div", null,
133
+ react_1.default.createElement("a", { className: "link-plain", onClick: props.onCancel, key: "cancel-customize" }, "Cancel")));
94
134
  }
95
135
  return null;
96
136
  };
97
- render() {
98
- return R("div", null, R("p", null, "Please select a color scheme"), lodash_1.default.map(ColorPaletteCollectionComponent.palettes, (config, index) => {
99
- return R(ColorPaletteComponent, {
100
- key: index,
101
- index,
102
- colorSet: ColorSchemeFactory_1.default.createColorScheme({
103
- type: config.type,
104
- number: Math.min(this.props.categories.length - 1, 6),
105
- reversed: config.reversed
106
- }),
107
- onPaletteSelected: this.onPaletteSelected,
108
- number: this.props.categories.length
109
- });
110
- }), this.renderCancel());
137
+ function renderPalette(palette, index) {
138
+ return (react_1.default.createElement(ColorPaletteComponent, { key: index, index: index, colorSet: generatePaletteColors(palette, 6), onPaletteSelected: onPaletteSelected }));
111
139
  }
140
+ return (react_1.default.createElement("div", null,
141
+ react_1.default.createElement("p", null, "Please select a color scheme"),
142
+ palettes.map((palette, index) => renderPalette(palette, index)),
143
+ renderCancel()));
112
144
  }
113
145
  exports.default = ColorPaletteCollectionComponent;
114
146
  class ColorPaletteComponent extends react_1.default.Component {
115
- static defaultProps = { number: 6 };
116
147
  handleSelect = () => {
117
148
  return this.props.onPaletteSelected(this.props.index);
118
149
  };
119
150
  render() {
120
- return R("div", { onClick: this.handleSelect, className: "axis-palette" }, lodash_1.default.map(this.props.colorSet.slice(0, this.props.number), (color, i) => {
151
+ return (react_1.default.createElement("div", { onClick: this.handleSelect, className: "axis-palette" }, lodash_1.default.map(this.props.colorSet, (color, i) => {
121
152
  const cellStyle = {
122
153
  display: "inline-block",
123
154
  height: 20,
124
155
  width: 20,
125
156
  backgroundColor: color
126
157
  };
127
- return R("div", { style: cellStyle, key: i }, " ");
128
- }));
158
+ return react_1.default.createElement("div", { style: cellStyle, key: i }, " ");
159
+ })));
129
160
  }
130
161
  }
@@ -1,8 +1,7 @@
1
- import PropTypes from "prop-types";
2
1
  import React, { ReactNode } from "react";
3
2
  import { DataSource, Schema } from "@mwater/expressions";
4
3
  import UndoStack from "../UndoStack";
5
- import DashboardViewComponent from "./DashboardViewComponent";
4
+ import { DashboardViewComponentHandle } from "./DashboardViewComponent";
6
5
  import QuickfiltersComponent from "../quickfilter/QuickfiltersComponent";
7
6
  import SettingsModalComponent from "./SettingsModalComponent";
8
7
  import { DashboardDesign } from "./DashboardDesign";
@@ -51,18 +50,12 @@ export interface DashboardComponentState {
51
50
  * Manages undo stack and quickfilter value
52
51
  */
53
52
  export default class DashboardComponent extends React.Component<DashboardComponentProps, DashboardComponentState> {
54
- dashboardView: DashboardViewComponent | null;
53
+ dashboardView: DashboardViewComponentHandle | null;
55
54
  static defaultProps: {
56
55
  printScaling: boolean;
57
56
  };
58
- static childContextTypes: {
59
- locale: PropTypes.Requireable<string>;
60
- };
61
57
  settings: SettingsModalComponent | null;
62
- getChildContext(): {
63
- locale: string | undefined;
64
- };
65
- constructor(props: any);
58
+ constructor(props: DashboardComponentProps);
66
59
  getQuickfilterValues: () => any[];
67
60
  componentWillReceiveProps(nextProps: any): void;
68
61
  handlePrint: () => void;
@@ -76,7 +69,6 @@ export default class DashboardComponent extends React.Component<DashboardCompone
76
69
  handleStyleChange: (style: any) => void;
77
70
  handleDesignChange: (design: any) => void;
78
71
  handleShowQuickfilters: () => void;
79
- handleUpgrade: () => void;
80
72
  getCompiledFilters(): JsonQLFilter[];
81
73
  renderEditingSwitch(): React.DetailedReactHTMLElement<{
82
74
  key: string;
@@ -97,6 +89,6 @@ export default class DashboardComponent extends React.Component<DashboardCompone
97
89
  };
98
90
  }, HTMLElement>;
99
91
  renderQuickfilter(): React.CElement<import("../quickfilter/QuickfiltersComponent").QuickfiltersComponentProps, QuickfiltersComponent>;
100
- refDashboardView: (el: any) => any;
92
+ refDashboardView: (el: any) => void;
101
93
  render(): React.JSX.Element;
102
94
  }
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const prop_types_1 = __importDefault(require("prop-types"));
30
29
  const lodash_1 = __importDefault(require("lodash"));
31
30
  const react_1 = __importDefault(require("react"));
32
31
  const R = react_1.default.createElement;
@@ -37,7 +36,6 @@ const QuickfiltersComponent_1 = __importDefault(require("../quickfilter/Quickfil
37
36
  const QuickfilterCompiler_1 = __importDefault(require("../quickfilter/QuickfilterCompiler"));
38
37
  const SettingsModalComponent_1 = __importDefault(require("./SettingsModalComponent"));
39
38
  const LayoutManager_1 = __importDefault(require("../layouts/LayoutManager"));
40
- const DashboardUpgrader_1 = __importDefault(require("./DashboardUpgrader"));
41
39
  const LayoutOptionsComponent_1 = require("./LayoutOptionsComponent");
42
40
  const ModalWindowComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalWindowComponent"));
43
41
  const layoutOptions_1 = require("./layoutOptions");
@@ -48,22 +46,13 @@ const expressions_ui_1 = require("@mwater/expressions-ui");
48
46
  class DashboardComponent extends react_1.default.Component {
49
47
  dashboardView;
50
48
  static defaultProps = { printScaling: true };
51
- static childContextTypes = {
52
- locale: prop_types_1.default.string,
53
- };
54
49
  settings;
55
- getChildContext() {
56
- return {
57
- // Pass locale down. Both here and DashboardViewComponent to ensure that quickfilters also get context
58
- locale: this.props.design.locale,
59
- };
60
- }
61
50
  constructor(props) {
62
51
  super(props);
63
52
  const layoutOptions = (0, layoutOptions_1.getLayoutOptions)(props.design);
64
53
  this.state = {
65
54
  undoStack: new UndoStack_1.default().push(props.design),
66
- quickfiltersValues: props.quickfiltersValues,
55
+ quickfiltersValues: props.quickfiltersValues || null,
67
56
  editing: LayoutManager_1.default.createLayoutManager(props.design.layout).isEmpty(props.design.items) &&
68
57
  props.onDesignChange != null,
69
58
  layoutOptionsOpen: false,
@@ -93,7 +82,7 @@ class DashboardComponent extends react_1.default.Component {
93
82
  }
94
83
  }
95
84
  handlePrint = () => {
96
- this.dashboardView.print();
85
+ this.dashboardView?.print();
97
86
  };
98
87
  handleUndo = () => {
99
88
  const undoStack = this.state.undoStack.undo();
@@ -139,14 +128,6 @@ class DashboardComponent extends react_1.default.Component {
139
128
  handleShowQuickfilters = () => {
140
129
  return this.setState({ hideQuickfilters: false });
141
130
  };
142
- handleUpgrade = () => {
143
- if (!confirm("This will upgrade your dashboard to the new kind with enhanced features. You can click Undo immediately afterwards if you wish to revert it. Continue?")) {
144
- return;
145
- }
146
- const design = new DashboardUpgrader_1.default().upgrade(this.props.design);
147
- this.props.onDesignChange(design);
148
- alert("Upgrade completed. Some widgets may need to be resized. Click Undo to revert back to old dashboard style.");
149
- };
150
131
  // Get filters from props filters combined with dashboard filters
151
132
  getCompiledFilters() {
152
133
  let compiledFilters = DashboardUtils.getCompiledFilters(this.props.design, this.props.schema, DashboardUtils.getFilterableTables(this.props.design, this.props.schema));
@@ -164,9 +145,7 @@ class DashboardComponent extends react_1.default.Component {
164
145
  return R("button", { type: "button", key: "style", className: "btn btn-link btn-sm", onClick: this.handleOpenLayoutOptions }, R("span", { className: "fa fa-mobile" }), R("span", { className: "hide-600px" }, " Layout "));
165
146
  }
166
147
  renderActionLinks() {
167
- return R("div", null, this.state.editing && (this.props.design.layout || "grid") === "grid"
168
- ? R("a", { key: "upgrade", className: "btn btn-info btn-sm", onClick: this.handleUpgrade }, "Upgrade Dashboard...")
169
- : undefined, this.state.editing
148
+ return R("div", null, this.state.editing
170
149
  ? [
171
150
  R("a", {
172
151
  key: "undo",
@@ -209,7 +188,7 @@ class DashboardComponent extends react_1.default.Component {
209
188
  });
210
189
  }
211
190
  refDashboardView = (el) => {
212
- return (this.dashboardView = el);
191
+ this.dashboardView = el;
213
192
  };
214
193
  render() {
215
194
  let filters = this.props.filters || [];
@@ -241,19 +220,20 @@ class DashboardComponent extends react_1.default.Component {
241
220
  });
242
221
  // Pass active tables down to table select components so they can present a shorter list
243
222
  return react_1.default.createElement(expressions_ui_1.ActiveTablesContext.Provider, { value: DashboardUtils.getFilterableTables(this.props.design, this.props.schema) },
244
- react_1.default.createElement("div", { style: {
245
- display: "grid",
246
- gridTemplateRows: this.props.hideTitleBar ? "auto 1fr" : "auto auto 1fr",
247
- height: "100%"
248
- } },
249
- !this.props.hideTitleBar ? this.renderTitleBar() : undefined,
250
- react_1.default.createElement("div", null, !this.state.hideQuickfilters ? this.renderQuickfilter() : undefined),
251
- dashboardView,
252
- this.props.onDesignChange != null && (react_1.default.createElement(SettingsModalComponent_1.default, { onDesignChange: this.handleDesignChange, schema: this.props.schema, dataSource: this.props.dataSource, ref: (c) => {
253
- this.settings = c;
254
- } })),
255
- this.state.layoutOptionsOpen && (react_1.default.createElement(ModalWindowComponent_1.default, { isOpen: true, outerPadding: 10, innerPadding: 10 },
256
- react_1.default.createElement(LayoutOptionsComponent_1.LayoutOptionsComponent, { design: this.props.design, onDesignChange: this.props.onDesignChange, onClose: () => this.setState({ layoutOptionsOpen: false }), dashboardView: readonlyDashboardView, quickfiltersView: this.renderQuickfilter() })))));
223
+ react_1.default.createElement(expressions_ui_1.LocaleContext.Provider, { value: this.props.design.locale ?? "en" },
224
+ react_1.default.createElement("div", { style: {
225
+ display: "grid",
226
+ gridTemplateRows: this.props.hideTitleBar ? "auto 1fr" : "auto auto 1fr",
227
+ height: "100%"
228
+ } },
229
+ !this.props.hideTitleBar ? this.renderTitleBar() : undefined,
230
+ react_1.default.createElement("div", null, !this.state.hideQuickfilters ? this.renderQuickfilter() : undefined),
231
+ dashboardView,
232
+ this.props.onDesignChange != null && (react_1.default.createElement(SettingsModalComponent_1.default, { onDesignChange: this.handleDesignChange, schema: this.props.schema, dataSource: this.props.dataSource, ref: (c) => {
233
+ this.settings = c;
234
+ } })),
235
+ this.state.layoutOptionsOpen && (react_1.default.createElement(ModalWindowComponent_1.default, { isOpen: true, outerPadding: 10, innerPadding: 10, onRequestClose: () => this.setState({ layoutOptionsOpen: false }) },
236
+ react_1.default.createElement(LayoutOptionsComponent_1.LayoutOptionsComponent, { design: this.props.design, onDesignChange: this.props.onDesignChange, dashboardView: readonlyDashboardView, quickfiltersView: this.renderQuickfilter() }))))));
257
237
  }
258
238
  }
259
239
  exports.default = DashboardComponent;
@@ -12,11 +12,11 @@ export interface DashboardDesign {
12
12
  /** array of quick filters (user-selectable filters). See quickfilter/README.md */
13
13
  quickfilters?: Quickfilter[];
14
14
  /** layout engine to use (`blocks` is new default) */
15
- layout: "blocks" | "grid";
16
- /** optional theme to use */
15
+ layout: "blocks";
16
+ /** Optional theme to use. Defaults to "default" theme. */
17
17
  style?: DashboardTheme;
18
18
  /** Options for layout including responsiveness, scaling, etc */
19
- layoutOptions?: BlocksLayoutOptions;
19
+ layoutOptions?: Partial<BlocksLayoutOptions>;
20
20
  /** filter expression indexed by table. e.g. { sometable: logical expression, etc. } */
21
21
  filters?: {
22
22
  [tableId: string]: Expr;
@@ -54,7 +54,42 @@ class DashboardUpgrader {
54
54
  }
55
55
  }
56
56
  else if (lineItems.length === 1) {
57
- newItems.blocks.push(convertBlock(lineItems[0], items[lineItems[0]]));
57
+ const item = items[lineItems[0]];
58
+ const convertedBlock = convertBlock(lineItems[0], item);
59
+ // If widget goes all the way across
60
+ if (item.layout.x + item.layout.w == 24) {
61
+ newItems.blocks.push(convertedBlock);
62
+ }
63
+ else {
64
+ const leftSpacerWidth = item.layout.x;
65
+ const rightSpacerWidth = 24 - (item.layout.x + item.layout.w);
66
+ const blocks = [];
67
+ const weights = [];
68
+ if (leftSpacerWidth > 0) {
69
+ blocks.push({
70
+ id: (0, uuid_1.default)(),
71
+ type: "spacer",
72
+ aspectRatio: 3,
73
+ });
74
+ weights.push(leftSpacerWidth);
75
+ }
76
+ blocks.push(convertedBlock);
77
+ weights.push(item.layout.w);
78
+ if (rightSpacerWidth > 0) {
79
+ blocks.push({
80
+ id: (0, uuid_1.default)(),
81
+ type: "spacer",
82
+ aspectRatio: 3,
83
+ });
84
+ weights.push(rightSpacerWidth);
85
+ }
86
+ newItems.blocks.push({
87
+ id: (0, uuid_1.default)(),
88
+ type: "horizontal",
89
+ blocks,
90
+ weights,
91
+ });
92
+ }
58
93
  delete items[lineItems[0]];
59
94
  }
60
95
  y += 1;
@@ -1,8 +1,5 @@
1
- import PropTypes from "prop-types";
2
1
  import React from "react";
3
2
  import { DataSource, Schema } from "@mwater/expressions";
4
- import WidgetScoper from "../widgets/WidgetScoper";
5
- import WidgetScopesViewComponent from "../widgets/WidgetScopesViewComponent";
6
3
  import { DashboardDataSource, DashboardDesign, JsonQLFilter } from "..";
7
4
  export interface DashboardViewComponentProps {
8
5
  /** schema to use */
@@ -34,38 +31,12 @@ export interface DashboardViewComponentProps {
34
31
  /** Change to force a refresh */
35
32
  refreshKey?: any;
36
33
  }
34
+ export interface DashboardViewComponentHandle {
35
+ print: () => Promise<void>;
36
+ }
37
37
  /**
38
38
  * Displays a dashboard, handling removing of widgets. No title bar or other decorations.
39
39
  * Handles scoping and stores the state of scope
40
40
  */
41
- export default class DashboardViewComponent extends React.Component<DashboardViewComponentProps, {
42
- widgetScoper: WidgetScoper;
43
- }> {
44
- static childContextTypes: {
45
- locale: PropTypes.Requireable<string>;
46
- };
47
- widgetComps: {
48
- [widgetId: string]: any;
49
- };
50
- getChildContext(): {
51
- locale: string | undefined;
52
- };
53
- constructor(props: any);
54
- componentDidMount(): void;
55
- componentWillUnmount(): void;
56
- handleStorageChange: () => void;
57
- handleScopeChange: (id: any, scope: any) => void;
58
- handleRemoveScope: (id: any) => void;
59
- handleItemsChange: (items: any) => void;
60
- handleClipboardChange: (block: any) => void;
61
- getClipboardContents(): any;
62
- print: () => Promise<void>;
63
- getCompiledFilters(): JsonQLFilter[];
64
- getTOCEntries(layoutManager: any): any[];
65
- handleScrollToTOCEntry: (widgetId: any, entryId: any) => any;
66
- renderScopes(): React.CElement<import("../widgets/WidgetScopesViewComponent").WidgetScopesViewComponentProps, WidgetScopesViewComponent>;
67
- compRef: (widgetId: any, comp: any) => any;
68
- render(): React.DetailedReactHTMLElement<{
69
- style: React.CSSProperties;
70
- }, HTMLElement>;
71
- }
41
+ declare const DashboardViewComponent: React.ForwardRefExoticComponent<DashboardViewComponentProps & React.RefAttributes<DashboardViewComponentHandle>>;
42
+ export default DashboardViewComponent;