@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.
- package/lib/ColorComponent.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +19 -9
- package/lib/MWaterContextComponent.js +38 -22
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +15 -3
- package/lib/MWaterLoaderComponent.js +11 -2
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +12 -8
- package/lib/axes/AxisComponent.d.ts +6 -9
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -17
- package/lib/dashboards/DashboardComponent.js +20 -67
- package/lib/dashboards/DashboardDesign.d.ts +5 -20
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +112 -136
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +209 -39
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridComponent.d.ts +2 -9
- package/lib/datagrids/DatagridDataSource.d.ts +3 -3
- package/lib/datagrids/DatagridDataSource.js +0 -14
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +8 -6
- package/lib/datagrids/DatagridViewComponent.js +1 -1
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
- package/lib/datagrids/ServerDatagridDataSource.js +88 -36
- package/lib/demo.js +4 -4
- package/lib/index.css +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +5 -2
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +0 -1
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +3 -11
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +3 -13
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +3 -4
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +70 -56
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
- package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
- package/lib/widgets/MapWidget.d.ts +4 -7
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -74
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +8 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/GlobalFilter.ts +17 -0
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +42 -33
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +14 -4
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +16 -13
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +73 -147
- package/src/dashboards/DashboardDesign.ts +5 -25
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDataSource.ts +6 -12
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
- package/src/datagrids/DatagridViewComponent.ts +3 -3
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +107 -45
- package/src/demo.ts +4 -4
- package/src/index.css +5 -0
- package/src/index.ts +2 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +5 -2
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +0 -1
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +8 -8
- package/src/maps/VectorMapViewComponent.tsx +2 -2
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +88 -74
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +26 -2
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -304
- package/src/dashboards/SettingsModalComponent.ts +0 -169
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- package/src/widgets/text/TextWidgetComponent.ts +0 -120
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Quickfilter } from "../quickfilter/Quickfilter";
|
|
2
|
-
import {
|
|
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"
|
|
15
|
-
/**
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
widgetComps;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
64
|
+
handleScrollToTOCEntry(props.initialTOCEntryScroll.widgetId, props.initialTOCEntryScroll.entryId);
|
|
66
65
|
}, 0);
|
|
67
66
|
}
|
|
68
67
|
// Add listener to localstorage to update clipboard display
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
handleStorageChange = () => {
|
|
76
|
-
|
|
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
|
-
|
|
77
|
+
const handleScopeChange = (id, scope) => {
|
|
78
|
+
setWidgetScoper(widgetScoper.applyScope(id, scope));
|
|
80
79
|
};
|
|
81
|
-
handleRemoveScope = (id) => {
|
|
82
|
-
|
|
80
|
+
const handleRemoveScope = (id) => {
|
|
81
|
+
setWidgetScoper(widgetScoper.applyScope(id, null));
|
|
83
82
|
};
|
|
84
|
-
handleItemsChange = (items) => {
|
|
85
|
-
const design = lodash_1.default.extend({},
|
|
86
|
-
|
|
83
|
+
const handleItemsChange = (items) => {
|
|
84
|
+
const design = lodash_1.default.extend({}, props.design, { items });
|
|
85
|
+
props.onDesignChange(design);
|
|
87
86
|
};
|
|
88
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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.
|
|
116
|
+
(0, vectorMaps_1.setPrintingModeEnabled)(true);
|
|
121
117
|
// Create element at 1080 wide (use as standard printing width)
|
|
122
|
-
const elem =
|
|
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.
|
|
124
|
+
(0, vectorMaps_1.setPrintingModeEnabled)(false);
|
|
128
125
|
}
|
|
129
126
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
137
|
-
getTOCEntries(layoutManager) {
|
|
134
|
+
};
|
|
135
|
+
const getTOCEntries = (layoutManager) => {
|
|
138
136
|
const entries = [];
|
|
139
|
-
for (let { id, type, design } of layoutManager.getAllWidgets(
|
|
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,
|
|
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 =
|
|
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
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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 */
|