@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
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties } from "react"
|
|
2
|
-
import ReactDOM from "react-dom"
|
|
3
|
-
import _ from "lodash"
|
|
4
|
-
const R = React.createElement
|
|
5
|
-
import { DragSource, DropTarget } from "react-dnd"
|
|
6
|
-
import DecoratedBlockComponent from "../DecoratedBlockComponent"
|
|
7
|
-
|
|
8
|
-
export interface LayoutComponentProps {
|
|
9
|
-
/** Opaque information to be used when a block is dragged */
|
|
10
|
-
dragInfo: any
|
|
11
|
-
canDrag: boolean
|
|
12
|
-
connectMoveHandle: any
|
|
13
|
-
connectResizeHandle: any
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Render a child element as draggable, resizable block, injecting handle connectors
|
|
17
|
-
// to child element
|
|
18
|
-
class LayoutComponent extends React.Component<LayoutComponentProps> {
|
|
19
|
-
render() {
|
|
20
|
-
if (this.props.canDrag) {
|
|
21
|
-
return React.cloneElement(React.Children.only(this.props.children!) as any, {
|
|
22
|
-
connectMoveHandle: this.props.connectMoveHandle,
|
|
23
|
-
connectResizeHandle: this.props.connectResizeHandle
|
|
24
|
-
})
|
|
25
|
-
} else {
|
|
26
|
-
return this.props.children
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const moveSpec = {
|
|
32
|
-
beginDrag(props: any, monitor: any, component: any) {
|
|
33
|
-
return props.dragInfo
|
|
34
|
-
},
|
|
35
|
-
canDrag(props: any, monitor: any) {
|
|
36
|
-
return props.canDrag
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function moveCollect(connect: any, monitor: any) {
|
|
41
|
-
return {
|
|
42
|
-
connectMoveHandle: connect.dragSource()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const MoveLayoutComponent = DragSource("block-move", moveSpec, moveCollect)(LayoutComponent)
|
|
47
|
-
|
|
48
|
-
const resizeSpec = {
|
|
49
|
-
beginDrag(props: any, monitor: any, component: any) {
|
|
50
|
-
return props.dragInfo
|
|
51
|
-
},
|
|
52
|
-
canDrag(props: any, monitor: any) {
|
|
53
|
-
return props.canDrag
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function resizeCollect(connect: any, monitor: any) {
|
|
58
|
-
return {
|
|
59
|
-
connectResizeHandle: connect.dragSource()
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const MoveResizeLayoutComponent = DragSource("block-resize", resizeSpec, resizeCollect)(MoveLayoutComponent)
|
|
64
|
-
|
|
65
|
-
interface ContainerProps {
|
|
66
|
-
layoutEngine: any
|
|
67
|
-
/** Lookup of id -> { widget:, layout: } */
|
|
68
|
-
items: any
|
|
69
|
-
/** Called with lookup of id -> { widget:, layout: } */
|
|
70
|
-
onItemsChange?: any
|
|
71
|
-
/** Renders a widget */
|
|
72
|
-
renderWidget: any
|
|
73
|
-
/** width in pixels */
|
|
74
|
-
width: number
|
|
75
|
-
connectDropTarget: any
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
interface ContainerState {
|
|
79
|
-
moveHover: any
|
|
80
|
-
resizeHover: any
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Container contains layouts to layout. It renders widgets at the correct location.
|
|
84
|
-
class Container extends React.Component<ContainerProps, ContainerState> {
|
|
85
|
-
constructor(props: any) {
|
|
86
|
-
super(props)
|
|
87
|
-
this.state = { moveHover: null, resizeHover: null }
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
setMoveHover(hoverInfo: any) {
|
|
91
|
-
return this.setState({ moveHover: hoverInfo })
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
setResizeHover(hoverInfo: any) {
|
|
95
|
-
return this.setState({ resizeHover: hoverInfo })
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
dropLayout(id: any, droppedRect: any, widget: any) {
|
|
99
|
-
// Stop hover
|
|
100
|
-
this.setState({ moveHover: null, resizeHover: null })
|
|
101
|
-
|
|
102
|
-
// Convert rect to layout
|
|
103
|
-
const droppedLayout = this.props.layoutEngine.rectToLayout(droppedRect)
|
|
104
|
-
|
|
105
|
-
// Insert dropped layout
|
|
106
|
-
let items = _.clone(this.props.items)
|
|
107
|
-
items[id] = { layout: droppedLayout, widget }
|
|
108
|
-
|
|
109
|
-
let layouts: any = {}
|
|
110
|
-
for (id in items) {
|
|
111
|
-
const item = items[id]
|
|
112
|
-
layouts[id] = item.layout
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Perform layout
|
|
116
|
-
layouts = this.props.layoutEngine.performLayout(layouts, id)
|
|
117
|
-
|
|
118
|
-
// Update item layouts
|
|
119
|
-
items = _.mapValues(items, (item, id) => {
|
|
120
|
-
return _.extend({}, item, { layout: layouts[id!] })
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
return this.props.onItemsChange(items)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Called when a block is dropped
|
|
127
|
-
dropMoveLayout(dropInfo: any) {
|
|
128
|
-
// Get rectangle of dropped block
|
|
129
|
-
const droppedRect = {
|
|
130
|
-
x: dropInfo.x,
|
|
131
|
-
y: dropInfo.y,
|
|
132
|
-
width: dropInfo.dragInfo.bounds.width, // width and height are from drop info
|
|
133
|
-
height: dropInfo.dragInfo.bounds.height
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return this.dropLayout(dropInfo.dragInfo.id, droppedRect, dropInfo.dragInfo.widget)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
dropResizeLayout(dropInfo: any) {
|
|
140
|
-
// Get rectangle of hovered block
|
|
141
|
-
const droppedRect = {
|
|
142
|
-
x: dropInfo.dragInfo.bounds.x,
|
|
143
|
-
y: dropInfo.dragInfo.bounds.y,
|
|
144
|
-
width: dropInfo.width,
|
|
145
|
-
height: dropInfo.height
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return this.dropLayout(dropInfo.dragInfo.id, droppedRect, dropInfo.dragInfo.widget)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
componentWillReceiveProps(nextProps: any) {
|
|
152
|
-
// Reset hover if not over
|
|
153
|
-
if (!nextProps.isOver && (this.state.moveHover || this.state.resizeHover)) {
|
|
154
|
-
// Defer to prevent "Cannot dispatch in the middle of a dispatch." error
|
|
155
|
-
_.defer(() => {
|
|
156
|
-
this.setState({ moveHover: null, resizeHover: null })
|
|
157
|
-
})
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
handleRemove = (id: any) => {
|
|
162
|
-
// Update item layouts
|
|
163
|
-
const items = _.omit(this.props.items, id)
|
|
164
|
-
return this.props.onItemsChange(items)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
handleWidgetDesignChange = (id: any, widgetDesign: any) => {
|
|
168
|
-
let { widget } = this.props.items[id]
|
|
169
|
-
widget = _.extend({}, widget, { design: widgetDesign })
|
|
170
|
-
|
|
171
|
-
let item = this.props.items[id]
|
|
172
|
-
item = _.extend({}, item, { widget })
|
|
173
|
-
|
|
174
|
-
const items = _.clone(this.props.items)
|
|
175
|
-
items[id] = item
|
|
176
|
-
|
|
177
|
-
return this.props.onItemsChange(items)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
renderPlaceholder(bounds: any) {
|
|
181
|
-
return R("div", {
|
|
182
|
-
key: "placeholder",
|
|
183
|
-
style: {
|
|
184
|
-
position: "absolute",
|
|
185
|
-
left: bounds.x,
|
|
186
|
-
top: bounds.y,
|
|
187
|
-
width: bounds.width,
|
|
188
|
-
height: bounds.height,
|
|
189
|
-
border: "dashed 3px #AAA",
|
|
190
|
-
borderRadius: 5,
|
|
191
|
-
padding: 5
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Render a particular layout. Allow visible to be false so that
|
|
197
|
-
// dragged elements can retain state
|
|
198
|
-
renderItem = (id: any, item: any, layout: any, visible = true) => {
|
|
199
|
-
// Calculate bounds
|
|
200
|
-
const bounds = this.props.layoutEngine.getLayoutBounds(layout)
|
|
201
|
-
|
|
202
|
-
// Position absolutely
|
|
203
|
-
const style: CSSProperties = {
|
|
204
|
-
position: "absolute",
|
|
205
|
-
left: bounds.x,
|
|
206
|
-
top: bounds.y
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (!visible) {
|
|
210
|
-
style.display = "none"
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Create dragInfo which is all the info needed to drop the layout
|
|
214
|
-
const dragInfo = {
|
|
215
|
-
id,
|
|
216
|
-
bounds,
|
|
217
|
-
widget: item.widget
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
let elem = this.props.renderWidget({
|
|
221
|
-
id,
|
|
222
|
-
type: item.widget.type,
|
|
223
|
-
design: item.widget.design,
|
|
224
|
-
onDesignChange: this.props.onItemsChange != null ? this.handleWidgetDesignChange.bind(null, id) : undefined,
|
|
225
|
-
width: bounds.width - 10,
|
|
226
|
-
height: bounds.height - 10
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
// Render decorated if editable
|
|
230
|
-
if (this.props.onItemsChange) {
|
|
231
|
-
elem = React.createElement(
|
|
232
|
-
DecoratedBlockComponent,
|
|
233
|
-
// style: { width: bounds.width, height: bounds.height }
|
|
234
|
-
{ onBlockRemove: this.handleRemove.bind(null, id) },
|
|
235
|
-
elem
|
|
236
|
-
)
|
|
237
|
-
} else {
|
|
238
|
-
elem = R(
|
|
239
|
-
"div",
|
|
240
|
-
{ className: "mwater-visualization-block-view" },
|
|
241
|
-
// style: { width: bounds.width, height: bounds.height },
|
|
242
|
-
elem
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Clone element, injecting width, height and enclosing in a dnd block
|
|
247
|
-
return R(
|
|
248
|
-
"div",
|
|
249
|
-
{ style, key: id },
|
|
250
|
-
React.createElement(MoveResizeLayoutComponent, { dragInfo, canDrag: this.props.onItemsChange != null }, elem)
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Calculate a lookup of layouts incorporating hover info
|
|
255
|
-
calculateLayouts(props: any, state: any) {
|
|
256
|
-
// Get hovered block if present
|
|
257
|
-
let hoveredRect, id
|
|
258
|
-
let hoveredDragInfo = null
|
|
259
|
-
let hoveredLayout = null // Layout of hovered block
|
|
260
|
-
if (state.moveHover) {
|
|
261
|
-
hoveredDragInfo = state.moveHover.dragInfo
|
|
262
|
-
hoveredRect = {
|
|
263
|
-
x: state.moveHover.x,
|
|
264
|
-
y: state.moveHover.y,
|
|
265
|
-
width: state.moveHover.dragInfo.bounds.width,
|
|
266
|
-
height: state.moveHover.dragInfo.bounds.height
|
|
267
|
-
}
|
|
268
|
-
hoveredLayout = props.layoutEngine.rectToLayout(hoveredRect)
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (state.resizeHover) {
|
|
272
|
-
hoveredDragInfo = state.resizeHover.dragInfo
|
|
273
|
-
hoveredRect = {
|
|
274
|
-
x: state.resizeHover.dragInfo.bounds.x,
|
|
275
|
-
y: state.resizeHover.dragInfo.bounds.y,
|
|
276
|
-
width: state.resizeHover.width,
|
|
277
|
-
height: state.resizeHover.height
|
|
278
|
-
}
|
|
279
|
-
hoveredLayout = props.layoutEngine.rectToLayout(hoveredRect)
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
let layouts: any = {}
|
|
283
|
-
for (id in props.items) {
|
|
284
|
-
const item = props.items[id]
|
|
285
|
-
layouts[id] = item.layout
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// Add hovered layout
|
|
289
|
-
if (hoveredDragInfo) {
|
|
290
|
-
layouts[hoveredDragInfo.id] = hoveredLayout
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Perform layout
|
|
294
|
-
layouts = props.layoutEngine.performLayout(layouts, hoveredDragInfo ? hoveredDragInfo.id : undefined)
|
|
295
|
-
return layouts
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
renderItems(items: any) {
|
|
299
|
-
let id
|
|
300
|
-
const layouts = this.calculateLayouts(this.props, this.state)
|
|
301
|
-
|
|
302
|
-
const renderElems = []
|
|
303
|
-
const hover = this.state.moveHover || this.state.resizeHover
|
|
304
|
-
|
|
305
|
-
// Render blocks in their adjusted position
|
|
306
|
-
const ids = []
|
|
307
|
-
for (id in items) {
|
|
308
|
-
ids.push(id)
|
|
309
|
-
}
|
|
310
|
-
if (hover && !ids.includes(hover.dragInfo.id)) {
|
|
311
|
-
ids.push(hover.dragInfo.id)
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
for (id of _.sortBy(ids)) {
|
|
315
|
-
const item = items[id]
|
|
316
|
-
if (!hover || id !== hover.dragInfo.id) {
|
|
317
|
-
renderElems.push(this.renderItem(id, item, layouts[id]))
|
|
318
|
-
} else {
|
|
319
|
-
// Render it anyway so that its state is retained
|
|
320
|
-
if (item) {
|
|
321
|
-
renderElems.push(this.renderItem(id, item, layouts[id], false))
|
|
322
|
-
}
|
|
323
|
-
renderElems.push(this.renderPlaceholder(this.props.layoutEngine.getLayoutBounds(layouts[id])))
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return renderElems
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// This gets called 100s of times when dragging
|
|
331
|
-
shouldComponentUpdate(nextProps: any, nextState: any) {
|
|
332
|
-
if (this.props.width !== nextProps.width) {
|
|
333
|
-
return true
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (this.props.layoutEngine !== nextProps.layoutEngine) {
|
|
337
|
-
return true
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const layouts = this.calculateLayouts(this.props, this.state)
|
|
341
|
-
const nextLayouts = this.calculateLayouts(nextProps, nextState)
|
|
342
|
-
|
|
343
|
-
if (!_.isEqual(layouts, nextLayouts)) {
|
|
344
|
-
return true
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return false
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
render() {
|
|
351
|
-
// Determine height using layout engine
|
|
352
|
-
const style = {
|
|
353
|
-
width: this.props.width,
|
|
354
|
-
height: "100%", // @props.layoutEngine.calculateHeight(layouts)
|
|
355
|
-
position: "relative"
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// Connect as a drop target
|
|
359
|
-
return this.props.connectDropTarget(R("div", { style }, this.renderItems(this.props.items)))
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const targetSpec = {
|
|
364
|
-
drop(props: any, monitor: any, component: any) {
|
|
365
|
-
if (monitor.getItemType() === "block-move") {
|
|
366
|
-
const rect = (ReactDOM.findDOMNode(component) as Element).getBoundingClientRect()
|
|
367
|
-
component.dropMoveLayout({
|
|
368
|
-
dragInfo: monitor.getItem(),
|
|
369
|
-
x:
|
|
370
|
-
monitor.getClientOffset().x -
|
|
371
|
-
(monitor.getInitialClientOffset().x - monitor.getInitialSourceClientOffset().x) -
|
|
372
|
-
rect.left,
|
|
373
|
-
y:
|
|
374
|
-
monitor.getClientOffset().y -
|
|
375
|
-
(monitor.getInitialClientOffset().y - monitor.getInitialSourceClientOffset().y) -
|
|
376
|
-
rect.top
|
|
377
|
-
})
|
|
378
|
-
}
|
|
379
|
-
if (monitor.getItemType() === "block-resize") {
|
|
380
|
-
component.dropResizeLayout({
|
|
381
|
-
dragInfo: monitor.getItem(),
|
|
382
|
-
width: monitor.getItem().bounds.width + monitor.getDifferenceFromInitialOffset().x,
|
|
383
|
-
height: monitor.getItem().bounds.height + monitor.getDifferenceFromInitialOffset().y
|
|
384
|
-
})
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
hover(props: any, monitor: any, component: any) {
|
|
388
|
-
if (monitor.getItemType() === "block-move") {
|
|
389
|
-
const rect = (ReactDOM.findDOMNode(component) as Element).getBoundingClientRect()
|
|
390
|
-
component.setMoveHover({
|
|
391
|
-
dragInfo: monitor.getItem(),
|
|
392
|
-
x:
|
|
393
|
-
monitor.getClientOffset().x -
|
|
394
|
-
(monitor.getInitialClientOffset().x - monitor.getInitialSourceClientOffset().x) -
|
|
395
|
-
rect.left,
|
|
396
|
-
y:
|
|
397
|
-
monitor.getClientOffset().y -
|
|
398
|
-
(monitor.getInitialClientOffset().y - monitor.getInitialSourceClientOffset().y) -
|
|
399
|
-
rect.top
|
|
400
|
-
})
|
|
401
|
-
}
|
|
402
|
-
if (monitor.getItemType() === "block-resize") {
|
|
403
|
-
component.setResizeHover({
|
|
404
|
-
dragInfo: monitor.getItem(),
|
|
405
|
-
width: monitor.getItem().bounds.width + monitor.getDifferenceFromInitialOffset().x,
|
|
406
|
-
height: monitor.getItem().bounds.height + monitor.getDifferenceFromInitialOffset().y
|
|
407
|
-
})
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
function targetCollect(connect: any, monitor: any) {
|
|
413
|
-
return {
|
|
414
|
-
connectDropTarget: connect.dropTarget(),
|
|
415
|
-
isOver: monitor.isOver(),
|
|
416
|
-
clientOffset: monitor.getClientOffset()
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
export default DropTarget(["block-move", "block-resize"], targetSpec, targetCollect)(Container)
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
const R = React.createElement
|
|
3
|
-
import _ from "lodash"
|
|
4
|
-
import ClickOutHandler from "react-onclickout"
|
|
5
|
-
import Color from "color"
|
|
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 R(
|
|
55
|
-
ClickOutHandler,
|
|
56
|
-
{ onClickOut: () => this.setState({ open: false }) },
|
|
57
|
-
R(
|
|
58
|
-
"div",
|
|
59
|
-
{
|
|
60
|
-
className: "mwater-visualization-text-palette-item",
|
|
61
|
-
onMouseDown: this.handleMouseDown,
|
|
62
|
-
style: { position: "relative" }
|
|
63
|
-
},
|
|
64
|
-
this.state.open
|
|
65
|
-
? R(
|
|
66
|
-
"div",
|
|
67
|
-
{ style: popupPosition },
|
|
68
|
-
R(ColorPaletteComponent, {
|
|
69
|
-
onSetColor: (color: any) => {
|
|
70
|
-
this.props.onSetColor(color)
|
|
71
|
-
return this.setState({ open: false })
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
)
|
|
75
|
-
: undefined,
|
|
76
|
-
|
|
77
|
-
R("i", { className: "fa fa-tint" })
|
|
78
|
-
)
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
interface ColorPaletteComponentProps {
|
|
84
|
-
onSetColor: any
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
class ColorPaletteComponent extends React.Component<ColorPaletteComponentProps> {
|
|
88
|
-
renderColor(color: any) {
|
|
89
|
-
return R(
|
|
90
|
-
"td",
|
|
91
|
-
null,
|
|
92
|
-
R("div", {
|
|
93
|
-
style: { width: 16, height: 15, backgroundColor: color, margin: 1 },
|
|
94
|
-
onMouseDown: (ev: any) => {
|
|
95
|
-
ev.preventDefault()
|
|
96
|
-
return this.props.onSetColor(color)
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
render() {
|
|
103
|
-
const baseColors = [
|
|
104
|
-
"#FF0000", // red
|
|
105
|
-
"#FFAA00", // orange
|
|
106
|
-
"#FFFF00", // yellow
|
|
107
|
-
"#00FF00", // green
|
|
108
|
-
"#00FFFF", // cyan
|
|
109
|
-
"#0000FF", // blue
|
|
110
|
-
"#9900FF", // purple
|
|
111
|
-
"#FF00FF" // magenta
|
|
112
|
-
]
|
|
113
|
-
return R(
|
|
114
|
-
"div",
|
|
115
|
-
{ style: { padding: 5 } },
|
|
116
|
-
R(
|
|
117
|
-
"table",
|
|
118
|
-
null,
|
|
119
|
-
R(
|
|
120
|
-
"tbody",
|
|
121
|
-
null,
|
|
122
|
-
// Grey shades
|
|
123
|
-
R(
|
|
124
|
-
"tr",
|
|
125
|
-
null,
|
|
126
|
-
_.map(_.range(0, 8), (i) => {
|
|
127
|
-
return this.renderColor(Color({ r: (i * 255) / 7, g: (i * 255) / 7, b: (i * 255) / 7 }).hex())
|
|
128
|
-
})
|
|
129
|
-
),
|
|
130
|
-
R("tr", { style: { height: 5 } }),
|
|
131
|
-
// Base colors
|
|
132
|
-
R(
|
|
133
|
-
"tr",
|
|
134
|
-
null,
|
|
135
|
-
_.map(baseColors, (c) => this.renderColor(c))
|
|
136
|
-
),
|
|
137
|
-
R("tr", { style: { height: 5 } }),
|
|
138
|
-
R(
|
|
139
|
-
"tr",
|
|
140
|
-
null,
|
|
141
|
-
_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.7).hex()))
|
|
142
|
-
),
|
|
143
|
-
R(
|
|
144
|
-
"tr",
|
|
145
|
-
null,
|
|
146
|
-
_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.5).hex()))
|
|
147
|
-
),
|
|
148
|
-
R(
|
|
149
|
-
"tr",
|
|
150
|
-
null,
|
|
151
|
-
_.map(baseColors, (c) => this.renderColor(Color(c).lighten(0.3).hex()))
|
|
152
|
-
),
|
|
153
|
-
R(
|
|
154
|
-
"tr",
|
|
155
|
-
null,
|
|
156
|
-
_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.3).hex()))
|
|
157
|
-
),
|
|
158
|
-
R(
|
|
159
|
-
"tr",
|
|
160
|
-
null,
|
|
161
|
-
_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.5).hex()))
|
|
162
|
-
),
|
|
163
|
-
R(
|
|
164
|
-
"tr",
|
|
165
|
-
null,
|
|
166
|
-
_.map(baseColors, (c) => this.renderColor(Color(c).darken(0.7).hex()))
|
|
167
|
-
)
|
|
168
|
-
)
|
|
169
|
-
)
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
const R = React.createElement
|
|
3
|
-
import _ from "lodash"
|
|
4
|
-
import ClickOutHandler from "react-onclickout"
|
|
5
|
-
|
|
6
|
-
export interface FontSizePaletteItemProps {
|
|
7
|
-
/** Called with "125%", etc. */
|
|
8
|
-
onSetSize: any
|
|
9
|
-
/** should the popup be under or over? */
|
|
10
|
-
position?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface FontSizePaletteItemState {
|
|
14
|
-
open: any
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Palette item that allows picking a size from dropdown
|
|
18
|
-
export default class FontSizePaletteItem extends React.Component<FontSizePaletteItemProps, FontSizePaletteItemState> {
|
|
19
|
-
static defaultProps = { position: "under" }
|
|
20
|
-
|
|
21
|
-
constructor(props: any) {
|
|
22
|
-
super(props)
|
|
23
|
-
this.state = {
|
|
24
|
-
open: false
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
handleMouseDown = (ev: any) => {
|
|
29
|
-
// Don't lose focus from editor
|
|
30
|
-
ev.preventDefault()
|
|
31
|
-
return this.setState({ open: !this.state.open })
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
renderSize(label: any, value: any) {
|
|
35
|
-
return R(
|
|
36
|
-
"div",
|
|
37
|
-
{
|
|
38
|
-
className: "font-size-palette-menu-item",
|
|
39
|
-
onMouseDown: (ev) => {
|
|
40
|
-
ev.preventDefault()
|
|
41
|
-
this.props.onSetSize(value)
|
|
42
|
-
return this.setState({ open: false })
|
|
43
|
-
},
|
|
44
|
-
key: value
|
|
45
|
-
},
|
|
46
|
-
label
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
renderSizes() {
|
|
51
|
-
return R(
|
|
52
|
-
"div",
|
|
53
|
-
null,
|
|
54
|
-
this.renderSize("Tiny", "50%"),
|
|
55
|
-
this.renderSize("Small", "66%"),
|
|
56
|
-
this.renderSize("Normal", "100%"),
|
|
57
|
-
this.renderSize("Large", "150%"),
|
|
58
|
-
this.renderSize("Huge", "200%")
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
render() {
|
|
63
|
-
const popupPosition: React.CSSProperties = {
|
|
64
|
-
position: "absolute",
|
|
65
|
-
left: 0,
|
|
66
|
-
zIndex: 1000,
|
|
67
|
-
backgroundColor: "white",
|
|
68
|
-
border: "solid 1px #AAA",
|
|
69
|
-
borderRadius: 3
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (this.props.position === "under") {
|
|
73
|
-
popupPosition["top"] = 26
|
|
74
|
-
} else {
|
|
75
|
-
popupPosition["bottom"] = 26
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return R(
|
|
79
|
-
ClickOutHandler,
|
|
80
|
-
{ onClickOut: () => this.setState({ open: false }) },
|
|
81
|
-
R(
|
|
82
|
-
"div",
|
|
83
|
-
{
|
|
84
|
-
className: "mwater-visualization-text-palette-item",
|
|
85
|
-
onMouseDown: this.handleMouseDown,
|
|
86
|
-
style: { position: "relative" }
|
|
87
|
-
},
|
|
88
|
-
R(
|
|
89
|
-
"style",
|
|
90
|
-
null,
|
|
91
|
-
`\
|
|
92
|
-
.font-size-palette-menu-item {
|
|
93
|
-
color: black;
|
|
94
|
-
background-color: white;
|
|
95
|
-
text-align: left;
|
|
96
|
-
padding: 5px 15px 5px 15px;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
}
|
|
99
|
-
.font-size-palette-menu-item:hover {
|
|
100
|
-
background-color: #DDD;
|
|
101
|
-
}\
|
|
102
|
-
`
|
|
103
|
-
),
|
|
104
|
-
this.state.open ? R("div", { style: popupPosition }, this.renderSizes()) : undefined,
|
|
105
|
-
|
|
106
|
-
R("i", { className: "fa fa-arrows-v" })
|
|
107
|
-
)
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
}
|