@mwater/visualization 5.1.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ColorComponent.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +19 -9
- package/lib/MWaterContextComponent.js +38 -22
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +15 -3
- package/lib/MWaterLoaderComponent.js +11 -2
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +12 -8
- package/lib/axes/AxisComponent.d.ts +6 -9
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -17
- package/lib/dashboards/DashboardComponent.js +20 -67
- package/lib/dashboards/DashboardDesign.d.ts +5 -20
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +112 -136
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +209 -39
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridComponent.d.ts +2 -9
- package/lib/datagrids/DatagridDataSource.d.ts +3 -3
- package/lib/datagrids/DatagridDataSource.js +0 -14
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +8 -6
- package/lib/datagrids/DatagridViewComponent.js +1 -1
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
- package/lib/datagrids/ServerDatagridDataSource.js +88 -36
- package/lib/demo.js +4 -4
- package/lib/index.css +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +5 -2
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +0 -1
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +3 -11
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +3 -13
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +3 -4
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +70 -56
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
- package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
- package/lib/widgets/MapWidget.d.ts +4 -7
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -74
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +8 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/GlobalFilter.ts +17 -0
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +42 -33
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +14 -4
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +16 -13
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +73 -147
- package/src/dashboards/DashboardDesign.ts +5 -25
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDataSource.ts +6 -12
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
- package/src/datagrids/DatagridViewComponent.ts +3 -3
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +107 -45
- package/src/demo.ts +4 -4
- package/src/index.css +5 -0
- package/src/index.ts +2 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +5 -2
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +0 -1
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +8 -8
- package/src/maps/VectorMapViewComponent.tsx +2 -2
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +88 -74
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +26 -2
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -304
- package/src/dashboards/SettingsModalComponent.ts +0 -169
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- package/src/widgets/text/TextWidgetComponent.ts +0 -120
package/src/maps/vectorMaps.tsx
CHANGED
|
@@ -7,6 +7,13 @@ import "maplibre-gl/dist/maplibre-gl.css"
|
|
|
7
7
|
import "./VectorMapViewComponent.css"
|
|
8
8
|
import React from "react"
|
|
9
9
|
|
|
10
|
+
/** Set to true to enable printing by preserving the drawing buffer */
|
|
11
|
+
let printingModeEnabled = false
|
|
12
|
+
|
|
13
|
+
export function setPrintingModeEnabled(val: boolean) {
|
|
14
|
+
printingModeEnabled = val
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
/* Hooks and functions related to displaying a vector map */
|
|
11
18
|
|
|
12
19
|
let mapTilerApiKey = ""
|
|
@@ -56,9 +63,10 @@ export function useVectorMap(options: {
|
|
|
56
63
|
if (!divRef) {
|
|
57
64
|
return
|
|
58
65
|
}
|
|
59
|
-
|
|
60
|
-
const observer = new IntersectionObserver(function(entries) {
|
|
61
|
-
|
|
66
|
+
|
|
67
|
+
const observer = new IntersectionObserver(function (entries) {
|
|
68
|
+
// When in printing mode, always visible as we need to render the map
|
|
69
|
+
setMapDivVisible(entries[0].isIntersecting || printingModeEnabled)
|
|
62
70
|
})
|
|
63
71
|
observer.observe(divRef)
|
|
64
72
|
return () => {
|
|
@@ -80,64 +88,70 @@ export function useVectorMap(options: {
|
|
|
80
88
|
return
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
[
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
try {
|
|
92
|
+
const m = new maplibregl.Map({
|
|
93
|
+
container: divRef,
|
|
94
|
+
bounds: bounds,
|
|
95
|
+
scrollZoom: scrollZoom === false ? false : true,
|
|
96
|
+
dragPan: dragPan === false ? false : true,
|
|
97
|
+
touchZoomRotate: touchZoomRotate === false ? false : true,
|
|
98
|
+
attributionControl: false,
|
|
99
|
+
boxZoom: false,
|
|
100
|
+
style: {
|
|
101
|
+
version: 8,
|
|
102
|
+
layers: [],
|
|
103
|
+
sources: {}
|
|
104
|
+
},
|
|
105
|
+
// Prevent scrolling outside of world bounds
|
|
106
|
+
maxBounds: [
|
|
107
|
+
[-179.9, -85], // Southwest coordinates
|
|
108
|
+
[179.9, 85] // Northeast coordinates
|
|
109
|
+
],
|
|
110
|
+
preserveDrawingBuffer: printingModeEnabled
|
|
111
|
+
})
|
|
102
112
|
|
|
103
|
-
|
|
113
|
+
setHasWebGLContext(true)
|
|
104
114
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
// Add listener for losing context
|
|
116
|
+
m.on("webglcontextlost", () => {
|
|
117
|
+
console.warn("Lost WebGL context")
|
|
118
|
+
setHasWebGLContext(false)
|
|
119
|
+
})
|
|
110
120
|
|
|
111
|
-
|
|
112
|
-
|
|
121
|
+
// Add zoom controls to the map.
|
|
122
|
+
m.addControl(new maplibregl.NavigationControl({}), "top-left")
|
|
113
123
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
// Add scale control
|
|
125
|
+
const scale = new maplibregl.ScaleControl({
|
|
126
|
+
unit: "metric"
|
|
127
|
+
})
|
|
128
|
+
m.addControl(scale)
|
|
129
|
+
|
|
130
|
+
// Speed up wheel scrolling
|
|
131
|
+
m.scrollZoom.setWheelZoomRate(1 / 250)
|
|
132
|
+
|
|
133
|
+
// Dynamically load symbols
|
|
134
|
+
m.on("styleimagemissing" as any, function (ev: { id: string }) {
|
|
135
|
+
// Check if known
|
|
136
|
+
const mapSymbol = mapSymbols.find((s) => s.value == ev.id)
|
|
137
|
+
if (mapSymbol) {
|
|
138
|
+
m.loadImage(mapSymbol.url, (err: any, image: any) => {
|
|
139
|
+
if (image && !m.hasImage(mapSymbol.value)) {
|
|
140
|
+
m.addImage(mapSymbol.value, image, { sdf: true })
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
})
|
|
135
145
|
|
|
136
|
-
|
|
146
|
+
setMap(m)
|
|
137
147
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
return () => {
|
|
149
|
+
m.remove()
|
|
150
|
+
setHasWebGLContext(false)
|
|
151
|
+
}
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.error("Error loading map", e)
|
|
154
|
+
alert(T`Error loading map. Please check that your browser and drivers are updated.`)
|
|
141
155
|
}
|
|
142
156
|
}, [mapReloadCount])
|
|
143
157
|
|
|
@@ -178,10 +192,10 @@ export function useHoverCursor(map: maplibregl.Map | undefined, layerIds: string
|
|
|
178
192
|
|
|
179
193
|
/** Apply user style to a map with base style */
|
|
180
194
|
export function useStyleMap(options: {
|
|
181
|
-
map: maplibregl.Map | undefined,
|
|
195
|
+
map: maplibregl.Map | undefined,
|
|
182
196
|
baseLayer: BaseLayer,
|
|
183
197
|
baseLayerOpacity?: number | null,
|
|
184
|
-
userStyle: maplibregl.StyleSpecification | null | undefined,
|
|
198
|
+
userStyle: maplibregl.StyleSpecification | null | undefined,
|
|
185
199
|
}) {
|
|
186
200
|
const { map, baseLayer, baseLayerOpacity, userStyle } = options
|
|
187
201
|
|
|
@@ -220,11 +234,11 @@ export function useBaseStyle(baseLayer: BaseLayer) {
|
|
|
220
234
|
}
|
|
221
235
|
|
|
222
236
|
if (baseLayer == "cartodb_positron") {
|
|
223
|
-
loadStyle(`https://api.maptiler.com/maps/
|
|
237
|
+
loadStyle(`https://api.maptiler.com/maps/5f972163-6078-4341-982a-5c8bc4447e68/style.json?key=${mapTilerApiKey}`)
|
|
224
238
|
} else if (baseLayer == "cartodb_dark_matter") {
|
|
225
|
-
loadStyle(`https://api.maptiler.com/maps/
|
|
239
|
+
loadStyle(`https://api.maptiler.com/maps/1d3e957b-c546-4791-b9de-dce203538429/style.json?key=${mapTilerApiKey}`)
|
|
226
240
|
} else if (baseLayer == "bing_road") {
|
|
227
|
-
loadStyle(`https://api.maptiler.com/maps/streets/style.json?key=${mapTilerApiKey}`)
|
|
241
|
+
loadStyle(`https://api.maptiler.com/maps/streets-v2/style.json?key=${mapTilerApiKey}`)
|
|
228
242
|
} else if (baseLayer == "bing_aerial") {
|
|
229
243
|
// Switched to Bing for superior aerial imagery
|
|
230
244
|
loadBingBasemap("AerialWithLabels", 1).then(setBaseStyle)
|
|
@@ -243,8 +257,8 @@ export function useBaseStyle(baseLayer: BaseLayer) {
|
|
|
243
257
|
|
|
244
258
|
/** Combines a base style and a user style */
|
|
245
259
|
export function mergeBaseAndUserStyle(
|
|
246
|
-
baseStyle: maplibregl.StyleSpecification | null | undefined,
|
|
247
|
-
userStyle: maplibregl.StyleSpecification | null | undefined,
|
|
260
|
+
baseStyle: maplibregl.StyleSpecification | null | undefined,
|
|
261
|
+
userStyle: maplibregl.StyleSpecification | null | undefined,
|
|
248
262
|
baseLayerOpacity?: number | null) {
|
|
249
263
|
// Merge until baseStyle and userStyle are present
|
|
250
264
|
if (!baseStyle || !userStyle) {
|
|
@@ -283,9 +297,9 @@ export function mergeBaseAndUserStyle(
|
|
|
283
297
|
return style
|
|
284
298
|
}
|
|
285
299
|
|
|
286
|
-
export function AttributionControl(props: {
|
|
300
|
+
export function AttributionControl(props: {
|
|
287
301
|
baseLayer: BaseLayer
|
|
288
|
-
extraText?: string
|
|
302
|
+
extraText?: string
|
|
289
303
|
}) {
|
|
290
304
|
if (props.baseLayer == "blank") {
|
|
291
305
|
return <div className="newmap-attribution-control">
|
|
@@ -306,7 +320,7 @@ export function AttributionControl(props: {
|
|
|
306
320
|
<div className="newmap-attribution-control">
|
|
307
321
|
<a href="https://www.maptiler.com/copyright/" target="_blank">
|
|
308
322
|
© MapTiler
|
|
309
|
-
</a>
|
|
323
|
+
</a>
|
|
310
324
|
{" "}
|
|
311
325
|
<a href="https://www.openstreetmap.org/about/" target="_blank">
|
|
312
326
|
© OpenStreetMap
|
|
@@ -324,15 +338,15 @@ export function VectorMapLogo(props: {
|
|
|
324
338
|
}
|
|
325
339
|
|
|
326
340
|
if (props.baseLayer == "bing_aerial") {
|
|
327
|
-
return <img
|
|
328
|
-
src="https://dev.virtualearth.net/Branding/logo_powered_by.png"
|
|
329
|
-
style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
|
|
341
|
+
return <img
|
|
342
|
+
src="https://dev.virtualearth.net/Branding/logo_powered_by.png"
|
|
343
|
+
style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
|
|
330
344
|
/>
|
|
331
345
|
}
|
|
332
346
|
|
|
333
|
-
return <img
|
|
334
|
-
src={require("./Maptiler-logo.png").default}
|
|
335
|
-
style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
|
|
347
|
+
return <img
|
|
348
|
+
src={require("./Maptiler-logo.png").default}
|
|
349
|
+
style={{ position: "absolute", bottom: 38, left: 11, height: 22, zIndex: 1000, pointerEvents: "none" }}
|
|
336
350
|
/>
|
|
337
351
|
}
|
|
338
352
|
|
|
@@ -342,12 +356,12 @@ async function loadBingBasemap(basemapType: "AerialWithLabels", opacity: number)
|
|
|
342
356
|
|
|
343
357
|
const metadata = await fetch(`https://dev.virtualearth.net/REST/v1/Imagery/Metadata/${basemapType}?key=${bingApiKey}`).then((response) => response.json())
|
|
344
358
|
const resource = metadata.resourceSets[0].resources[0]
|
|
345
|
-
|
|
359
|
+
|
|
346
360
|
return {
|
|
347
361
|
sources: {
|
|
348
362
|
"bing_raster": {
|
|
349
363
|
type: "raster",
|
|
350
|
-
tiles: resource.imageUrlSubdomains.map((subdomain: string) =>
|
|
364
|
+
tiles: resource.imageUrlSubdomains.map((subdomain: string) =>
|
|
351
365
|
resource.imageUrl.replace("{subdomain}", subdomain).replace("{culture}", "").replace("http:", "https:")),
|
|
352
366
|
tileSize: resource.imageHeight,
|
|
353
367
|
}
|
|
@@ -407,4 +421,4 @@ export function usePersistedMapBounds(map: Map | undefined, localStorageKey: str
|
|
|
407
421
|
}
|
|
408
422
|
}, [map])
|
|
409
423
|
}
|
|
410
|
-
|
|
424
|
+
|
|
@@ -81,7 +81,7 @@ export default class QuickfilterCompiler {
|
|
|
81
81
|
return filters
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
compileToFilterExpr(expr: any, value: any, multi
|
|
84
|
+
compileToFilterExpr(expr: any, value: any, multi?: boolean): OpExpr | null {
|
|
85
85
|
// Get type of expr
|
|
86
86
|
const type = new ExprUtils(this.schema).getExprType(expr)
|
|
87
87
|
const idTable = new ExprUtils(this.schema).getExprIdTable(expr)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
2
|
import React from "react"
|
|
4
3
|
const R = React.createElement
|
|
5
4
|
import { default as ReactSelect } from "react-select"
|
|
@@ -12,6 +11,7 @@ import IdArrayQuickfilterComponent from "./IdArrayQuickfilterComponent"
|
|
|
12
11
|
import { Quickfilter, QuickfilterLock } from "./Quickfilter"
|
|
13
12
|
import { QuickfiltersDataSource } from "./QuickfiltersDataSource"
|
|
14
13
|
import { JsonQLFilter } from ".."
|
|
14
|
+
import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
|
|
15
15
|
|
|
16
16
|
export interface QuickfiltersComponentProps {
|
|
17
17
|
/** Design of quickfilters. See README.md */
|
|
@@ -219,7 +219,7 @@ interface EnumQuickfilterComponentProps {
|
|
|
219
219
|
|
|
220
220
|
/** Quickfilter for an enum */
|
|
221
221
|
class EnumQuickfilterComponent extends React.Component<EnumQuickfilterComponentProps> {
|
|
222
|
-
static
|
|
222
|
+
static contextType = LocaleContext
|
|
223
223
|
|
|
224
224
|
handleSingleChange = (val: any) => {
|
|
225
225
|
if (val) {
|
|
@@ -275,7 +275,7 @@ class EnumQuickfilterComponent extends React.Component<EnumQuickfilterComponentP
|
|
|
275
275
|
render() {
|
|
276
276
|
const options = _.map(this.props.options, (opt) => ({
|
|
277
277
|
value: opt.id,
|
|
278
|
-
label: ExprUtils.localizeString(opt.name, this.context
|
|
278
|
+
label: ExprUtils.localizeString(opt.name, this.context)
|
|
279
279
|
}))
|
|
280
280
|
|
|
281
281
|
// Determine width, estimating about 8 px per letter with 120px padding
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React, { ReactNode } from "react"
|
|
2
|
+
import _ from "lodash"
|
|
3
|
+
import ClickOutHandler from "react-onclickout"
|
|
4
|
+
|
|
5
|
+
export interface DropdownItem {
|
|
6
|
+
label: ReactNode
|
|
7
|
+
value: string
|
|
8
|
+
/** If true, this item will be rendered only when "More..." is clicked. */
|
|
9
|
+
more?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DropdownPaletteItemProps {
|
|
13
|
+
label: ReactNode
|
|
14
|
+
|
|
15
|
+
items: DropdownItem[]
|
|
16
|
+
|
|
17
|
+
/** Called with clicked item */
|
|
18
|
+
onSelect: (value: string) => void
|
|
19
|
+
|
|
20
|
+
/** should the popup be under or over? */
|
|
21
|
+
position?: "under" | "over"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface DropdownPaletteItemState {
|
|
25
|
+
open: boolean
|
|
26
|
+
moreOpen: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Palette item that allows picking from dropdown */
|
|
30
|
+
export default class DropdownPaletteItem extends React.Component<DropdownPaletteItemProps, DropdownPaletteItemState> {
|
|
31
|
+
static defaultProps = { position: "under" }
|
|
32
|
+
|
|
33
|
+
constructor(props: DropdownPaletteItemProps) {
|
|
34
|
+
super(props)
|
|
35
|
+
this.state = {
|
|
36
|
+
open: false,
|
|
37
|
+
moreOpen: false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
handleMouseDown = (ev: React.MouseEvent) => {
|
|
42
|
+
// Ignore if clicking on menu
|
|
43
|
+
if ((ev.target as HTMLElement).className === "dropdown-palette-menu-item") {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Don't lose focus from editor
|
|
48
|
+
ev.preventDefault()
|
|
49
|
+
this.setState({ open: !this.state.open })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
handleMoreClick = (ev: React.MouseEvent) => {
|
|
53
|
+
ev.preventDefault()
|
|
54
|
+
this.setState({ moreOpen: true })
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
renderItem(item: DropdownItem) {
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
className="dropdown-palette-menu-item"
|
|
61
|
+
onMouseDown={(ev: React.MouseEvent) => {
|
|
62
|
+
ev.preventDefault()
|
|
63
|
+
this.props.onSelect(item.value)
|
|
64
|
+
this.setState({ open: false })
|
|
65
|
+
}}
|
|
66
|
+
key={item.value}
|
|
67
|
+
>
|
|
68
|
+
{item.label}
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
renderItems() {
|
|
74
|
+
const visibleItems = this.state.moreOpen ? this.props.items : this.props.items.filter(item => !item.more)
|
|
75
|
+
const halfLength = Math.ceil(visibleItems.length / 2)
|
|
76
|
+
const leftColumn = visibleItems.slice(0, halfLength)
|
|
77
|
+
const rightColumn = visibleItems.slice(halfLength)
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div className="dropdown-palette-menu">
|
|
81
|
+
<div style={{ display: 'flex' }}>
|
|
82
|
+
<div style={{ flex: 1 }}>
|
|
83
|
+
{leftColumn.map(item => this.renderItem(item))}
|
|
84
|
+
</div>
|
|
85
|
+
<div style={{ flex: 1 }}>
|
|
86
|
+
{rightColumn.map(item => this.renderItem(item))}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
{this.props.items.some(item => item.more) && !this.state.moreOpen && (
|
|
90
|
+
<div
|
|
91
|
+
className="dropdown-palette-menu-item"
|
|
92
|
+
onMouseDown={this.handleMoreClick}
|
|
93
|
+
>
|
|
94
|
+
More...
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
render() {
|
|
102
|
+
const popupPosition: React.CSSProperties = {
|
|
103
|
+
position: "absolute",
|
|
104
|
+
left: 0,
|
|
105
|
+
zIndex: 1000,
|
|
106
|
+
backgroundColor: "white",
|
|
107
|
+
border: "solid 1px #AAA",
|
|
108
|
+
borderRadius: 3
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (this.props.position === "under") {
|
|
112
|
+
popupPosition.top = 26
|
|
113
|
+
} else {
|
|
114
|
+
popupPosition.bottom = 26
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<ClickOutHandler onClickOut={() => this.setState({ open: false, moreOpen: false })}>
|
|
119
|
+
<div
|
|
120
|
+
className="mwater-visualization-text-palette-item"
|
|
121
|
+
style={{ position: "relative" }}
|
|
122
|
+
onMouseDown={this.handleMouseDown}
|
|
123
|
+
>
|
|
124
|
+
<style>
|
|
125
|
+
{`
|
|
126
|
+
.dropdown-palette-menu-item {
|
|
127
|
+
color: black;
|
|
128
|
+
background-color: white;
|
|
129
|
+
text-align: left;
|
|
130
|
+
padding: 5px 15px 5px 15px;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
}
|
|
133
|
+
.dropdown-palette-menu-item:hover {
|
|
134
|
+
background-color: #DDD;
|
|
135
|
+
}
|
|
136
|
+
`}
|
|
137
|
+
</style>
|
|
138
|
+
{this.state.open ? <div style={popupPosition}>{this.renderItems()}</div> : undefined}
|
|
139
|
+
{this.props.label}
|
|
140
|
+
</div>
|
|
141
|
+
</ClickOutHandler>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import _ from "lodash"
|
|
3
|
+
import ClickOutHandler from "react-onclickout"
|
|
4
|
+
import Color from "color"
|
|
5
|
+
import { CustomColorsContext } from "../CustomColorsContext"
|
|
6
|
+
|
|
7
|
+
export interface FontColorPaletteItemProps {
|
|
8
|
+
/** Called with "#FF8800", etc. */
|
|
9
|
+
onSetColor: any
|
|
10
|
+
/** should the popup be under or over? */
|
|
11
|
+
position?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface FontColorPaletteItemState {
|
|
15
|
+
open: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Palette item that allows picking a color
|
|
19
|
+
export default class FontColorPaletteItem extends React.Component<
|
|
20
|
+
FontColorPaletteItemProps,
|
|
21
|
+
FontColorPaletteItemState
|
|
22
|
+
> {
|
|
23
|
+
static defaultProps = { position: "under" }
|
|
24
|
+
|
|
25
|
+
constructor(props: any) {
|
|
26
|
+
super(props)
|
|
27
|
+
this.state = {
|
|
28
|
+
open: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
handleMouseDown = (ev: any) => {
|
|
33
|
+
// Don't lose focus from editor
|
|
34
|
+
ev.preventDefault()
|
|
35
|
+
return this.setState({ open: !this.state.open })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
render() {
|
|
39
|
+
const popupPosition: React.CSSProperties = {
|
|
40
|
+
position: "absolute",
|
|
41
|
+
left: 0,
|
|
42
|
+
zIndex: 1000,
|
|
43
|
+
backgroundColor: "white",
|
|
44
|
+
border: "solid 1px #AAA",
|
|
45
|
+
borderRadius: 3
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (this.props.position === "under") {
|
|
49
|
+
popupPosition["top"] = 26
|
|
50
|
+
} else {
|
|
51
|
+
popupPosition["bottom"] = 26
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ClickOutHandler onClickOut={() => this.setState({ open: false })}>
|
|
56
|
+
<div
|
|
57
|
+
className="mwater-visualization-text-palette-item"
|
|
58
|
+
onMouseDown={this.handleMouseDown}
|
|
59
|
+
style={{ position: "relative" }}
|
|
60
|
+
>
|
|
61
|
+
{this.state.open ? (
|
|
62
|
+
<div style={popupPosition}>
|
|
63
|
+
<ColorPaletteComponent
|
|
64
|
+
onSetColor={(color: any) => {
|
|
65
|
+
this.props.onSetColor(color)
|
|
66
|
+
return this.setState({ open: false })
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
) : undefined}
|
|
71
|
+
|
|
72
|
+
<i className="fas fa-palette" />
|
|
73
|
+
</div>
|
|
74
|
+
</ClickOutHandler>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface ColorPaletteComponentProps {
|
|
80
|
+
onSetColor: any
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
class ColorPaletteComponent extends React.Component<ColorPaletteComponentProps> {
|
|
84
|
+
static contextType = CustomColorsContext
|
|
85
|
+
declare context: React.ContextType<typeof CustomColorsContext>
|
|
86
|
+
|
|
87
|
+
renderColor(color: any) {
|
|
88
|
+
return (
|
|
89
|
+
<td>
|
|
90
|
+
<div
|
|
91
|
+
style={{ width: 16, height: 15, backgroundColor: color, margin: 1 }}
|
|
92
|
+
onMouseDown={(ev: any) => {
|
|
93
|
+
ev.preventDefault()
|
|
94
|
+
this.props.onSetColor(color)
|
|
95
|
+
}}
|
|
96
|
+
/>
|
|
97
|
+
</td>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
render() {
|
|
102
|
+
const baseColors = [
|
|
103
|
+
"#FF0000", // red
|
|
104
|
+
"#FFAA00", // orange
|
|
105
|
+
"#FFFF00", // yellow
|
|
106
|
+
"#00FF00", // green
|
|
107
|
+
"#00FFFF", // cyan
|
|
108
|
+
"#0000FF", // blue
|
|
109
|
+
"#9900FF", // purple
|
|
110
|
+
"#FF00FF" // magenta
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
const customColors = this.context?.customColors || []
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div style={{ padding: 5 }}>
|
|
117
|
+
<table>
|
|
118
|
+
<tbody>
|
|
119
|
+
{/* Custom colors */}
|
|
120
|
+
{_.chunk(customColors.filter(color => color != null), 8).map((colorGroup, index) => (
|
|
121
|
+
<tr key={index}>
|
|
122
|
+
{colorGroup.map((color) => this.renderColor(color))}
|
|
123
|
+
</tr>
|
|
124
|
+
))}
|
|
125
|
+
{/* Grey shades */}
|
|
126
|
+
<tr>
|
|
127
|
+
{_.map(_.range(0, 8), (i) => {
|
|
128
|
+
return this.renderColor(Color({ r: (i * 255) / 7, g: (i * 255) / 7, b: (i * 255) / 7 }).hex())
|
|
129
|
+
})}
|
|
130
|
+
</tr>
|
|
131
|
+
<tr style={{ height: 5 }} />
|
|
132
|
+
{/* Base colors */}
|
|
133
|
+
<tr>
|
|
134
|
+
{_.map(baseColors, (c) => this.renderColor(c))}
|
|
135
|
+
</tr>
|
|
136
|
+
<tr style={{ height: 5 }} />
|
|
137
|
+
<tr>
|
|
138
|
+
{_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.7).hex()))}
|
|
139
|
+
</tr>
|
|
140
|
+
<tr>
|
|
141
|
+
{_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.5).hex()))}
|
|
142
|
+
</tr>
|
|
143
|
+
<tr>
|
|
144
|
+
{_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.3).hex()))}
|
|
145
|
+
</tr>
|
|
146
|
+
<tr>
|
|
147
|
+
{_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.3).hex()))}
|
|
148
|
+
</tr>
|
|
149
|
+
<tr>
|
|
150
|
+
{_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.5).hex()))}
|
|
151
|
+
</tr>
|
|
152
|
+
<tr>
|
|
153
|
+
{_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.7).hex()))}
|
|
154
|
+
</tr>
|
|
155
|
+
</tbody>
|
|
156
|
+
</table>
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -82,6 +82,9 @@ export default class ItemsHtmlConverter {
|
|
|
82
82
|
if (!allowedStyles[key]) {
|
|
83
83
|
continue
|
|
84
84
|
}
|
|
85
|
+
if (value == null || value === "") {
|
|
86
|
+
continue
|
|
87
|
+
}
|
|
85
88
|
|
|
86
89
|
if (!first) {
|
|
87
90
|
attrs += " "
|
|
@@ -163,14 +166,21 @@ export default class ItemsHtmlConverter {
|
|
|
163
166
|
const item: HtmlItemElement = { type: "element", tag, items: this.convertElemToItems((node as HTMLElement)) }
|
|
164
167
|
|
|
165
168
|
// Add style
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
const nodeElement = node as HTMLElement
|
|
170
|
+
if (nodeElement.style != null) {
|
|
171
|
+
const styleDeclaration = nodeElement.style
|
|
172
|
+
for (const style of styleDeclaration) {
|
|
173
|
+
if (!allowedStyles[style as string]) {
|
|
174
|
+
continue
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const value = styleDeclaration[style as any]
|
|
178
|
+
if (value == null || value === "") {
|
|
169
179
|
continue
|
|
170
180
|
}
|
|
171
181
|
|
|
172
182
|
item.style = item.style || {}
|
|
173
|
-
item.style[style] =
|
|
183
|
+
item.style[style] = value
|
|
174
184
|
}
|
|
175
185
|
}
|
|
176
186
|
|
|
@@ -243,4 +253,4 @@ var allowedStyles: { [style: string]: number } = {
|
|
|
243
253
|
"text-decoration": 1,
|
|
244
254
|
color: 1,
|
|
245
255
|
"font-size": 1
|
|
246
|
-
}
|
|
256
|
+
}
|