drf-react-by-schema 0.28.7 → 0.28.9
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/dist/@types/index.d.ts +410 -0
- package/dist/@types/index.d.ts.map +1 -0
- package/dist/@types/index.js +9 -0
- package/dist/@types/string-mask.d.ts +10 -0
- package/dist/@types/string-mask.d.ts.map +1 -0
- package/dist/@types/string-mask.js +1 -0
- package/dist/api.d.ts +81 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +1118 -0
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts +8 -0
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.js +86 -0
- package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts +12 -0
- package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.js +71 -0
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts +9 -0
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.js +21 -0
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts +26 -0
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +146 -0
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts +73 -0
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.js +421 -0
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts +18 -0
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.js +105 -0
- package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts +11 -0
- package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/FileInputCell.js +155 -0
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +12 -0
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.js +36 -0
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts +10 -0
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.js +85 -0
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts +11 -0
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.js +87 -0
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts +18 -0
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.js +24 -0
- package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts +8 -0
- package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridDateInput.js +166 -0
- package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts +6 -0
- package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.js +154 -0
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +10 -0
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.js +78 -0
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts +8 -0
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.js +30 -0
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +7 -0
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +74 -0
- package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +21 -0
- package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/InputInterval.js +131 -0
- package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts +9 -0
- package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/MobileSearchBar.js +70 -0
- package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts +7 -0
- package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.js +41 -0
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +24 -0
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +259 -0
- package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts +5 -0
- package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/geoConstants.js +6 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts +33 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.js +161 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts +14 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.js +69 -0
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts +9 -0
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.js +73 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts +30 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.js +199 -0
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts +33 -0
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.js +270 -0
- package/dist/components/DataGridBySchemaEditable/utils.d.ts +40 -0
- package/dist/components/DataGridBySchemaEditable/utils.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/utils.js +181 -0
- package/dist/components/DataGridBySchemaEditable.d.ts +64 -0
- package/dist/components/DataGridBySchemaEditable.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable.js +172 -0
- package/dist/components/DataTotals.d.ts +12 -0
- package/dist/components/DataTotals.d.ts.map +1 -0
- package/dist/components/DataTotals.js +32 -0
- package/dist/components/DataTotalsServer.d.ts +10 -0
- package/dist/components/DataTotalsServer.d.ts.map +1 -0
- package/dist/components/DataTotalsServer.js +18 -0
- package/dist/components/DialogActions.d.ts +11 -0
- package/dist/components/DialogActions.d.ts.map +1 -0
- package/dist/components/DialogActions.js +20 -0
- package/dist/components/FileTypeIcon.d.ts +18 -0
- package/dist/components/FileTypeIcon.d.ts.map +1 -0
- package/dist/components/FileTypeIcon.js +48 -0
- package/dist/components/GenericModelList.d.ts +53 -0
- package/dist/components/GenericModelList.d.ts.map +1 -0
- package/dist/components/GenericModelList.js +194 -0
- package/dist/components/GenericRelatedModelList.d.ts +55 -0
- package/dist/components/GenericRelatedModelList.d.ts.map +1 -0
- package/dist/components/GenericRelatedModelList.js +181 -0
- package/dist/components/GenericRelatedModelListTable.d.ts +56 -0
- package/dist/components/GenericRelatedModelListTable.d.ts.map +1 -0
- package/dist/components/GenericRelatedModelListTable.js +31 -0
- package/dist/components/Image.d.ts +10 -0
- package/dist/components/Image.d.ts.map +1 -0
- package/dist/components/Image.js +111 -0
- package/dist/components/details/DetailBySchema.d.ts +4 -0
- package/dist/components/details/DetailBySchema.d.ts.map +1 -0
- package/dist/components/details/DetailBySchema.js +175 -0
- package/dist/components/details/DetailFieldBySchema.d.ts +4 -0
- package/dist/components/details/DetailFieldBySchema.d.ts.map +1 -0
- package/dist/components/details/DetailFieldBySchema.js +88 -0
- package/dist/components/forms/ChangePasswordForm.d.ts +7 -0
- package/dist/components/forms/ChangePasswordForm.d.ts.map +1 -0
- package/dist/components/forms/ChangePasswordForm.js +93 -0
- package/dist/components/forms/DialogFormBySchema.d.ts +22 -0
- package/dist/components/forms/DialogFormBySchema.d.ts.map +1 -0
- package/dist/components/forms/DialogFormBySchema.js +97 -0
- package/dist/components/forms/FieldBySchema.d.ts +4 -0
- package/dist/components/forms/FieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/FieldBySchema.js +80 -0
- package/dist/components/forms/ForgotPasswordForm.d.ts +11 -0
- package/dist/components/forms/ForgotPasswordForm.d.ts.map +1 -0
- package/dist/components/forms/ForgotPasswordForm.js +114 -0
- package/dist/components/forms/Form.d.ts +61 -0
- package/dist/components/forms/Form.d.ts.map +1 -0
- package/dist/components/forms/Form.js +264 -0
- package/dist/components/forms/FormActions.d.ts +20 -0
- package/dist/components/forms/FormActions.d.ts.map +1 -0
- package/dist/components/forms/FormActions.js +55 -0
- package/dist/components/forms/FormBySchema.d.ts +21 -0
- package/dist/components/forms/FormBySchema.d.ts.map +1 -0
- package/dist/components/forms/FormBySchema.js +280 -0
- package/dist/components/forms/FormWatcher.d.ts +10 -0
- package/dist/components/forms/FormWatcher.d.ts.map +1 -0
- package/dist/components/forms/FormWatcher.js +25 -0
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts +13 -0
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.js +133 -0
- package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts +4 -0
- package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/BooleanFieldBySchema.js +39 -0
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts +5 -0
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.js +54 -0
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts +5 -0
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.js +47 -0
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts +14 -0
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.js +272 -0
- package/dist/components/forms/inputs/FileFieldBySchema.d.ts +4 -0
- package/dist/components/forms/inputs/FileFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/FileFieldBySchema.js +144 -0
- package/dist/components/forms/inputs/FloatFieldBySchema.d.ts +4 -0
- package/dist/components/forms/inputs/FloatFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/FloatFieldBySchema.js +64 -0
- package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts +8 -0
- package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/GeometryFieldBySchema.js +61 -0
- package/dist/components/forms/inputs/MapGeometryPicker.d.ts +19 -0
- package/dist/components/forms/inputs/MapGeometryPicker.d.ts.map +1 -0
- package/dist/components/forms/inputs/MapGeometryPicker.js +344 -0
- package/dist/components/forms/inputs/PatternFieldBySchema.d.ts +4 -0
- package/dist/components/forms/inputs/PatternFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/PatternFieldBySchema.js +56 -0
- package/dist/components/forms/inputs/TextFieldBySchema.d.ts +4 -0
- package/dist/components/forms/inputs/TextFieldBySchema.d.ts.map +1 -0
- package/dist/components/forms/inputs/TextFieldBySchema.js +56 -0
- package/dist/components/forms/inputs/leafletMarker.d.ts +12 -0
- package/dist/components/forms/inputs/leafletMarker.d.ts.map +1 -0
- package/dist/components/forms/inputs/leafletMarker.js +52 -0
- package/dist/context/APIWrapper.d.ts +18 -0
- package/dist/context/APIWrapper.d.ts.map +1 -0
- package/dist/context/APIWrapper.js +593 -0
- package/dist/context/APIWrapperContext.d.ts +132 -0
- package/dist/context/APIWrapperContext.d.ts.map +1 -0
- package/dist/context/APIWrapperContext.js +63 -0
- package/dist/context/DRFReactBySchemaContext.d.ts +31 -0
- package/dist/context/DRFReactBySchemaContext.d.ts.map +1 -0
- package/dist/context/DRFReactBySchemaContext.js +20 -0
- package/dist/context/DRFReactBySchemaProvider.d.ts +5 -0
- package/dist/context/DRFReactBySchemaProvider.d.ts.map +1 -0
- package/dist/context/DRFReactBySchemaProvider.js +105 -0
- package/dist/context/Overlays.d.ts +5 -0
- package/dist/context/Overlays.d.ts.map +1 -0
- package/dist/context/Overlays.js +114 -0
- package/dist/context/PrivateContext.d.ts +10 -0
- package/dist/context/PrivateContext.d.ts.map +1 -0
- package/dist/context/PrivateContext.js +16 -0
- package/dist/hooks/useDeepMemo.d.ts +2 -0
- package/dist/hooks/useDeepMemo.d.ts.map +1 -0
- package/dist/hooks/useDeepMemo.js +13 -0
- package/dist/hooks/useWhyDidYouUpdate.d.ts +4 -0
- package/dist/hooks/useWhyDidYouUpdate.d.ts.map +1 -0
- package/dist/hooks/useWhyDidYouUpdate.js +26 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/styles/grid.d.ts +3 -0
- package/dist/styles/grid.d.ts.map +1 -0
- package/dist/styles/grid.js +38 -0
- package/dist/styles/index.d.ts +3 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/index.js +38 -0
- package/dist/styles/layout.d.ts +23 -0
- package/dist/styles/layout.d.ts.map +1 -0
- package/dist/styles/layout.js +71 -0
- package/dist/styles/texts.d.ts +66 -0
- package/dist/styles/texts.d.ts.map +1 -0
- package/dist/styles/texts.js +73 -0
- package/dist/styles/theme.d.ts +29 -0
- package/dist/styles/theme.d.ts.map +1 -0
- package/dist/styles/theme.js +226 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/utils.d.ts +107 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +957 -0
- package/package.json +12 -4
|
@@ -0,0 +1,344 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = MapGeometryPicker;
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
42
|
+
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
43
|
+
const FormHelperText_1 = __importDefault(require("@mui/material/FormHelperText"));
|
|
44
|
+
const styles_1 = require("@mui/material/styles");
|
|
45
|
+
const react_leaflet_1 = require("react-leaflet");
|
|
46
|
+
const leaflet_1 = __importDefault(require("leaflet"));
|
|
47
|
+
require("leaflet/dist/leaflet.css");
|
|
48
|
+
// leaflet-draw does not export; augments global L with Control.Draw.
|
|
49
|
+
require("leaflet-draw");
|
|
50
|
+
require("leaflet-draw/dist/leaflet.draw.css");
|
|
51
|
+
const leafletMarker_1 = require("./leafletMarker");
|
|
52
|
+
const texts_1 = require("../../../styles/texts");
|
|
53
|
+
const utils_1 = require("../../../utils");
|
|
54
|
+
// Markers need a servable icon; leaflet's stock icons 404 inside an SPA.
|
|
55
|
+
(0, leafletMarker_1.applyDefaultLeafletIcon)();
|
|
56
|
+
// Build the drf-react-by-schema geometry out of leaflet-draw features. Leaflet
|
|
57
|
+
// already parses/produces GeoJSON (L.geoJSON, FeatureGroup.toGeoJSON), so here
|
|
58
|
+
// we only reshape the resulting features into the right geometry type.
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
function buildOutput(geometry, features) {
|
|
61
|
+
const geoms = features.map((f) => f === null || f === void 0 ? void 0 : f.geometry).filter((g) => g);
|
|
62
|
+
if (geometry === 'point') {
|
|
63
|
+
const point = geoms.find((g) => g.type === 'Point');
|
|
64
|
+
return point ? { type: 'Point', coordinates: point.coordinates } : null;
|
|
65
|
+
}
|
|
66
|
+
if (geometry === 'polygon') {
|
|
67
|
+
const polygon = geoms.find((g) => g.type === 'Polygon');
|
|
68
|
+
return polygon ? { type: 'Polygon', coordinates: polygon.coordinates } : null;
|
|
69
|
+
}
|
|
70
|
+
if (geometry === 'multipoint') {
|
|
71
|
+
const coords = geoms.filter((g) => g.type === 'Point').map((g) => g.coordinates);
|
|
72
|
+
return coords.length ? { type: 'MultiPoint', coordinates: coords } : null;
|
|
73
|
+
}
|
|
74
|
+
if (geometry === 'multipolygon') {
|
|
75
|
+
const coords = geoms.filter((g) => g.type === 'Polygon').map((g) => g.coordinates);
|
|
76
|
+
return coords.length ? { type: 'MultiPolygon', coordinates: coords } : null;
|
|
77
|
+
}
|
|
78
|
+
// geometrycollection: points and polygons drawn together
|
|
79
|
+
const list = geoms.filter((g) => g.type === 'Point' || g.type === 'Polygon');
|
|
80
|
+
return list.length ? { type: 'GeometryCollection', geometries: list } : null;
|
|
81
|
+
}
|
|
82
|
+
// Counts the markers/polygons currently drawn so single-instance fields can
|
|
83
|
+
// hide their "add" tool once one shape already exists.
|
|
84
|
+
function layerCounts(featureGroup) {
|
|
85
|
+
let markers = 0;
|
|
86
|
+
let polygons = 0;
|
|
87
|
+
featureGroup.eachLayer((layer) => {
|
|
88
|
+
if (layer instanceof leaflet_1.default.Marker)
|
|
89
|
+
markers += 1;
|
|
90
|
+
else if (layer instanceof leaflet_1.default.Polygon)
|
|
91
|
+
polygons += 1;
|
|
92
|
+
});
|
|
93
|
+
return { markers, polygons };
|
|
94
|
+
}
|
|
95
|
+
// The geometry picker only enables marker + polygon draw plus edit/remove, so only
|
|
96
|
+
// those leaflet-draw strings are themeable here. Build the subset shown by the UI.
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
function leafletDrawLocalization(gt) {
|
|
99
|
+
return {
|
|
100
|
+
draw: {
|
|
101
|
+
toolbar: {
|
|
102
|
+
actions: { title: gt.cancelDrawing, text: gt.cancelDrawing },
|
|
103
|
+
finish: { title: gt.finishDrawing, text: gt.finishDrawing },
|
|
104
|
+
undo: { title: gt.undoPoint, text: gt.undoPoint },
|
|
105
|
+
buttons: { marker: gt.drawAMarker, polygon: gt.drawAPolygon },
|
|
106
|
+
},
|
|
107
|
+
handlers: {
|
|
108
|
+
marker: { tooltip: { start: gt.clickToPlaceMarker } },
|
|
109
|
+
polygon: {
|
|
110
|
+
tooltip: {
|
|
111
|
+
start: gt.clickToStartShape,
|
|
112
|
+
cont: gt.clickToContinueShape,
|
|
113
|
+
end: gt.clickToCloseShape,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
edit: {
|
|
119
|
+
toolbar: {
|
|
120
|
+
actions: {
|
|
121
|
+
save: { title: gt.saveChanges, text: gt.saveChanges },
|
|
122
|
+
cancel: { title: gt.cancelEdit, text: gt.cancelEdit },
|
|
123
|
+
clearAll: { title: gt.clearAll, text: gt.clearAll },
|
|
124
|
+
},
|
|
125
|
+
buttons: {
|
|
126
|
+
edit: gt.editLayers,
|
|
127
|
+
editDisabled: gt.editLayersDisabled,
|
|
128
|
+
remove: gt.deleteLayers,
|
|
129
|
+
removeDisabled: gt.deleteLayersDisabled,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
handlers: {
|
|
133
|
+
edit: { tooltip: { text: gt.dragToEditFeatures, subtext: gt.clickCancelToUndo } },
|
|
134
|
+
remove: { tooltip: { text: gt.clickFeatureToRemove } },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// Deep-merge the themed subset over leaflet-draw's global (English) defaults so any
|
|
140
|
+
// string we don't theme keeps a sane value. leaflet-draw reads L.drawLocal at runtime.
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
function deepMerge(target, source) {
|
|
143
|
+
for (const key in source) {
|
|
144
|
+
const sv = source[key];
|
|
145
|
+
const tv = target === null || target === void 0 ? void 0 : target[key];
|
|
146
|
+
if (sv && typeof sv === 'object' && !Array.isArray(sv) && tv && typeof tv === 'object' && !Array.isArray(tv)) {
|
|
147
|
+
target[key] = deepMerge(tv, sv);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
target[key] = sv;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return target;
|
|
154
|
+
}
|
|
155
|
+
function applyLeafletDrawLocalization(gt) {
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
deepMerge(leaflet_1.default.drawLocal, leafletDrawLocalization(gt));
|
|
158
|
+
}
|
|
159
|
+
// Which draw tools each geometry allows.
|
|
160
|
+
const markerEnabledFor = (g) => g === 'point' || g === 'multipoint' || g === 'geometrycollection';
|
|
161
|
+
const polygonEnabledFor = (g) => g === 'polygon' || g === 'multipolygon' || g === 'geometrycollection';
|
|
162
|
+
// Attaches leaflet-draw to the react-leaflet map and emits GeoJSON on changes.
|
|
163
|
+
// Per-geometry behavior:
|
|
164
|
+
// point / polygon -> single instance (add hidden once one exists; move/remove)
|
|
165
|
+
// multipoint -> many draggable/removable points
|
|
166
|
+
// multipolygon -> many editable/removable polygons
|
|
167
|
+
// geometrycollection -> many points AND many polygons
|
|
168
|
+
function DrawEditor({ geometry, value, onChange, }) {
|
|
169
|
+
const map = (0, react_leaflet_1.useMap)();
|
|
170
|
+
const texts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)());
|
|
171
|
+
const featureGroupRef = (0, react_1.useRef)(null);
|
|
172
|
+
const drawControlRef = (0, react_1.useRef)(null);
|
|
173
|
+
const lastEmittedRef = (0, react_1.useRef)('__init__');
|
|
174
|
+
const onChangeRef = (0, react_1.useRef)(onChange);
|
|
175
|
+
onChangeRef.current = onChange;
|
|
176
|
+
const geometryRef = (0, react_1.useRef)(geometry);
|
|
177
|
+
geometryRef.current = geometry;
|
|
178
|
+
// Hides the add tool for single-instance fields once a shape exists; existing
|
|
179
|
+
// shapes stay draggable (points) / editable (polygons) and removable.
|
|
180
|
+
const updateCap = () => {
|
|
181
|
+
const featureGroup = featureGroupRef.current;
|
|
182
|
+
const drawControl = drawControlRef.current;
|
|
183
|
+
if (!featureGroup || !drawControl)
|
|
184
|
+
return;
|
|
185
|
+
const g = geometryRef.current;
|
|
186
|
+
const { markers, polygons } = layerCounts(featureGroup);
|
|
187
|
+
const single = isSingle(g);
|
|
188
|
+
const capMarker = single && g === 'point' && markers > 0;
|
|
189
|
+
const capPolygon = single && g === 'polygon' && polygons > 0;
|
|
190
|
+
// setDrawingOptions() only stores options — it does not re-render the
|
|
191
|
+
// toolbar, so a capped single-instance field would keep an active "add"
|
|
192
|
+
// button. Rebuild the control so the button is actually hidden/disabled.
|
|
193
|
+
map.removeControl(drawControl);
|
|
194
|
+
const rebuilt = new leaflet_1.default.Control.Draw({
|
|
195
|
+
draw: {
|
|
196
|
+
marker: markerEnabledFor(g) && !capMarker ? {} : false,
|
|
197
|
+
polygon: polygonEnabledFor(g) && !capPolygon ? {} : false,
|
|
198
|
+
polyline: false,
|
|
199
|
+
rectangle: false,
|
|
200
|
+
circle: false,
|
|
201
|
+
circlemarker: false,
|
|
202
|
+
},
|
|
203
|
+
edit: { featureGroup },
|
|
204
|
+
});
|
|
205
|
+
drawControlRef.current = rebuilt;
|
|
206
|
+
map.addControl(rebuilt);
|
|
207
|
+
};
|
|
208
|
+
const emit = () => {
|
|
209
|
+
var _a;
|
|
210
|
+
const featureGroup = featureGroupRef.current;
|
|
211
|
+
if (!featureGroup)
|
|
212
|
+
return;
|
|
213
|
+
const g = geometryRef.current;
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
215
|
+
const output = buildOutput(g, ((_a = featureGroup.toGeoJSON()) === null || _a === void 0 ? void 0 : _a.features) || []);
|
|
216
|
+
const text = output ? JSON.stringify(output) : '';
|
|
217
|
+
lastEmittedRef.current = text;
|
|
218
|
+
onChangeRef.current(text || null);
|
|
219
|
+
updateCap();
|
|
220
|
+
};
|
|
221
|
+
// Markers are draggable so an existing point can be moved; drag-end updates value.
|
|
222
|
+
const applyBehaviors = (layer) => {
|
|
223
|
+
if (layer instanceof leaflet_1.default.Marker) {
|
|
224
|
+
layer.options.draggable = true;
|
|
225
|
+
layer.on('dragend', emit);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
const addGeoJSON = (data) => {
|
|
230
|
+
const featureGroup = featureGroupRef.current;
|
|
231
|
+
if (!featureGroup || !data)
|
|
232
|
+
return;
|
|
233
|
+
leaflet_1.default.geoJSON(data).eachLayer((layer) => {
|
|
234
|
+
featureGroup.addLayer(layer);
|
|
235
|
+
applyBehaviors(layer);
|
|
236
|
+
});
|
|
237
|
+
const bounds = featureGroup.getBounds();
|
|
238
|
+
if (bounds.isValid())
|
|
239
|
+
map.fitBounds(bounds, { padding: [40, 40] });
|
|
240
|
+
};
|
|
241
|
+
(0, react_1.useEffect)(() => {
|
|
242
|
+
applyLeafletDrawLocalization(texts.geometry);
|
|
243
|
+
const featureGroup = new leaflet_1.default.FeatureGroup().addTo(map);
|
|
244
|
+
featureGroupRef.current = featureGroup;
|
|
245
|
+
const g = geometryRef.current;
|
|
246
|
+
const drawControl = new leaflet_1.default.Control.Draw({
|
|
247
|
+
draw: {
|
|
248
|
+
marker: markerEnabledFor(g) ? {} : false,
|
|
249
|
+
polygon: polygonEnabledFor(g) ? {} : false,
|
|
250
|
+
polyline: false,
|
|
251
|
+
rectangle: false,
|
|
252
|
+
circle: false,
|
|
253
|
+
circlemarker: false,
|
|
254
|
+
},
|
|
255
|
+
edit: { featureGroup },
|
|
256
|
+
});
|
|
257
|
+
drawControlRef.current = drawControl;
|
|
258
|
+
map.addControl(drawControl);
|
|
259
|
+
map.on(leaflet_1.default.Draw.Event.CREATED,
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
|
+
(e) => {
|
|
262
|
+
// Forbid a second single-instance shape (point/polygon) even if the
|
|
263
|
+
// toolbar was manually re-enabled.
|
|
264
|
+
const g = geometryRef.current;
|
|
265
|
+
if (isSingle(g)) {
|
|
266
|
+
const isMarker = e.layer instanceof leaflet_1.default.Marker;
|
|
267
|
+
const isPolygon = e.layer instanceof leaflet_1.default.Polygon;
|
|
268
|
+
const { markers, polygons } = layerCounts(featureGroup);
|
|
269
|
+
if ((g === 'point' && isMarker && markers > 0) ||
|
|
270
|
+
(g === 'polygon' && isPolygon && polygons > 0)) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
featureGroup.addLayer(e.layer);
|
|
275
|
+
applyBehaviors(e.layer);
|
|
276
|
+
emit();
|
|
277
|
+
});
|
|
278
|
+
map.on(leaflet_1.default.Draw.Event.EDITED, emit);
|
|
279
|
+
map.on(leaflet_1.default.Draw.Event.DELETED, emit);
|
|
280
|
+
const initial = (0, utils_1.parseGeoJSON)(geometry, value);
|
|
281
|
+
if (initial)
|
|
282
|
+
addGeoJSON(initial);
|
|
283
|
+
updateCap();
|
|
284
|
+
return () => {
|
|
285
|
+
if (drawControlRef.current)
|
|
286
|
+
map.removeControl(drawControlRef.current);
|
|
287
|
+
map.removeLayer(featureGroup);
|
|
288
|
+
featureGroupRef.current = null;
|
|
289
|
+
drawControlRef.current = null;
|
|
290
|
+
};
|
|
291
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
292
|
+
}, []);
|
|
293
|
+
// Sync externally-driven value (reset after save/edit elsewhere). Avoids the
|
|
294
|
+
// feedback loop when this component itself emitted the change. Malformed text
|
|
295
|
+
// keeps the last valid geometry on the map (an error is shown in the field);
|
|
296
|
+
// only a legitimate empty value clears the features.
|
|
297
|
+
(0, react_1.useEffect)(() => {
|
|
298
|
+
const normalized = value || '';
|
|
299
|
+
if (normalized === lastEmittedRef.current)
|
|
300
|
+
return;
|
|
301
|
+
lastEmittedRef.current = normalized;
|
|
302
|
+
const featureGroup = featureGroupRef.current;
|
|
303
|
+
if (!featureGroup)
|
|
304
|
+
return;
|
|
305
|
+
const geo = (0, utils_1.parseGeoJSON)(geometry, value);
|
|
306
|
+
if (geo) {
|
|
307
|
+
featureGroup.clearLayers();
|
|
308
|
+
addGeoJSON(geo);
|
|
309
|
+
}
|
|
310
|
+
else if (normalized.trim() === '') {
|
|
311
|
+
featureGroup.clearLayers();
|
|
312
|
+
updateCap();
|
|
313
|
+
}
|
|
314
|
+
// malformed non-empty text: keep current features, error is shown in the field
|
|
315
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
316
|
+
}, [value, geometry, map]);
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
function MapGeometryPicker({ geometry, value, label, onChange, error, helperText, sx, height = 340, }) {
|
|
320
|
+
const texts = (0, texts_1.getThemeTexts)((0, styles_1.useTheme)());
|
|
321
|
+
const geometryTexts = texts.geometry;
|
|
322
|
+
const valueText = value || '';
|
|
323
|
+
// Malformed detection: non-empty text that isn't GeoJSON (or of the wrong
|
|
324
|
+
// geometry type). Invalid input is flagged as an error instead of silently
|
|
325
|
+
// wiping the features from the map.
|
|
326
|
+
const malformed = valueText.trim() !== '' && !(0, utils_1.parseGeoJSON)(geometry, valueText);
|
|
327
|
+
return (react_1.default.createElement(Box_1.default, { sx: Object.assign({ mt: 1, mb: 1, width: '100%' }, sx) },
|
|
328
|
+
react_1.default.createElement(Box_1.default, { "data-testid": `map-${geometry}`, sx: {
|
|
329
|
+
height,
|
|
330
|
+
width: '100%',
|
|
331
|
+
overflow: 'hidden',
|
|
332
|
+
borderRadius: 1,
|
|
333
|
+
border: (t) => `1px solid ${error ? t.palette.error.main : t.palette.divider}`,
|
|
334
|
+
zIndex: 1 /* keep leaflet controls above MUI overlays */,
|
|
335
|
+
} },
|
|
336
|
+
react_1.default.createElement(react_leaflet_1.MapContainer, { center: [-14.235, -51.9253], zoom: 4, style: { height: '100%', width: '100%' }, zoomControl: false },
|
|
337
|
+
react_1.default.createElement(react_leaflet_1.ZoomControl, { zoomInTitle: geometryTexts.zoomIn, zoomOutTitle: geometryTexts.zoomOut }),
|
|
338
|
+
react_1.default.createElement(react_leaflet_1.TileLayer, { attribution: "\u00A9 OpenStreetMap contributors", url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" }),
|
|
339
|
+
react_1.default.createElement(DrawEditor, { geometry: geometry, value: value, onChange: onChange }))),
|
|
340
|
+
react_1.default.createElement(TextField_1.default, { value: value, onChange: (e) => onChange(e.target.value || null), variant: "outlined", margin: "dense", fullWidth: true, size: "small", label: geometry === 'point' ? geometryTexts.labelPoint : geometryTexts.labelOther, multiline: geometry !== 'point', minRows: geometry !== 'point' ? 3 : 1, sx: { mt: 1 }, error: malformed, helperText: malformed ? geometryTexts.malformed : geometryTexts.synced }),
|
|
341
|
+
label && react_1.default.createElement(FormHelperText_1.default, { sx: { mt: 0.5 } }, label),
|
|
342
|
+
(helperText || error) && (react_1.default.createElement(FormHelperText_1.default, { error: error, sx: { mt: 0.5 } }, helperText))));
|
|
343
|
+
}
|
|
344
|
+
const isSingle = (g) => g === 'point' || g === 'polygon';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
+
export default function PatternFieldBySchema({ name, schema, control, errors, fieldKey, index, sx, type, autoComplete, disabled, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
|
+
//# sourceMappingURL=PatternFieldBySchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatternFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/PatternFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAc,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,iCA8DpB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = PatternFieldBySchema;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
20
|
+
const react_number_format_1 = require("react-number-format");
|
|
21
|
+
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
22
|
+
const utils_1 = require("../../../utils");
|
|
23
|
+
function PatternFieldBySchema(_a) {
|
|
24
|
+
var _b;
|
|
25
|
+
var { name, schema, control, errors, fieldKey, index, sx = { mr: 2 }, type, autoComplete, disabled, onValueChange, autoFocus } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "fieldKey", "index", "sx", "type", "autoComplete", "disabled", "onValueChange", "autoFocus"]);
|
|
26
|
+
if (!(name in schema)) {
|
|
27
|
+
console.error(`PatternFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const fieldSchema = schema[name];
|
|
31
|
+
if (fieldKey && index && index >= 0) {
|
|
32
|
+
name = `${fieldKey}.${index}.${name}`;
|
|
33
|
+
}
|
|
34
|
+
const { error, helperText } = fieldKey && index && index >= 0
|
|
35
|
+
? (0, utils_1.errorProps)({
|
|
36
|
+
fieldKey,
|
|
37
|
+
index,
|
|
38
|
+
fieldKeyProp: name,
|
|
39
|
+
errors,
|
|
40
|
+
})
|
|
41
|
+
: {
|
|
42
|
+
error: errors && Boolean(errors[name]),
|
|
43
|
+
helperText: errors && errors[name] ? (_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message : fieldSchema.help_text || '',
|
|
44
|
+
};
|
|
45
|
+
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => {
|
|
46
|
+
const { ref } = field, props = __rest(field, ["ref"]);
|
|
47
|
+
return (react_1.default.createElement(react_number_format_1.PatternFormat, Object.assign({ inputRef: ref }, props, other, { id: name, key: name, label: fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), disabled: fieldSchema.disabled === true || disabled, onChange: undefined, onValueChange: (values) => {
|
|
48
|
+
field.onChange(values.value);
|
|
49
|
+
if (onValueChange) {
|
|
50
|
+
onValueChange(values.value);
|
|
51
|
+
}
|
|
52
|
+
}, margin: "normal", fullWidth: true, error: error, helperText: helperText, sx: sx, type: type, autoComplete: autoComplete, autoFocus: autoFocus,
|
|
53
|
+
// valueIsNumericString
|
|
54
|
+
format: fieldSchema.pattern_format || '', mask: "_", customInput: TextField_1.default })));
|
|
55
|
+
} }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
+
export default function TextFieldBySchema({ name, schema, control, errors, multiline, minRows, fieldKey, index, sx, type, autoComplete, disabled, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
|
+
//# sourceMappingURL=TextFieldBySchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/TextFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,SAAiB,EACjB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,EAAc,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,iCA6DpB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = TextFieldBySchema;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
20
|
+
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
21
|
+
const utils_1 = require("../../../utils");
|
|
22
|
+
function TextFieldBySchema(_a) {
|
|
23
|
+
var _b;
|
|
24
|
+
var { name, schema, control, errors, multiline = false, minRows, fieldKey, index, sx = { mr: 2 }, type, autoComplete, disabled, onValueChange, autoFocus } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "minRows", "fieldKey", "index", "sx", "type", "autoComplete", "disabled", "onValueChange", "autoFocus"]);
|
|
25
|
+
if (!(name in schema)) {
|
|
26
|
+
console.error(`TextFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const fieldSchema = schema[name];
|
|
30
|
+
if (fieldKey && index && index >= 0) {
|
|
31
|
+
name = `${fieldKey}.${index}.${name}`;
|
|
32
|
+
}
|
|
33
|
+
if (fieldSchema.type === 'password') {
|
|
34
|
+
type = 'password';
|
|
35
|
+
}
|
|
36
|
+
if (type === 'password') {
|
|
37
|
+
autoComplete = 'current-password';
|
|
38
|
+
}
|
|
39
|
+
const { error, helperText } = fieldKey && index && index >= 0
|
|
40
|
+
? (0, utils_1.errorProps)({
|
|
41
|
+
fieldKey,
|
|
42
|
+
index,
|
|
43
|
+
fieldKeyProp: name,
|
|
44
|
+
errors,
|
|
45
|
+
})
|
|
46
|
+
: {
|
|
47
|
+
error: errors && Boolean(errors[name]),
|
|
48
|
+
helperText: errors && errors[name] ? (_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message : fieldSchema.help_text || '',
|
|
49
|
+
};
|
|
50
|
+
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(TextField_1.default, Object.assign({}, field, other, { id: name, key: name, label: fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), disabled: fieldSchema.disabled === true || disabled, onChange: (e) => {
|
|
51
|
+
field.onChange(e.target.value);
|
|
52
|
+
if (onValueChange) {
|
|
53
|
+
onValueChange(e);
|
|
54
|
+
}
|
|
55
|
+
}, margin: "normal", fullWidth: true, multiline: multiline, error: error, helperText: helperText, sx: sx, type: type, autoComplete: autoComplete, minRows: minRows, autoFocus: autoFocus }))) }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import L from 'leaflet';
|
|
2
|
+
export declare const DEFAULT_MARKER_PIN_SVG: string;
|
|
3
|
+
export declare const DEFAULT_MARKER_SHADOW_SVG: string;
|
|
4
|
+
export declare const DEFAULT_MARKER_ICON_URL: string;
|
|
5
|
+
export declare const DEFAULT_MARKER_SHADOW_URL: string;
|
|
6
|
+
/**
|
|
7
|
+
* Point L.Icon.Default at a servable marker so geometry widgets render points.
|
|
8
|
+
* No args: apply the built-in SVG icon once; skip if any icon is already set.
|
|
9
|
+
* With `userOptions`: always merge (custom marker wins).
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyDefaultLeafletIcon(userOptions?: Partial<L.IconOptions>): void;
|
|
12
|
+
//# sourceMappingURL=leafletMarker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leafletMarker.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/leafletMarker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,SAAS,CAAC;AAKxB,eAAO,MAAM,sBAAsB,QAIzB,CAAC;AAEX,eAAO,MAAM,yBAAyB,QAG5B,CAAC;AAIX,eAAO,MAAM,uBAAuB,QAAoC,CAAC;AACzE,eAAO,MAAM,yBAAyB,QAAuC,CAAC;AAgB9E;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,IAAI,CAalF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_MARKER_SHADOW_URL = exports.DEFAULT_MARKER_ICON_URL = exports.DEFAULT_MARKER_SHADOW_SVG = exports.DEFAULT_MARKER_PIN_SVG = void 0;
|
|
7
|
+
exports.applyDefaultLeafletIcon = applyDefaultLeafletIcon;
|
|
8
|
+
const leaflet_1 = __importDefault(require("leaflet"));
|
|
9
|
+
// Leaflet's stock icons are page-relative PNGs that 404 inside an SPA. Use an
|
|
10
|
+
// inline-SVG data-URI default so markers render under any bundler with no assets.
|
|
11
|
+
exports.DEFAULT_MARKER_PIN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="25" height="41" viewBox="0 0 25 41">' +
|
|
12
|
+
'<path d="M12.5 0C6.7 0 2.1 4.2 2.1 9.4c0 7.7 10.4 31.6 10.4 31.6S22.9 17.1 22.9 9.4C22.9 4.2 18.3 0 12.5 0z" fill="#3388ff" stroke="#ffffff" stroke-width="1.5" stroke-linejoin="round"/>' +
|
|
13
|
+
'<circle cx="12.5" cy="9" r="6.2" fill="#ffffff"/>' +
|
|
14
|
+
'</svg>';
|
|
15
|
+
exports.DEFAULT_MARKER_SHADOW_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="41" height="41" viewBox="0 0 41 41">' +
|
|
16
|
+
'<path d="M20.5 38c-5.4 0-9.7-1-9.9-2.2-.2-1.2 4.1-2.1 9.6-2.1 5.6 0 10.2 1 10 2.2-.2 1.2-4.3 2.1-9.7 2.1z" fill="rgba(0,0,0,0.4)"/>' +
|
|
17
|
+
'</svg>';
|
|
18
|
+
const toDataUri = (svg) => `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
19
|
+
exports.DEFAULT_MARKER_ICON_URL = toDataUri(exports.DEFAULT_MARKER_PIN_SVG);
|
|
20
|
+
exports.DEFAULT_MARKER_SHADOW_URL = toDataUri(exports.DEFAULT_MARKER_SHADOW_SVG);
|
|
21
|
+
let applied = false;
|
|
22
|
+
const DEFAULT_ICON_OPTIONS = {
|
|
23
|
+
iconUrl: exports.DEFAULT_MARKER_ICON_URL,
|
|
24
|
+
iconRetinaUrl: exports.DEFAULT_MARKER_ICON_URL, // SVG scales; stays crisp on retina
|
|
25
|
+
shadowUrl: exports.DEFAULT_MARKER_SHADOW_URL,
|
|
26
|
+
iconSize: leaflet_1.default.point(25, 41),
|
|
27
|
+
iconAnchor: leaflet_1.default.point(12, 41),
|
|
28
|
+
popupAnchor: leaflet_1.default.point(1, -34),
|
|
29
|
+
tooltipAnchor: leaflet_1.default.point(16, -28),
|
|
30
|
+
shadowSize: leaflet_1.default.point(41, 41),
|
|
31
|
+
shadowAnchor: leaflet_1.default.point(12, 41),
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Point L.Icon.Default at a servable marker so geometry widgets render points.
|
|
35
|
+
* No args: apply the built-in SVG icon once; skip if any icon is already set.
|
|
36
|
+
* With `userOptions`: always merge (custom marker wins).
|
|
37
|
+
*/
|
|
38
|
+
function applyDefaultLeafletIcon(userOptions) {
|
|
39
|
+
if (userOptions) {
|
|
40
|
+
leaflet_1.default.Icon.Default.mergeOptions(userOptions); // explicit custom icon wins
|
|
41
|
+
applied = true;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (applied)
|
|
45
|
+
return;
|
|
46
|
+
if (leaflet_1.default.Icon.Default.prototype.options.iconUrl) {
|
|
47
|
+
applied = true; // consumer already picked their own icon; keep it
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
leaflet_1.default.Icon.Default.mergeOptions(DEFAULT_ICON_OPTIONS);
|
|
51
|
+
applied = true;
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TField } from '../@types';
|
|
3
|
+
import { DialogType, FormTools, PageFormType, SnackBarType } from './APIWrapperContext';
|
|
4
|
+
interface APIWrapperProps<T extends TField = void> {
|
|
5
|
+
handleLoading: (x: boolean) => void;
|
|
6
|
+
setSnackBar: (x: Partial<SnackBarType>) => void;
|
|
7
|
+
setDialog: (newState: Partial<DialogType> | null) => void;
|
|
8
|
+
pageForm: PageFormType<T> | null;
|
|
9
|
+
setPageForm: (x: Partial<PageFormType<T>>) => void;
|
|
10
|
+
resetPageForm: () => void;
|
|
11
|
+
formTools?: FormTools<T>;
|
|
12
|
+
setFormTools: (x: FormTools<T>) => void;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
declare function APIWrapper({ handleLoading, setSnackBar, setDialog, pageForm, setPageForm, resetPageForm, formTools, setFormTools, children, }: APIWrapperProps): React.JSX.Element;
|
|
16
|
+
declare const _default: React.MemoExoticComponent<typeof APIWrapper>;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=APIWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"APIWrapper.d.ts","sourceRoot":"","sources":["../../src/context/APIWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwE,MAAM,OAAO,CAAC;AAM7F,OAAO,EAgBL,MAAM,EAGP,MAAM,WAAW,CAAC;AAkCnB,OAAO,EAEL,UAAU,EAEV,SAAS,EAMT,YAAY,EACZ,YAAY,EACb,MAAM,qBAAqB,CAAC;AAI7B,UAAU,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI;IAC/C,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAChD,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1D,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACnD,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,YAAY,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,iBAAS,UAAU,CAAC,EAClB,aAAa,EACb,WAAW,EACX,SAAS,EACT,QAAQ,EACR,WAAW,EACX,aAAa,EACb,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,EAAE,eAAe,qBA2uBjB;;AAED,wBAAsC"}
|