@mwater/visualization 5.4.1 → 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 +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
- package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChart.js +63 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
- package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
- package/lib/widgets/charts/table/TableChart.d.ts +1 -0
- package/lib/widgets/charts/table/TableChart.js +15 -0
- package/lib/widgets/text/TextComponent.d.ts +11 -4
- package/lib/widgets/text/TextComponent.js +11 -8
- package/lib/widgets/text/TextWidget.d.ts +6 -3
- package/lib/widgets/text/TextWidget.js +7 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
- package/lib/widgets/text/TextWidgetComponent.js +7 -1
- package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
- package/lib/widgets/text/TextWidgetDesign.js +1 -1
- package/package.json +7 -8
- package/src/ColorComponent.tsx +1 -2
- package/src/IdSelection.ts +62 -0
- package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
- package/src/MWaterLoaderComponent.ts +28 -26
- package/src/MWaterResponsesFilterComponent.ts +5 -2
- package/src/MWaterTableSelectComponent.tsx +5 -9
- package/src/autotranslate.ts +141 -0
- package/src/axes/AxisBuilder.ts +3 -3
- package/src/axes/AxisColorEditorComponent.tsx +5 -0
- package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
- package/src/axes/CategoryMapComponent.ts +4 -4
- package/src/axes/RangesComponent.ts +3 -2
- package/src/dashboards/DashboardComponent.tsx +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 +2 -2
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
- package/src/widgets/charts/pivot/PivotChart.ts +73 -0
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
- package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
- package/src/widgets/charts/table/TableChart.ts +17 -0
- package/src/widgets/text/TextComponent.tsx +22 -12
- package/src/widgets/text/TextWidget.ts +9 -2
- package/src/widgets/text/TextWidgetComponent.tsx +16 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -7
- package/test/IdSelectionTests.ts +54 -0
- package/test/LayeredChartCompilerTests.ts +0 -2
- package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
- package/test/wellknownTests.ts +144 -0
- package/src/datagrids/DatagridComponent.ts +0 -478
- package/src/datagrids/DatagridViewComponent.ts +0 -464
- package/src/datagrids/EditExprCellComponent.tsx +0 -305
- package/src/datagrids/README.md +0 -3
- package/src/maps/BufferLayerDesignerComponent.ts +0 -311
- package/src/widgets/TOCWidget.ts +0 -326
- package/test/LegoLayoutEngineTests.ts +0 -69
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.CellEditor = void 0;
|
|
30
|
+
exports.canEditType = canEditType;
|
|
31
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
+
const react_1 = __importStar(require("react"));
|
|
33
|
+
const expressions_1 = require("@mwater/expressions");
|
|
34
|
+
const react_select_1 = __importDefault(require("react-select"));
|
|
35
|
+
const react_datepicker_1 = __importDefault(require("react-datepicker"));
|
|
36
|
+
require("react-datepicker/dist/react-datepicker.css");
|
|
37
|
+
const moment_1 = __importDefault(require("moment"));
|
|
38
|
+
const expressions_ui_1 = require("@mwater/expressions-ui");
|
|
39
|
+
/** Determine if type can be edited */
|
|
40
|
+
function canEditType(type) {
|
|
41
|
+
return ["text", "number", "enum", "enumset", "boolean", "date", "datetime", "id", "id[]"].includes(type);
|
|
42
|
+
}
|
|
43
|
+
/** Cell editor for a cell of the grid */
|
|
44
|
+
const CellEditor = (props) => {
|
|
45
|
+
const editorOptions = props.editorOptions;
|
|
46
|
+
const [value, setValue] = (0, react_1.useState)(props.initialValue);
|
|
47
|
+
const [valid, setValid] = (0, react_1.useState)(true);
|
|
48
|
+
// Hook save function
|
|
49
|
+
editorOptions.setSaveEdit(() => {
|
|
50
|
+
if (!valid) {
|
|
51
|
+
return Promise.resolve(false);
|
|
52
|
+
}
|
|
53
|
+
if (value == props.initialValue) {
|
|
54
|
+
return Promise.resolve(true);
|
|
55
|
+
}
|
|
56
|
+
return props.updateCellValue(value);
|
|
57
|
+
});
|
|
58
|
+
if (editorOptions.saving) {
|
|
59
|
+
return (react_1.default.createElement("div", { style: { backgroundColor: "#EEE", width: editorOptions.width, height: editorOptions.height, padding: 10 } },
|
|
60
|
+
react_1.default.createElement("i", { className: "fa fa-spinner fa-spin" })));
|
|
61
|
+
}
|
|
62
|
+
if (props.type == "text") {
|
|
63
|
+
return (react_1.default.createElement("input", { type: "text", value: value || "", className: "form-control", onChange: (ev) => {
|
|
64
|
+
setValue(ev.target.value || null);
|
|
65
|
+
}, onKeyDown: (ev) => {
|
|
66
|
+
if (ev.keyCode == 13) {
|
|
67
|
+
editorOptions.onEndEdit();
|
|
68
|
+
}
|
|
69
|
+
}, style: { height: editorOptions.height }, ref: (node) => {
|
|
70
|
+
if (node) {
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
if (node) {
|
|
73
|
+
node.focus();
|
|
74
|
+
}
|
|
75
|
+
}, 0);
|
|
76
|
+
}
|
|
77
|
+
} }));
|
|
78
|
+
}
|
|
79
|
+
if (props.type == "number") {
|
|
80
|
+
return (react_1.default.createElement(NumberInput, { value: value, onChange: setValue, onValid: setValid, height: editorOptions.height, onEnter: editorOptions.onEndEdit }));
|
|
81
|
+
}
|
|
82
|
+
if (props.type == "enum") {
|
|
83
|
+
return react_1.default.createElement(EnumEditor, { value: value, onChange: setValue, enumValues: props.enumValues, locale: props.locale });
|
|
84
|
+
}
|
|
85
|
+
if (props.type == "enumset") {
|
|
86
|
+
return react_1.default.createElement(EnumsetEditor, { value: value, onChange: setValue, enumValues: props.enumValues, locale: props.locale });
|
|
87
|
+
}
|
|
88
|
+
if (props.type == "boolean") {
|
|
89
|
+
return react_1.default.createElement(BooleanEditor, { value: value, onChange: setValue });
|
|
90
|
+
}
|
|
91
|
+
if (props.type == "date") {
|
|
92
|
+
return react_1.default.createElement(DateEditor, { value: value, onChange: setValue, locale: props.locale });
|
|
93
|
+
}
|
|
94
|
+
if (props.type == "datetime") {
|
|
95
|
+
return react_1.default.createElement(DatetimeEditor, { value: value, onChange: setValue, locale: props.locale });
|
|
96
|
+
}
|
|
97
|
+
if (props.type == "id") {
|
|
98
|
+
return (react_1.default.createElement(expressions_ui_1.IdLiteralComponent, { schema: props.schema, dataSource: props.dataSource, idTable: props.idTable, value: value, onChange: setValue }));
|
|
99
|
+
}
|
|
100
|
+
if (props.type == "id[]") {
|
|
101
|
+
return (react_1.default.createElement(expressions_ui_1.IdLiteralComponent, { schema: props.schema, dataSource: props.dataSource, idTable: props.idTable, value: value, onChange: setValue, multi: true }));
|
|
102
|
+
}
|
|
103
|
+
// if (props.type == "geometry") {
|
|
104
|
+
// const str = value.type == "Point" ? `${value.coordinates[1].toFixed(6)} ${value.coordinates[0].toFixed(6)}` : value.type
|
|
105
|
+
// return <div className="custom-table-grid-cell-text">
|
|
106
|
+
// { str }
|
|
107
|
+
// </div>
|
|
108
|
+
// }
|
|
109
|
+
// TODO
|
|
110
|
+
// text[]
|
|
111
|
+
// image
|
|
112
|
+
// imagelist
|
|
113
|
+
// json
|
|
114
|
+
return react_1.default.createElement("div", null);
|
|
115
|
+
};
|
|
116
|
+
exports.CellEditor = CellEditor;
|
|
117
|
+
/** Number input that calls onChange when number is valid and updates valid status */
|
|
118
|
+
const NumberInput = (props) => {
|
|
119
|
+
const [str, setStr] = (0, react_1.useState)(props.value != null ? props.value + "" : "");
|
|
120
|
+
const handleChange = (ev) => {
|
|
121
|
+
const text = ev.target.value;
|
|
122
|
+
setStr(text);
|
|
123
|
+
if (!text) {
|
|
124
|
+
props.onChange(null);
|
|
125
|
+
props.onValid(true);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const num = parseFloat(text);
|
|
129
|
+
if (!isNaN(num)) {
|
|
130
|
+
props.onChange(num);
|
|
131
|
+
props.onValid(true);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
props.onValid(false);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return (react_1.default.createElement("input", { type: "number", value: str, className: "form-control", onChange: handleChange, style: { height: props.height }, onKeyDown: (ev) => {
|
|
139
|
+
if (ev.keyCode == 13) {
|
|
140
|
+
props.onEnter();
|
|
141
|
+
}
|
|
142
|
+
}, ref: (node) => {
|
|
143
|
+
if (node) {
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
if (node) {
|
|
146
|
+
node.focus();
|
|
147
|
+
}
|
|
148
|
+
}, 0);
|
|
149
|
+
}
|
|
150
|
+
} }));
|
|
151
|
+
};
|
|
152
|
+
/** Editor for an enum value */
|
|
153
|
+
const EnumEditor = (props) => {
|
|
154
|
+
const options = props.enumValues.map((v) => ({ label: expressions_1.ExprUtils.localizeString(v.name, props.locale), value: v.id }));
|
|
155
|
+
return (react_1.default.createElement(react_select_1.default, { options: options, isClearable: true, onChange: (opt) => props.onChange(opt ? opt.value : null), value: options.find((opt) => opt.value == props.value) || null, styles: {
|
|
156
|
+
// Keep menu above modal
|
|
157
|
+
menu: (style) => ({ ...style, zIndex: 2000 })
|
|
158
|
+
}, ref: (node) => {
|
|
159
|
+
if (node) {
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
if (node) {
|
|
162
|
+
node.focus();
|
|
163
|
+
}
|
|
164
|
+
}, 0);
|
|
165
|
+
}
|
|
166
|
+
} }));
|
|
167
|
+
};
|
|
168
|
+
/** Editor for an enumset value */
|
|
169
|
+
const EnumsetEditor = (props) => {
|
|
170
|
+
const options = props.enumValues.map((v) => ({ label: expressions_1.ExprUtils.localizeString(v.name, props.locale), value: v.id }));
|
|
171
|
+
const value = lodash_1.default.map(props.value || [], (v) => lodash_1.default.find(options, (o) => o.value == v)) || [];
|
|
172
|
+
return (react_1.default.createElement(react_select_1.default, { options: options, isClearable: true, isMulti: true, onChange: (opt) => {
|
|
173
|
+
props.onChange(opt && opt.length > 0 ? lodash_1.default.pluck(opt, "value") : null);
|
|
174
|
+
}, value: value, styles: {
|
|
175
|
+
// Keep menu above modal
|
|
176
|
+
menu: (style) => ({ ...style, zIndex: 2000 })
|
|
177
|
+
}, ref: (node) => {
|
|
178
|
+
if (node) {
|
|
179
|
+
setTimeout(() => {
|
|
180
|
+
if (node) {
|
|
181
|
+
node.focus();
|
|
182
|
+
}
|
|
183
|
+
}, 0);
|
|
184
|
+
}
|
|
185
|
+
} }));
|
|
186
|
+
};
|
|
187
|
+
/** Editor for a boolean value */
|
|
188
|
+
const BooleanEditor = (props) => {
|
|
189
|
+
const options = [
|
|
190
|
+
{ label: T `True`, value: true },
|
|
191
|
+
{ label: T `False`, value: false }
|
|
192
|
+
];
|
|
193
|
+
return (react_1.default.createElement(react_select_1.default, { options: options, isClearable: true, onChange: (opt) => props.onChange(opt ? opt.value : null), value: options.find((opt) => opt.value == props.value) || null, styles: {
|
|
194
|
+
// Keep menu above modal
|
|
195
|
+
menu: (style) => ({ ...style, zIndex: 2000 })
|
|
196
|
+
}, ref: (node) => {
|
|
197
|
+
if (node) {
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
if (node) {
|
|
200
|
+
node.focus();
|
|
201
|
+
}
|
|
202
|
+
}, 0);
|
|
203
|
+
}
|
|
204
|
+
} }));
|
|
205
|
+
};
|
|
206
|
+
/** Editor for a date */
|
|
207
|
+
const DateEditor = (props) => {
|
|
208
|
+
const momentDate = props.value ? (0, moment_1.default)(props.value, "YYYY-MM-DD") : null;
|
|
209
|
+
const handleChange = (0, react_1.useCallback)((value) => {
|
|
210
|
+
props.onChange(value ? value.format("YYYY-MM-DD") : null);
|
|
211
|
+
}, [props.onChange]);
|
|
212
|
+
return (react_1.default.createElement("div", { style: { padding: 2 } },
|
|
213
|
+
react_1.default.createElement(react_datepicker_1.default, { isClearable: true, selected: momentDate, onChange: handleChange, dateFormat: "YYYY-MM-DD", className: "form-control", locale: props.locale })));
|
|
214
|
+
};
|
|
215
|
+
/** Editor for a date */
|
|
216
|
+
const DatetimeEditor = (props) => {
|
|
217
|
+
const momentDate = props.value ? (0, moment_1.default)(props.value, moment_1.default.ISO_8601) : null;
|
|
218
|
+
const handleChange = (0, react_1.useCallback)((value) => {
|
|
219
|
+
props.onChange(value ? value.toISOString() : null);
|
|
220
|
+
}, [props.onChange]);
|
|
221
|
+
return (react_1.default.createElement("div", { style: { padding: 2 } },
|
|
222
|
+
react_1.default.createElement(react_datepicker_1.default, { fixedHeight: true, isClearable: true, selected: momentDate, onChange: handleChange, dateFormat: "YYYY-MM-DD HH:mm", className: "form-control", showTimeSelect: true, timeFormat: "HH:mm", locale: props.locale })));
|
|
223
|
+
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
-
import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelModalComponent";
|
|
3
2
|
import { DataSource, Expr, Schema } from "@mwater/expressions";
|
|
4
|
-
import
|
|
5
|
-
import FindReplaceModalComponent from "./FindReplaceModalComponent";
|
|
3
|
+
import { RowUpdate } from "./DatagridViewComponent";
|
|
6
4
|
import DatagridDataSource from "./DatagridDataSource";
|
|
7
5
|
import { DatagridDesign, JsonQLFilter } from "..";
|
|
6
|
+
export interface DatagridComponentRef {
|
|
7
|
+
getQuickfilterValues: () => any[];
|
|
8
|
+
getQuickfilterFilters: () => JsonQLFilter[];
|
|
9
|
+
reload: () => void;
|
|
10
|
+
}
|
|
8
11
|
export interface DatagridComponentProps {
|
|
9
|
-
/**
|
|
12
|
+
/** Schema to use */
|
|
10
13
|
schema: Schema;
|
|
11
|
-
/**
|
|
14
|
+
/** Data source to use */
|
|
12
15
|
dataSource: DataSource;
|
|
13
|
-
/**
|
|
16
|
+
/** Datagrid data source to use */
|
|
14
17
|
datagridDataSource: DatagridDataSource;
|
|
18
|
+
/** Design of datagrid to use */
|
|
15
19
|
design: DatagridDesign;
|
|
16
20
|
/** Called when design changes */
|
|
17
21
|
onDesignChange?: (design: DatagridDesign) => void;
|
|
@@ -27,88 +31,15 @@ export interface DatagridComponentProps {
|
|
|
27
31
|
onRowClick?: (tableId: string, rowId: any) => void;
|
|
28
32
|
/** Called when row is double-clicked with (tableId, rowId) */
|
|
29
33
|
onRowDoubleClick?: (tableId: string, rowId: any) => void;
|
|
34
|
+
/** Called when a set of rows is deleted with (tableId, rowIds). Can be cancelled via the abort signal */
|
|
35
|
+
onRowsDelete?: (tableId: string, rowIds: any[], signal: AbortSignal) => Promise<void>;
|
|
30
36
|
/** Locked quickfilter values. See README in quickfilters */
|
|
31
37
|
quickfilterLocks?: any[];
|
|
32
38
|
filters?: JsonQLFilter[];
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
quickfiltersHeight: number | null;
|
|
41
|
-
quickfiltersValues: null | any[];
|
|
42
|
-
refreshKey: number;
|
|
43
|
-
/** Number of rows */
|
|
44
|
-
numRows?: number;
|
|
45
|
-
}
|
|
46
|
-
export default class DatagridComponent extends React.Component<DatagridComponentProps, DatagridComponentState> {
|
|
47
|
-
datagridView?: DatagridViewComponent | null;
|
|
48
|
-
quickfilters?: HTMLElement | null;
|
|
49
|
-
findReplaceModal: FindReplaceModalComponent | null;
|
|
50
|
-
constructor(props: DatagridComponentProps);
|
|
51
|
-
reload(): void;
|
|
52
|
-
componentDidMount(): void;
|
|
53
|
-
componentDidUpdate(prevProps: DatagridComponentProps, prevState: DatagridComponentState): void;
|
|
54
|
-
loadRowCount(): void;
|
|
55
|
-
handleRefreshData: () => void;
|
|
56
|
-
updateHeight(): void;
|
|
57
|
-
getQuickfilterValues: () => any[];
|
|
58
|
-
getQuickfilterFilters: () => JsonQLFilter[];
|
|
59
|
-
handleCellEditingToggle: () => void;
|
|
60
|
-
handleEdit: () => void;
|
|
61
|
-
getCompiledFilters(): JsonQLFilter[];
|
|
62
|
-
renderCellEdit(): React.DetailedReactHTMLElement<{
|
|
63
|
-
key: string;
|
|
64
|
-
className: string;
|
|
65
|
-
onClick: () => void;
|
|
66
|
-
}, HTMLElement> | null;
|
|
67
|
-
renderEditButton(): React.DetailedReactHTMLElement<{
|
|
68
|
-
type: string;
|
|
69
|
-
className: string;
|
|
70
|
-
onClick: () => void;
|
|
71
|
-
}, HTMLElement> | null;
|
|
72
|
-
renderFindReplace(): React.DetailedReactHTMLElement<{
|
|
73
|
-
key: string;
|
|
74
|
-
className: string;
|
|
75
|
-
onClick: () => void;
|
|
76
|
-
}, HTMLElement> | null;
|
|
77
|
-
renderTitleBar(): React.DetailedReactHTMLElement<{
|
|
78
|
-
style: {
|
|
79
|
-
position: "absolute";
|
|
80
|
-
top: number;
|
|
81
|
-
left: number;
|
|
82
|
-
right: number;
|
|
83
|
-
height: number;
|
|
84
|
-
padding: number;
|
|
85
|
-
};
|
|
86
|
-
}, HTMLElement>;
|
|
87
|
-
renderQuickfilter(): React.DetailedReactHTMLElement<{
|
|
88
|
-
style: {
|
|
89
|
-
position: "absolute";
|
|
90
|
-
top: number;
|
|
91
|
-
left: number;
|
|
92
|
-
right: number;
|
|
93
|
-
};
|
|
94
|
-
ref: (c: HTMLElement | null) => void;
|
|
95
|
-
}, HTMLElement>;
|
|
96
|
-
renderEditor(): React.CElement<DatagridEditorComponentProps, DatagridEditorComponent> | undefined;
|
|
97
|
-
renderFindReplaceModal(filters: any): React.CElement<any, FindReplaceModalComponent>;
|
|
98
|
-
render(): React.FunctionComponentElement<React.ProviderProps<string>>;
|
|
99
|
-
}
|
|
100
|
-
interface DatagridEditorComponentProps {
|
|
101
|
-
schema: Schema;
|
|
102
|
-
dataSource: DataSource;
|
|
103
|
-
design: DatagridDesign;
|
|
104
|
-
onDesignChange: (design: DatagridDesign) => void;
|
|
105
|
-
onCancel: () => void;
|
|
106
|
-
}
|
|
107
|
-
/** Popup editor */
|
|
108
|
-
declare class DatagridEditorComponent extends React.Component<DatagridEditorComponentProps, {
|
|
109
|
-
design: DatagridDesign;
|
|
110
|
-
}> {
|
|
111
|
-
constructor(props: DatagridEditorComponentProps);
|
|
112
|
-
render(): React.CElement<import("@mwater/react-library/lib/ActionCancelModalComponent").ActionCancelModalComponentProps, ActionCancelModalComponent>;
|
|
113
|
-
}
|
|
114
|
-
export {};
|
|
40
|
+
/**
|
|
41
|
+
* Datagrid with decorations
|
|
42
|
+
* Design should be cleaned already before being passed in (see DatagridUtils)
|
|
43
|
+
*/
|
|
44
|
+
declare const _default: React.ForwardRefExoticComponent<DatagridComponentProps & React.RefAttributes<DatagridComponentRef>>;
|
|
45
|
+
export default _default;
|