@mwater/visualization 5.4.1 → 5.4.3
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 +12 -20
- package/lib/dashboards/DashboardComponent.js +109 -69
- 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/languages.js +6 -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/Quickfilter.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +5 -30
- package/lib/quickfilter/QuickfiltersDesignComponent.js +56 -63
- 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 +1 -1
- 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/PivotChartLayoutComponent.js +1 -1
- 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 +189 -125
- 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/languages.ts +6 -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/Quickfilter.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +127 -128
- 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 +2 -2
- 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
|
@@ -47,7 +47,7 @@ export default class ItemsHtmlConverter {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Converts list of items to html
|
|
50
|
-
convertItemsToHtml(items:
|
|
50
|
+
convertItemsToHtml(items: HtmlItem[]) {
|
|
51
51
|
let html = ""
|
|
52
52
|
|
|
53
53
|
for (let item of items || []) {
|
|
@@ -66,19 +66,20 @@ export default class ItemsHtmlConverter {
|
|
|
66
66
|
// Escape HTML
|
|
67
67
|
html += _.escape(itemStr)
|
|
68
68
|
} else if (item.type === "element") {
|
|
69
|
-
|
|
69
|
+
const element = item as HtmlItemElement
|
|
70
|
+
if (!allowedTags[element.tag]) {
|
|
70
71
|
// Ignore and do contents
|
|
71
|
-
html += this.convertItemsToHtml(
|
|
72
|
+
html += this.convertItemsToHtml(element.items || [])
|
|
72
73
|
continue
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
let attrs = ""
|
|
76
77
|
// Add style
|
|
77
|
-
if (
|
|
78
|
+
if (element.style) {
|
|
78
79
|
attrs += ' style="'
|
|
79
80
|
let first = true
|
|
80
|
-
for (let key in
|
|
81
|
-
const value =
|
|
81
|
+
for (let key in element.style) {
|
|
82
|
+
const value = element.style[key]
|
|
82
83
|
if (!allowedStyles[key]) {
|
|
83
84
|
continue
|
|
84
85
|
}
|
|
@@ -97,20 +98,20 @@ export default class ItemsHtmlConverter {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
// Add href
|
|
100
|
-
if (
|
|
101
|
-
attrs += ' href="' +
|
|
101
|
+
if (element.href) {
|
|
102
|
+
attrs += ' href="' + element.href + '"'
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// Add target
|
|
105
|
-
if (
|
|
106
|
-
attrs += ' target="' + _.escape(
|
|
106
|
+
if (element.target) {
|
|
107
|
+
attrs += ' target="' + _.escape(element.target) + '"'
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
// Special case for self-closing tags
|
|
110
|
-
if (["br"].includes(
|
|
111
|
-
html += `<${
|
|
111
|
+
if (["br"].includes(element.tag)) {
|
|
112
|
+
html += `<${element.tag}${attrs}>`
|
|
112
113
|
} else {
|
|
113
|
-
html += `<${
|
|
114
|
+
html += `<${element.tag}${attrs}>` + this.convertItemsToHtml(element.items || []) + `</${element.tag}>`
|
|
114
115
|
}
|
|
115
116
|
} else {
|
|
116
117
|
html += this.convertSpecialItemToHtml(item)
|
|
@@ -123,6 +124,8 @@ export default class ItemsHtmlConverter {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
// console.log "createHtml: #{html}"
|
|
127
|
+
// console.log("convertItemsToHtml: " + JSON.stringify(items, null, 2))
|
|
128
|
+
// console.log("convertItemsToHtml: " + html)
|
|
126
129
|
return html
|
|
127
130
|
}
|
|
128
131
|
|
|
@@ -168,16 +171,22 @@ export default class ItemsHtmlConverter {
|
|
|
168
171
|
const nodeElement = node as HTMLElement
|
|
169
172
|
if (nodeElement.style != null) {
|
|
170
173
|
const styleDeclaration = nodeElement.style
|
|
171
|
-
for (
|
|
172
|
-
|
|
174
|
+
for (let i = 0; i < styleDeclaration.length; i++) {
|
|
175
|
+
const style = styleDeclaration[i]
|
|
176
|
+
if (!allowedStyles[style]) {
|
|
173
177
|
continue
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
const value = styleDeclaration
|
|
180
|
+
const value = styleDeclaration.getPropertyValue(style)
|
|
177
181
|
if (value == null || value === "") {
|
|
178
182
|
continue
|
|
179
183
|
}
|
|
180
184
|
|
|
185
|
+
// Ignore bootstrap variables in style values
|
|
186
|
+
if (value.startsWith("var(--bs-")) {
|
|
187
|
+
continue
|
|
188
|
+
}
|
|
189
|
+
|
|
181
190
|
item.style = item.style || {}
|
|
182
191
|
item.style[style] = value
|
|
183
192
|
}
|
|
@@ -203,7 +212,12 @@ export default class ItemsHtmlConverter {
|
|
|
203
212
|
item.target = (node as HTMLLinkElement).target
|
|
204
213
|
}
|
|
205
214
|
|
|
206
|
-
|
|
215
|
+
// Unwrap pointless span elements that have no style and one child
|
|
216
|
+
if (tag === "span" && item.style == null && item.items?.length === 1) {
|
|
217
|
+
items.push(item.items[0])
|
|
218
|
+
} else {
|
|
219
|
+
items.push(item)
|
|
220
|
+
}
|
|
207
221
|
|
|
208
222
|
// Handle text
|
|
209
223
|
} else if (node.nodeType === 3) {
|
|
@@ -218,7 +232,8 @@ export default class ItemsHtmlConverter {
|
|
|
218
232
|
}
|
|
219
233
|
|
|
220
234
|
// console.log JSON.stringify(items, null, 2)
|
|
221
|
-
|
|
235
|
+
// console.log("convertElemToItems: " + elem.outerHTML)
|
|
236
|
+
// console.log("convertElemToItems: " + JSON.stringify(items, null, 2))
|
|
222
237
|
return items
|
|
223
238
|
}
|
|
224
239
|
}
|
package/src/wellknown.ts
CHANGED
|
@@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
21
21
|
|
|
22
22
|
const numberRegexp: RegExp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
|
|
23
23
|
// Matches sequences like '100 100' or '100 100 100'.
|
|
24
|
-
const tuples: RegExp = new RegExp('^' + numberRegexp.source + '(\\s' + numberRegexp.source + '){1,}');
|
|
24
|
+
const tuples: RegExp = new RegExp('^' + numberRegexp.source + '(\\s' + numberRegexp.source + '){1,3}');
|
|
25
25
|
|
|
26
26
|
/*
|
|
27
27
|
* Parse WKT and return GeoJSON.
|
|
@@ -61,12 +61,12 @@ export function parse(input: string): any {
|
|
|
61
61
|
function white(): void { $(/^\s*/); }
|
|
62
62
|
|
|
63
63
|
function multicoords(): any[] | null {
|
|
64
|
-
white()
|
|
65
|
-
let depth: number = 0
|
|
66
|
-
let rings: any[] = []
|
|
67
|
-
let stack: any[][] = [rings]
|
|
68
|
-
let pointer: any[] = rings
|
|
69
|
-
let elem: string | null
|
|
64
|
+
white()
|
|
65
|
+
let depth: number = 0
|
|
66
|
+
let rings: any[] = []
|
|
67
|
+
let stack: any[][] = [rings]
|
|
68
|
+
let pointer: any[] = rings
|
|
69
|
+
let elem: string | null
|
|
70
70
|
|
|
71
71
|
while (elem =
|
|
72
72
|
$(/^(\()/) ||
|
|
@@ -74,33 +74,35 @@ export function parse(input: string): any {
|
|
|
74
74
|
$(/^(,)/) ||
|
|
75
75
|
$(tuples)) {
|
|
76
76
|
if (elem === '(') {
|
|
77
|
-
stack.push(pointer)
|
|
78
|
-
pointer = []
|
|
79
|
-
stack[stack.length - 1].push(pointer)
|
|
80
|
-
depth
|
|
77
|
+
stack.push(pointer)
|
|
78
|
+
pointer = []
|
|
79
|
+
stack[stack.length - 1].push(pointer)
|
|
80
|
+
depth++
|
|
81
81
|
} else if (elem === ')') {
|
|
82
82
|
// For the case: Polygon(), ...
|
|
83
|
-
if (pointer.length === 0) return null
|
|
83
|
+
if (pointer.length === 0) return null
|
|
84
84
|
|
|
85
|
-
pointer = stack.pop() || []
|
|
85
|
+
pointer = stack.pop() || []
|
|
86
86
|
// the stack was empty, input was malformed
|
|
87
|
-
if (!pointer) return null
|
|
88
|
-
depth
|
|
89
|
-
if (depth === 0) break
|
|
87
|
+
if (!pointer) return null
|
|
88
|
+
depth--
|
|
89
|
+
if (depth === 0) break
|
|
90
90
|
} else if (elem === ',') {
|
|
91
|
-
pointer = []
|
|
92
|
-
stack[stack.length - 1].push(pointer)
|
|
91
|
+
pointer = []
|
|
92
|
+
stack[stack.length - 1].push(pointer)
|
|
93
93
|
} else if (!elem.split(/\s/g).some(s => isNaN(s as any))) {
|
|
94
|
-
|
|
94
|
+
// Split into values and only take first 3 if there are 4 (ZM coordinates)
|
|
95
|
+
const values = elem.split(/\s/g).map(parseFloat)
|
|
96
|
+
Array.prototype.push.apply(pointer, values.length === 4 ? values.slice(0, 3) : values)
|
|
95
97
|
} else {
|
|
96
|
-
return null
|
|
98
|
+
return null
|
|
97
99
|
}
|
|
98
|
-
white()
|
|
100
|
+
white()
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
if (depth !== 0) return null
|
|
103
|
+
if (depth !== 0) return null
|
|
102
104
|
|
|
103
|
-
return rings
|
|
105
|
+
return rings
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
function coords(): any[] | null {
|
|
@@ -115,7 +117,8 @@ export function parse(input: string): any {
|
|
|
115
117
|
item = [];
|
|
116
118
|
} else if (!pt.split(/\s/g).some(s => isNaN(s as any))) {
|
|
117
119
|
if (!item) item = [];
|
|
118
|
-
|
|
120
|
+
const values = pt.split(/\s/g).map(parseFloat)
|
|
121
|
+
Array.prototype.push.apply(item, values.length === 4 ? values.slice(0, 3) : values);
|
|
119
122
|
}
|
|
120
123
|
white();
|
|
121
124
|
}
|
|
@@ -127,7 +130,7 @@ export function parse(input: string): any {
|
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
function point(): any | null {
|
|
130
|
-
if (!$(/^(point(\
|
|
133
|
+
if (!$(/^(point(\s+zm|\s+z)?)/i)) return null;
|
|
131
134
|
white();
|
|
132
135
|
if (!$(/^(\()/)) return null;
|
|
133
136
|
let c: any[] | null = coords();
|
|
@@ -141,7 +144,7 @@ export function parse(input: string): any {
|
|
|
141
144
|
}
|
|
142
145
|
|
|
143
146
|
function multipoint(): any | null {
|
|
144
|
-
if (!$(/^(multipoint(\
|
|
147
|
+
if (!$(/^(multipoint(\s+zm|\s+z)?)/i)) return null;
|
|
145
148
|
white();
|
|
146
149
|
let newCoordsFormat: string = _!
|
|
147
150
|
.substring(_!.indexOf('(') + 1, _!.length - 1)
|
|
@@ -158,7 +161,7 @@ export function parse(input: string): any {
|
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
function multilinestring(): any | null {
|
|
161
|
-
if (!$(/^(multilinestring(\
|
|
164
|
+
if (!$(/^(multilinestring(\s+zm|\s+z)?)/i)) return null;
|
|
162
165
|
white();
|
|
163
166
|
let c: any[] | null = multicoords();
|
|
164
167
|
if (!c) return null;
|
|
@@ -170,7 +173,7 @@ export function parse(input: string): any {
|
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
function linestring(): any | null {
|
|
173
|
-
if (!$(/^(linestring(\
|
|
176
|
+
if (!$(/^(linestring(\s+zm|\s+z)?)/i)) return null;
|
|
174
177
|
white();
|
|
175
178
|
if (!$(/^(\()/)) return null;
|
|
176
179
|
let c: any[] | null = coords();
|
|
@@ -183,7 +186,7 @@ export function parse(input: string): any {
|
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
function polygon(): any | null {
|
|
186
|
-
if (!$(/^(polygon(\
|
|
189
|
+
if (!$(/^(polygon(\s+zm|\s+z)?)/i)) return null;
|
|
187
190
|
white();
|
|
188
191
|
let c: any[] | null = multicoords();
|
|
189
192
|
if (!c) return null;
|
|
@@ -194,7 +197,7 @@ export function parse(input: string): any {
|
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
function multipolygon(): any | null {
|
|
197
|
-
if (!$(/^(multipolygon(\
|
|
200
|
+
if (!$(/^(multipolygon(\s+zm|\s+z)?)/i)) return null;
|
|
198
201
|
white();
|
|
199
202
|
let c: any[] | null = multicoords();
|
|
200
203
|
if (!c) return null;
|
|
@@ -62,7 +62,8 @@ export default class ImageWidget extends Widget {
|
|
|
62
62
|
onDesignChange: options.onDesignChange,
|
|
63
63
|
width: options.width,
|
|
64
64
|
height: options.height,
|
|
65
|
-
singleRowTable: options.singleRowTable
|
|
65
|
+
singleRowTable: options.singleRowTable,
|
|
66
|
+
translate: options.translate
|
|
66
67
|
})
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -144,4 +145,12 @@ export default class ImageWidget extends Widget {
|
|
|
144
145
|
|
|
145
146
|
return []
|
|
146
147
|
}
|
|
148
|
+
|
|
149
|
+
getTranslatableStrings(design: ImageWidgetDesign, schema: Schema): string[] {
|
|
150
|
+
const strings: string[] = []
|
|
151
|
+
if (design.caption) {
|
|
152
|
+
strings.push(design.caption)
|
|
153
|
+
}
|
|
154
|
+
return strings
|
|
155
|
+
}
|
|
147
156
|
}
|
|
@@ -29,6 +29,7 @@ export interface ImageWidgetComponentProps {
|
|
|
29
29
|
width: number
|
|
30
30
|
height: number
|
|
31
31
|
singleRowTable?: string
|
|
32
|
+
translate: (input: string) => string
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export default class ImageWidgetComponent extends AsyncLoadComponent<ImageWidgetComponentProps, { data: any, loading: boolean }> {
|
|
@@ -154,9 +155,9 @@ export default class ImageWidgetComponent extends AsyncLoadComponent<ImageWidget
|
|
|
154
155
|
className: "mwater-visualization-image-widget",
|
|
155
156
|
style: { position: "relative", width: this.props.width, height: this.props.height }
|
|
156
157
|
},
|
|
157
|
-
captionPosition === "top" ? R("div", { className: "caption" }, this.props.design.caption) : undefined,
|
|
158
|
+
captionPosition === "top" && this.props.design.caption ? R("div", { className: "caption" }, this.props.translate(this.props.design.caption)) : undefined,
|
|
158
159
|
R("div", { className: "image" }, this.renderContent()),
|
|
159
|
-
captionPosition === "bottom" ? R("div", { className: "caption" }, this.props.design.caption) : undefined
|
|
160
|
+
captionPosition === "bottom" && this.props.design.caption ? R("div", { className: "caption" }, this.props.translate(this.props.design.caption)) : undefined
|
|
160
161
|
)
|
|
161
162
|
)
|
|
162
163
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
const R = React.createElement
|
|
3
2
|
import _ from "lodash"
|
|
4
3
|
import Widget, { CreateViewElementOptions } from "./Widget"
|
|
5
4
|
import DropdownWidgetComponent from "./DropdownWidgetComponent"
|
|
@@ -7,6 +6,7 @@ import ModalWindowComponent from "@mwater/react-library/lib/ModalWindowComponent
|
|
|
7
6
|
import * as MapUtils from "../maps/MapUtils"
|
|
8
7
|
import { DataSource, Schema } from "@mwater/expressions"
|
|
9
8
|
import { WidgetDataSource } from "./WidgetDataSource"
|
|
9
|
+
import { MapDesign } from "../maps/MapDesign"
|
|
10
10
|
|
|
11
11
|
// Design is the map design specified in maps/Map Design.md
|
|
12
12
|
export default class MapWidget extends Widget {
|
|
@@ -24,28 +24,33 @@ export default class MapWidget extends Widget {
|
|
|
24
24
|
// height: height in pixels on screen
|
|
25
25
|
// onRowClick: Called with (tableId, rowId) when item is clicked
|
|
26
26
|
createViewElement(options: CreateViewElementOptions) {
|
|
27
|
-
return
|
|
28
|
-
schema
|
|
29
|
-
dataSource
|
|
30
|
-
widgetDataSource
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
return <MapWidgetComponent
|
|
28
|
+
schema={options.schema}
|
|
29
|
+
dataSource={options.dataSource}
|
|
30
|
+
widgetDataSource={options.widgetDataSource}
|
|
31
|
+
design={options.design}
|
|
32
|
+
onDesignChange={options.onDesignChange}
|
|
33
|
+
scope={options.scope}
|
|
34
|
+
filters={options.filters}
|
|
35
|
+
onScopeChange={options.onScopeChange}
|
|
36
|
+
width={options.width}
|
|
37
|
+
height={options.height}
|
|
38
|
+
onRowClick={options.onRowClick}
|
|
39
|
+
refreshKey={options.refreshKey}
|
|
40
|
+
locale={options.locale}
|
|
41
|
+
translate={options.translate}
|
|
42
|
+
/>
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
// Get a list of table ids that can be filtered on
|
|
45
|
-
getFilterableTables(design:
|
|
46
|
+
getFilterableTables(design: MapDesign, schema: Schema) {
|
|
46
47
|
// Get filterable tables
|
|
47
48
|
return MapUtils.getFilterableTables(design, schema)
|
|
48
49
|
}
|
|
50
|
+
|
|
51
|
+
getTranslatableStrings(design: MapDesign, schema: Schema): string[] {
|
|
52
|
+
return MapUtils.getTranslatableStrings(design, schema)
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
interface MapWidgetComponentProps {
|
|
@@ -54,8 +59,7 @@ interface MapWidgetComponentProps {
|
|
|
54
59
|
/** Data source to use */
|
|
55
60
|
dataSource: DataSource
|
|
56
61
|
widgetDataSource: WidgetDataSource
|
|
57
|
-
|
|
58
|
-
design: any
|
|
62
|
+
design: MapDesign
|
|
59
63
|
/** Called with new design. null/undefined for readonly */
|
|
60
64
|
onDesignChange?: any
|
|
61
65
|
width?: number
|
|
@@ -69,6 +73,10 @@ interface MapWidgetComponentProps {
|
|
|
69
73
|
onRowClick?: any
|
|
70
74
|
/** TODO: implement refreshing */
|
|
71
75
|
refreshKey?: any
|
|
76
|
+
/** Locale to use. Overrides map design locale */
|
|
77
|
+
locale: string
|
|
78
|
+
/** Translate function to use for display */
|
|
79
|
+
translate: (input: string) => string
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
interface MapWidgetComponentState {
|
|
@@ -115,83 +123,69 @@ class MapWidgetComponent extends React.Component<MapWidgetComponentProps, MapWid
|
|
|
115
123
|
const MapDesignerComponent = require("../maps/MapDesignerComponent").default
|
|
116
124
|
|
|
117
125
|
// Create editor
|
|
118
|
-
const editor =
|
|
119
|
-
schema
|
|
120
|
-
dataSource
|
|
121
|
-
design
|
|
122
|
-
onDesignChange
|
|
123
|
-
filters
|
|
124
|
-
|
|
126
|
+
const editor = <MapDesignerComponent
|
|
127
|
+
schema={this.props.schema}
|
|
128
|
+
dataSource={this.props.dataSource}
|
|
129
|
+
design={this.state.editDesign}
|
|
130
|
+
onDesignChange={this.handleEditDesignChange}
|
|
131
|
+
filters={this.props.filters}
|
|
132
|
+
/>
|
|
125
133
|
|
|
126
134
|
// Create map (maxing out at half of width of screen)
|
|
127
|
-
const width = Math.min(document.body.clientWidth / 2, this.props.width)
|
|
128
|
-
const height = (this.props.height * width) / this.props.width
|
|
135
|
+
const width = Math.min(document.body.clientWidth / 2, this.props.width || 0)
|
|
136
|
+
const height = ((this.props.height || 0) * width) / (this.props.width || 1)
|
|
129
137
|
const chart = this.renderContent(this.state.editDesign, this.handleEditDesignChange, width, height)
|
|
130
138
|
|
|
131
|
-
const content =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
editor
|
|
159
|
-
)
|
|
160
|
-
)
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
return React.createElement(
|
|
164
|
-
ModalWindowComponent,
|
|
165
|
-
{
|
|
166
|
-
isOpen: true,
|
|
167
|
-
onRequestClose: this.handleEndEditing
|
|
168
|
-
},
|
|
169
|
-
content
|
|
170
|
-
)
|
|
139
|
+
const content = <div style={{ height: "100%", width: "100%" }}>
|
|
140
|
+
<div style={{
|
|
141
|
+
position: "absolute",
|
|
142
|
+
left: 0,
|
|
143
|
+
top: 0,
|
|
144
|
+
border: "solid 2px #EEE",
|
|
145
|
+
borderRadius: 8,
|
|
146
|
+
padding: 10,
|
|
147
|
+
width: width + 20,
|
|
148
|
+
height: height + 20
|
|
149
|
+
}}>
|
|
150
|
+
{chart}
|
|
151
|
+
</div>
|
|
152
|
+
<div style={{ width: "100%", height: "100%", paddingLeft: width + 40 }}>
|
|
153
|
+
<div style={{ width: "100%", height: "100%", overflowY: "auto", paddingLeft: 20, borderLeft: "solid 3px #AAA" }}>
|
|
154
|
+
{editor}
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
return <ModalWindowComponent
|
|
160
|
+
isOpen={true}
|
|
161
|
+
onRequestClose={this.handleEndEditing}
|
|
162
|
+
>
|
|
163
|
+
{content}
|
|
164
|
+
</ModalWindowComponent>
|
|
171
165
|
}
|
|
172
166
|
|
|
173
167
|
renderContent(design: any, onDesignChange: any, width: any, height: any) {
|
|
174
168
|
// Require here to prevent server require problems
|
|
175
169
|
const { MapViewComponent } = require("../maps/MapViewComponent")
|
|
176
170
|
|
|
177
|
-
return
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
design
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
171
|
+
return <div style={{ width, height, padding: 10 }}>
|
|
172
|
+
<MapViewComponent
|
|
173
|
+
schema={this.props.schema}
|
|
174
|
+
design={design}
|
|
175
|
+
dataSource={this.props.dataSource}
|
|
176
|
+
mapDataSource={this.props.widgetDataSource.getMapDataSource!(design)}
|
|
177
|
+
onDesignChange={onDesignChange}
|
|
178
|
+
scope={this.props.scope}
|
|
179
|
+
onScopeChange={this.props.onScopeChange}
|
|
180
|
+
extraFilters={this.props.filters}
|
|
181
|
+
width={width - 20}
|
|
182
|
+
height={height - 20}
|
|
183
|
+
scrollWheelZoom={false} // Prevent accidental zooming
|
|
184
|
+
onRowClick={this.props.onRowClick}
|
|
185
|
+
locale={this.props.locale}
|
|
186
|
+
translate={this.props.translate}
|
|
187
|
+
/>
|
|
188
|
+
</div>
|
|
195
189
|
}
|
|
196
190
|
|
|
197
191
|
render() {
|
|
@@ -203,20 +197,15 @@ class MapWidgetComponent extends React.Component<MapWidgetComponentProps, MapWid
|
|
|
203
197
|
const handleDesignChange = (d: any) => this.setState({ transientDesign: d })
|
|
204
198
|
|
|
205
199
|
// Wrap in a simple widget
|
|
206
|
-
return
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
dropdownItems
|
|
217
|
-
},
|
|
218
|
-
this.renderContent(this.state.transientDesign, handleDesignChange, this.props.width, this.props.height)
|
|
219
|
-
)
|
|
220
|
-
)
|
|
200
|
+
return <div>
|
|
201
|
+
{this.props.onDesignChange != null ? this.renderEditor() : undefined}
|
|
202
|
+
<DropdownWidgetComponent
|
|
203
|
+
width={this.props.width}
|
|
204
|
+
height={this.props.height}
|
|
205
|
+
dropdownItems={dropdownItems}
|
|
206
|
+
>
|
|
207
|
+
{this.renderContent(this.state.transientDesign, handleDesignChange, this.props.width, this.props.height)}
|
|
208
|
+
</DropdownWidgetComponent>
|
|
209
|
+
</div>
|
|
221
210
|
}
|
|
222
211
|
}
|
|
@@ -7,6 +7,9 @@ import DropdownWidgetComponent from "./DropdownWidgetComponent"
|
|
|
7
7
|
import Markdown from "markdown-it"
|
|
8
8
|
import ModalWindowComponent from "@mwater/react-library/lib/ModalWindowComponent"
|
|
9
9
|
|
|
10
|
+
/** Widget for displaying markdown. Deprecated. Use TextWidget instead.
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
10
13
|
export default class MarkdownWidget extends Widget {
|
|
11
14
|
// Creates a React element that is a view of the widget
|
|
12
15
|
// options:
|