@mwater/visualization 5.4.0 → 5.4.2
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.js +2 -1
- package/lib/IdSelection.d.ts +16 -0
- package/lib/IdSelection.js +59 -0
- package/lib/MWaterAddRelatedIndicatorComponent.js +2 -2
- package/lib/MWaterCompleteTableSelectComponent.d.ts +3 -8
- package/lib/MWaterCompleteTableSelectComponent.js +36 -42
- package/lib/MWaterLoaderComponent.d.ts +11 -10
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterResponsesFilterComponent.js +1 -1
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +4 -6
- package/lib/autotranslate.d.ts +20 -0
- package/lib/autotranslate.js +122 -0
- package/lib/axes/AxisBuilder.js +3 -3
- package/lib/axes/AxisColorEditorComponent.js +4 -0
- package/lib/axes/AxisComponent.d.ts +8 -12
- package/lib/axes/AxisComponent.js +32 -80
- package/lib/axes/CategoryMapComponent.js +4 -4
- package/lib/axes/RangesComponent.js +2 -2
- package/lib/dashboards/DashboardComponent.d.ts +6 -0
- package/lib/dashboards/DashboardComponent.js +44 -12
- package/lib/dashboards/DashboardDesign.d.ts +11 -2
- package/lib/dashboards/DashboardUtils.d.ts +5 -0
- package/lib/dashboards/DashboardUtils.js +30 -0
- package/lib/dashboards/DashboardViewComponent.d.ts +2 -0
- package/lib/dashboards/DashboardViewComponent.js +16 -3
- package/lib/dashboards/ServerDashboardDataSource.js +2 -1
- package/lib/dashboards/SettingsModalComponent.d.ts +1 -1
- package/lib/dashboards/SettingsModalComponent.js +256 -19
- package/lib/dashboards/WidgetComponent.d.ts +6 -3
- package/lib/dashboards/WidgetComponent.js +3 -1
- package/lib/datagrids/CellEditor.d.ts +19 -0
- package/lib/datagrids/CellEditor.js +223 -0
- package/lib/datagrids/DatagridComponent.d.ts +18 -87
- package/lib/datagrids/DatagridComponent.js +304 -222
- package/lib/datagrids/DatagridViewComponent.d.ts +15 -53
- package/lib/datagrids/DatagridViewComponent.js +256 -257
- package/lib/datagrids/DirectDatagridDataSource.js +2 -3
- package/lib/datagrids/ExprCellComponent.d.ts +8 -15
- package/lib/datagrids/ExprCellComponent.js +11 -15
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -6
- package/lib/datagrids/FindReplaceModalComponent.js +38 -75
- package/lib/index.css +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
- package/lib/mWaterLoader.d.ts +1 -1
- package/lib/maps/BufferLayer.d.ts +7 -5
- package/lib/maps/BufferLayer.js +69 -48
- package/lib/maps/BufferLayerDesign.d.ts +21 -14
- package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
- package/lib/maps/BufferLayerDesignerComponent.js +68 -102
- package/lib/maps/ChoroplethLayer.d.ts +5 -4
- package/lib/maps/ChoroplethLayer.js +32 -9
- package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
- package/lib/maps/ChoroplethLayerDesigner.js +4 -2
- package/lib/maps/ClusterLayer.d.ts +3 -4
- package/lib/maps/ClusterLayer.js +2 -1
- package/lib/maps/DetailLevelSelectComponent.js +1 -1
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +5 -3
- package/lib/maps/GridLayer.d.ts +3 -4
- package/lib/maps/GridLayer.js +2 -1
- package/lib/maps/GridLayerDesigner.js +5 -3
- package/lib/maps/HoverContent.d.ts +11 -3
- package/lib/maps/HoverContent.js +25 -9
- package/lib/maps/Layer.d.ts +24 -3
- package/lib/maps/Layer.js +5 -1
- package/lib/maps/LayerFactory.js +0 -8
- package/lib/maps/LayerLegendComponent.js +0 -1
- package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/LeafletMapComponent.js +3 -1
- package/lib/maps/LegendComponent.d.ts +1 -0
- package/lib/maps/LegendComponent.js +9 -1
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +2 -2
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.d.ts +4 -3
- package/lib/maps/MapDesignerComponent.js +68 -74
- package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
- package/lib/maps/MapUtils.d.ts +4 -0
- package/lib/maps/MapUtils.js +19 -0
- package/lib/maps/MapViewComponent.d.ts +8 -3
- package/lib/maps/MarkersLayer.d.ts +5 -4
- package/lib/maps/MarkersLayer.js +33 -7
- package/lib/maps/MarkersLayerDesign.d.ts +19 -16
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
- package/lib/maps/PopupFilterJoinsUtils.js +0 -6
- package/lib/maps/RasterMapViewComponent.d.ts +3 -31
- package/lib/maps/RasterMapViewComponent.js +7 -2
- package/lib/maps/ServerMapDataSource.js +2 -1
- package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
- package/lib/maps/SwitchableTileUrlLayer.js +2 -1
- package/lib/maps/TileUrlLayer.d.ts +4 -5
- package/lib/maps/TileUrlLayer.js +2 -1
- package/lib/maps/VectorMapViewComponent.d.ts +5 -37
- package/lib/maps/VectorMapViewComponent.js +19 -8
- package/lib/maps/maps.d.ts +3 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersDesignComponent.js +19 -35
- package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
- package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
- package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
- package/lib/richtext/ExprItemsTranslator.js +149 -0
- package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
- package/lib/richtext/ItemsHtmlConverter.js +31 -15
- package/lib/wellknown.js +12 -9
- package/lib/widgets/IFrameWidget.d.ts +4 -4
- package/lib/widgets/ImageWidget.d.ts +7 -4
- package/lib/widgets/ImageWidget.js +9 -1
- package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
- package/lib/widgets/ImageWidgetComponent.js +1 -1
- package/lib/widgets/MapWidget.d.ts +5 -48
- package/lib/widgets/MapWidget.js +26 -63
- package/lib/widgets/MarkdownWidget.d.ts +3 -0
- package/lib/widgets/MarkdownWidget.js +3 -0
- package/lib/widgets/TOCWidget.d.ts +15 -27
- package/lib/widgets/TOCWidget.js +107 -183
- package/lib/widgets/Widget.d.ts +18 -7
- package/lib/widgets/Widget.js +4 -0
- package/lib/widgets/WidgetScopesViewComponent.js +1 -1
- package/lib/widgets/charts/Chart.d.ts +10 -1
- package/lib/widgets/charts/Chart.js +22 -11
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +6 -3
- package/lib/widgets/charts/ChartWidget.d.ts +2 -0
- package/lib/widgets/charts/ChartWidget.js +9 -1
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
- package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
- package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
- package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
- package/lib/widgets/charts/layered/LayeredChart.js +63 -3
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +3 -3
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
- package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChart.js +63 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +6 -0
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
- package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
- package/lib/widgets/charts/table/TableChart.d.ts +1 -0
- package/lib/widgets/charts/table/TableChart.js +15 -0
- package/lib/widgets/text/TextComponent.d.ts +11 -4
- package/lib/widgets/text/TextComponent.js +11 -8
- package/lib/widgets/text/TextWidget.d.ts +6 -3
- package/lib/widgets/text/TextWidget.js +7 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
- package/lib/widgets/text/TextWidgetComponent.js +7 -1
- package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
- package/lib/widgets/text/TextWidgetDesign.js +1 -1
- package/package.json +7 -8
- package/src/ColorComponent.tsx +1 -2
- package/src/IdSelection.ts +62 -0
- package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
- package/src/MWaterLoaderComponent.ts +28 -26
- package/src/MWaterResponsesFilterComponent.ts +5 -2
- package/src/MWaterTableSelectComponent.tsx +5 -9
- package/src/autotranslate.ts +141 -0
- package/src/axes/AxisBuilder.ts +3 -3
- package/src/axes/AxisColorEditorComponent.tsx +5 -0
- package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
- package/src/axes/CategoryMapComponent.ts +4 -4
- package/src/axes/RangesComponent.ts +3 -2
- package/src/dashboards/DashboardComponent.tsx +79 -14
- package/src/dashboards/DashboardDesign.ts +9 -2
- package/src/dashboards/DashboardUtils.ts +39 -0
- package/src/dashboards/DashboardViewComponent.tsx +22 -3
- package/src/dashboards/ServerDashboardDataSource.ts +2 -1
- package/src/dashboards/SettingsModalComponent.tsx +450 -35
- package/src/dashboards/WidgetComponent.tsx +12 -6
- package/src/datagrids/CellEditor.tsx +354 -0
- package/src/datagrids/DatagridComponent.tsx +646 -0
- package/src/datagrids/DatagridViewComponent.tsx +539 -0
- package/src/datagrids/DirectDatagridDataSource.ts +2 -3
- package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
- package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
- package/src/index.css +1 -1
- package/src/index.ts +0 -1
- package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
- package/src/mWaterLoader.ts +1 -1
- package/src/maps/BufferLayer.ts +83 -60
- package/src/maps/BufferLayerDesign.ts +20 -14
- package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
- package/src/maps/ChoroplethLayer.ts +40 -19
- package/src/maps/ChoroplethLayerDesign.ts +4 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
- package/src/maps/ClusterLayer.ts +4 -10
- package/src/maps/DetailLevelSelectComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +2 -1
- package/src/maps/EditPopupComponent.ts +7 -3
- package/src/maps/GridLayer.ts +4 -10
- package/src/maps/GridLayerDesigner.tsx +5 -3
- package/src/maps/HoverContent.tsx +40 -16
- package/src/maps/Layer.ts +28 -10
- package/src/maps/LayerFactory.ts +0 -8
- package/src/maps/LayerLegendComponent.ts +2 -4
- package/src/maps/LayerSwitcherComponent.tsx +6 -2
- package/src/maps/LeafletMapComponent.tsx +3 -1
- package/src/maps/LegendComponent.tsx +10 -1
- package/src/maps/MWaterServerLayer.ts +3 -3
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +3 -0
- package/src/maps/MapDesignerComponent.tsx +165 -162
- package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
- package/src/maps/MapUtils.ts +24 -0
- package/src/maps/MapViewComponent.tsx +11 -3
- package/src/maps/MarkersLayer.ts +44 -18
- package/src/maps/MarkersLayerDesign.ts +19 -16
- package/src/maps/PopupFilterJoinsUtils.ts +6 -2
- package/src/maps/RasterMapViewComponent.ts +9 -45
- package/src/maps/ServerMapDataSource.ts +2 -2
- package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
- package/src/maps/TileUrlLayer.tsx +4 -10
- package/src/maps/VectorMapViewComponent.tsx +28 -55
- package/src/maps/maps.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +56 -74
- package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
- package/src/richtext/ExprItemsTranslator.ts +176 -0
- package/src/richtext/ItemsHtmlConverter.ts +33 -18
- package/src/wellknown.ts +33 -30
- package/src/widgets/ImageWidget.ts +10 -1
- package/src/widgets/ImageWidgetComponent.ts +3 -2
- package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
- package/src/widgets/MarkdownWidget.ts +3 -0
- package/src/widgets/TOCWidget.tsx +281 -0
- package/src/widgets/Widget.ts +25 -5
- package/src/widgets/WidgetScopesViewComponent.ts +2 -1
- package/src/widgets/charts/Chart.ts +31 -12
- package/src/widgets/charts/ChartViewComponent.ts +13 -3
- package/src/widgets/charts/ChartWidget.ts +11 -1
- package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
- package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
- package/src/widgets/charts/layered/LayeredChart.ts +71 -3
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +4 -4
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
- package/src/widgets/charts/pivot/PivotChart.ts +73 -0
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
- package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
- package/src/widgets/charts/table/TableChart.ts +17 -0
- package/src/widgets/text/TextComponent.tsx +22 -12
- package/src/widgets/text/TextWidget.ts +9 -2
- package/src/widgets/text/TextWidgetComponent.tsx +16 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -7
- package/test/IdSelectionTests.ts +54 -0
- package/test/LayeredChartCompilerTests.ts +0 -2
- package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
- package/test/wellknownTests.ts +144 -0
- package/src/datagrids/DatagridComponent.ts +0 -478
- package/src/datagrids/DatagridViewComponent.ts +0 -464
- package/src/datagrids/EditExprCellComponent.tsx +0 -305
- package/src/datagrids/README.md +0 -3
- package/src/maps/BufferLayerDesignerComponent.ts +0 -311
- package/src/widgets/TOCWidget.ts +0 -326
- package/test/LegoLayoutEngineTests.ts +0 -69
package/lib/widgets/MapWidget.js
CHANGED
|
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const react_1 = __importDefault(require("react"));
|
|
30
|
-
const R = react_1.default.createElement;
|
|
31
30
|
const lodash_1 = __importDefault(require("lodash"));
|
|
32
31
|
const Widget_1 = __importDefault(require("./Widget"));
|
|
33
32
|
const DropdownWidgetComponent_1 = __importDefault(require("./DropdownWidgetComponent"));
|
|
@@ -49,26 +48,16 @@ class MapWidget extends Widget_1.default {
|
|
|
49
48
|
// height: height in pixels on screen
|
|
50
49
|
// onRowClick: Called with (tableId, rowId) when item is clicked
|
|
51
50
|
createViewElement(options) {
|
|
52
|
-
return react_1.default.createElement(MapWidgetComponent, {
|
|
53
|
-
schema: options.schema,
|
|
54
|
-
dataSource: options.dataSource,
|
|
55
|
-
widgetDataSource: options.widgetDataSource,
|
|
56
|
-
design: options.design,
|
|
57
|
-
onDesignChange: options.onDesignChange,
|
|
58
|
-
scope: options.scope,
|
|
59
|
-
filters: options.filters,
|
|
60
|
-
onScopeChange: options.onScopeChange,
|
|
61
|
-
width: options.width,
|
|
62
|
-
height: options.height,
|
|
63
|
-
onRowClick: options.onRowClick,
|
|
64
|
-
refreshKey: options.refreshKey
|
|
65
|
-
});
|
|
51
|
+
return react_1.default.createElement(MapWidgetComponent, { schema: options.schema, dataSource: options.dataSource, widgetDataSource: options.widgetDataSource, design: options.design, onDesignChange: options.onDesignChange, scope: options.scope, filters: options.filters, onScopeChange: options.onScopeChange, width: options.width, height: options.height, onRowClick: options.onRowClick, refreshKey: options.refreshKey, locale: options.locale, translate: options.translate });
|
|
66
52
|
}
|
|
67
53
|
// Get a list of table ids that can be filtered on
|
|
68
54
|
getFilterableTables(design, schema) {
|
|
69
55
|
// Get filterable tables
|
|
70
56
|
return MapUtils.getFilterableTables(design, schema);
|
|
71
57
|
}
|
|
58
|
+
getTranslatableStrings(design, schema) {
|
|
59
|
+
return MapUtils.getTranslatableStrings(design, schema);
|
|
60
|
+
}
|
|
72
61
|
}
|
|
73
62
|
exports.default = MapWidget;
|
|
74
63
|
class MapWidgetComponent extends react_1.default.Component {
|
|
@@ -102,53 +91,31 @@ class MapWidgetComponent extends react_1.default.Component {
|
|
|
102
91
|
// Require here to prevent server require problems
|
|
103
92
|
const MapDesignerComponent = require("../maps/MapDesignerComponent").default;
|
|
104
93
|
// Create editor
|
|
105
|
-
const editor = react_1.default.createElement(MapDesignerComponent, {
|
|
106
|
-
schema: this.props.schema,
|
|
107
|
-
dataSource: this.props.dataSource,
|
|
108
|
-
design: this.state.editDesign,
|
|
109
|
-
onDesignChange: this.handleEditDesignChange,
|
|
110
|
-
filters: this.props.filters
|
|
111
|
-
});
|
|
94
|
+
const editor = react_1.default.createElement(MapDesignerComponent, { schema: this.props.schema, dataSource: this.props.dataSource, design: this.state.editDesign, onDesignChange: this.handleEditDesignChange, filters: this.props.filters });
|
|
112
95
|
// Create map (maxing out at half of width of screen)
|
|
113
|
-
const width = Math.min(document.body.clientWidth / 2, this.props.width);
|
|
114
|
-
const height = (this.props.height * width) / this.props.width;
|
|
96
|
+
const width = Math.min(document.body.clientWidth / 2, this.props.width || 0);
|
|
97
|
+
const height = ((this.props.height || 0) * width) / (this.props.width || 1);
|
|
115
98
|
const chart = this.renderContent(this.state.editDesign, this.handleEditDesignChange, width, height);
|
|
116
|
-
const content =
|
|
117
|
-
style: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
},
|
|
130
|
-
return react_1.default.createElement(ModalWindowComponent_1.default, {
|
|
131
|
-
isOpen: true,
|
|
132
|
-
onRequestClose: this.handleEndEditing
|
|
133
|
-
}, content);
|
|
99
|
+
const content = react_1.default.createElement("div", { style: { height: "100%", width: "100%" } },
|
|
100
|
+
react_1.default.createElement("div", { style: {
|
|
101
|
+
position: "absolute",
|
|
102
|
+
left: 0,
|
|
103
|
+
top: 0,
|
|
104
|
+
border: "solid 2px #EEE",
|
|
105
|
+
borderRadius: 8,
|
|
106
|
+
padding: 10,
|
|
107
|
+
width: width + 20,
|
|
108
|
+
height: height + 20
|
|
109
|
+
} }, chart),
|
|
110
|
+
react_1.default.createElement("div", { style: { width: "100%", height: "100%", paddingLeft: width + 40 } },
|
|
111
|
+
react_1.default.createElement("div", { style: { width: "100%", height: "100%", overflowY: "auto", paddingLeft: 20, borderLeft: "solid 3px #AAA" } }, editor)));
|
|
112
|
+
return react_1.default.createElement(ModalWindowComponent_1.default, { isOpen: true, onRequestClose: this.handleEndEditing }, content);
|
|
134
113
|
}
|
|
135
114
|
renderContent(design, onDesignChange, width, height) {
|
|
136
115
|
// Require here to prevent server require problems
|
|
137
116
|
const { MapViewComponent } = require("../maps/MapViewComponent");
|
|
138
|
-
return
|
|
139
|
-
schema: this.props.schema,
|
|
140
|
-
design,
|
|
141
|
-
dataSource: this.props.dataSource,
|
|
142
|
-
mapDataSource: this.props.widgetDataSource.getMapDataSource(design),
|
|
143
|
-
onDesignChange,
|
|
144
|
-
scope: this.props.scope,
|
|
145
|
-
onScopeChange: this.props.onScopeChange,
|
|
146
|
-
extraFilters: this.props.filters,
|
|
147
|
-
width: width - 20,
|
|
148
|
-
height: height - 20,
|
|
149
|
-
scrollWheelZoom: false, // Prevent accidental zooming
|
|
150
|
-
onRowClick: this.props.onRowClick
|
|
151
|
-
}));
|
|
117
|
+
return react_1.default.createElement("div", { style: { width, height, padding: 10 } },
|
|
118
|
+
react_1.default.createElement(MapViewComponent, { schema: this.props.schema, design: design, dataSource: this.props.dataSource, mapDataSource: this.props.widgetDataSource.getMapDataSource(design), onDesignChange: onDesignChange, scope: this.props.scope, onScopeChange: this.props.onScopeChange, extraFilters: this.props.filters, width: width - 20, height: height - 20, scrollWheelZoom: false, onRowClick: this.props.onRowClick, locale: this.props.locale, translate: this.props.translate }));
|
|
152
119
|
}
|
|
153
120
|
render() {
|
|
154
121
|
const dropdownItems = [];
|
|
@@ -157,12 +124,8 @@ class MapWidgetComponent extends react_1.default.Component {
|
|
|
157
124
|
}
|
|
158
125
|
const handleDesignChange = (d) => this.setState({ transientDesign: d });
|
|
159
126
|
// Wrap in a simple widget
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
width: this.props.width,
|
|
164
|
-
height: this.props.height,
|
|
165
|
-
dropdownItems
|
|
166
|
-
}, this.renderContent(this.state.transientDesign, handleDesignChange, this.props.width, this.props.height)));
|
|
127
|
+
return react_1.default.createElement("div", null,
|
|
128
|
+
this.props.onDesignChange != null ? this.renderEditor() : undefined,
|
|
129
|
+
react_1.default.createElement(DropdownWidgetComponent_1.default, { width: this.props.width, height: this.props.height, dropdownItems: dropdownItems }, this.renderContent(this.state.transientDesign, handleDesignChange, this.props.width, this.props.height)));
|
|
167
130
|
}
|
|
168
131
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Widget, { CreateViewElementOptions } from "./Widget";
|
|
3
3
|
import ModalWindowComponent from "@mwater/react-library/lib/ModalWindowComponent";
|
|
4
|
+
/** Widget for displaying markdown. Deprecated. Use TextWidget instead.
|
|
5
|
+
* @deprecated
|
|
6
|
+
*/
|
|
4
7
|
export default class MarkdownWidget extends Widget {
|
|
5
8
|
createViewElement(options: CreateViewElementOptions): React.CElement<any, MarkdownWidgetComponent>;
|
|
6
9
|
isAutoHeight(): boolean;
|
|
@@ -10,6 +10,9 @@ const Widget_1 = __importDefault(require("./Widget"));
|
|
|
10
10
|
const DropdownWidgetComponent_1 = __importDefault(require("./DropdownWidgetComponent"));
|
|
11
11
|
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
12
12
|
const ModalWindowComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalWindowComponent"));
|
|
13
|
+
/** Widget for displaying markdown. Deprecated. Use TextWidget instead.
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
13
16
|
class MarkdownWidget extends Widget_1.default {
|
|
14
17
|
// Creates a React element that is a view of the widget
|
|
15
18
|
// options:
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import Widget, { CreateViewElementOptions } from "./Widget";
|
|
4
|
-
import
|
|
3
|
+
import { Schema } from "@mwater/expressions";
|
|
4
|
+
export interface TOCWidgetDesign {
|
|
5
|
+
/** Header text. Defaults to blank */
|
|
6
|
+
header?: string;
|
|
7
|
+
/** Border weight. Defaults to 0=None. 1=light, 2=medium, 3=heavy */
|
|
8
|
+
borderWeight?: number;
|
|
9
|
+
/** True/false for prepending numbering to entries (e.g. 3.4.1) */
|
|
10
|
+
numbering?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Table of contents widget that displays the h1, h2, etc entries from all text fields in one widget
|
|
14
|
+
*/
|
|
5
15
|
export default class TOCWidget extends Widget {
|
|
6
|
-
|
|
16
|
+
/** Creates a React element that is a view of the widget */
|
|
17
|
+
createViewElement(options: CreateViewElementOptions): React.JSX.Element;
|
|
7
18
|
isAutoHeight(): boolean;
|
|
19
|
+
getTranslatableStrings(design: TOCWidgetDesign, schema: Schema): string[];
|
|
8
20
|
}
|
|
9
|
-
declare class TOCWidgetComponent extends React.Component {
|
|
10
|
-
static propTypes: {
|
|
11
|
-
design: PropTypes.Validator<object>;
|
|
12
|
-
onDesignChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
13
|
-
width: PropTypes.Requireable<number>;
|
|
14
|
-
height: PropTypes.Requireable<number>;
|
|
15
|
-
tocEntries: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
16
|
-
id: PropTypes.Requireable<any>;
|
|
17
|
-
widgetId: PropTypes.Validator<string>;
|
|
18
|
-
level: PropTypes.Validator<number>;
|
|
19
|
-
text: PropTypes.Validator<string>;
|
|
20
|
-
}> | null | undefined)[]>;
|
|
21
|
-
onScrollToTOCEntry: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
};
|
|
23
|
-
constructor(props: any);
|
|
24
|
-
handleStartEditing: () => void;
|
|
25
|
-
handleEndEditing: () => void;
|
|
26
|
-
renderEditor(): React.CElement<import("@mwater/react-library/lib/ModalPopupComponent").ModalPopupComponentProps, ModalPopupComponent> | null;
|
|
27
|
-
renderContent(): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
28
|
-
render(): React.DetailedReactHTMLElement<{
|
|
29
|
-
onDoubleClick: () => void;
|
|
30
|
-
}, HTMLElement>;
|
|
31
|
-
}
|
|
32
|
-
export {};
|
package/lib/widgets/TOCWidget.js
CHANGED
|
@@ -26,146 +26,88 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const
|
|
30
|
-
const react_1 = __importDefault(require("react"));
|
|
31
|
-
const R = react_1.default.createElement;
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
32
30
|
const lodash_1 = __importDefault(require("lodash"));
|
|
33
31
|
const ui = __importStar(require("@mwater/react-library/lib/bootstrap"));
|
|
34
|
-
const update_1 = __importDefault(require("@mwater/react-library/lib/update"));
|
|
35
32
|
const Widget_1 = __importDefault(require("./Widget"));
|
|
36
33
|
const DropdownWidgetComponent_1 = __importDefault(require("./DropdownWidgetComponent"));
|
|
37
34
|
const ModalPopupComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalPopupComponent"));
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// numbering: true/false for prepending numbering to entries (e.g. 3.4.1)
|
|
35
|
+
const immer_1 = __importDefault(require("immer"));
|
|
36
|
+
/**
|
|
37
|
+
* Table of contents widget that displays the h1, h2, etc entries from all text fields in one widget
|
|
38
|
+
*/
|
|
43
39
|
class TOCWidget extends Widget_1.default {
|
|
44
|
-
|
|
45
|
-
// options:
|
|
46
|
-
// schema: schema to use
|
|
47
|
-
// dataSource: data source to use
|
|
48
|
-
// widgetDataSource: Gives data to the widget in a way that allows client-server separation and secure sharing. See definition in WidgetDataSource.
|
|
49
|
-
// design: widget design
|
|
50
|
-
// scope: scope of the widget (when the widget self-selects a particular scope)
|
|
51
|
-
// filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct
|
|
52
|
-
// onScopeChange: called with scope of widget
|
|
53
|
-
// onDesignChange: called with new design. null/undefined for readonly
|
|
54
|
-
// width: width in pixels on screen
|
|
55
|
-
// height: height in pixels on screen
|
|
56
|
-
// tocEntries: entries in the table of contents
|
|
57
|
-
// onScrollToTOCEntry: called with (widgetId, tocEntryId) to scroll to TOC entry
|
|
40
|
+
/** Creates a React element that is a view of the widget */
|
|
58
41
|
createViewElement(options) {
|
|
59
|
-
return
|
|
60
|
-
design: options.design,
|
|
61
|
-
onDesignChange: options.onDesignChange,
|
|
62
|
-
width: options.width,
|
|
63
|
-
height: options.height,
|
|
64
|
-
tocEntries: options.tocEntries,
|
|
65
|
-
onScrollToTOCEntry: options.onScrollToTOCEntry
|
|
66
|
-
});
|
|
42
|
+
return react_1.default.createElement(TOCWidgetComponent, { design: options.design, onDesignChange: options.onDesignChange ?? undefined, width: options.width, height: options.height, tocEntries: options.tocEntries, onScrollToTOCEntry: options.onScrollToTOCEntry, translate: options.translate });
|
|
67
43
|
}
|
|
68
44
|
// Determine if widget is auto-height, which means that a vertical height is not required.
|
|
69
45
|
isAutoHeight() {
|
|
70
46
|
return true;
|
|
71
47
|
}
|
|
48
|
+
getTranslatableStrings(design, schema) {
|
|
49
|
+
const strings = [];
|
|
50
|
+
if (design.header) {
|
|
51
|
+
strings.push(design.header);
|
|
52
|
+
}
|
|
53
|
+
return strings;
|
|
54
|
+
}
|
|
72
55
|
}
|
|
73
56
|
exports.default = TOCWidget;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
height: prop_types_1.default.number,
|
|
80
|
-
tocEntries: prop_types_1.default.arrayOf(prop_types_1.default.shape({
|
|
81
|
-
id: prop_types_1.default.any,
|
|
82
|
-
widgetId: prop_types_1.default.string.isRequired,
|
|
83
|
-
level: prop_types_1.default.number.isRequired,
|
|
84
|
-
text: prop_types_1.default.string.isRequired
|
|
85
|
-
})),
|
|
86
|
-
onScrollToTOCEntry: prop_types_1.default.func
|
|
87
|
-
};
|
|
88
|
-
constructor(props) {
|
|
89
|
-
super(props);
|
|
90
|
-
this.state = {
|
|
91
|
-
editing: false // true if editing
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
handleStartEditing = () => {
|
|
95
|
-
return this.setState({ editing: true });
|
|
57
|
+
function TOCWidgetComponent(props) {
|
|
58
|
+
const { design, onDesignChange, width, height, tocEntries, onScrollToTOCEntry, translate } = props;
|
|
59
|
+
const [editing, setEditing] = (0, react_1.useState)(false);
|
|
60
|
+
const handleStartEditing = () => {
|
|
61
|
+
setEditing(true);
|
|
96
62
|
};
|
|
97
|
-
handleEndEditing = () => {
|
|
98
|
-
|
|
63
|
+
const handleEndEditing = () => {
|
|
64
|
+
setEditing(false);
|
|
99
65
|
};
|
|
100
|
-
renderEditor() {
|
|
101
|
-
if (!
|
|
66
|
+
const renderEditor = () => {
|
|
67
|
+
if (!editing) {
|
|
102
68
|
return null;
|
|
103
69
|
}
|
|
104
70
|
// Create editor
|
|
105
|
-
const editor =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
renderContent() {
|
|
116
|
-
return R(TOCWidgetViewComponent, {
|
|
117
|
-
design: this.props.design,
|
|
118
|
-
onDesignChange: this.props.onDesignChange,
|
|
119
|
-
width: this.props.width,
|
|
120
|
-
height: this.props.height,
|
|
121
|
-
tocEntries: this.props.tocEntries,
|
|
122
|
-
onScrollToTOCEntry: this.props.onScrollToTOCEntry
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
render() {
|
|
126
|
-
const dropdownItems = [];
|
|
127
|
-
if (this.props.onDesignChange != null) {
|
|
128
|
-
dropdownItems.push({ label: T `Edit`, icon: "pencil", onClick: this.handleStartEditing });
|
|
129
|
-
}
|
|
130
|
-
// Wrap in a simple widget
|
|
131
|
-
return R("div", { onDoubleClick: this.handleStartEditing }, this.props.onDesignChange != null ? this.renderEditor() : undefined, R(DropdownWidgetComponent_1.default, {
|
|
132
|
-
width: this.props.width,
|
|
133
|
-
height: this.props.height,
|
|
134
|
-
dropdownItems
|
|
135
|
-
}, this.renderContent()));
|
|
71
|
+
const editor = react_1.default.createElement(TOCWidgetDesignerComponent, { design: design, onDesignChange: onDesignChange });
|
|
72
|
+
return react_1.default.createElement(ModalPopupComponent_1.default, { showCloseX: true, header: T `Table of Contents Options`, onClose: handleEndEditing }, editor);
|
|
73
|
+
};
|
|
74
|
+
const renderContent = () => {
|
|
75
|
+
return react_1.default.createElement(TOCWidgetViewComponent, { design: design, onDesignChange: onDesignChange, width: width, height: height, tocEntries: tocEntries, onScrollToTOCEntry: onScrollToTOCEntry, translate: translate });
|
|
76
|
+
};
|
|
77
|
+
const dropdownItems = [];
|
|
78
|
+
if (onDesignChange != null) {
|
|
79
|
+
dropdownItems.push({ label: T `Edit`, icon: "pencil", onClick: handleStartEditing });
|
|
136
80
|
}
|
|
81
|
+
// Wrap in a simple widget
|
|
82
|
+
return react_1.default.createElement("div", { onDoubleClick: handleStartEditing },
|
|
83
|
+
onDesignChange != null ? renderEditor() : undefined,
|
|
84
|
+
react_1.default.createElement(DropdownWidgetComponent_1.default, { width: width, height: height, dropdownItems: dropdownItems }, renderContent()));
|
|
137
85
|
}
|
|
138
86
|
// Displays the contents of the widget
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
width: prop_types_1.default.number,
|
|
144
|
-
height: prop_types_1.default.number,
|
|
145
|
-
tocEntries: prop_types_1.default.arrayOf(prop_types_1.default.shape({
|
|
146
|
-
id: prop_types_1.default.any,
|
|
147
|
-
widgetId: prop_types_1.default.string.isRequired,
|
|
148
|
-
level: prop_types_1.default.number.isRequired,
|
|
149
|
-
text: prop_types_1.default.string.isRequired
|
|
150
|
-
})),
|
|
151
|
-
onScrollToTOCEntry: prop_types_1.default.func
|
|
87
|
+
function TOCWidgetViewComponent(props) {
|
|
88
|
+
const { design, onDesignChange, width, height, tocEntries, onScrollToTOCEntry, translate } = props;
|
|
89
|
+
const handleEntryClick = (tocEntry) => {
|
|
90
|
+
return onScrollToTOCEntry?.(tocEntry.widgetId, tocEntry.id);
|
|
152
91
|
};
|
|
153
|
-
|
|
154
|
-
return this.props.onScrollToTOCEntry?.(tocEntry.widgetId, tocEntry.id);
|
|
155
|
-
};
|
|
156
|
-
renderTOCEntry(tocEntry, index) {
|
|
92
|
+
const renderTOCEntry = (tocEntry, index) => {
|
|
157
93
|
// Find indentation number (e.g "1.3.2") by counting # backwards that are same level with no level lower
|
|
158
94
|
let level;
|
|
159
95
|
let indentation = "";
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
for (
|
|
96
|
+
if (design.numbering) {
|
|
97
|
+
// For each level up to the current entry's level
|
|
98
|
+
for (let level = 1; level <= tocEntry.level; level++) {
|
|
163
99
|
let value = 0;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
100
|
+
// Count entries at this level up to current index
|
|
101
|
+
for (let i = 0; i <= index; i++) {
|
|
102
|
+
const entry = tocEntries?.[i];
|
|
103
|
+
if (!entry) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (entry.level === level) {
|
|
107
|
+
value++;
|
|
167
108
|
}
|
|
168
|
-
else if (
|
|
109
|
+
else if (entry.level < level) {
|
|
110
|
+
// Reset counter when we hit a higher level
|
|
169
111
|
value = 0;
|
|
170
112
|
}
|
|
171
113
|
}
|
|
@@ -173,82 +115,64 @@ class TOCWidgetViewComponent extends react_1.default.Component {
|
|
|
173
115
|
}
|
|
174
116
|
indentation += " ";
|
|
175
117
|
}
|
|
176
|
-
return
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return
|
|
204
|
-
}),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
? R("div", { className: "text-muted" }, T `Table of Contents will appear here as text blocks with headings are added to the dashboard`)
|
|
118
|
+
return react_1.default.createElement("div", { key: index, style: { paddingLeft: tocEntry.level * 8 - 8 } },
|
|
119
|
+
react_1.default.createElement("a", { className: "link-plain", onClick: () => handleEntryClick(tocEntry) },
|
|
120
|
+
indentation,
|
|
121
|
+
react_1.default.createElement("span", null, translate(tocEntry.text))));
|
|
122
|
+
};
|
|
123
|
+
// Get border
|
|
124
|
+
const border = (() => {
|
|
125
|
+
switch (design.borderWeight) {
|
|
126
|
+
case 0:
|
|
127
|
+
return "none";
|
|
128
|
+
case 1:
|
|
129
|
+
return "solid 1px #f4f4f4";
|
|
130
|
+
case 2:
|
|
131
|
+
return "solid 1px #ccc";
|
|
132
|
+
case 3:
|
|
133
|
+
return "solid 1px #888";
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
return react_1.default.createElement("div", { style: {
|
|
137
|
+
width,
|
|
138
|
+
height,
|
|
139
|
+
border,
|
|
140
|
+
padding: 5,
|
|
141
|
+
margin: 1
|
|
142
|
+
} },
|
|
143
|
+
react_1.default.createElement("div", { style: { fontWeight: "bold" } }, design.header ? props.translate(design.header) : ""),
|
|
144
|
+
lodash_1.default.map(tocEntries || [], (tocEntry, i) => {
|
|
145
|
+
return renderTOCEntry(tocEntry, i);
|
|
146
|
+
}),
|
|
147
|
+
onDesignChange && (tocEntries || []).length === 0
|
|
148
|
+
? react_1.default.createElement("div", { className: "text-muted" }, T `Table of Contents will appear here as text blocks with headings are added to the dashboard`)
|
|
208
149
|
: undefined);
|
|
209
|
-
}
|
|
210
150
|
}
|
|
211
151
|
// Designer for TOC widget options
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
super(...args);
|
|
215
|
-
this.update = this.update.bind(this);
|
|
216
|
-
}
|
|
217
|
-
static propTypes = {
|
|
218
|
-
design: prop_types_1.default.object.isRequired,
|
|
219
|
-
onDesignChange: prop_types_1.default.func.isRequired
|
|
220
|
-
};
|
|
152
|
+
function TOCWidgetDesignerComponent(props) {
|
|
153
|
+
const { design, onDesignChange } = props;
|
|
221
154
|
// Updates design with the specified changes
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const design = lodash_1.default.extend({}, this.props.design, { markdown: ev.target.value });
|
|
227
|
-
return this.props.onDesignChange(design);
|
|
155
|
+
const handleUpdate = (field) => (value) => {
|
|
156
|
+
onDesignChange((0, immer_1.default)(design, draft => {
|
|
157
|
+
draft[field] = value;
|
|
158
|
+
}));
|
|
228
159
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
inline: true,
|
|
237
|
-
value: this.props.design.numbering || false,
|
|
238
|
-
radioValue: false,
|
|
239
|
-
onChange: this.update("numbering")
|
|
240
|
-
}, T `Off`)));
|
|
241
|
-
}
|
|
160
|
+
return react_1.default.createElement("div", null,
|
|
161
|
+
react_1.default.createElement(ui.FormGroup, { label: T `Header` },
|
|
162
|
+
react_1.default.createElement(ui.TextInput, { value: design.header || "", onChange: handleUpdate("header"), placeholder: T `None` })),
|
|
163
|
+
react_1.default.createElement(ui.FormGroup, { label: T `Border` },
|
|
164
|
+
react_1.default.createElement(BorderComponent, { value: design.borderWeight || 0, onChange: handleUpdate("borderWeight") })),
|
|
165
|
+
react_1.default.createElement(ui.FormGroup, { label: T `Numbering` },
|
|
166
|
+
react_1.default.createElement(ui.Radio, { inline: true, value: design.numbering || false, radioValue: true, onChange: handleUpdate("numbering") }, T `On`),
|
|
167
|
+
react_1.default.createElement(ui.Radio, { inline: true, value: design.numbering || false, radioValue: false, onChange: handleUpdate("numbering") }, T `Off`)));
|
|
242
168
|
}
|
|
243
169
|
// Allows setting border heaviness
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return R("div", null, R(ui.Radio, { inline: true, value, radioValue: 0, onChange: this.props.onChange }, T `None`), R(ui.Radio, { inline: true, value, radioValue: 1, onChange: this.props.onChange }, T `Light`), R(ui.Radio, { inline: true, value, radioValue: 2, onChange: this.props.onChange }, T `Medium`), R(ui.Radio, { inline: true, value, radioValue: 3, onChange: this.props.onChange }, T `Heavy`));
|
|
253
|
-
}
|
|
170
|
+
function BorderComponent(props) {
|
|
171
|
+
const { value, defaultValue, onChange } = props;
|
|
172
|
+
const currentValue = value != null ? value : defaultValue;
|
|
173
|
+
return react_1.default.createElement("div", null,
|
|
174
|
+
react_1.default.createElement(ui.Radio, { inline: true, value: currentValue, radioValue: 0, onChange: onChange }, T `None`),
|
|
175
|
+
react_1.default.createElement(ui.Radio, { inline: true, value: currentValue, radioValue: 1, onChange: onChange }, T `Light`),
|
|
176
|
+
react_1.default.createElement(ui.Radio, { inline: true, value: currentValue, radioValue: 2, onChange: onChange }, T `Medium`),
|
|
177
|
+
react_1.default.createElement(ui.Radio, { inline: true, value: currentValue, radioValue: 3, onChange: onChange }, T `Heavy`));
|
|
254
178
|
}
|
package/lib/widgets/Widget.d.ts
CHANGED
|
@@ -9,18 +9,16 @@ export interface CreateViewElementOptions {
|
|
|
9
9
|
dataSource: DataSource;
|
|
10
10
|
/** Gives data to the widget in a way that allows client-server separation and secure sharing. See definition in WidgetDataSource. **/
|
|
11
11
|
widgetDataSource: WidgetDataSource;
|
|
12
|
-
/** widget design
|
|
13
|
-
design:
|
|
12
|
+
/** widget design */
|
|
13
|
+
design: any;
|
|
14
14
|
/** scope of the widget (when the widget self-selects a particular scope) **/
|
|
15
15
|
scope?: WidgetScope | null;
|
|
16
16
|
/** array of filters to apply.**/
|
|
17
17
|
filters: JsonQLFilter[];
|
|
18
18
|
/** called with scope of widget **/
|
|
19
|
-
onScopeChange
|
|
19
|
+
onScopeChange?: (scope: WidgetScope | null) => void;
|
|
20
20
|
/** called with new design. null/undefined for readonly **/
|
|
21
|
-
onDesignChange?:
|
|
22
|
-
(design: object): void;
|
|
23
|
-
} | null;
|
|
21
|
+
onDesignChange?: ((design: any) => void) | null;
|
|
24
22
|
/** width in pixels on screen **/
|
|
25
23
|
width?: number;
|
|
26
24
|
/** height in pixels on screen **/
|
|
@@ -34,13 +32,24 @@ export interface CreateViewElementOptions {
|
|
|
34
32
|
[key: string]: string;
|
|
35
33
|
};
|
|
36
34
|
/** Entries in the table of content */
|
|
37
|
-
tocEntries?:
|
|
35
|
+
tocEntries?: TOCEntry[];
|
|
38
36
|
/** the widget callback ref */
|
|
39
37
|
widgetRef?: (widget: any) => void;
|
|
40
38
|
/** called with (widgetId, tocEntryId) to scroll to TOC entry */
|
|
41
39
|
onScrollToTOCEntry?: (widgetId: string, tocEntryId: string) => void;
|
|
42
40
|
/** A key that changes when the widget should be refreshed */
|
|
43
41
|
refreshKey?: any;
|
|
42
|
+
/** Locale to use for display */
|
|
43
|
+
locale: string;
|
|
44
|
+
/** Translate function to use for display. Returns same string when editing. */
|
|
45
|
+
translate: (input: string) => string;
|
|
46
|
+
}
|
|
47
|
+
/** An entry in the table of contents */
|
|
48
|
+
export interface TOCEntry {
|
|
49
|
+
id: any;
|
|
50
|
+
widgetId: string;
|
|
51
|
+
level: number;
|
|
52
|
+
text: string;
|
|
44
53
|
}
|
|
45
54
|
export default class Widget {
|
|
46
55
|
/** Creates a React element that is a view of the widget */
|
|
@@ -60,4 +69,6 @@ export default class Widget {
|
|
|
60
69
|
text: string;
|
|
61
70
|
level: number;
|
|
62
71
|
}[];
|
|
72
|
+
/** Gets any strings that should be translated */
|
|
73
|
+
getTranslatableStrings(design: any, schema: Schema): string[];
|
|
63
74
|
}
|
package/lib/widgets/Widget.js
CHANGED
|
@@ -30,7 +30,7 @@ class WidgetScopesViewComponent extends react_1.default.Component {
|
|
|
30
30
|
if (lodash_1.default.compact(lodash_1.default.values(scopes)).length === 0) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
|
-
return R("div", { className: "alert alert-info" }, R("span", { className: "fas fa-filter" }), T `
|
|
33
|
+
return R("div", { className: "alert alert-info" }, R("span", { className: "fas fa-filter" }), " ", T `Filters: `, lodash_1.default.map(lodash_1.default.keys(scopes), (id) => this.renderScope(id, scopes[id])));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.default = WidgetScopesViewComponent;
|