@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
|
@@ -13,6 +13,7 @@ import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelMo
|
|
|
13
13
|
import { FormGroup } from "@mwater/react-library/lib/bootstrap"
|
|
14
14
|
import ColorComponent from "../../ColorComponent"
|
|
15
15
|
import { Select } from "@mwater/react-library/lib/bootstrap"
|
|
16
|
+
import { translateHtmlItems } from "../../richtext/ExprItemsTranslator"
|
|
16
17
|
|
|
17
18
|
export interface TextWidgetComponentProps {
|
|
18
19
|
design: TextWidgetDesign
|
|
@@ -28,8 +29,15 @@ export interface TextWidgetComponentProps {
|
|
|
28
29
|
/** Table that is filtered to have one row */
|
|
29
30
|
singleRowTable?: string
|
|
30
31
|
namedStrings?: any
|
|
32
|
+
|
|
31
33
|
/** A key that changes when the widget should be refreshed */
|
|
32
34
|
refreshKey?: any
|
|
35
|
+
|
|
36
|
+
/** Locale to use for display */
|
|
37
|
+
locale: string
|
|
38
|
+
|
|
39
|
+
/** Translate function to use for display. Returns same string when editing. */
|
|
40
|
+
translate: (input: string) => string
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
// Widget which displays styled text with embedded expressions
|
|
@@ -200,9 +208,15 @@ export default class TextWidgetComponent extends AsyncLoadComponent<TextWidgetCo
|
|
|
200
208
|
|
|
201
209
|
const padding = this.props.design.padding ?? 0
|
|
202
210
|
|
|
211
|
+
// Translate items if needed
|
|
212
|
+
const translatedDesign = this.props.onDesignChange ? this.props.design : {
|
|
213
|
+
...this.props.design,
|
|
214
|
+
items: translateHtmlItems(this.props.design.items || [], this.props.translate)
|
|
215
|
+
}
|
|
216
|
+
|
|
203
217
|
return (
|
|
204
218
|
<TextComponent
|
|
205
|
-
design={
|
|
219
|
+
design={translatedDesign}
|
|
206
220
|
onDesignChange={this.props.onDesignChange}
|
|
207
221
|
schema={this.props.schema}
|
|
208
222
|
dataSource={this.props.dataSource}
|
|
@@ -211,6 +225,7 @@ export default class TextWidgetComponent extends AsyncLoadComponent<TextWidgetCo
|
|
|
211
225
|
height={this.props.height ? this.props.height - padding * 2 : undefined}
|
|
212
226
|
singleRowTable={this.props.singleRowTable}
|
|
213
227
|
namedStrings={this.props.namedStrings}
|
|
228
|
+
locale={this.props.locale}
|
|
214
229
|
/>
|
|
215
230
|
)
|
|
216
231
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HtmlItem } from "../../richtext/ItemsHtmlConverter"
|
|
3
|
-
|
|
4
|
-
export type TextWidgetItem = HtmlItem | HtmlItemExpr
|
|
1
|
+
import { HtmlItemOrExpr } from "../../richtext/ExprItemsHtmlConverter"
|
|
5
2
|
|
|
6
3
|
export interface TextWidgetDesign {
|
|
7
4
|
/** Text widget stores its content as array of items. See ItemsHtmlConverter TODO */
|
|
8
|
-
items
|
|
5
|
+
items?: HtmlItemOrExpr[]
|
|
9
6
|
|
|
10
7
|
/** "title" for title block. default is "default" */
|
|
11
8
|
style?: "title" | "default" | "header" | "footer"
|
|
@@ -29,5 +26,5 @@ export interface TextWidgetDesign {
|
|
|
29
26
|
|
|
30
27
|
/** Returns true if the text widget design is empty. */
|
|
31
28
|
export function isEmptyTextWidgetDesign(design: TextWidgetDesign | undefined): boolean {
|
|
32
|
-
return design == null || design.items.length === 0
|
|
33
|
-
}
|
|
29
|
+
return design == null || (design.items != null && design.items.length === 0)
|
|
30
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { assert } from "chai"
|
|
2
|
+
import IdSelection from "../src/IdSelection"
|
|
3
|
+
|
|
4
|
+
describe("IdSelection", function () {
|
|
5
|
+
beforeEach(function(this: any) {
|
|
6
|
+
this.sel = new IdSelection()
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it("adds id", function(this: any) {
|
|
10
|
+
const sel = this.sel.add("1")
|
|
11
|
+
assert.isTrue(sel.isSelected("1"))
|
|
12
|
+
assert.isFalse(sel.isSelected("2"))
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it("removes id", function(this: any) {
|
|
16
|
+
let sel = this.sel.add("1")
|
|
17
|
+
sel = sel.remove("1")
|
|
18
|
+
assert.isFalse(sel.isSelected("1"))
|
|
19
|
+
assert.isFalse(sel.isSelected("2"))
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it("toggles id", function(this: any) {
|
|
23
|
+
let sel = this.sel.toggle("1")
|
|
24
|
+
assert.isTrue(sel.isSelected("1"))
|
|
25
|
+
sel = sel.toggle("1")
|
|
26
|
+
assert.isFalse(sel.isSelected("1"))
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it("inverts", function(this: any) {
|
|
30
|
+
let sel = this.sel.add("1")
|
|
31
|
+
sel = sel.invert()
|
|
32
|
+
assert.isTrue(sel.isSelected("2"))
|
|
33
|
+
assert.isFalse(sel.isSelected("1"))
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it("adds in inverts", function(this: any) {
|
|
37
|
+
let sel = this.sel.add("1")
|
|
38
|
+
sel = sel.invert()
|
|
39
|
+
sel = sel.add("1")
|
|
40
|
+
assert.isTrue(sel.isSelected("1"))
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("none", function(this: any) {
|
|
44
|
+
let sel = this.sel.add("1")
|
|
45
|
+
sel = sel.none()
|
|
46
|
+
assert.isFalse(sel.isSelected("1"))
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
return it("all", function(this: any) {
|
|
50
|
+
const sel = this.sel.all("1")
|
|
51
|
+
assert.isTrue(sel.isSelected("1"))
|
|
52
|
+
assert.isTrue(sel.isSelected("2"))
|
|
53
|
+
})
|
|
54
|
+
})
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { assert } from "chai"
|
|
2
|
+
import { translateHtmlItems, getHtmlItemsStrings } from "../../src/richtext/ExprItemsTranslator"
|
|
3
|
+
import { HtmlItemElement } from "../../src/richtext/ItemsHtmlConverter"
|
|
4
|
+
import { HtmlItemExpr, HtmlItemOrExpr } from "../../src/richtext/ExprItemsHtmlConverter"
|
|
5
|
+
|
|
6
|
+
describe("ExprItemsTranslator", function () {
|
|
7
|
+
describe("translateHtmlItems", function () {
|
|
8
|
+
it("should translate simple strings", function () {
|
|
9
|
+
const items: HtmlItemOrExpr[] = ["Hello ", "World"]
|
|
10
|
+
const translatedItems = translateHtmlItems(items, (input) => input.toUpperCase())
|
|
11
|
+
assert.deepEqual(translatedItems, ["HELLO WORLD"])
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("should translate nested items", function () {
|
|
15
|
+
const items: HtmlItemOrExpr[] = [
|
|
16
|
+
{
|
|
17
|
+
type: "element",
|
|
18
|
+
tag: "p",
|
|
19
|
+
items: ["Hello", { type: "element", tag: "b", items: ["World"] } as HtmlItemElement]
|
|
20
|
+
} as HtmlItemElement
|
|
21
|
+
]
|
|
22
|
+
const translatedItems = translateHtmlItems(items, (input) => input.toUpperCase())
|
|
23
|
+
assert.deepEqual(translatedItems, [
|
|
24
|
+
{
|
|
25
|
+
type: "element",
|
|
26
|
+
tag: "p",
|
|
27
|
+
items: ["HELLO", { type: "element", tag: "b", items: ["WORLD"] } as HtmlItemElement]
|
|
28
|
+
} as HtmlItemElement
|
|
29
|
+
])
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it("should translate expression items", function () {
|
|
33
|
+
const items: HtmlItemOrExpr[] = [
|
|
34
|
+
{
|
|
35
|
+
type: "expr",
|
|
36
|
+
id: "1",
|
|
37
|
+
expr: { type: "literal", valueType: "text", value: "Hello" },
|
|
38
|
+
labelText: "Greeting"
|
|
39
|
+
} as HtmlItemExpr
|
|
40
|
+
]
|
|
41
|
+
const translatedItems = translateHtmlItems(items, (input) => input.toUpperCase())
|
|
42
|
+
assert.deepEqual(translatedItems, [
|
|
43
|
+
{
|
|
44
|
+
type: "expr",
|
|
45
|
+
id: "1",
|
|
46
|
+
expr: { type: "literal", valueType: "text", value: "Hello" },
|
|
47
|
+
labelText: "GREETING"
|
|
48
|
+
} as HtmlItemExpr
|
|
49
|
+
])
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it("should translate expression items within a string", function () {
|
|
53
|
+
const items: HtmlItemOrExpr[] = [
|
|
54
|
+
"Hello, ",
|
|
55
|
+
{
|
|
56
|
+
type: "expr",
|
|
57
|
+
id: "1",
|
|
58
|
+
expr: { type: "literal", valueType: "text", value: "Hello" },
|
|
59
|
+
labelText: "Greeting"
|
|
60
|
+
} as HtmlItemExpr,
|
|
61
|
+
"!"
|
|
62
|
+
]
|
|
63
|
+
const translatedItems = translateHtmlItems(items, (input) => input.toUpperCase())
|
|
64
|
+
assert.deepEqual(translatedItems, [
|
|
65
|
+
"HELLO, ",
|
|
66
|
+
{
|
|
67
|
+
type: "expr",
|
|
68
|
+
id: "1",
|
|
69
|
+
expr: { type: "literal", valueType: "text", value: "Hello" },
|
|
70
|
+
labelText: "GREETING"
|
|
71
|
+
} as HtmlItemExpr,
|
|
72
|
+
"!"
|
|
73
|
+
])
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it("should translate links while preserving the href", function () {
|
|
77
|
+
const items: HtmlItemOrExpr[] = [
|
|
78
|
+
"Hello, ",
|
|
79
|
+
{
|
|
80
|
+
type: "element",
|
|
81
|
+
tag: "a",
|
|
82
|
+
items: ["there"],
|
|
83
|
+
href: "https://example.com"
|
|
84
|
+
} as HtmlItemElement,
|
|
85
|
+
"!"
|
|
86
|
+
]
|
|
87
|
+
const translatedItems = translateHtmlItems(items, (input) => input.toUpperCase())
|
|
88
|
+
assert.deepEqual(translatedItems, [
|
|
89
|
+
"HELLO, ",
|
|
90
|
+
{
|
|
91
|
+
type: "element",
|
|
92
|
+
tag: "a",
|
|
93
|
+
items: ["THERE"],
|
|
94
|
+
href: "HTTPS://EXAMPLE.COM"
|
|
95
|
+
} as HtmlItemElement,
|
|
96
|
+
"!"
|
|
97
|
+
])
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it("should collect all unique strings", function () {
|
|
101
|
+
const items: HtmlItemOrExpr[] = [
|
|
102
|
+
"Start ",
|
|
103
|
+
{
|
|
104
|
+
type: "element",
|
|
105
|
+
tag: "p",
|
|
106
|
+
items: ["Hello ", { type: "element", tag: "b", items: ["World"] }]
|
|
107
|
+
} as HtmlItemElement,
|
|
108
|
+
" This is a ",
|
|
109
|
+
{
|
|
110
|
+
type: "expr",
|
|
111
|
+
id: "1",
|
|
112
|
+
expr: { type: "literal", valueType: "text", value: "Hello" },
|
|
113
|
+
labelText: "Greeting"
|
|
114
|
+
} as HtmlItemExpr,
|
|
115
|
+
"!"
|
|
116
|
+
]
|
|
117
|
+
const strings = getHtmlItemsStrings(items)
|
|
118
|
+
assert.deepEqual(strings, ["Start", "Hello <b>World</b>", "Greeting", "This is a {0}!"])
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
describe("getHtmlItemsStrings", function () {
|
|
123
|
+
it("should collect all unique strings", function () {
|
|
124
|
+
const items: HtmlItemOrExpr[] = [
|
|
125
|
+
"Start ",
|
|
126
|
+
{
|
|
127
|
+
type: "element",
|
|
128
|
+
tag: "p",
|
|
129
|
+
items: ["Hello ", { type: "element", tag: "b", items: ["World"] }]
|
|
130
|
+
} as HtmlItemElement,
|
|
131
|
+
" This is a ",
|
|
132
|
+
{
|
|
133
|
+
type: "expr",
|
|
134
|
+
id: "1",
|
|
135
|
+
expr: { type: "literal", valueType: "text", value: "Hello" },
|
|
136
|
+
labelText: "Greeting"
|
|
137
|
+
} as HtmlItemExpr,
|
|
138
|
+
"!"
|
|
139
|
+
]
|
|
140
|
+
const strings = getHtmlItemsStrings(items)
|
|
141
|
+
assert.deepEqual(strings, ["Start", "Hello <b>World</b>", "Greeting", "This is a {0}!"])
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
})
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { assert } from "chai"
|
|
2
|
+
import { parse, stringify } from "../src/wellknown"
|
|
3
|
+
|
|
4
|
+
describe("WellKnown", () => {
|
|
5
|
+
describe("parse", () => {
|
|
6
|
+
it("parses a point", () => {
|
|
7
|
+
const result = parse("POINT (1 2)")
|
|
8
|
+
assert.deepEqual(result, {
|
|
9
|
+
type: "Point",
|
|
10
|
+
coordinates: [1, 2]
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it("parses a linestring", () => {
|
|
15
|
+
const result = parse("LINESTRING (1 2, 3 4)")
|
|
16
|
+
assert.deepEqual(result, {
|
|
17
|
+
type: "LineString",
|
|
18
|
+
coordinates: [[1, 2], [3, 4]]
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it("parses a polygon", () => {
|
|
23
|
+
const result = parse("POLYGON ((1 2, 3 4, 5 6, 1 2))")
|
|
24
|
+
assert.deepEqual(result, {
|
|
25
|
+
type: "Polygon",
|
|
26
|
+
coordinates: [[[1, 2], [3, 4], [5, 6], [1, 2]]]
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it("parses a polygon with hole", () => {
|
|
31
|
+
const result = parse("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (2 2, 8 2, 8 8, 2 8, 2 2))")
|
|
32
|
+
assert.deepEqual(result, {
|
|
33
|
+
type: "Polygon",
|
|
34
|
+
coordinates: [
|
|
35
|
+
[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]],
|
|
36
|
+
[[2, 2], [8, 2], [8, 8], [2, 8], [2, 2]]
|
|
37
|
+
]
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it("parses a multipoint", () => {
|
|
42
|
+
const result = parse("MULTIPOINT ((1 2), (3 4))")
|
|
43
|
+
assert.deepEqual(result, {
|
|
44
|
+
type: "MultiPoint",
|
|
45
|
+
coordinates: [[1, 2], [3, 4]]
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("handles SRID", () => {
|
|
50
|
+
const result = parse("SRID=4326;POINT (1 2)")
|
|
51
|
+
assert.deepEqual(result, {
|
|
52
|
+
type: "Point",
|
|
53
|
+
coordinates: [1, 2],
|
|
54
|
+
crs: {
|
|
55
|
+
type: "name",
|
|
56
|
+
properties: {
|
|
57
|
+
name: "urn:ogc:def:crs:EPSG::4326"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it("returns null for invalid input", () => {
|
|
64
|
+
const result = parse("POINT (not a point)")
|
|
65
|
+
assert.isNull(result)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it("parses a multilinestring", () => {
|
|
69
|
+
const result = parse("MULTILINESTRING ((1 2, 3 4), (5 6, 7 8))")
|
|
70
|
+
assert.deepEqual(result, {
|
|
71
|
+
type: "MultiLineString",
|
|
72
|
+
coordinates: [
|
|
73
|
+
[[1, 2], [3, 4]],
|
|
74
|
+
[[5, 6], [7, 8]]
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it("parses a multilinestring with z coordinate", () => {
|
|
80
|
+
const result = parse("MULTILINESTRING Z ((1 2 10, 3 4 11), (5 6 12, 7 8 13))")
|
|
81
|
+
assert.deepEqual(result, {
|
|
82
|
+
type: "MultiLineString",
|
|
83
|
+
coordinates: [
|
|
84
|
+
[[1, 2, 10], [3, 4, 11]],
|
|
85
|
+
[[5, 6, 12], [7, 8, 13]]
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it("parses a multilinestring with zm coordinate, ignoring m", () => {
|
|
91
|
+
const result = parse("MULTILINESTRING ZM ((1 2 10 100, 3 4 11 101), (5 6 12 102, 7 8 13 103))")
|
|
92
|
+
assert.deepEqual(result, {
|
|
93
|
+
type: "MultiLineString",
|
|
94
|
+
coordinates: [
|
|
95
|
+
[[1, 2, 10], [3, 4, 11]],
|
|
96
|
+
[[5, 6, 12], [7, 8, 13]]
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
describe("stringify", () => {
|
|
103
|
+
it("stringifies a point", () => {
|
|
104
|
+
const point = {
|
|
105
|
+
type: "Point",
|
|
106
|
+
coordinates: [1, 2]
|
|
107
|
+
}
|
|
108
|
+
assert.equal(stringify(point), "POINT (1 2)")
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it("stringifies a linestring", () => {
|
|
112
|
+
const linestring = {
|
|
113
|
+
type: "LineString",
|
|
114
|
+
coordinates: [[1, 2], [3, 4]]
|
|
115
|
+
}
|
|
116
|
+
assert.equal(stringify(linestring), "LINESTRING (1 2, 3 4)")
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it("stringifies a polygon", () => {
|
|
120
|
+
const polygon = {
|
|
121
|
+
type: "Polygon",
|
|
122
|
+
coordinates: [[[1, 2], [3, 4], [5, 6], [1, 2]]]
|
|
123
|
+
}
|
|
124
|
+
assert.equal(stringify(polygon), "POLYGON ((1 2, 3 4, 5 6, 1 2))")
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it("stringifies a multilinestring", () => {
|
|
128
|
+
const multilinestring = {
|
|
129
|
+
type: "MultiLineString",
|
|
130
|
+
coordinates: [
|
|
131
|
+
[[1, 2], [3, 4]],
|
|
132
|
+
[[5, 6], [7, 8]]
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
assert.equal(stringify(multilinestring), "MULTILINESTRING ((1 2, 3 4), (5 6, 7 8))")
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it("throws error for invalid input", () => {
|
|
139
|
+
assert.throws(() => {
|
|
140
|
+
stringify({ type: "Invalid" })
|
|
141
|
+
}, "stringify requires a valid GeoJSON Feature or geometry object as input")
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
})
|