@mapcomponents/ra-geospatial 1.0.4 → 1.5.1-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.
Files changed (41) hide show
  1. package/.babelrc +12 -0
  2. package/.storybook/main.ts +25 -0
  3. package/.storybook/manager.js +6 -0
  4. package/.storybook/mapcomponents_logo.png +0 -0
  5. package/.storybook/preview.ts +27 -0
  6. package/.storybook/style.css +20 -0
  7. package/.storybook/wheregroupTheme.js +9 -0
  8. package/README.md +71 -1
  9. package/assets/ra_geospatial_screenshots.png +0 -0
  10. package/eslint.config.cjs +3 -0
  11. package/index.html +16 -0
  12. package/package.json +21 -35
  13. package/project.json +14 -0
  14. package/public/favicon.ico +0 -0
  15. package/public/logo.png +0 -0
  16. package/public/manifest.json +25 -0
  17. package/src/components/GeospatialInput.stories.tsx +83 -0
  18. package/src/components/GeospatialInput.tsx +14 -17
  19. package/src/components/GeospatialInputMap.tsx +175 -170
  20. package/src/components/GeospatialShow.stories.tsx +84 -0
  21. package/src/components/GeospatialShow.tsx +14 -17
  22. package/src/components/GeospatialShowMap.tsx +53 -58
  23. package/src/contexts/DataContext.jsx +66 -0
  24. package/src/contexts/dataProvider.tsx +30 -0
  25. package/src/contexts/lsDataProvider.js +138 -0
  26. package/src/decorators/ReactAdminDefaultDecorator.tsx +40 -0
  27. package/src/index.ts +2 -2
  28. package/src/layout/GisLayout.jsx +90 -0
  29. package/src/ra_components/Poi.tsx +42 -0
  30. package/src/ra_components/Property.tsx +42 -0
  31. package/src/ra_components/Route.tsx +42 -0
  32. package/src/ra_components/raGeospatialProps.ts +5 -0
  33. package/src/ra_components/raGeospatialWebGisProps.ts +5 -0
  34. package/src/types.d.ts +3 -2
  35. package/tsconfig.json +7 -101
  36. package/tsconfig.lib.json +29 -0
  37. package/vite.config.ts +49 -0
  38. package/dist/index.esm.js +0 -155
  39. package/dist/index.esm.js.map +0 -1
  40. package/package-lock.json +0 -16564
  41. package/rollup.config.js +0 -50
package/.babelrc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@nx/react/babel",
5
+ {
6
+ "runtime": "automatic",
7
+ "useBuiltIns": "usage"
8
+ }
9
+ ]
10
+ ],
11
+ "plugins": []
12
+ }
@@ -0,0 +1,25 @@
1
+ import { dirname, join } from 'node:path';
2
+ import type { StorybookConfig } from '@storybook/react-vite';
3
+
4
+ const config: StorybookConfig = {
5
+ stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
6
+ framework: {
7
+ name: getAbsolutePath("@storybook/react-vite"),
8
+ options: {
9
+ builder: {
10
+ viteConfigPath: 'vite.config.ts',
11
+ },
12
+ },
13
+ },
14
+ staticDirs: ['../public'],
15
+ };
16
+
17
+ export default config;
18
+
19
+ // To customize your Vite configuration you can use the viteFinal field.
20
+ // Check https://storybook.js.org/docs/react/builders/vite#configuration
21
+ // and https://nx.dev/recipes/storybook/custom-builder-configs
22
+
23
+ function getAbsolutePath(value: string): any {
24
+ return dirname(require.resolve(join(value, "package.json")));
25
+ }
@@ -0,0 +1,6 @@
1
+ import { addons } from "@storybook/addons";
2
+ import wheregroupTheme from "./wheregroupTheme";
3
+
4
+ addons.setConfig({
5
+ theme: wheregroupTheme,
6
+ });
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ import { create } from 'storybook/theming';
2
+ import logo from './mapcomponents_logo.png';
3
+
4
+ export default create({
5
+ base: 'light',
6
+ brandTitle: 'WhereGroup GmbH',
7
+ brandUrl: 'https://wheregroup.com',
8
+ brandImage: logo,
9
+ });
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
- Input and view components to work with geospatial data in react admin.
5
+ [![npm version](https://badge.fury.io/js/@mapcomponents%2Fra-geospatial.svg)](https://badge.fury.io/js/@mapcomponents%2Fra-geospatial) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![downloads](https://img.shields.io/npm/dt/@mapcomponents%2Fra-geospatial.svg) ![downloads](https://img.shields.io/npm/dm/@mapcomponents%2Fra-geospatial.svg)
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
+ ![RaGeospatialInput & RaGeospatialShow](https://github.com/mapcomponents/ra-geospatial/blob/main/assets/ra_geospatial_screenshots.png?raw=true)
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
@@ -0,0 +1,3 @@
1
+ const baseConfig = require('../../eslint.config.mjs').default;
2
+
3
+ module.exports = [...baseConfig];
package/index.html ADDED
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Ra-Geospatial</title>
6
+ <base href="/" />
7
+
8
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
9
+ <link rel="icon" type="image/x-icon" href="./favicon.ico" />
10
+ <link rel="stylesheet" href="/src/styles.css" />
11
+ </head>
12
+ <body>
13
+ <div id="root"></div>
14
+ <script type="module" src="/src/main.tsx"></script>
15
+ </body>
16
+ </html>
package/package.json CHANGED
@@ -1,42 +1,28 @@
1
1
  {
2
2
  "name": "@mapcomponents/ra-geospatial",
3
- "version": "1.0.4",
4
- "description": "",
5
- "private": false,
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.1-0",
4
+ "main": "src/index.ts",
5
+ "types": "./index.d.ts",
11
6
  "type": "module",
12
- "scripts": {
13
- "build": "rollup -c",
14
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "exports": {
8
+ ".": {
9
+ "import": "./index.mjs",
10
+ "require": "./index.js"
11
+ }
15
12
  },
16
- "author": "",
17
13
  "dependencies": {
18
- "@turf/turf": "^6.5.0",
19
- "maplibre-gl": "^2.4.0"
20
- },
21
- "devDependencies": {
22
- "@babel/core": "^7.20.12",
23
- "@mapcomponents/react-maplibre": "^0.1.69",
24
- "@rollup/plugin-alias": "^4.0.3",
25
- "@rollup/plugin-babel": "^6.0.3",
26
- "@rollup/plugin-commonjs": "^24.0.1",
27
- "@rollup/plugin-node-resolve": "^15.0.1",
28
- "@rollup/plugin-url": "^8.0.1",
29
- "@turf/helpers": "^6.5.0",
30
- "@types/wellknown": "^0.5.4",
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
+ "@mui/icons-material": "^7.3.2",
17
+ "@mui/material": "^7.3.2",
18
+ "@turf/helpers": "^7.2.0",
19
+ "@turf/turf": "^7.2.0",
20
+ "@types/geojson": "^7946.0.16",
21
+ "lodash": "^4.17.21",
22
+ "maplibre-gl": "^5.7.0",
23
+ "ra-data-fakerest": "^5.11.0",
24
+ "react-admin": "^5.11.0",
25
+ "react-router-dom": "^7.8.2",
40
26
  "wellknown": "^0.5.0"
41
27
  }
42
- }
28
+ }
package/project.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "ra-geospatial",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/ra-geospatial/src",
5
+ "projectType": "library",
6
+ "tags": [],
7
+ "targets": {
8
+ "storybook": {
9
+ "options": {
10
+ "port": 4402
11
+ }
12
+ }
13
+ }
14
+ }
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "favicon.ico",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
@@ -0,0 +1,83 @@
1
+ import type { Meta } from '@storybook/react-vite';
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 React from "react";
2
- import { MapComponentsProvider } from "@mapcomponents/react-maplibre";
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
- return (
9
- <>
10
- {props.embeddedMap ? (
11
- <MapComponentsProvider>
12
- <GeometryInputMap {...props} />
13
- </MapComponentsProvider>
14
- ) : (
15
- <GeometryInputMap {...props} />
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
- embeddedMap: true,
18
+ embeddedMap: true,
22
19
  };
23
20
 
24
21
  export default GeospatialInput;