@mapcomponents/ra-geospatial 1.0.4 → 1.5.5
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 +19 -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 +71 -1
- package/assets/ra_geospatial_screenshots.png +0 -0
- package/eslint.config.cjs +3 -0
- package/package.json +22 -35
- package/project.json +8 -0
- package/src/components/GeospatialInput.stories.tsx +83 -0
- package/src/components/GeospatialInput.tsx +14 -17
- package/src/components/GeospatialInputMap.tsx +172 -169
- package/src/components/GeospatialShow.stories.tsx +84 -0
- package/src/components/GeospatialShow.tsx +15 -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 +142 -0
- package/src/decorators/ReactAdminDefaultDecorator.tsx +41 -0
- package/src/index.ts +2 -2
- package/src/layout/GisLayout.jsx +97 -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 +49 -0
- package/dist/index.esm.js +0 -155
- package/dist/index.esm.js.map +0 -1
- package/package-lock.json +0 -16564
- package/rollup.config.js +0 -50
package/.babelrc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
|
|
5
|
+
framework: {
|
|
6
|
+
name: '@storybook/react-vite',
|
|
7
|
+
options: {
|
|
8
|
+
builder: {
|
|
9
|
+
viteConfigPath: 'vite.config.ts',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default config;
|
|
16
|
+
|
|
17
|
+
// To customize your Vite configuration you can use the viteFinal field.
|
|
18
|
+
// Check https://storybook.js.org/docs/react/builders/vite#configuration
|
|
19
|
+
// and https://nx.dev/recipes/storybook/custom-builder-configs
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
|
|
3
|
+
export const parameters = {
|
|
4
|
+
docs: {
|
|
5
|
+
inlineStories: false,
|
|
6
|
+
},
|
|
7
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
8
|
+
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const globalTypes = {
|
|
12
|
+
theme: {
|
|
13
|
+
name: 'Theme',
|
|
14
|
+
title: 'Theme',
|
|
15
|
+
description: 'Theme for your components',
|
|
16
|
+
defaultValue: 'light',
|
|
17
|
+
toolbar: {
|
|
18
|
+
icon: 'paintbrush',
|
|
19
|
+
dynamicTitle: true,
|
|
20
|
+
items: [
|
|
21
|
+
{ value: 'light', left: '☀️', title: 'Light mode' },
|
|
22
|
+
{ value: 'dark', left: '🌙', title: 'Dark mode' },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const tags = ['autodocs'];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.docs-story > div:first-child{
|
|
2
|
+
z-index:0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.docs-story > div > div:first-child, .innerZoomElementWrapper, .innerZoomElementWrapper > div:first-child, .innerZoomElementWrapper > div:first-child > div:first-child{
|
|
6
|
+
|
|
7
|
+
position: absolute;
|
|
8
|
+
top: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
right: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.docs-story > div > div:first-child{
|
|
15
|
+
height: initial;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.innerZoomElementWrapper > div > div > div:first-child{
|
|
19
|
+
height: 100% !important;
|
|
20
|
+
}
|
package/README.md
CHANGED
|
@@ -1,4 +1,74 @@
|
|
|
1
|
+
<img src="https://avatars.githubusercontent.com/u/64851912" alt="MapComponents logo" width="80"/>
|
|
2
|
+
|
|
1
3
|
# @mapcomponents/ra-geospatial
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
[](https://badge.fury.io/js/@mapcomponents%2Fra-geospatial) [](https://opensource.org/licenses/MIT)  
|
|
6
|
+
|
|
7
|
+
Input and view components to work with geospatial data in react admin. This package is based on @mapcomponents/react-maplibre and uses MapLibre-gl to display geospatial data on a map.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
RaGeospatialInput & RaGeospatialShow used to edit a polygon geometry in a react-admin application.
|
|
12
|
+
|
|
13
|
+
## Demos
|
|
14
|
+
|
|
15
|
+
- [react admin & mapcomponents Demo](https://cioddi.github.io/mc-react-admin-apps/react-admin-demo)
|
|
16
|
+
- [webGIS Demo (embeddedMap: false)](https://cioddi.github.io/mc-react-admin-apps/webgis-demo)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add @mapcomponents/ra-geospatial
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Exports
|
|
25
|
+
|
|
26
|
+
### RaGeospatialInput
|
|
27
|
+
|
|
28
|
+
Input component to edit or create geospatial data.
|
|
29
|
+
|
|
30
|
+
### RaGeospatialShow
|
|
31
|
+
|
|
32
|
+
Show component to display geospatial data.
|
|
33
|
+
|
|
34
|
+
#### Props
|
|
35
|
+
|
|
36
|
+
- **embeddedMap**: boolean (default: false) - If true, the map will be embedded in the component. If false, the component will not create it's own MapContext and add a MapLibreMap component but instead expect a MapContext and a MapLibreMap component to be present in the parent component.
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
```JSX
|
|
41
|
+
import {
|
|
42
|
+
RaGeospatialInput,
|
|
43
|
+
RaGeospatialShow,
|
|
44
|
+
} from "@mapcomponents/ra-geospatial";
|
|
45
|
+
|
|
46
|
+
export const PoiEdit = () => (
|
|
47
|
+
<Edit>
|
|
48
|
+
<SimpleForm>
|
|
49
|
+
<TextInput source="title" />
|
|
50
|
+
<TextInput source="geom" />
|
|
51
|
+
<RaGeospatialInput source="geom" />
|
|
52
|
+
</SimpleForm>
|
|
53
|
+
</Edit>
|
|
54
|
+
);
|
|
55
|
+
export const PoiCreate = () => (
|
|
56
|
+
<Create>
|
|
57
|
+
<SimpleForm>
|
|
58
|
+
<TextInput source="title" />
|
|
59
|
+
<TextInput source="geom" />
|
|
60
|
+
<RaGeospatialInput source="geom" />
|
|
61
|
+
</SimpleForm>
|
|
62
|
+
</Create>
|
|
63
|
+
);
|
|
4
64
|
|
|
65
|
+
export const PoiShow = () => (
|
|
66
|
+
<Show>
|
|
67
|
+
<SimpleShowLayout>
|
|
68
|
+
<TextField source="id" />
|
|
69
|
+
<TextField source="title" />
|
|
70
|
+
<RaGeospatialShow source="geom" />
|
|
71
|
+
</SimpleShowLayout>
|
|
72
|
+
</Show>
|
|
73
|
+
);
|
|
74
|
+
```
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,42 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapcomponents/ra-geospatial",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"module": "dist/index.esm.js",
|
|
9
|
-
"source": "src/index.ts",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "1.5.5",
|
|
4
|
+
"main": "src/index.ts",
|
|
5
|
+
"types": "./index.d.ts",
|
|
11
6
|
"type": "module",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./index.mjs",
|
|
10
|
+
"require": "./index.js"
|
|
11
|
+
}
|
|
15
12
|
},
|
|
16
|
-
"author": "",
|
|
17
13
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"react": "^18.2.0",
|
|
32
|
-
"react-admin": "^4.7.2",
|
|
33
|
-
"rollup": "^3.12.0",
|
|
34
|
-
"rollup-plugin-delete": "^2.0.0",
|
|
35
|
-
"rollup-plugin-import-css": "^3.1.0",
|
|
36
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
37
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
38
|
-
"rollup-plugin-typescript2": "^0.34.1",
|
|
39
|
-
"typescript": "^4.9.5",
|
|
14
|
+
"@emotion/react": "^11.14.0",
|
|
15
|
+
"@emotion/styled": "^11.14.1",
|
|
16
|
+
"@mapcomponents/react-maplibre": "^1.3.3",
|
|
17
|
+
"@mui/icons-material": "^7.2.0",
|
|
18
|
+
"@mui/material": "^7.2.0",
|
|
19
|
+
"@turf/helpers": "^7.2.0",
|
|
20
|
+
"@turf/turf": "^7.2.0",
|
|
21
|
+
"@types/geojson": "^7946.0.16",
|
|
22
|
+
"lodash": "^4.17.21",
|
|
23
|
+
"maplibre-gl": "^5.6.1",
|
|
24
|
+
"ra-data-fakerest": "^5.10.0",
|
|
25
|
+
"react-admin": "^5.10.0",
|
|
26
|
+
"react-router-dom": "^7.7.1",
|
|
40
27
|
"wellknown": "^0.5.0"
|
|
41
28
|
}
|
|
42
|
-
}
|
|
29
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/react';
|
|
2
|
+
import GeospatialInput from './GeospatialInput';
|
|
3
|
+
import { ReactAdminDefaultDecorator } from '../decorators/ReactAdminDefaultDecorator';
|
|
4
|
+
import { PoiEdit, PoiEditWebGis } from '../ra_components/Poi';
|
|
5
|
+
import { PropertyEdit, PropertyEditWebGis } from '../ra_components/Property';
|
|
6
|
+
import { RouteEdit, RouteEditWebGis } from '../ra_components/Route';
|
|
7
|
+
import GisLayout from '../layout/GisLayout';
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
component: GeospatialInput,
|
|
11
|
+
title: 'MapComponents/GeospatialInput',
|
|
12
|
+
decorators: [ReactAdminDefaultDecorator],
|
|
13
|
+
} satisfies Meta<typeof GeospatialInput>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
export const PoisEdit = PoiEdit.bind({});
|
|
18
|
+
|
|
19
|
+
PoisEdit.args = {
|
|
20
|
+
primary: true,
|
|
21
|
+
embeddedMap: true,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
PoisEdit.parameters = {
|
|
25
|
+
name: 'pois',
|
|
26
|
+
};
|
|
27
|
+
export const PropertiesEdit = PropertyEdit.bind({});
|
|
28
|
+
|
|
29
|
+
PropertiesEdit.args = {
|
|
30
|
+
primary: true,
|
|
31
|
+
embeddedMap: true,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
PropertiesEdit.parameters = {
|
|
35
|
+
name: 'properties',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const RoutesEdit = RouteEdit.bind({});
|
|
39
|
+
|
|
40
|
+
RoutesEdit.args = {
|
|
41
|
+
primary: true,
|
|
42
|
+
embeddedMap: true,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
RoutesEdit.parameters = {
|
|
46
|
+
name: 'routes',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const PoisEditGIS = PoiEditWebGis.bind({});
|
|
50
|
+
|
|
51
|
+
PoisEditGIS.args = {
|
|
52
|
+
primary: true,
|
|
53
|
+
embeddedMap: false,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
PoisEditGIS.parameters = {
|
|
57
|
+
name: 'pois',
|
|
58
|
+
layout: GisLayout,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const PropertiesEditGIS = PropertyEditWebGis.bind({});
|
|
62
|
+
|
|
63
|
+
PropertiesEditGIS.args = {
|
|
64
|
+
primary: true,
|
|
65
|
+
embeddedMap: false,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
PropertiesEditGIS.parameters = {
|
|
69
|
+
name: 'properties',
|
|
70
|
+
layout: GisLayout,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const RoutesEditGIS = RouteEditWebGis.bind({});
|
|
74
|
+
|
|
75
|
+
RoutesEditGIS.args = {
|
|
76
|
+
primary: true,
|
|
77
|
+
embeddedMap: false,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
RoutesEditGIS.parameters = {
|
|
81
|
+
name: 'routes',
|
|
82
|
+
layout: GisLayout,
|
|
83
|
+
};
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import GeometryInputMap, {
|
|
4
|
-
GeospatialInputMapProps,
|
|
5
|
-
} from "./GeospatialInputMap.js";
|
|
1
|
+
import { MapComponentsProvider } from '@mapcomponents/react-maplibre';
|
|
2
|
+
import GeospatialInputMap, { GeospatialInputMapProps } from './GeospatialInputMap.js';
|
|
6
3
|
|
|
7
4
|
function GeospatialInput(props: GeospatialInputMapProps) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
{props.embeddedMap ? (
|
|
8
|
+
<MapComponentsProvider>
|
|
9
|
+
<GeospatialInputMap {...props} />
|
|
10
|
+
</MapComponentsProvider>
|
|
11
|
+
) : (
|
|
12
|
+
<GeospatialInputMap {...props} />
|
|
13
|
+
)}
|
|
14
|
+
</>
|
|
15
|
+
);
|
|
19
16
|
}
|
|
20
17
|
GeospatialInput.defaultProps = {
|
|
21
|
-
|
|
18
|
+
embeddedMap: true,
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
export default GeospatialInput;
|