@mwater/visualization 5.2.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +5 -16
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +4 -6
- package/lib/MWaterContextComponent.js +4 -13
- package/lib/MWaterLoaderComponent.d.ts +5 -3
- package/lib/MWaterLoaderComponent.js +2 -1
- 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/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +3 -1
- package/lib/axes/AxisComponent.d.ts +2 -5
- 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 -12
- package/lib/dashboards/DashboardComponent.js +18 -38
- package/lib/dashboards/DashboardDesign.d.ts +3 -3
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +109 -132
- 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 +211 -42
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- 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/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.js +87 -33
- package/lib/demo.js +3 -3
- package/lib/index.css +5 -0
- package/lib/index.d.ts +1 -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 -57
- 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/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 +2 -1
- package/lib/maps/ChoroplethLayer.js +2 -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/MapComponent.d.ts +1 -4
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +1 -4
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/ServerMapDataSource.d.ts +2 -3
- 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.js +61 -55
- 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 +1 -2
- package/lib/widgets/ImageWidgetComponent.d.ts +2 -3
- package/lib/widgets/MapWidget.d.ts +2 -0
- package/lib/widgets/MapWidget.js +2 -1
- 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 -62
- 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/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 +3 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -2
- 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 -112
- 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 +1 -1
- 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 -28
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- 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 +11 -11
- 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 +13 -1
- 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 +9 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- 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 +8 -17
- package/src/MWaterLoaderComponent.ts +6 -3
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/AxisBuilder.ts +7 -5
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +71 -107
- package/src/dashboards/DashboardDesign.ts +3 -3
- 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 +380 -75
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/ServerDatagridDataSource.ts +106 -43
- package/src/demo.ts +3 -3
- package/src/index.css +5 -0
- package/src/index.ts +1 -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 +2 -1
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +7 -7
- package/src/maps/VectorMapViewComponent.tsx +2 -1
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +79 -74
- 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 +13 -14
- 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 +22 -1
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -303
- 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
|
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const lodash_1 = __importDefault(require("lodash"));
|
|
30
30
|
const react_1 = __importDefault(require("react"));
|
|
31
|
-
const R = react_1.default.createElement;
|
|
32
31
|
const uuid_1 = __importDefault(require("uuid"));
|
|
33
32
|
const DraggableBlockComponent_1 = __importDefault(require("./DraggableBlockComponent"));
|
|
34
33
|
const DecoratedBlockComponent_1 = __importDefault(require("../DecoratedBlockComponent"));
|
|
@@ -38,9 +37,9 @@ const blockUtils = __importStar(require("./blockUtils"));
|
|
|
38
37
|
const AutoSizeComponent_1 = __importDefault(require("@mwater/react-library/lib/AutoSizeComponent"));
|
|
39
38
|
const HorizontalBlockComponent_1 = __importDefault(require("./HorizontalBlockComponent"));
|
|
40
39
|
const layoutOptions_1 = require("../../dashboards/layoutOptions");
|
|
41
|
-
|
|
42
|
-
Renders the complete layout of the blocks and also optionally a palette to the left
|
|
43
|
-
that can be used to drag new items into the layout. Palette is only displayed if onItemsChange is not null
|
|
40
|
+
/**
|
|
41
|
+
Renders the complete layout of the blocks and also optionally a palette to the left
|
|
42
|
+
that can be used to drag new items into the layout. Palette is only displayed if onItemsChange is not null
|
|
44
43
|
*/
|
|
45
44
|
class BlocksDisplayComponent extends react_1.default.Component {
|
|
46
45
|
handleBlockDrop = (sourceBlock, targetBlock, side) => {
|
|
@@ -62,98 +61,58 @@ class BlocksDisplayComponent extends react_1.default.Component {
|
|
|
62
61
|
items = blockUtils.cleanBlock(items);
|
|
63
62
|
return this.props.onItemsChange(items);
|
|
64
63
|
};
|
|
65
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Render a single block (and its children)
|
|
66
|
+
* @param block Block to render
|
|
67
|
+
* @param collapseColumns True to collapse columns
|
|
68
|
+
* @param priority Priority of widget. Higher priority widgets are rendered first
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
renderBlock = (block, collapseColumns, priority) => {
|
|
66
72
|
let elem = null;
|
|
67
73
|
switch (block.type) {
|
|
68
74
|
case "root":
|
|
69
|
-
return
|
|
70
|
-
key: block.id,
|
|
71
|
-
block,
|
|
72
|
-
collapseColumns,
|
|
73
|
-
renderBlock: this.renderBlock,
|
|
74
|
-
onBlockDrop: this.props.onItemsChange != null ? this.handleBlockDrop : undefined,
|
|
75
|
-
onBlockRemove: this.props.onItemsChange != null ? this.handleBlockRemove : undefined
|
|
76
|
-
});
|
|
77
|
-
break;
|
|
75
|
+
return react_1.default.createElement(RootBlockComponent, { key: block.id, block: block, collapseColumns: collapseColumns, renderBlock: this.renderBlock, onBlockDrop: this.props.onItemsChange != null ? this.handleBlockDrop : undefined, onBlockRemove: this.props.onItemsChange != null ? this.handleBlockRemove : undefined, priority: priority });
|
|
78
76
|
case "vertical":
|
|
79
|
-
return
|
|
80
|
-
key: block.id,
|
|
81
|
-
block,
|
|
82
|
-
collapseColumns,
|
|
83
|
-
renderBlock: this.renderBlock,
|
|
84
|
-
onBlockDrop: this.props.onItemsChange != null ? this.handleBlockDrop : undefined,
|
|
85
|
-
onBlockRemove: this.props.onItemsChange != null ? this.handleBlockRemove : undefined
|
|
86
|
-
});
|
|
87
|
-
break;
|
|
77
|
+
return react_1.default.createElement(VerticalBlockComponent, { key: block.id, block: block, collapseColumns: collapseColumns, renderBlock: this.renderBlock, onBlockDrop: this.props.onItemsChange != null ? this.handleBlockDrop : undefined, onBlockRemove: this.props.onItemsChange != null ? this.handleBlockRemove : undefined, priority: priority });
|
|
88
78
|
case "horizontal":
|
|
89
|
-
return
|
|
90
|
-
key: block.id,
|
|
91
|
-
block,
|
|
92
|
-
collapseColumns,
|
|
93
|
-
renderBlock: this.renderBlock,
|
|
94
|
-
onBlockDrop: this.props.onItemsChange != null ? this.handleBlockDrop : undefined,
|
|
95
|
-
onBlockRemove: this.props.onItemsChange != null ? this.handleBlockRemove : undefined,
|
|
96
|
-
onBlockUpdate: this.props.onItemsChange != null ? this.handleBlockUpdate : undefined
|
|
97
|
-
});
|
|
98
|
-
break;
|
|
79
|
+
return react_1.default.createElement(HorizontalBlockComponent_1.default, { key: block.id, block: block, collapseColumns: collapseColumns, renderBlock: this.renderBlock, onBlockDrop: this.props.onItemsChange != null ? this.handleBlockDrop : undefined, onBlockRemove: this.props.onItemsChange != null ? this.handleBlockRemove : undefined, priority: priority, onBlockUpdate: this.props.onItemsChange != null ? this.handleBlockUpdate : undefined });
|
|
99
80
|
case "spacer":
|
|
100
|
-
elem =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
width: size.width,
|
|
105
|
-
height: block.aspectRatio != null ? size.width / block.aspectRatio : undefined
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
81
|
+
elem = react_1.default.createElement(AutoSizeComponent_1.default, { injectWidth: true, key: block.id }, (size) => (react_1.default.createElement("div", { id: block.id, style: {
|
|
82
|
+
width: size.width,
|
|
83
|
+
height: block.aspectRatio != null ? size.width / block.aspectRatio : undefined
|
|
84
|
+
} })));
|
|
109
85
|
if (this.props.onItemsChange) {
|
|
110
|
-
elem =
|
|
111
|
-
key: block.id,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}, R(DecoratedBlockComponent_1.default, {
|
|
115
|
-
key: block.id,
|
|
116
|
-
aspectRatio: block.aspectRatio,
|
|
117
|
-
onAspectRatioChange: block.aspectRatio != null
|
|
118
|
-
? (aspectRatio) => this.props.onItemsChange(blockUtils.updateBlock(this.props.items, lodash_1.default.extend({}, block, { aspectRatio })))
|
|
119
|
-
: undefined,
|
|
120
|
-
onBlockRemove: this.props.onItemsChange != null ? this.handleBlockDrop.bind(null, block) : undefined
|
|
121
|
-
}, elem));
|
|
86
|
+
elem = (react_1.default.createElement(DraggableBlockComponent_1.default, { key: block.id, block: block, onBlockDrop: this.handleBlockDrop },
|
|
87
|
+
react_1.default.createElement(DecoratedBlockComponent_1.default, { key: block.id, isDragging: false, aspectRatio: block.aspectRatio, onAspectRatioChange: block.aspectRatio != null
|
|
88
|
+
? (aspectRatio) => this.props.onItemsChange(blockUtils.updateBlock(this.props.items, lodash_1.default.extend({}, block, { aspectRatio })))
|
|
89
|
+
: undefined, onBlockRemove: this.props.onItemsChange != null ? this.handleBlockDrop.bind(null, block) : undefined }, elem)));
|
|
122
90
|
}
|
|
123
91
|
break;
|
|
124
92
|
case "widget":
|
|
125
|
-
elem =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
93
|
+
elem = react_1.default.createElement(AutoSizeComponent_1.default, { injectWidth: true, key: block.id }, (size) => this.props.renderWidget({
|
|
94
|
+
id: block.id,
|
|
95
|
+
type: block.widgetType,
|
|
96
|
+
design: block.design,
|
|
97
|
+
onDesignChange: this.props.onItemsChange
|
|
98
|
+
? (design) => this.props.onItemsChange(blockUtils.updateBlock(this.props.items, lodash_1.default.extend({}, block, { design })))
|
|
99
|
+
: undefined,
|
|
100
|
+
width: size.width,
|
|
101
|
+
height: block.aspectRatio != null ? size.width / block.aspectRatio : undefined,
|
|
102
|
+
priority
|
|
103
|
+
}));
|
|
137
104
|
if (this.props.onItemsChange) {
|
|
138
|
-
elem =
|
|
139
|
-
key: block.id,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}, R(DecoratedBlockComponent_1.default, {
|
|
143
|
-
key: block.id,
|
|
144
|
-
aspectRatio: block.aspectRatio,
|
|
145
|
-
onAspectRatioChange: block.aspectRatio != null
|
|
146
|
-
? (aspectRatio) => this.props.onItemsChange(blockUtils.updateBlock(this.props.items, lodash_1.default.extend({}, block, { aspectRatio })))
|
|
147
|
-
: undefined,
|
|
148
|
-
onBlockRemove: this.props.onItemsChange != null ? this.handleBlockDrop.bind(null, block) : undefined
|
|
149
|
-
}, elem));
|
|
105
|
+
elem = (react_1.default.createElement(DraggableBlockComponent_1.default, { key: block.id, block: block, onBlockDrop: this.handleBlockDrop },
|
|
106
|
+
react_1.default.createElement(DecoratedBlockComponent_1.default, { key: block.id, isDragging: false, aspectRatio: block.aspectRatio, onAspectRatioChange: block.aspectRatio != null
|
|
107
|
+
? (aspectRatio) => this.props.onItemsChange(blockUtils.updateBlock(this.props.items, lodash_1.default.extend({}, block, { aspectRatio })))
|
|
108
|
+
: undefined, onBlockRemove: this.props.onItemsChange != null ? this.handleBlockDrop.bind(null, block) : undefined }, elem)));
|
|
150
109
|
}
|
|
151
110
|
break;
|
|
152
111
|
default:
|
|
153
112
|
throw new Error(`Unknown block type ${block.type}`);
|
|
154
113
|
}
|
|
155
114
|
// Wrap block in padding
|
|
156
|
-
return
|
|
115
|
+
return (react_1.default.createElement("div", { key: block.id, className: `mwater-visualization-block mwater-visualization-block-${block.type}` }, elem));
|
|
157
116
|
};
|
|
158
117
|
createBlockItem(block) {
|
|
159
118
|
// Add unique id
|
|
@@ -162,101 +121,55 @@ class BlocksDisplayComponent extends react_1.default.Component {
|
|
|
162
121
|
});
|
|
163
122
|
}
|
|
164
123
|
renderPalette() {
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
createItem: this.createBlockItem({
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}), R(PaletteItemComponent_1.default, {
|
|
215
|
-
createItem: this.createBlockItem({
|
|
216
|
-
type: "widget",
|
|
217
|
-
aspectRatio: 1.4,
|
|
218
|
-
widgetType: "CalendarChart",
|
|
219
|
-
design: {}
|
|
220
|
-
}),
|
|
221
|
-
title: R("i", { className: "fa fa-calendar" }),
|
|
222
|
-
subtitle: "Calendar"
|
|
223
|
-
}), R(PaletteItemComponent_1.default, {
|
|
224
|
-
createItem: this.createBlockItem({
|
|
225
|
-
type: "widget",
|
|
226
|
-
aspectRatio: 1.4,
|
|
227
|
-
widgetType: "ImageMosaicChart",
|
|
228
|
-
design: {}
|
|
229
|
-
}),
|
|
230
|
-
title: R("i", { className: "fa fa-th" }),
|
|
231
|
-
subtitle: "Mosaic"
|
|
232
|
-
}), R(PaletteItemComponent_1.default, {
|
|
233
|
-
createItem: this.createBlockItem({ type: "spacer", aspectRatio: 2 }),
|
|
234
|
-
title: R("i", { className: "fa fa-square-o" }),
|
|
235
|
-
subtitle: "Spacer"
|
|
236
|
-
}), R(PaletteItemComponent_1.default, {
|
|
237
|
-
createItem: this.createBlockItem({
|
|
238
|
-
type: "widget",
|
|
239
|
-
aspectRatio: 16.0 / 9.0,
|
|
240
|
-
widgetType: "IFrame",
|
|
241
|
-
design: {}
|
|
242
|
-
}),
|
|
243
|
-
title: R("i", { className: "fa fa-youtube-play" }),
|
|
244
|
-
subtitle: "Video"
|
|
245
|
-
}), R(PaletteItemComponent_1.default, {
|
|
246
|
-
createItem: this.createBlockItem({
|
|
247
|
-
type: "widget",
|
|
248
|
-
widgetType: "TOC",
|
|
249
|
-
design: { numbering: false, borderWeight: 2, header: "Contents" }
|
|
250
|
-
}),
|
|
251
|
-
title: R("i", { className: "fa fa-list-ol" }),
|
|
252
|
-
subtitle: "TOC"
|
|
253
|
-
}), this.props.onClipboardChange
|
|
254
|
-
? R(ClipboardPaletteItemComponent_1.default, {
|
|
255
|
-
clipboard: this.props.clipboard,
|
|
256
|
-
onClipboardChange: this.props.onClipboardChange,
|
|
257
|
-
cantPasteMessage: this.props.cantPasteMessage
|
|
258
|
-
})
|
|
259
|
-
: undefined));
|
|
124
|
+
return (react_1.default.createElement("div", { key: "palette", style: { width: 141, height: "100%", position: "absolute", top: 0, left: 0 } },
|
|
125
|
+
react_1.default.createElement("div", { className: "mwater-visualization-palette", style: { height: "100%" } },
|
|
126
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({ type: "widget", widgetType: "Text", design: { style: "title" } }), title: react_1.default.createElement("i", { className: "fa fa-font" }), subtitle: "Title" }),
|
|
127
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({ type: "widget", widgetType: "Text", design: {} }), title: react_1.default.createElement("i", { className: "fa fa-align-left" }), subtitle: "Text" }),
|
|
128
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({ type: "widget", aspectRatio: 1.4, widgetType: "Image", design: {} }), title: react_1.default.createElement("i", { className: "fa fa-picture-o" }), subtitle: "Image" }),
|
|
129
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({
|
|
130
|
+
type: "widget",
|
|
131
|
+
aspectRatio: 1.4,
|
|
132
|
+
widgetType: "LayeredChart",
|
|
133
|
+
design: {}
|
|
134
|
+
}), title: react_1.default.createElement("i", { className: "fa fa-bar-chart" }), subtitle: "Chart" }),
|
|
135
|
+
!this.props.disableMaps && (react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({
|
|
136
|
+
type: "widget",
|
|
137
|
+
aspectRatio: 2,
|
|
138
|
+
widgetType: "Map",
|
|
139
|
+
design: {
|
|
140
|
+
baseLayer: "bing_road",
|
|
141
|
+
layerViews: [],
|
|
142
|
+
filters: {},
|
|
143
|
+
bounds: { w: -40, n: 25, e: 40, s: -25 }
|
|
144
|
+
}
|
|
145
|
+
}), title: react_1.default.createElement("i", { className: "fa fa-map-o" }), subtitle: "Map" })),
|
|
146
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({ type: "widget", aspectRatio: 1.4, widgetType: "TableChart", design: {} }), title: react_1.default.createElement("i", { className: "fa fa-table" }), subtitle: "Table" }),
|
|
147
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({ type: "widget", widgetType: "PivotChart", design: {} }), title: react_1.default.createElement("img", { width: 24, height: 24, src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAb0lEQVRIx91VQQrAIAwzo/7/ydllG0MQS21EzMW2ICFtoyBZlLDn/LOgySPAG1xFDDmBtZI6efoMvODozkyL2IlTCOisfS2KrqG0RXus6fkEVBIw08khE62aQY0ogMdEswqwYouwvQ8s+4M576m4Ae/tET/u1taEAAAAAElFTkSuQmCC" }), subtitle: "Pivot" }),
|
|
148
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({
|
|
149
|
+
type: "widget",
|
|
150
|
+
aspectRatio: 1.4,
|
|
151
|
+
widgetType: "CalendarChart",
|
|
152
|
+
design: {}
|
|
153
|
+
}), title: react_1.default.createElement("i", { className: "fa fa-calendar" }), subtitle: "Calendar" }),
|
|
154
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({
|
|
155
|
+
type: "widget",
|
|
156
|
+
aspectRatio: 1.4,
|
|
157
|
+
widgetType: "ImageMosaicChart",
|
|
158
|
+
design: {}
|
|
159
|
+
}), title: react_1.default.createElement("i", { className: "fa fa-th" }), subtitle: "Mosaic" }),
|
|
160
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({ type: "spacer", aspectRatio: 2 }), title: react_1.default.createElement("i", { className: "fa fa-square-o" }), subtitle: "Spacer" }),
|
|
161
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({
|
|
162
|
+
type: "widget",
|
|
163
|
+
aspectRatio: 16.0 / 9.0,
|
|
164
|
+
widgetType: "IFrame",
|
|
165
|
+
design: {}
|
|
166
|
+
}), title: react_1.default.createElement("i", { className: "fa fa-youtube-play" }), subtitle: "Video" }),
|
|
167
|
+
react_1.default.createElement(PaletteItemComponent_1.default, { createItem: this.createBlockItem({
|
|
168
|
+
type: "widget",
|
|
169
|
+
widgetType: "TOC",
|
|
170
|
+
design: { numbering: false, borderWeight: 2, header: "Contents" }
|
|
171
|
+
}), title: react_1.default.createElement("i", { className: "fa fa-list-ol" }), subtitle: "TOC" }),
|
|
172
|
+
this.props.onClipboardChange && (react_1.default.createElement(ClipboardPaletteItemComponent_1.default, { clipboard: this.props.clipboard, onClipboardChange: this.props.onClipboardChange, cantPasteMessage: this.props.cantPasteMessage })))));
|
|
260
173
|
}
|
|
261
174
|
render() {
|
|
262
175
|
let innerParentStyle;
|
|
@@ -264,18 +177,27 @@ class BlocksDisplayComponent extends react_1.default.Component {
|
|
|
264
177
|
if (this.props.onItemsChange) {
|
|
265
178
|
innerParentStyle = {};
|
|
266
179
|
innerParentStyle.maxWidth = layoutOptions.maximumWidth || undefined;
|
|
267
|
-
return
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
180
|
+
return (react_1.default.createElement(layoutOptions_1.DashboardStyleWrapper, { style: { width: "100%", height: "100%", overflow: "hidden", position: "relative" }, layoutOptions: layoutOptions },
|
|
181
|
+
this.renderPalette(),
|
|
182
|
+
react_1.default.createElement("div", { style: {
|
|
183
|
+
position: "absolute",
|
|
184
|
+
left: 141,
|
|
185
|
+
top: 0,
|
|
186
|
+
bottom: 0,
|
|
187
|
+
right: 0,
|
|
188
|
+
overflowX: "auto",
|
|
189
|
+
overflowY: "scroll"
|
|
190
|
+
}, className: `mwater-visualization-block-parent-outer mwater-visualization-block-editing` },
|
|
191
|
+
react_1.default.createElement("div", { key: "inner", className: `mwater-visualization-block-parent-inner mwater-visualization-block-parent-inner-${this.props.style || "default"}`, style: innerParentStyle }, this.renderBlock(this.props.items, false, 0)))));
|
|
275
192
|
}
|
|
276
193
|
else {
|
|
277
|
-
return
|
|
278
|
-
const outerParentStyle = {
|
|
194
|
+
return (react_1.default.createElement(AutoSizeComponent_1.default, { injectWidth: true, injectHeight: true }, (size) => {
|
|
195
|
+
const outerParentStyle = {
|
|
196
|
+
width: "100%",
|
|
197
|
+
height: "100%",
|
|
198
|
+
overflowX: "auto",
|
|
199
|
+
overflowY: "scroll"
|
|
200
|
+
};
|
|
279
201
|
innerParentStyle = {};
|
|
280
202
|
// Remove padding if small
|
|
281
203
|
if (size.width < 600) {
|
|
@@ -295,32 +217,25 @@ class BlocksDisplayComponent extends react_1.default.Component {
|
|
|
295
217
|
outerParentStyle.transformOrigin = "top left";
|
|
296
218
|
}
|
|
297
219
|
}
|
|
298
|
-
return
|
|
299
|
-
style: outerParentStyle,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
key: "inner",
|
|
303
|
-
className: `mwater-visualization-block-parent-inner mwater-visualization-block-parent-inner-${this.props.style || "default"}`,
|
|
304
|
-
style: innerParentStyle
|
|
305
|
-
}, this.renderBlock(this.props.items, layoutOptions.collapseColumnsWidth != null && size.width <= layoutOptions.collapseColumnsWidth)));
|
|
306
|
-
});
|
|
220
|
+
return (react_1.default.createElement(layoutOptions_1.DashboardStyleWrapper, { style: { width: "100%", height: "100%" }, layoutOptions: layoutOptions },
|
|
221
|
+
react_1.default.createElement("div", { style: outerParentStyle, className: `mwater-visualization-block-parent-outer mwater-visualization-block-parent-outer-${this.props.style || "default"} mwater-visualization-block-viewing` },
|
|
222
|
+
react_1.default.createElement("div", { key: "inner", className: `mwater-visualization-block-parent-inner mwater-visualization-block-parent-inner-${this.props.style || "default"}`, style: innerParentStyle }, this.renderBlock(this.props.items, layoutOptions.collapseColumnsWidth != null && size.width <= layoutOptions.collapseColumnsWidth, 0)))));
|
|
223
|
+
}));
|
|
307
224
|
}
|
|
308
225
|
}
|
|
309
226
|
}
|
|
310
227
|
exports.default = BlocksDisplayComponent;
|
|
311
228
|
class RootBlockComponent extends react_1.default.Component {
|
|
312
229
|
render() {
|
|
313
|
-
const elem =
|
|
314
|
-
|
|
315
|
-
})
|
|
230
|
+
const elem = (
|
|
231
|
+
// Flex to prevent margin collapse
|
|
232
|
+
react_1.default.createElement("div", { key: "root", style: { display: "flex", flexDirection: "column" } }, lodash_1.default.map(this.props.block.blocks, (block, index) => {
|
|
233
|
+
// Render with negative priority so that the first block is rendered first
|
|
234
|
+
return this.props.renderBlock(block, this.props.collapseColumns, this.props.priority - index);
|
|
235
|
+
})));
|
|
316
236
|
// If draggable
|
|
317
237
|
if (this.props.onBlockDrop != null) {
|
|
318
|
-
return
|
|
319
|
-
block: this.props.block,
|
|
320
|
-
onBlockDrop: this.props.onBlockDrop,
|
|
321
|
-
style: { height: "100%" },
|
|
322
|
-
onlyBottom: true
|
|
323
|
-
}, elem);
|
|
238
|
+
return (react_1.default.createElement(DraggableBlockComponent_1.default, { block: this.props.block, onBlockDrop: this.props.onBlockDrop, style: { height: "100%" }, onlyBottom: true }, elem));
|
|
324
239
|
}
|
|
325
240
|
else {
|
|
326
241
|
return elem;
|
|
@@ -329,8 +244,10 @@ class RootBlockComponent extends react_1.default.Component {
|
|
|
329
244
|
}
|
|
330
245
|
class VerticalBlockComponent extends react_1.default.Component {
|
|
331
246
|
render() {
|
|
332
|
-
return
|
|
333
|
-
|
|
334
|
-
}
|
|
247
|
+
return (
|
|
248
|
+
// Flex to prevent margin collapse
|
|
249
|
+
react_1.default.createElement("div", { style: { display: "flex", flexDirection: "column" } }, lodash_1.default.map(this.props.block.blocks, block => {
|
|
250
|
+
return this.props.renderBlock(block, this.props.collapseColumns, this.props.priority);
|
|
251
|
+
})));
|
|
335
252
|
}
|
|
336
253
|
}
|
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import LayoutManager from "../LayoutManager";
|
|
2
|
+
import LayoutManager, { RenderLayoutOptions } from "../LayoutManager";
|
|
3
|
+
import BlocksDisplayComponent from "./BlocksDisplayComponent";
|
|
3
4
|
export default class BlocksLayoutManager extends LayoutManager {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
layoutOptions: any;
|
|
9
|
-
renderWidget: any;
|
|
10
|
-
disableMaps: any;
|
|
11
|
-
clipboard: any;
|
|
12
|
-
onClipboardChange: any;
|
|
13
|
-
cantPasteMessage: any;
|
|
14
|
-
}, React.Component<{
|
|
15
|
-
items: any;
|
|
16
|
-
onItemsChange: any;
|
|
17
|
-
style: any;
|
|
18
|
-
layoutOptions: any;
|
|
19
|
-
renderWidget: any;
|
|
20
|
-
disableMaps: any;
|
|
21
|
-
clipboard: any;
|
|
22
|
-
onClipboardChange: any;
|
|
23
|
-
cantPasteMessage: any;
|
|
24
|
-
}, any, any>>;
|
|
5
|
+
/**
|
|
6
|
+
* Renders the layout as a react element
|
|
7
|
+
*/
|
|
8
|
+
renderLayout(options: RenderLayoutOptions): React.CElement<import("./BlocksDisplayComponent").BlocksDisplayComponentProps, BlocksDisplayComponent>;
|
|
25
9
|
isEmpty(items: any): boolean;
|
|
26
10
|
getWidgetTypeAndDesign(items: any, widgetId: any): {
|
|
27
11
|
type: string;
|
|
@@ -8,24 +8,15 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const R = react_1.default.createElement;
|
|
9
9
|
const uuid_1 = __importDefault(require("uuid"));
|
|
10
10
|
const LayoutManager_1 = __importDefault(require("../LayoutManager"));
|
|
11
|
+
const BlocksDisplayComponent_1 = __importDefault(require("./BlocksDisplayComponent"));
|
|
11
12
|
class BlocksLayoutManager extends LayoutManager_1.default {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// onItemsChange: Called when items changes
|
|
16
|
-
// renderWidget: called with ({ id:, type:, design:, onDesignChange:, width:, height: })
|
|
17
|
-
// style: style to use for layout. null for default
|
|
18
|
-
// layoutOptions: layout options to use
|
|
19
|
-
// disableMaps: true to disable maps
|
|
20
|
-
// clipboard: clipboard contents
|
|
21
|
-
// onClipboardChange: called when clipboard is changed
|
|
22
|
-
// cantPasteMesssage: message to display if clipboard can't be pasted into current dashboard
|
|
13
|
+
/**
|
|
14
|
+
* Renders the layout as a react element
|
|
15
|
+
*/
|
|
23
16
|
renderLayout(options) {
|
|
24
|
-
|
|
25
|
-
return R(BlocksDisplayComponent, {
|
|
17
|
+
return R(BlocksDisplayComponent_1.default, {
|
|
26
18
|
items: options.items || { id: "root", type: "root", blocks: [] },
|
|
27
19
|
onItemsChange: options.onItemsChange,
|
|
28
|
-
style: options.style,
|
|
29
20
|
layoutOptions: options.layoutOptions,
|
|
30
21
|
renderWidget: options.renderWidget,
|
|
31
22
|
disableMaps: options.disableMaps,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
2
|
import { LayoutBlock } from "./blockUtils";
|
|
3
3
|
export interface HorizontalBlockComponentProps {
|
|
4
4
|
block: LayoutBlock;
|
|
5
|
-
collapseColumns
|
|
6
|
-
|
|
5
|
+
collapseColumns: boolean;
|
|
6
|
+
priority: number;
|
|
7
|
+
renderBlock: (block: LayoutBlock, collapseColumns: boolean, priority: number) => ReactElement;
|
|
7
8
|
/** Called with (sourceBlock, targetBlock, side) when block is dropped on it. side is top, left, bottom, right */
|
|
8
9
|
onBlockDrop?: any;
|
|
9
10
|
/** Called with (block) when block is removed */
|
|
@@ -21,7 +22,7 @@ export default class HorizontalBlockComponent extends React.Component<Horizontal
|
|
|
21
22
|
blockRefs: {
|
|
22
23
|
[blockId: string]: HTMLElement | null;
|
|
23
24
|
};
|
|
24
|
-
constructor(props:
|
|
25
|
+
constructor(props: HorizontalBlockComponentProps);
|
|
25
26
|
componentWillUnmount(): void;
|
|
26
27
|
handleMouseDown: (index: any, ev: any) => void;
|
|
27
28
|
handleMouseMove: (ev: any) => void;
|
|
@@ -23,7 +23,7 @@ class HorizontalBlockComponent extends react_1.default.Component {
|
|
|
23
23
|
componentWillUnmount() {
|
|
24
24
|
// Remove listeners
|
|
25
25
|
document.removeEventListener("mousemove", this.handleMouseMove);
|
|
26
|
-
|
|
26
|
+
document.removeEventListener("mouseup", this.handleMouseUp);
|
|
27
27
|
}
|
|
28
28
|
handleMouseDown = (index, ev) => {
|
|
29
29
|
// Prevent html5 drag
|
|
@@ -35,7 +35,7 @@ class HorizontalBlockComponent extends react_1.default.Component {
|
|
|
35
35
|
rightSize: this.blockRefs[`block${index + 1}`].offsetWidth
|
|
36
36
|
});
|
|
37
37
|
document.addEventListener("mousemove", this.handleMouseMove);
|
|
38
|
-
|
|
38
|
+
document.addEventListener("mouseup", this.handleMouseUp);
|
|
39
39
|
};
|
|
40
40
|
handleMouseMove = (ev) => {
|
|
41
41
|
if (!this.state.dragInitialX) {
|
|
@@ -76,7 +76,7 @@ class HorizontalBlockComponent extends react_1.default.Component {
|
|
|
76
76
|
let asc, end;
|
|
77
77
|
let asc1, end1;
|
|
78
78
|
if (this.props.collapseColumns) {
|
|
79
|
-
return R("div", null, lodash_1.default.map(this.props.block.blocks, (block
|
|
79
|
+
return R("div", null, lodash_1.default.map(this.props.block.blocks, (block) => this.props.renderBlock(block, true, this.props.priority)));
|
|
80
80
|
}
|
|
81
81
|
// Calculate widths (percentages)
|
|
82
82
|
let totalWeight = 0;
|
|
@@ -110,7 +110,7 @@ class HorizontalBlockComponent extends react_1.default.Component {
|
|
|
110
110
|
ref: (c) => {
|
|
111
111
|
return (this.blockRefs[`block${index}`] = c);
|
|
112
112
|
}
|
|
113
|
-
}, this.props.renderBlock(block))
|
|
113
|
+
}, this.props.renderBlock(block, false, this.props.priority))
|
|
114
114
|
];
|
|
115
115
|
}))));
|
|
116
116
|
// Allow dropping
|
|
@@ -131,7 +131,7 @@ class HorizontalBlockComponent extends react_1.default.Component {
|
|
|
131
131
|
return (this.blockRefs[`block${index}`] = c);
|
|
132
132
|
},
|
|
133
133
|
className: "mwater-visualization-horizontal-block-item"
|
|
134
|
-
}, this.props.renderBlock(block))
|
|
134
|
+
}, this.props.renderBlock(block, false, this.props.priority))
|
|
135
135
|
];
|
|
136
136
|
}));
|
|
137
137
|
}
|
package/lib/mWaterLoader.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface MWaterLoaderOptions {
|
|
|
14
14
|
localCaching?: boolean;
|
|
15
15
|
/** Locales of the schema to load. Default is all. */
|
|
16
16
|
locales?: string[];
|
|
17
|
+
/** Origin of usage. e.g. "dashboards:43445364..." */
|
|
18
|
+
origin?: string;
|
|
17
19
|
}
|
|
18
20
|
/** Loads a schema and data source that is specific to mWater server */
|
|
19
21
|
export default function mWaterLoader(options: MWaterLoaderOptions, callback: (error: any, config?: {
|
package/lib/mWaterLoader.js
CHANGED
|
@@ -42,7 +42,8 @@ function mWaterLoader(options, callback) {
|
|
|
42
42
|
const schema = new expressions_1.Schema(schemaJson);
|
|
43
43
|
const dataSource = new MWaterDataSource_1.default(options.apiUrl, options.client, {
|
|
44
44
|
serverCaching: false,
|
|
45
|
-
localCaching: options.localCaching != null ? options.localCaching : true
|
|
45
|
+
localCaching: options.localCaching != null ? options.localCaching : true,
|
|
46
|
+
origin: options.origin
|
|
46
47
|
});
|
|
47
48
|
return callback(null, {
|
|
48
49
|
schema,
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { DataSource, Schema } from "@mwater/expressions";
|
|
3
|
+
import { MapDesign } from "..";
|
|
4
4
|
export interface AddLayerComponentProps {
|
|
5
5
|
/** Number of layers that already exist */
|
|
6
6
|
layerNumber: number;
|
|
7
7
|
/** See Map Design.md */
|
|
8
|
-
design:
|
|
8
|
+
design: MapDesign;
|
|
9
9
|
/** Called with new design */
|
|
10
|
-
onDesignChange:
|
|
10
|
+
onDesignChange: (design: MapDesign) => void;
|
|
11
11
|
/** Schema to use */
|
|
12
12
|
schema: Schema;
|
|
13
13
|
dataSource: DataSource;
|
|
14
14
|
}
|
|
15
15
|
export default class AddLayerComponent extends React.Component<AddLayerComponentProps> {
|
|
16
|
-
static
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
handleAddLayer: (newLayer: any) => any;
|
|
20
|
-
handleAddLayerView: (layerView: any) => any;
|
|
16
|
+
static contextType: React.Context<import("../MWaterContextComponent").AddLayerElementFactory | undefined>;
|
|
17
|
+
handleAddLayer: (newLayer: any) => void;
|
|
18
|
+
handleAddLayerView: (layerView: any) => void;
|
|
21
19
|
render(): any;
|
|
22
20
|
}
|
|
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const prop_types_1 = __importDefault(require("prop-types"));
|
|
7
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
7
|
const react_1 = __importDefault(require("react"));
|
|
9
8
|
const R = react_1.default.createElement;
|
|
10
9
|
const uuid_1 = __importDefault(require("uuid"));
|
|
11
10
|
const LayerFactory_1 = __importDefault(require("./LayerFactory"));
|
|
11
|
+
const MWaterContextComponent_1 = require("../MWaterContextComponent");
|
|
12
12
|
// Dropdown to add a new layer.
|
|
13
13
|
// Can be overridden by context of addLayerElementFactory which is called with all props
|
|
14
14
|
class AddLayerComponent extends react_1.default.Component {
|
|
15
|
-
static
|
|
15
|
+
static contextType = MWaterContextComponent_1.AddLayerElementFactoryContext;
|
|
16
16
|
handleAddLayer = (newLayer) => {
|
|
17
17
|
const layerView = {
|
|
18
18
|
id: (0, uuid_1.default)(),
|
|
@@ -32,12 +32,12 @@ class AddLayerComponent extends react_1.default.Component {
|
|
|
32
32
|
// Add to list
|
|
33
33
|
const layerViews = this.props.design.layerViews.slice();
|
|
34
34
|
layerViews.push(layerView);
|
|
35
|
-
const design =
|
|
36
|
-
|
|
35
|
+
const design = { ...this.props.design, layerViews };
|
|
36
|
+
this.props.onDesignChange(design);
|
|
37
37
|
};
|
|
38
38
|
render() {
|
|
39
|
-
if (this.context
|
|
40
|
-
return this.context
|
|
39
|
+
if (this.context) {
|
|
40
|
+
return this.context(this.props);
|
|
41
41
|
}
|
|
42
42
|
const newLayers = [
|
|
43
43
|
{
|