@mwater/visualization 5.4.0 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ColorComponent.js +2 -1
- package/lib/IdSelection.d.ts +16 -0
- package/lib/IdSelection.js +59 -0
- package/lib/MWaterAddRelatedIndicatorComponent.js +2 -2
- package/lib/MWaterCompleteTableSelectComponent.d.ts +3 -8
- package/lib/MWaterCompleteTableSelectComponent.js +36 -42
- package/lib/MWaterLoaderComponent.d.ts +11 -10
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterResponsesFilterComponent.js +1 -1
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +4 -6
- package/lib/autotranslate.d.ts +20 -0
- package/lib/autotranslate.js +122 -0
- package/lib/axes/AxisBuilder.js +3 -3
- package/lib/axes/AxisColorEditorComponent.js +4 -0
- package/lib/axes/AxisComponent.d.ts +8 -12
- package/lib/axes/AxisComponent.js +32 -80
- package/lib/axes/CategoryMapComponent.js +4 -4
- package/lib/axes/RangesComponent.js +2 -2
- package/lib/dashboards/DashboardComponent.d.ts +6 -0
- package/lib/dashboards/DashboardComponent.js +44 -12
- package/lib/dashboards/DashboardDesign.d.ts +11 -2
- package/lib/dashboards/DashboardUtils.d.ts +5 -0
- package/lib/dashboards/DashboardUtils.js +30 -0
- package/lib/dashboards/DashboardViewComponent.d.ts +2 -0
- package/lib/dashboards/DashboardViewComponent.js +16 -3
- package/lib/dashboards/ServerDashboardDataSource.js +2 -1
- package/lib/dashboards/SettingsModalComponent.d.ts +1 -1
- package/lib/dashboards/SettingsModalComponent.js +256 -19
- package/lib/dashboards/WidgetComponent.d.ts +6 -3
- package/lib/dashboards/WidgetComponent.js +3 -1
- package/lib/datagrids/CellEditor.d.ts +19 -0
- package/lib/datagrids/CellEditor.js +223 -0
- package/lib/datagrids/DatagridComponent.d.ts +18 -87
- package/lib/datagrids/DatagridComponent.js +304 -222
- package/lib/datagrids/DatagridViewComponent.d.ts +15 -53
- package/lib/datagrids/DatagridViewComponent.js +256 -257
- package/lib/datagrids/DirectDatagridDataSource.js +2 -3
- package/lib/datagrids/ExprCellComponent.d.ts +8 -15
- package/lib/datagrids/ExprCellComponent.js +11 -15
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -6
- package/lib/datagrids/FindReplaceModalComponent.js +38 -75
- package/lib/index.css +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
- package/lib/mWaterLoader.d.ts +1 -1
- package/lib/maps/BufferLayer.d.ts +7 -5
- package/lib/maps/BufferLayer.js +69 -48
- package/lib/maps/BufferLayerDesign.d.ts +21 -14
- package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
- package/lib/maps/BufferLayerDesignerComponent.js +68 -102
- package/lib/maps/ChoroplethLayer.d.ts +5 -4
- package/lib/maps/ChoroplethLayer.js +32 -9
- package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
- package/lib/maps/ChoroplethLayerDesigner.js +4 -2
- package/lib/maps/ClusterLayer.d.ts +3 -4
- package/lib/maps/ClusterLayer.js +2 -1
- package/lib/maps/DetailLevelSelectComponent.js +1 -1
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +5 -3
- package/lib/maps/GridLayer.d.ts +3 -4
- package/lib/maps/GridLayer.js +2 -1
- package/lib/maps/GridLayerDesigner.js +5 -3
- package/lib/maps/HoverContent.d.ts +11 -3
- package/lib/maps/HoverContent.js +25 -9
- package/lib/maps/Layer.d.ts +24 -3
- package/lib/maps/Layer.js +5 -1
- package/lib/maps/LayerFactory.js +0 -8
- package/lib/maps/LayerLegendComponent.js +0 -1
- package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/LeafletMapComponent.js +3 -1
- package/lib/maps/LegendComponent.d.ts +1 -0
- package/lib/maps/LegendComponent.js +9 -1
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +2 -2
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.d.ts +4 -3
- package/lib/maps/MapDesignerComponent.js +68 -74
- package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
- package/lib/maps/MapUtils.d.ts +4 -0
- package/lib/maps/MapUtils.js +19 -0
- package/lib/maps/MapViewComponent.d.ts +8 -3
- package/lib/maps/MarkersLayer.d.ts +5 -4
- package/lib/maps/MarkersLayer.js +33 -7
- package/lib/maps/MarkersLayerDesign.d.ts +19 -16
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
- package/lib/maps/PopupFilterJoinsUtils.js +0 -6
- package/lib/maps/RasterMapViewComponent.d.ts +3 -31
- package/lib/maps/RasterMapViewComponent.js +7 -2
- package/lib/maps/ServerMapDataSource.js +2 -1
- package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
- package/lib/maps/SwitchableTileUrlLayer.js +2 -1
- package/lib/maps/TileUrlLayer.d.ts +4 -5
- package/lib/maps/TileUrlLayer.js +2 -1
- package/lib/maps/VectorMapViewComponent.d.ts +5 -37
- package/lib/maps/VectorMapViewComponent.js +19 -8
- package/lib/maps/maps.d.ts +3 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersDesignComponent.js +19 -35
- package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
- package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
- package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
- package/lib/richtext/ExprItemsTranslator.js +149 -0
- package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
- package/lib/richtext/ItemsHtmlConverter.js +31 -15
- package/lib/wellknown.js +12 -9
- package/lib/widgets/IFrameWidget.d.ts +4 -4
- package/lib/widgets/ImageWidget.d.ts +7 -4
- package/lib/widgets/ImageWidget.js +9 -1
- package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
- package/lib/widgets/ImageWidgetComponent.js +1 -1
- package/lib/widgets/MapWidget.d.ts +5 -48
- package/lib/widgets/MapWidget.js +26 -63
- package/lib/widgets/MarkdownWidget.d.ts +3 -0
- package/lib/widgets/MarkdownWidget.js +3 -0
- package/lib/widgets/TOCWidget.d.ts +15 -27
- package/lib/widgets/TOCWidget.js +107 -183
- package/lib/widgets/Widget.d.ts +18 -7
- package/lib/widgets/Widget.js +4 -0
- package/lib/widgets/WidgetScopesViewComponent.js +1 -1
- package/lib/widgets/charts/Chart.d.ts +10 -1
- package/lib/widgets/charts/Chart.js +22 -11
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +6 -3
- package/lib/widgets/charts/ChartWidget.d.ts +2 -0
- package/lib/widgets/charts/ChartWidget.js +9 -1
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
- package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
- package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
- package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
- package/lib/widgets/charts/layered/LayeredChart.js +63 -3
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +3 -3
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
- package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChart.js +63 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +6 -0
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
- package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
- package/lib/widgets/charts/table/TableChart.d.ts +1 -0
- package/lib/widgets/charts/table/TableChart.js +15 -0
- package/lib/widgets/text/TextComponent.d.ts +11 -4
- package/lib/widgets/text/TextComponent.js +11 -8
- package/lib/widgets/text/TextWidget.d.ts +6 -3
- package/lib/widgets/text/TextWidget.js +7 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
- package/lib/widgets/text/TextWidgetComponent.js +7 -1
- package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
- package/lib/widgets/text/TextWidgetDesign.js +1 -1
- package/package.json +7 -8
- package/src/ColorComponent.tsx +1 -2
- package/src/IdSelection.ts +62 -0
- package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
- package/src/MWaterLoaderComponent.ts +28 -26
- package/src/MWaterResponsesFilterComponent.ts +5 -2
- package/src/MWaterTableSelectComponent.tsx +5 -9
- package/src/autotranslate.ts +141 -0
- package/src/axes/AxisBuilder.ts +3 -3
- package/src/axes/AxisColorEditorComponent.tsx +5 -0
- package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
- package/src/axes/CategoryMapComponent.ts +4 -4
- package/src/axes/RangesComponent.ts +3 -2
- package/src/dashboards/DashboardComponent.tsx +79 -14
- package/src/dashboards/DashboardDesign.ts +9 -2
- package/src/dashboards/DashboardUtils.ts +39 -0
- package/src/dashboards/DashboardViewComponent.tsx +22 -3
- package/src/dashboards/ServerDashboardDataSource.ts +2 -1
- package/src/dashboards/SettingsModalComponent.tsx +450 -35
- package/src/dashboards/WidgetComponent.tsx +12 -6
- package/src/datagrids/CellEditor.tsx +354 -0
- package/src/datagrids/DatagridComponent.tsx +646 -0
- package/src/datagrids/DatagridViewComponent.tsx +539 -0
- package/src/datagrids/DirectDatagridDataSource.ts +2 -3
- package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
- package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
- package/src/index.css +1 -1
- package/src/index.ts +0 -1
- package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
- package/src/mWaterLoader.ts +1 -1
- package/src/maps/BufferLayer.ts +83 -60
- package/src/maps/BufferLayerDesign.ts +20 -14
- package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
- package/src/maps/ChoroplethLayer.ts +40 -19
- package/src/maps/ChoroplethLayerDesign.ts +4 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
- package/src/maps/ClusterLayer.ts +4 -10
- package/src/maps/DetailLevelSelectComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +2 -1
- package/src/maps/EditPopupComponent.ts +7 -3
- package/src/maps/GridLayer.ts +4 -10
- package/src/maps/GridLayerDesigner.tsx +5 -3
- package/src/maps/HoverContent.tsx +40 -16
- package/src/maps/Layer.ts +28 -10
- package/src/maps/LayerFactory.ts +0 -8
- package/src/maps/LayerLegendComponent.ts +2 -4
- package/src/maps/LayerSwitcherComponent.tsx +6 -2
- package/src/maps/LeafletMapComponent.tsx +3 -1
- package/src/maps/LegendComponent.tsx +10 -1
- package/src/maps/MWaterServerLayer.ts +3 -3
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +3 -0
- package/src/maps/MapDesignerComponent.tsx +165 -162
- package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
- package/src/maps/MapUtils.ts +24 -0
- package/src/maps/MapViewComponent.tsx +11 -3
- package/src/maps/MarkersLayer.ts +44 -18
- package/src/maps/MarkersLayerDesign.ts +19 -16
- package/src/maps/PopupFilterJoinsUtils.ts +6 -2
- package/src/maps/RasterMapViewComponent.ts +9 -45
- package/src/maps/ServerMapDataSource.ts +2 -2
- package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
- package/src/maps/TileUrlLayer.tsx +4 -10
- package/src/maps/VectorMapViewComponent.tsx +28 -55
- package/src/maps/maps.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +56 -74
- package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
- package/src/richtext/ExprItemsTranslator.ts +176 -0
- package/src/richtext/ItemsHtmlConverter.ts +33 -18
- package/src/wellknown.ts +33 -30
- package/src/widgets/ImageWidget.ts +10 -1
- package/src/widgets/ImageWidgetComponent.ts +3 -2
- package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
- package/src/widgets/MarkdownWidget.ts +3 -0
- package/src/widgets/TOCWidget.tsx +281 -0
- package/src/widgets/Widget.ts +25 -5
- package/src/widgets/WidgetScopesViewComponent.ts +2 -1
- package/src/widgets/charts/Chart.ts +31 -12
- package/src/widgets/charts/ChartViewComponent.ts +13 -3
- package/src/widgets/charts/ChartWidget.ts +11 -1
- package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
- package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
- package/src/widgets/charts/layered/LayeredChart.ts +71 -3
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +4 -4
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
- package/src/widgets/charts/pivot/PivotChart.ts +73 -0
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
- package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
- package/src/widgets/charts/table/TableChart.ts +17 -0
- package/src/widgets/text/TextComponent.tsx +22 -12
- package/src/widgets/text/TextWidget.ts +9 -2
- package/src/widgets/text/TextWidgetComponent.tsx +16 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -7
- package/test/IdSelectionTests.ts +54 -0
- package/test/LayeredChartCompilerTests.ts +0 -2
- package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
- package/test/wellknownTests.ts +144 -0
- package/src/datagrids/DatagridComponent.ts +0 -478
- package/src/datagrids/DatagridViewComponent.ts +0 -464
- package/src/datagrids/EditExprCellComponent.tsx +0 -305
- package/src/datagrids/README.md +0 -3
- package/src/maps/BufferLayerDesignerComponent.ts +0 -311
- package/src/widgets/TOCWidget.ts +0 -326
- package/test/LegoLayoutEngineTests.ts +0 -69
package/src/widgets/TOCWidget.ts
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import PropTypes from "prop-types"
|
|
2
|
-
import React from "react"
|
|
3
|
-
const R = React.createElement
|
|
4
|
-
import _ from "lodash"
|
|
5
|
-
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
6
|
-
import update from "@mwater/react-library/lib/update"
|
|
7
|
-
import Widget, { CreateViewElementOptions } from "./Widget"
|
|
8
|
-
import DropdownWidgetComponent from "./DropdownWidgetComponent"
|
|
9
|
-
import ModalPopupComponent from "@mwater/react-library/lib/ModalPopupComponent"
|
|
10
|
-
|
|
11
|
-
// Table of contents widget that displays the h1, h2, etc entries from all text fields in one widget
|
|
12
|
-
// design is:
|
|
13
|
-
// header: text of header. Defaults to "Contents"
|
|
14
|
-
// borderWeight: border weight. Defaults to 0=None. 1=light, 2=medium, 3=heavy
|
|
15
|
-
// numbering: true/false for prepending numbering to entries (e.g. 3.4.1)
|
|
16
|
-
export default class TOCWidget extends Widget {
|
|
17
|
-
// Creates a React element that is a view of the widget
|
|
18
|
-
// options:
|
|
19
|
-
// schema: schema to use
|
|
20
|
-
// dataSource: data source to use
|
|
21
|
-
// widgetDataSource: Gives data to the widget in a way that allows client-server separation and secure sharing. See definition in WidgetDataSource.
|
|
22
|
-
// design: widget design
|
|
23
|
-
// scope: scope of the widget (when the widget self-selects a particular scope)
|
|
24
|
-
// filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct
|
|
25
|
-
// onScopeChange: called with scope of widget
|
|
26
|
-
// onDesignChange: called with new design. null/undefined for readonly
|
|
27
|
-
// width: width in pixels on screen
|
|
28
|
-
// height: height in pixels on screen
|
|
29
|
-
// tocEntries: entries in the table of contents
|
|
30
|
-
// onScrollToTOCEntry: called with (widgetId, tocEntryId) to scroll to TOC entry
|
|
31
|
-
createViewElement(options: CreateViewElementOptions) {
|
|
32
|
-
return R(TOCWidgetComponent, {
|
|
33
|
-
design: options.design,
|
|
34
|
-
onDesignChange: options.onDesignChange,
|
|
35
|
-
width: options.width,
|
|
36
|
-
height: options.height,
|
|
37
|
-
tocEntries: options.tocEntries,
|
|
38
|
-
onScrollToTOCEntry: options.onScrollToTOCEntry
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Determine if widget is auto-height, which means that a vertical height is not required.
|
|
43
|
-
isAutoHeight() {
|
|
44
|
-
return true
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
class TOCWidgetComponent extends React.Component {
|
|
49
|
-
static propTypes = {
|
|
50
|
-
design: PropTypes.object.isRequired, // See Map Design.md
|
|
51
|
-
onDesignChange: PropTypes.func, // Called with new design. null/undefined for readonly
|
|
52
|
-
|
|
53
|
-
width: PropTypes.number,
|
|
54
|
-
height: PropTypes.number,
|
|
55
|
-
tocEntries: PropTypes.arrayOf(
|
|
56
|
-
PropTypes.shape({
|
|
57
|
-
id: PropTypes.any,
|
|
58
|
-
widgetId: PropTypes.string.isRequired,
|
|
59
|
-
level: PropTypes.number.isRequired,
|
|
60
|
-
text: PropTypes.string.isRequired
|
|
61
|
-
})
|
|
62
|
-
),
|
|
63
|
-
onScrollToTOCEntry: PropTypes.func
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
constructor(props: any) {
|
|
67
|
-
super(props)
|
|
68
|
-
this.state = {
|
|
69
|
-
editing: false // true if editing
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
handleStartEditing = () => {
|
|
74
|
-
return this.setState({ editing: true })
|
|
75
|
-
}
|
|
76
|
-
handleEndEditing = () => {
|
|
77
|
-
return this.setState({ editing: false })
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
renderEditor() {
|
|
81
|
-
if (!this.state.editing) {
|
|
82
|
-
return null
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Create editor
|
|
86
|
-
const editor = R(TOCWidgetDesignerComponent, {
|
|
87
|
-
design: this.props.design,
|
|
88
|
-
onDesignChange: this.props.onDesignChange
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
return R(
|
|
92
|
-
ModalPopupComponent,
|
|
93
|
-
{
|
|
94
|
-
showCloseX: true,
|
|
95
|
-
header: T`Table of Contents Options`,
|
|
96
|
-
onClose: this.handleEndEditing
|
|
97
|
-
},
|
|
98
|
-
editor
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
renderContent() {
|
|
103
|
-
return R(TOCWidgetViewComponent, {
|
|
104
|
-
design: this.props.design,
|
|
105
|
-
onDesignChange: this.props.onDesignChange,
|
|
106
|
-
width: this.props.width,
|
|
107
|
-
height: this.props.height,
|
|
108
|
-
tocEntries: this.props.tocEntries,
|
|
109
|
-
onScrollToTOCEntry: this.props.onScrollToTOCEntry
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
render() {
|
|
114
|
-
const dropdownItems = []
|
|
115
|
-
if (this.props.onDesignChange != null) {
|
|
116
|
-
dropdownItems.push({ label: T`Edit`, icon: "pencil", onClick: this.handleStartEditing })
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Wrap in a simple widget
|
|
120
|
-
return R(
|
|
121
|
-
"div",
|
|
122
|
-
{ onDoubleClick: this.handleStartEditing },
|
|
123
|
-
this.props.onDesignChange != null ? this.renderEditor() : undefined,
|
|
124
|
-
R(
|
|
125
|
-
DropdownWidgetComponent,
|
|
126
|
-
{
|
|
127
|
-
width: this.props.width,
|
|
128
|
-
height: this.props.height,
|
|
129
|
-
dropdownItems
|
|
130
|
-
},
|
|
131
|
-
this.renderContent()
|
|
132
|
-
)
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Displays the contents of the widget
|
|
138
|
-
class TOCWidgetViewComponent extends React.Component {
|
|
139
|
-
static propTypes = {
|
|
140
|
-
design: PropTypes.object.isRequired, // Design of chart
|
|
141
|
-
onDesignChange: PropTypes.func, // Called with new design. null/undefined for readonly
|
|
142
|
-
|
|
143
|
-
width: PropTypes.number,
|
|
144
|
-
height: PropTypes.number,
|
|
145
|
-
|
|
146
|
-
tocEntries: PropTypes.arrayOf(
|
|
147
|
-
PropTypes.shape({
|
|
148
|
-
id: PropTypes.any,
|
|
149
|
-
widgetId: PropTypes.string.isRequired,
|
|
150
|
-
level: PropTypes.number.isRequired,
|
|
151
|
-
text: PropTypes.string.isRequired
|
|
152
|
-
})
|
|
153
|
-
),
|
|
154
|
-
onScrollToTOCEntry: PropTypes.func
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
handleEntryClick = (tocEntry: any) => {
|
|
158
|
-
return this.props.onScrollToTOCEntry?.(tocEntry.widgetId, tocEntry.id)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
renderTOCEntry(tocEntry: any, index: any) {
|
|
162
|
-
// Find indentation number (e.g "1.3.2") by counting # backwards that are same level with no level lower
|
|
163
|
-
let level
|
|
164
|
-
let indentation = ""
|
|
165
|
-
if (this.props.design.numbering) {
|
|
166
|
-
let asc, end
|
|
167
|
-
for (
|
|
168
|
-
level = 1, end = tocEntry.level, asc = 1 <= end;
|
|
169
|
-
asc ? level <= end : level >= end;
|
|
170
|
-
asc ? level++ : level--
|
|
171
|
-
) {
|
|
172
|
-
let value = 0
|
|
173
|
-
for (let i2 = 0, end1 = index, asc1 = 0 <= end1; asc1 ? i2 <= end1 : i2 >= end1; asc1 ? i2++ : i2--) {
|
|
174
|
-
if (this.props.tocEntries[i2].level === level) {
|
|
175
|
-
value += 1
|
|
176
|
-
} else if (this.props.tocEntries[i2].level < level) {
|
|
177
|
-
value = 0
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
indentation += `${value}.`
|
|
182
|
-
}
|
|
183
|
-
indentation += " "
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return R(
|
|
187
|
-
"div",
|
|
188
|
-
{ key: index, style: { paddingLeft: tocEntry.level * 8 - 8 } },
|
|
189
|
-
R(
|
|
190
|
-
"a",
|
|
191
|
-
{ className: "link-plain", onClick: this.handleEntryClick.bind(null, tocEntry) },
|
|
192
|
-
indentation,
|
|
193
|
-
R("span", null, tocEntry.text)
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
render() {
|
|
199
|
-
// Get border
|
|
200
|
-
const border = (() => {
|
|
201
|
-
switch (this.props.design.borderWeight) {
|
|
202
|
-
case 0:
|
|
203
|
-
return "none"
|
|
204
|
-
case 1:
|
|
205
|
-
return "solid 1px #f4f4f4"
|
|
206
|
-
case 2:
|
|
207
|
-
return "solid 1px #ccc"
|
|
208
|
-
case 3:
|
|
209
|
-
return "solid 1px #888"
|
|
210
|
-
}
|
|
211
|
-
})()
|
|
212
|
-
|
|
213
|
-
return R(
|
|
214
|
-
"div",
|
|
215
|
-
{
|
|
216
|
-
style: {
|
|
217
|
-
width: this.props.width,
|
|
218
|
-
height: this.props.height,
|
|
219
|
-
border,
|
|
220
|
-
padding: 5,
|
|
221
|
-
margin: 1
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
// Render header
|
|
225
|
-
R("div", { style: { fontWeight: "bold" } }, this.props.design.header),
|
|
226
|
-
_.map(this.props.tocEntries, (tocEntry, i) => {
|
|
227
|
-
return this.renderTOCEntry(tocEntry, i)
|
|
228
|
-
}),
|
|
229
|
-
|
|
230
|
-
// Add placeholder if none and editable
|
|
231
|
-
this.props.onDesignChange && (this.props.tocEntries || []).length === 0
|
|
232
|
-
? R(
|
|
233
|
-
"div",
|
|
234
|
-
{ className: "text-muted" },
|
|
235
|
-
T`Table of Contents will appear here as text blocks with headings are added to the dashboard`
|
|
236
|
-
)
|
|
237
|
-
: undefined
|
|
238
|
-
)
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// Designer for TOC widget options
|
|
243
|
-
class TOCWidgetDesignerComponent extends React.Component {
|
|
244
|
-
constructor(...args: any[]) {
|
|
245
|
-
super(...args)
|
|
246
|
-
this.update = this.update.bind(this)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
static propTypes = {
|
|
250
|
-
design: PropTypes.object.isRequired,
|
|
251
|
-
onDesignChange: PropTypes.func.isRequired
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Updates design with the specified changes
|
|
255
|
-
update() {
|
|
256
|
-
return update(this.props.design, this.props.onDesignChange, arguments)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
handleMarkdownChange = (ev: any) => {
|
|
260
|
-
const design = _.extend({}, this.props.design, { markdown: ev.target.value })
|
|
261
|
-
return this.props.onDesignChange(design)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
render() {
|
|
265
|
-
return R(
|
|
266
|
-
"div",
|
|
267
|
-
null,
|
|
268
|
-
R(
|
|
269
|
-
ui.FormGroup,
|
|
270
|
-
{ label: T`Header` },
|
|
271
|
-
R(ui.TextInput, { value: this.props.design.header || "", onChange: this.update("header"), placeholder: T`None` })
|
|
272
|
-
),
|
|
273
|
-
R(
|
|
274
|
-
ui.FormGroup,
|
|
275
|
-
{ label: T`Border` },
|
|
276
|
-
R(BorderComponent, { value: this.props.design.borderWeight || 0, onChange: this.update("borderWeight") })
|
|
277
|
-
),
|
|
278
|
-
R(
|
|
279
|
-
ui.FormGroup,
|
|
280
|
-
{ label: T`Numbering` },
|
|
281
|
-
R(
|
|
282
|
-
ui.Radio,
|
|
283
|
-
{
|
|
284
|
-
inline: true,
|
|
285
|
-
value: this.props.design.numbering || false,
|
|
286
|
-
radioValue: true,
|
|
287
|
-
onChange: this.update("numbering")
|
|
288
|
-
},
|
|
289
|
-
T`On`
|
|
290
|
-
),
|
|
291
|
-
R(
|
|
292
|
-
ui.Radio,
|
|
293
|
-
{
|
|
294
|
-
inline: true,
|
|
295
|
-
value: this.props.design.numbering || false,
|
|
296
|
-
radioValue: false,
|
|
297
|
-
onChange: this.update("numbering")
|
|
298
|
-
},
|
|
299
|
-
T`Off`
|
|
300
|
-
)
|
|
301
|
-
)
|
|
302
|
-
)
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Allows setting border heaviness
|
|
307
|
-
class BorderComponent extends React.Component {
|
|
308
|
-
static propTypes = {
|
|
309
|
-
value: PropTypes.number,
|
|
310
|
-
defaultValue: PropTypes.number,
|
|
311
|
-
onChange: PropTypes.func.isRequired
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
render() {
|
|
315
|
-
const value = this.props.value != null ? this.props.value : this.props.defaultValue
|
|
316
|
-
|
|
317
|
-
return R(
|
|
318
|
-
"div",
|
|
319
|
-
null,
|
|
320
|
-
R(ui.Radio, { inline: true, value, radioValue: 0, onChange: this.props.onChange }, T`None`),
|
|
321
|
-
R(ui.Radio, { inline: true, value, radioValue: 1, onChange: this.props.onChange }, T`Light`),
|
|
322
|
-
R(ui.Radio, { inline: true, value, radioValue: 2, onChange: this.props.onChange }, T`Medium`),
|
|
323
|
-
R(ui.Radio, { inline: true, value, radioValue: 3, onChange: this.props.onChange }, T`Heavy`)
|
|
324
|
-
)
|
|
325
|
-
}
|
|
326
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// TODO: This file was created by bulk-decaffeinate.
|
|
2
|
-
// Sanity-check the conversion and remove this comment.
|
|
3
|
-
import { assert } from "chai"
|
|
4
|
-
import _ from "lodash"
|
|
5
|
-
import LegoLayoutEngine from "../src/layouts/grid/LegoLayoutEngine"
|
|
6
|
-
|
|
7
|
-
describe("LegoLayoutEngine", function () {
|
|
8
|
-
before(function () {
|
|
9
|
-
// 6 blocks across, each 10 px
|
|
10
|
-
return (this.le = new LegoLayoutEngine(60, 6))
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it("snaps to grid", function () {
|
|
14
|
-
const rectLayout = this.le.rectToLayout({ x: 11, y: 19, width: 32, height: 42 })
|
|
15
|
-
return assert.deepEqual(rectLayout, { x: 1, y: 2, w: 3, h: 4 })
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it("shifts existing to right if room", function () {
|
|
19
|
-
const existing = { x: 1, y: 2, w: 1, h: 1 }
|
|
20
|
-
const newOne = { x: 1, y: 2, w: 3, h: 4 }
|
|
21
|
-
|
|
22
|
-
let layouts = {
|
|
23
|
-
existing,
|
|
24
|
-
newOne
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
layouts = this.le.performLayout(layouts, "newOne")
|
|
28
|
-
return assert.deepEqual(layouts, {
|
|
29
|
-
existing: { x: 4, y: 2, w: 1, h: 1 },
|
|
30
|
-
newOne: { x: 1, y: 2, w: 3, h: 4 }
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it("shifts existing to down if no room", function () {
|
|
35
|
-
const existing = { x: 1, y: 2, w: 5, h: 1 }
|
|
36
|
-
const newOne = { x: 1, y: 2, w: 3, h: 4 }
|
|
37
|
-
|
|
38
|
-
let layouts = {
|
|
39
|
-
existing,
|
|
40
|
-
newOne
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
layouts = this.le.performLayout(layouts, "newOne")
|
|
44
|
-
return assert.deepEqual(layouts, {
|
|
45
|
-
existing: { x: 0, y: 6, w: 5, h: 1 }, // Moves to left
|
|
46
|
-
newOne: { x: 1, y: 2, w: 3, h: 4 }
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it("calculates height", function () {
|
|
51
|
-
const existing = { x: 1, y: 2, w: 5, h: 1 }
|
|
52
|
-
|
|
53
|
-
const layouts = {
|
|
54
|
-
existing
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const height = this.le.calculateHeight(layouts)
|
|
58
|
-
return assert.equal(height, 40)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
return it("appends layout", function () {
|
|
62
|
-
const existing = { x: 1, y: 2, w: 5, h: 1 }
|
|
63
|
-
|
|
64
|
-
const layouts = [existing]
|
|
65
|
-
|
|
66
|
-
const newOne = this.le.appendLayout(layouts, 4, 3)
|
|
67
|
-
return assert.deepEqual(newOne, { x: 0, y: 3, w: 4, h: 3 })
|
|
68
|
-
})
|
|
69
|
-
})
|