@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
@@ -1,6 +1,7 @@
1
1
  import { Quickfilter } from "../quickfilter/Quickfilter";
2
- import { LiteralType, Expr } from "@mwater/expressions";
2
+ import { Expr } from "@mwater/expressions";
3
3
  import { BlocksLayoutOptions, DashboardTheme } from "./layoutOptions";
4
+ import { GlobalFilter } from "../GlobalFilter";
4
5
  /** Dashboard design
5
6
  * Each understands enough of the dashboard design to create widgets.
6
7
  * Widget refers to the widget itself, where *item* refers also to the layout and id that it has in the dashboard.
@@ -11,11 +12,11 @@ export interface DashboardDesign {
11
12
  /** array of quick filters (user-selectable filters). See quickfilter/README.md */
12
13
  quickfilters?: Quickfilter[];
13
14
  /** layout engine to use (`blocks` is new default) */
14
- layout: "blocks" | "grid";
15
- /** optional theme to use */
15
+ layout: "blocks";
16
+ /** Optional theme to use. Defaults to "default" theme. */
16
17
  style?: DashboardTheme;
17
18
  /** Options for layout including responsiveness, scaling, etc */
18
- layoutOptions?: BlocksLayoutOptions;
19
+ layoutOptions?: Partial<BlocksLayoutOptions>;
19
20
  /** filter expression indexed by table. e.g. { sometable: logical expression, etc. } */
20
21
  filters?: {
21
22
  [tableId: string]: Expr;
@@ -27,19 +28,3 @@ export interface DashboardDesign {
27
28
  /** array of global filters. See below. */
28
29
  globalFilters?: GlobalFilter[];
29
30
  }
30
- /** Global Filters:
31
-
32
- Global filters apply to multiple tables at once if a certain column is present. User-interface to set them is application-specific
33
- and the default (non-mWater) dashboard applies them but does not allow editing.
34
-
35
- */
36
- export interface GlobalFilter {
37
- /** id of column to filter */
38
- columnId: string;
39
- /** type of column to filter (to ensure that consistent) */
40
- columnType: LiteralType;
41
- /** op of expression for filtering */
42
- op: string;
43
- /** array of expressions to use for filtering. field expression for column will be injected as expression 0 in the resulting filter expression */
44
- exprs: Expr[];
45
- }
@@ -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;
@@ -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,196 +38,174 @@ 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 () => {
117
- // Temporarily disable vector maps as WebGL is not supported in print mode
118
- const mapTilerAPIKey = (0, vectorMaps_1.getMapTilerApiKey)();
112
+ };
113
+ const print = async () => {
114
+ // Temporarily enable print mode for vector maps
119
115
  try {
120
- (0, vectorMaps_1.setMapTilerApiKey)("");
116
+ (0, vectorMaps_1.setPrintingModeEnabled)(true);
121
117
  // Create element at 1080 wide (use as standard printing width)
122
- 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 })));
123
120
  const printer = new ReactElementPrinter_1.default();
124
121
  await printer.print(elem, { delay: 5000 });
125
122
  }
126
123
  finally {
127
- (0, vectorMaps_1.setMapTilerApiKey)(mapTilerAPIKey);
124
+ (0, vectorMaps_1.setPrintingModeEnabled)(false);
128
125
  }
129
126
  };
130
- // Get filters from props filters combined with dashboard filters
131
- getCompiledFilters() {
132
- let compiledFilters = DashboardUtils.getCompiledFilters(this.props.design, this.props.schema, DashboardUtils.getFilterableTables(this.props.design, this.props.schema));
133
- 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 || []);
134
133
  return compiledFilters;
135
- }
136
- // Get list of TOC entries
137
- getTOCEntries(layoutManager) {
134
+ };
135
+ const getTOCEntries = (layoutManager) => {
138
136
  const entries = [];
139
- for (let { id, type, design } of layoutManager.getAllWidgets(this.props.design.items)) {
137
+ for (let { id, type, design } of layoutManager.getAllWidgets(props.design.items)) {
140
138
  const widget = WidgetFactory_1.default.createWidget(type);
141
139
  // Add widgetId to each one
142
- for (let entry of widget.getTOCEntries(design, this.props.namedStrings)) {
140
+ for (let entry of widget.getTOCEntries(design, props.namedStrings)) {
143
141
  entries.push(lodash_1.default.extend({}, entry, { widgetId: id }));
144
142
  }
145
143
  }
146
144
  return entries;
147
- }
148
- handleScrollToTOCEntry = (widgetId, entryId) => {
149
- const widgetComp = this.widgetComps[widgetId];
145
+ };
146
+ const handleScrollToTOCEntry = (widgetId, entryId) => {
147
+ const widgetComp = widgetComps.current[widgetId];
150
148
  if (!widgetComp) {
151
149
  return;
152
150
  }
153
151
  // Call scrollToTOCEntry if present
154
152
  return widgetComp.scrollToTOCEntry?.(entryId);
155
153
  };
156
- renderScopes() {
157
- return R(WidgetScopesViewComponent_1.default, {
158
- scopes: this.state.widgetScoper.getScopes(),
159
- onRemoveScope: this.handleRemoveScope
160
- });
161
- }
162
- compRef = (widgetId, comp) => {
163
- return (this.widgetComps[widgetId] = comp);
154
+ const renderScopes = () => {
155
+ return (react_1.default.createElement(WidgetScopesViewComponent_1.default, { scopes: widgetScoper.getScopes(), onRemoveScope: handleRemoveScope }));
164
156
  };
165
- render() {
166
- let cantPasteMessage = "";
167
- const layoutManager = LayoutManager_1.default.createLayoutManager(this.props.design.layout);
168
- const compiledFilters = this.getCompiledFilters();
169
- // Get filterable tables
170
- const filterableTables = DashboardUtils.getFilterableTables(this.props.design, this.props.schema);
171
- // Determine toc entries
172
- const tocEntries = this.getTOCEntries(layoutManager);
173
- // Get clipboard contents
174
- const clipboardContents = this.getClipboardContents();
175
- // Check if can't paste because of missing table
176
- if (clipboardContents && !lodash_1.default.all(clipboardContents.tables, (table) => this.props.schema.getTable(table))) {
177
- cantPasteMessage = "Dashboard is missing one or more data sources needed for the copied item.";
178
- }
179
- const renderWidget = (options) => {
180
- const widget = WidgetFactory_1.default.createWidget(options.type);
181
- // Get filters (passed in plus dashboard widget scoper filters)
182
- let filters = compiledFilters.concat(this.state.widgetScoper.getFilters(options.id));
183
- // Extend the filters to include implicit filters (filter children in 1-n relationships)
184
- if (this.props.design.implicitFiltersEnabled || this.props.design.implicitFiltersEnabled == null) {
185
- // Default is true
186
- const implicitFilterBuilder = new ImplicitFilterBuilder_1.default(this.props.schema);
187
- filters = implicitFilterBuilder.extendFilters(filterableTables, filters);
188
- }
189
- const widgetElem = R(WidgetComponent_1.WidgetComponent, {
190
- key: options.id,
191
- id: options.id,
192
- type: options.type,
193
- schema: this.props.schema,
194
- dataSource: this.props.dataSource,
195
- dashboardDataSource: this.props.dashboardDataSource,
196
- design: options.design,
197
- scope: this.state.widgetScoper.getScope(options.id),
198
- filters,
199
- onScopeChange: this.handleScopeChange.bind(null, options.id),
200
- onDesignChange: options.onDesignChange,
201
- width: options.width,
202
- height: options.height,
203
- onRowClick: this.props.onRowClick,
204
- namedStrings: this.props.namedStrings,
205
- tocEntries,
206
- onScrollToTOCEntry: this.handleScrollToTOCEntry,
207
- // Keep references to widget elements
208
- widgetRef: this.compRef.bind(null, options.id),
209
- refreshKey: this.props.refreshKey
210
- });
211
- return widgetElem;
212
- };
213
- const style = {
214
- height: "100%",
215
- position: "relative"
216
- };
217
- if (!this.props.printMode) {
218
- // Prevent this block from taking up too much space. Scrolling handled by layout manager.
219
- // Setting overflow-x stops the inner div from becoming too tall
220
- 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);
221
182
  }
222
- // Render widget container
223
- return R("div", { style }, !this.props.hideScopes ? this.renderScopes() : undefined, layoutManager.renderLayout({
224
- items: this.props.design.items,
225
- onItemsChange: this.props.onDesignChange != null ? this.handleItemsChange : undefined,
226
- style: this.props.design.style || null,
227
- layoutOptions: (0, layoutOptions_1.getLayoutOptions)(this.props.design),
228
- renderWidget,
229
- clipboard: clipboardContents?.block,
230
- onClipboardChange: this.handleClipboardChange,
231
- cantPasteMessage
232
- }));
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";
233
196
  }
234
- }
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
+ });
235
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 */