@mapcomponents/ra-geospatial 1.5.3 → 1.5.4-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/.babelrc +12 -0
- package/.storybook/main.ts +25 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/mapcomponents_logo.png +0 -0
- package/.storybook/preview.ts +27 -0
- package/.storybook/style.css +20 -0
- package/.storybook/wheregroupTheme.js +9 -0
- package/README.md +1 -2
- package/assets/ra_geospatial_screenshots.png +0 -0
- package/dist/README.md +74 -0
- package/dist/components/GeospatialInput.d.ts +9 -0
- package/dist/components/GeospatialInput.d.ts.map +1 -0
- package/dist/components/GeospatialInputMap.d.ts +18 -0
- package/dist/components/GeospatialInputMap.d.ts.map +1 -0
- package/dist/components/GeospatialShow.d.ts +9 -0
- package/dist/components/GeospatialShow.d.ts.map +1 -0
- package/dist/components/GeospatialShowMap.d.ts +11 -0
- package/dist/components/GeospatialShowMap.d.ts.map +1 -0
- package/dist/contexts/DataContext.d.ts +4 -0
- package/dist/contexts/DataContext.d.ts.map +1 -0
- package/dist/contexts/dataProvider.d.ts +35 -0
- package/dist/contexts/dataProvider.d.ts.map +1 -0
- package/dist/contexts/lsDataProvider.d.ts +44 -0
- package/dist/contexts/lsDataProvider.d.ts.map +1 -0
- package/dist/decorators/ReactAdminDefaultDecorator.d.ts +3 -0
- package/dist/decorators/ReactAdminDefaultDecorator.d.ts.map +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/html2canvas.esm-CUkZERmf.cjs +23 -0
- package/dist/html2canvas.esm-CUkZERmf.cjs.map +1 -0
- package/dist/html2canvas.esm-Dmi1NfiH.js +4872 -0
- package/dist/html2canvas.esm-Dmi1NfiH.js.map +1 -0
- package/dist/index-BYtSitNR.js +61509 -0
- package/dist/index-BYtSitNR.js.map +1 -0
- package/dist/index-DD78QbMh.cjs +1222 -0
- package/dist/index-DD78QbMh.cjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es-DBcuOIG0.js +6675 -0
- package/dist/index.es-DBcuOIG0.js.map +1 -0
- package/dist/index.es-YxBXdzDQ.cjs +19 -0
- package/dist/index.es-YxBXdzDQ.cjs.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/GisLayout.d.ts +6 -0
- package/dist/layout/GisLayout.d.ts.map +1 -0
- package/dist/logo.png +0 -0
- package/dist/manifest.json +25 -0
- package/dist/package.json +24 -0
- package/dist/purify.es-D1I7B1hP.cjs +3 -0
- package/dist/purify.es-D1I7B1hP.cjs.map +1 -0
- package/dist/purify.es-DHbHSKL1.js +529 -0
- package/dist/purify.es-DHbHSKL1.js.map +1 -0
- package/dist/ra_components/Poi.d.ts +5 -0
- package/dist/ra_components/Poi.d.ts.map +1 -0
- package/dist/ra_components/Property.d.ts +5 -0
- package/dist/ra_components/Property.d.ts.map +1 -0
- package/dist/ra_components/Route.d.ts +5 -0
- package/dist/ra_components/Route.d.ts.map +1 -0
- package/dist/ra_components/raGeospatialProps.d.ts +12 -0
- package/dist/ra_components/raGeospatialProps.d.ts.map +1 -0
- package/dist/ra_components/raGeospatialWebGisProps.d.ts +12 -0
- package/dist/ra_components/raGeospatialWebGisProps.d.ts.map +1 -0
- package/eslint.config.cjs +3 -0
- package/index.html +16 -0
- package/package.json +23 -42
- package/project.json +14 -0
- package/public/favicon.ico +0 -0
- package/public/logo.png +0 -0
- package/public/manifest.json +25 -0
- package/src/components/GeospatialInput.stories.tsx +83 -0
- package/src/components/GeospatialInput.tsx +14 -17
- package/src/components/GeospatialInputMap.tsx +172 -165
- package/src/components/GeospatialShow.stories.tsx +84 -0
- package/src/components/GeospatialShow.tsx +14 -17
- package/src/components/GeospatialShowMap.tsx +53 -58
- package/src/contexts/DataContext.jsx +66 -0
- package/src/contexts/dataProvider.tsx +30 -0
- package/src/contexts/lsDataProvider.js +138 -0
- package/src/decorators/ReactAdminDefaultDecorator.tsx +40 -0
- package/src/index.ts +2 -2
- package/src/layout/GisLayout.jsx +90 -0
- package/src/ra_components/Poi.tsx +42 -0
- package/src/ra_components/Property.tsx +42 -0
- package/src/ra_components/Route.tsx +42 -0
- package/src/ra_components/raGeospatialProps.ts +5 -0
- package/src/ra_components/raGeospatialWebGisProps.ts +5 -0
- package/src/types.d.ts +3 -2
- package/tsconfig.json +7 -101
- package/tsconfig.lib.json +29 -0
- package/vite.config.ts +58 -0
- package/dist/index.esm.js +0 -157
- package/dist/index.esm.js.map +0 -1
- package/rollup.config.js +0 -50
package/dist/index.esm.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { useMap, MapLibreMap, MlGeoJsonLayer, MlFeatureEditor, MapComponentsProvider } from '@mapcomponents/react-maplibre';
|
|
3
|
-
import { useRecordContext, useInput } from 'react-admin';
|
|
4
|
-
import { parse, stringify } from 'wellknown';
|
|
5
|
-
import { centroid } from '@turf/turf';
|
|
6
|
-
|
|
7
|
-
/******************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function __rest(s, e) {
|
|
25
|
-
var t = {};
|
|
26
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
27
|
-
t[p] = s[p];
|
|
28
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
29
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
30
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
31
|
-
t[p[i]] = s[p[i]];
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function GeospatialInputMap(props) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const source = props === null || props === void 0 ? void 0 : props.source;
|
|
39
|
-
const record = useRecordContext();
|
|
40
|
-
const mapHook = useMap({ mapId: props === null || props === void 0 ? void 0 : props.mapId });
|
|
41
|
-
const [geojson, setGeojson] = useState();
|
|
42
|
-
const [oldGeoJson, setOldGeoJson] = useState();
|
|
43
|
-
const _c = useInput(props), _d = _c.field, { name, onChange } = _d; __rest(_d, ["name", "onChange"]);
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (typeof record === "undefined" || !record[source])
|
|
46
|
-
return;
|
|
47
|
-
const _geoJson = {
|
|
48
|
-
type: "Feature",
|
|
49
|
-
properties: {},
|
|
50
|
-
geometry: parse(record[source]),
|
|
51
|
-
};
|
|
52
|
-
setGeojson(_geoJson);
|
|
53
|
-
setOldGeoJson(_geoJson);
|
|
54
|
-
}, [record, props.source]);
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
var _a;
|
|
57
|
-
if (!mapHook.map)
|
|
58
|
-
return;
|
|
59
|
-
if (typeof record !== "undefined" && record[source]) {
|
|
60
|
-
const _center = centroid(parse(record[source]));
|
|
61
|
-
if ((_a = _center === null || _center === void 0 ? void 0 : _center.geometry) === null || _a === void 0 ? void 0 : _a.coordinates) {
|
|
62
|
-
mapHook.map.setCenter(_center.geometry.coordinates);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, [mapHook.map]);
|
|
66
|
-
return (React.createElement(React.Fragment, null,
|
|
67
|
-
props.embeddedMap && (React.createElement(MapLibreMap, Object.assign({}, props === null || props === void 0 ? void 0 : props.MapLibreMapProps, { options: Object.assign({ zoom: 14, style: "https://wms.wheregroup.com/tileserver/style/klokantech-basic.json", center: [0, 0] }, (_a = props === null || props === void 0 ? void 0 : props.MapLibreMapProps) === null || _a === void 0 ? void 0 : _a.options), style: Object.assign({ width: "100%", height: "400px" }, (_b = props === null || props === void 0 ? void 0 : props.MapLibreMapProps) === null || _b === void 0 ? void 0 : _b.style) }))),
|
|
68
|
-
props.type === "point" && (React.createElement(React.Fragment, null,
|
|
69
|
-
oldGeoJson && (React.createElement(MlGeoJsonLayer, { mapId: props === null || props === void 0 ? void 0 : props.mapId, geojson: oldGeoJson, paint: {
|
|
70
|
-
"circle-radius": 8,
|
|
71
|
-
"circle-color": "#6f6f96",
|
|
72
|
-
"circle-stroke-color": "white",
|
|
73
|
-
"circle-stroke-width": 3,
|
|
74
|
-
"circle-opacity": 0.8,
|
|
75
|
-
}, type: "circle", insertBeforeLayer: "gl-draw-polygon-fill-inactive.cold" })),
|
|
76
|
-
React.createElement(MlFeatureEditor, { mapId: props === null || props === void 0 ? void 0 : props.mapId, geojson: geojson, mode: geojson ? "simple_select" : "draw_point", onChange: (_geojson) => {
|
|
77
|
-
if (typeof _geojson[0] !== "undefined") {
|
|
78
|
-
onChange(stringify(_geojson[0]));
|
|
79
|
-
}
|
|
80
|
-
} }))),
|
|
81
|
-
props.type === "polygon" && (React.createElement(React.Fragment, null,
|
|
82
|
-
oldGeoJson && (React.createElement(MlGeoJsonLayer, { mapId: props === null || props === void 0 ? void 0 : props.mapId, geojson: oldGeoJson, paint: {
|
|
83
|
-
"fill-color": "#6f6f96",
|
|
84
|
-
"fill-opacity": 0.6,
|
|
85
|
-
}, type: "fill", insertBeforeLayer: "gl-draw-polygon-fill-inactive.cold" })),
|
|
86
|
-
React.createElement(MlFeatureEditor, { mapId: props === null || props === void 0 ? void 0 : props.mapId, geojson: geojson, mode: geojson ? "simple_select" : "draw_polygon", onChange: (_geojson) => {
|
|
87
|
-
if (typeof _geojson[0] !== "undefined") {
|
|
88
|
-
onChange(stringify(_geojson[0]));
|
|
89
|
-
}
|
|
90
|
-
} }))),
|
|
91
|
-
props.type === "line" && (React.createElement(React.Fragment, null,
|
|
92
|
-
oldGeoJson && (React.createElement(MlGeoJsonLayer, { mapId: props === null || props === void 0 ? void 0 : props.mapId, geojson: oldGeoJson, paint: {
|
|
93
|
-
"line-width": 6,
|
|
94
|
-
"line-color": "#6f6f96",
|
|
95
|
-
"line-opacity": 0.6,
|
|
96
|
-
}, type: "line", insertBeforeLayer: "gl-draw-polygon-fill-inactive.cold" })),
|
|
97
|
-
React.createElement(MlFeatureEditor, { mapId: props === null || props === void 0 ? void 0 : props.mapId, geojson: geojson, mode: geojson ? "simple_select" : "draw_line_string", onChange: (_geojson) => {
|
|
98
|
-
if (typeof _geojson[0] !== "undefined") {
|
|
99
|
-
onChange(stringify(_geojson[0]));
|
|
100
|
-
}
|
|
101
|
-
} })))));
|
|
102
|
-
}
|
|
103
|
-
GeospatialInputMap.defaultProps = {
|
|
104
|
-
type: "point",
|
|
105
|
-
embeddedMap: true,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
function GeospatialInput(props) {
|
|
109
|
-
return (React.createElement(React.Fragment, null, props.embeddedMap ? (React.createElement(MapComponentsProvider, null,
|
|
110
|
-
React.createElement(GeospatialInputMap, Object.assign({}, props)))) : (React.createElement(GeospatialInputMap, Object.assign({}, props)))));
|
|
111
|
-
}
|
|
112
|
-
GeospatialInput.defaultProps = {
|
|
113
|
-
embeddedMap: true,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
function GeospatialShowMap(props) {
|
|
117
|
-
var _a, _b;
|
|
118
|
-
const source = props.source;
|
|
119
|
-
const record = useRecordContext();
|
|
120
|
-
const mapHook = useMap();
|
|
121
|
-
const [geojson, setGeojson] = useState();
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
if (!(record === null || record === void 0 ? void 0 : record[source]))
|
|
124
|
-
return;
|
|
125
|
-
const _geometry = parse(record[source]);
|
|
126
|
-
if (_geometry) {
|
|
127
|
-
setGeojson({
|
|
128
|
-
type: "Feature",
|
|
129
|
-
properties: {},
|
|
130
|
-
geometry: _geometry,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}, [record]);
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
var _a;
|
|
136
|
-
if (!mapHook.map || !geojson)
|
|
137
|
-
return;
|
|
138
|
-
const _center = centroid(geojson);
|
|
139
|
-
if ((_a = _center === null || _center === void 0 ? void 0 : _center.geometry) === null || _a === void 0 ? void 0 : _a.coordinates) {
|
|
140
|
-
mapHook.map.setCenter(_center.geometry.coordinates);
|
|
141
|
-
}
|
|
142
|
-
}, [mapHook.map, geojson]);
|
|
143
|
-
return (React.createElement(React.Fragment, null,
|
|
144
|
-
props.embeddedMap && (React.createElement(MapLibreMap, Object.assign({}, props === null || props === void 0 ? void 0 : props.MapLibreMapProps, { options: Object.assign({ zoom: 14, style: "https://wms.wheregroup.com/tileserver/style/klokantech-basic.json", center: [0, 0] }, (_a = props === null || props === void 0 ? void 0 : props.MapLibreMapProps) === null || _a === void 0 ? void 0 : _a.options), style: Object.assign({ width: "100%", height: "400px" }, (_b = props === null || props === void 0 ? void 0 : props.MapLibreMapProps) === null || _b === void 0 ? void 0 : _b.style) }))),
|
|
145
|
-
geojson && React.createElement(MlGeoJsonLayer, { geojson: geojson })));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function GeospatialShow(props) {
|
|
149
|
-
return (React.createElement(React.Fragment, null, props.embeddedMap ? (React.createElement(MapComponentsProvider, null,
|
|
150
|
-
React.createElement(GeospatialShowMap, Object.assign({}, props)))) : (React.createElement(GeospatialShowMap, Object.assign({}, props)))));
|
|
151
|
-
}
|
|
152
|
-
GeospatialShow.defaultProps = {
|
|
153
|
-
embeddedMap: true,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export { GeospatialInput as RaGeospatialInput, GeospatialShow as RaGeospatialShow };
|
|
157
|
-
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/rollup.config.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import peerDepsExternal from "rollup-plugin-peer-deps-external";
|
|
2
|
-
import resolve from "@rollup/plugin-node-resolve";
|
|
3
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
4
|
-
import typescript from "rollup-plugin-typescript2";
|
|
5
|
-
|
|
6
|
-
import babel from "@rollup/plugin-babel";
|
|
7
|
-
import url from "@rollup/plugin-url";
|
|
8
|
-
import external from "rollup-plugin-peer-deps-external";
|
|
9
|
-
|
|
10
|
-
import del from "rollup-plugin-delete";
|
|
11
|
-
|
|
12
|
-
const config = {
|
|
13
|
-
input: "src/index.ts",
|
|
14
|
-
output: [
|
|
15
|
-
{
|
|
16
|
-
inlineDynamicImports: true,
|
|
17
|
-
file: "dist/index.esm.js",
|
|
18
|
-
format: "esm",
|
|
19
|
-
sourcemap: true,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
plugins: [
|
|
23
|
-
url(),
|
|
24
|
-
babel({
|
|
25
|
-
exclude: "node_modules/**",
|
|
26
|
-
babelHelpers: "bundled",
|
|
27
|
-
presets: ["@babel/preset-react"],
|
|
28
|
-
}),
|
|
29
|
-
external(),
|
|
30
|
-
peerDepsExternal(),
|
|
31
|
-
commonjs(),
|
|
32
|
-
typescript({
|
|
33
|
-
useTsconfigDeclarationDir: true,
|
|
34
|
-
tsconfig: "tsconfig.json",
|
|
35
|
-
}),
|
|
36
|
-
del({ targets: ["build/*"] }),
|
|
37
|
-
],
|
|
38
|
-
external: [
|
|
39
|
-
"@mapcomponents/react-maplibre",
|
|
40
|
-
"react-admin",
|
|
41
|
-
"react",
|
|
42
|
-
"wellknown",
|
|
43
|
-
"@turf/turf",
|
|
44
|
-
],
|
|
45
|
-
|
|
46
|
-
onwarn: function (warning, warn) {
|
|
47
|
-
warn(warning);
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
export default config;
|