@mapcomponents/ra-geospatial 1.5.3 → 1.5.5-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 (86) hide show
  1. package/README.md +1 -2
  2. package/assets/ra_geospatial_screenshots.png +0 -0
  3. package/dist/README.md +74 -0
  4. package/dist/components/GeospatialInput.d.ts +9 -0
  5. package/dist/components/GeospatialInput.d.ts.map +1 -0
  6. package/dist/components/GeospatialInputMap.d.ts +18 -0
  7. package/dist/components/GeospatialInputMap.d.ts.map +1 -0
  8. package/dist/components/GeospatialShow.d.ts +9 -0
  9. package/dist/components/GeospatialShow.d.ts.map +1 -0
  10. package/dist/components/GeospatialShowMap.d.ts +11 -0
  11. package/dist/components/GeospatialShowMap.d.ts.map +1 -0
  12. package/dist/contexts/DataContext.d.ts +4 -0
  13. package/dist/contexts/DataContext.d.ts.map +1 -0
  14. package/dist/contexts/dataProvider.d.ts +35 -0
  15. package/dist/contexts/dataProvider.d.ts.map +1 -0
  16. package/dist/contexts/lsDataProvider.d.ts +44 -0
  17. package/dist/contexts/lsDataProvider.d.ts.map +1 -0
  18. package/dist/decorators/ReactAdminDefaultDecorator.d.ts +3 -0
  19. package/dist/decorators/ReactAdminDefaultDecorator.d.ts.map +1 -0
  20. package/dist/favicon.ico +0 -0
  21. package/dist/html2canvas.esm-CUkZERmf.cjs +23 -0
  22. package/dist/html2canvas.esm-CUkZERmf.cjs.map +1 -0
  23. package/dist/html2canvas.esm-Dmi1NfiH.js +4872 -0
  24. package/dist/html2canvas.esm-Dmi1NfiH.js.map +1 -0
  25. package/dist/index-BYtSitNR.js +61509 -0
  26. package/dist/index-BYtSitNR.js.map +1 -0
  27. package/dist/index-DD78QbMh.cjs +1222 -0
  28. package/dist/index-DD78QbMh.cjs.map +1 -0
  29. package/dist/index.cjs +2 -0
  30. package/dist/index.cjs.map +1 -0
  31. package/dist/index.css +1 -0
  32. package/dist/index.d.ts +3 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.es-DBcuOIG0.js +6675 -0
  35. package/dist/index.es-DBcuOIG0.js.map +1 -0
  36. package/dist/index.es-YxBXdzDQ.cjs +19 -0
  37. package/dist/index.es-YxBXdzDQ.cjs.map +1 -0
  38. package/dist/index.js +6 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/layout/GisLayout.d.ts +6 -0
  41. package/dist/layout/GisLayout.d.ts.map +1 -0
  42. package/dist/logo.png +0 -0
  43. package/dist/manifest.json +25 -0
  44. package/dist/package.json +24 -0
  45. package/dist/purify.es-D1I7B1hP.cjs +3 -0
  46. package/dist/purify.es-D1I7B1hP.cjs.map +1 -0
  47. package/dist/purify.es-DHbHSKL1.js +529 -0
  48. package/dist/purify.es-DHbHSKL1.js.map +1 -0
  49. package/dist/ra_components/Poi.d.ts +5 -0
  50. package/dist/ra_components/Poi.d.ts.map +1 -0
  51. package/dist/ra_components/Property.d.ts +5 -0
  52. package/dist/ra_components/Property.d.ts.map +1 -0
  53. package/dist/ra_components/Route.d.ts +5 -0
  54. package/dist/ra_components/Route.d.ts.map +1 -0
  55. package/dist/ra_components/raGeospatialProps.d.ts +12 -0
  56. package/dist/ra_components/raGeospatialProps.d.ts.map +1 -0
  57. package/dist/ra_components/raGeospatialWebGisProps.d.ts +12 -0
  58. package/dist/ra_components/raGeospatialWebGisProps.d.ts.map +1 -0
  59. package/eslint.config.cjs +3 -0
  60. package/index.html +16 -0
  61. package/package.json +23 -42
  62. package/project.json +14 -0
  63. package/src/components/GeospatialInput.stories.tsx +83 -0
  64. package/src/components/GeospatialInput.tsx +14 -17
  65. package/src/components/GeospatialInputMap.tsx +172 -165
  66. package/src/components/GeospatialShow.stories.tsx +84 -0
  67. package/src/components/GeospatialShow.tsx +14 -17
  68. package/src/components/GeospatialShowMap.tsx +53 -58
  69. package/src/contexts/DataContext.jsx +66 -0
  70. package/src/contexts/dataProvider.tsx +30 -0
  71. package/src/contexts/lsDataProvider.js +138 -0
  72. package/src/decorators/ReactAdminDefaultDecorator.tsx +40 -0
  73. package/src/index.ts +2 -2
  74. package/src/layout/GisLayout.jsx +90 -0
  75. package/src/ra_components/Poi.tsx +42 -0
  76. package/src/ra_components/Property.tsx +42 -0
  77. package/src/ra_components/Route.tsx +42 -0
  78. package/src/ra_components/raGeospatialProps.ts +5 -0
  79. package/src/ra_components/raGeospatialWebGisProps.ts +5 -0
  80. package/src/types.d.ts +3 -2
  81. package/tsconfig.lib.json +29 -0
  82. package/vite.config.ts +58 -0
  83. package/dist/index.esm.js +0 -157
  84. package/dist/index.esm.js.map +0 -1
  85. package/rollup.config.js +0 -50
  86. package/tsconfig.json +0 -103
@@ -0,0 +1,30 @@
1
+ import localStorageDataProvider from './lsDataProvider';
2
+
3
+ export const defaultData = {
4
+ pois: [
5
+ {
6
+ id: 0,
7
+ title: 'poi',
8
+ geom: 'POINT (7.077808464010502 50.74294216203171)',
9
+ },
10
+ ],
11
+ properties: [
12
+ {
13
+ id: 0,
14
+ title: 'property',
15
+ geom: 'POLYGON ((7.066952151714986 50.740002740511244, 7.0639480776189885 50.74065454154203, 7.064291400372213 50.74198527380986, 7.067381305157255 50.742121060690465, 7.067381305157255 50.740518750408825, 7.0669092363712025 50.73997558193838, 7.066952151714986 50.740002740511244))',
16
+ },
17
+ ],
18
+ routes: [
19
+ {
20
+ id: 0,
21
+ title: 'route',
22
+ geom: 'LINESTRING (7.072968944094811 50.737892872017426, 7.0724677647124565 50.73921232584979, 7.0719866325044904 50.7409250229731, 7.071808100376245 50.742318711300925, 7.072108808006249 50.7425470593881, 7.076779799853682 50.742876893548384, 7.077140649009607 50.742775406362085, 7.0774413566381895 50.74257243132925, 7.077862347320121 50.74252168743365, 7.078343479528058 50.74269929082783, 7.078503856930212 50.742889579431534, 7.079466121344723 50.74290226531082, 7.080187819656601 50.742876893548384, 7.08082932926672 50.74281346408284)',
23
+ },
24
+ ],
25
+ };
26
+
27
+ export const dataProvider = localStorageDataProvider({
28
+ localStorageUpdateDelay: 2,
29
+ defaultData: defaultData,
30
+ });
@@ -0,0 +1,138 @@
1
+ import fakeRestProvider from 'ra-data-fakerest';
2
+ import pullAt from 'lodash/pullAt';
3
+
4
+ /**
5
+ * Respond to react-admin data queries using a local database persisted in localStorage
6
+ *
7
+ * Useful for local-first web apps. The storage is shared between tabs.
8
+ *
9
+ * @example // initialize with no data
10
+ *
11
+ * import localStorageDataProvider from 'ra-data-local-storage';
12
+ * const dataProvider.tsx = localStorageDataProvider();
13
+ *
14
+ * @example // initialize with default data (will be ignored if data has been modified by user)
15
+ *
16
+ * import localStorageDataProvider from 'ra-data-local-storage';
17
+ * const dataProvider.tsx = localStorageDataProvider({
18
+ * defaultData: {
19
+ * posts: [
20
+ * { id: 0, title: 'Hello, world!' },
21
+ * { id: 1, title: 'FooBar' },
22
+ * ],
23
+ * comments: [
24
+ * { id: 0, post_id: 0, author: 'John Doe', body: 'Sensational!' },
25
+ * { id: 1, post_id: 0, author: 'Jane Doe', body: 'I agree' },
26
+ * ],
27
+ * }
28
+ * });
29
+ */
30
+ export default function localStorageDataProvider(params) {
31
+ const {
32
+ defaultData = {},
33
+ localStorageKey = 'ra-data-local-storage',
34
+ loggingEnabled = false,
35
+ localStorageUpdateDelay = 10, // milliseconds
36
+ } = params || {};
37
+ const localStorageData = localStorage.getItem(localStorageKey);
38
+ let data = localStorageData ? JSON.parse(localStorageData) : defaultData;
39
+
40
+ // change data by executing callback, then persist in localStorage
41
+ const updateLocalStorage = (callback) => {
42
+ // modify localStorage after the next tick
43
+ setTimeout(() => {
44
+ callback();
45
+ localStorage.setItem(localStorageKey, JSON.stringify(data));
46
+ const evt = new Event('storageItemUpdated', {
47
+ bubbles: true,
48
+ cancelable: false,
49
+ });
50
+ document.dispatchEvent(evt);
51
+ }, localStorageUpdateDelay);
52
+ };
53
+
54
+ let baseDataProvider = fakeRestProvider(data, loggingEnabled);
55
+
56
+ window?.addEventListener('storage', (event) => {
57
+ if (event.key === localStorageKey) {
58
+ const newData = JSON.parse(event.newValue);
59
+ data = newData;
60
+ baseDataProvider = fakeRestProvider(newData, loggingEnabled);
61
+ }
62
+ });
63
+
64
+ return {
65
+ // read methods are just proxies to FakeRest
66
+ getList: (resource, params) =>
67
+ baseDataProvider.getList(resource, params).catch((error) => {
68
+ if (error.code === 1) {
69
+ // undefined collection error: hide the error and return an empty list instead
70
+ return { data: [], total: 0 };
71
+ } else {
72
+ throw error;
73
+ }
74
+ }),
75
+ getOne: (resource, params) => baseDataProvider.getOne(resource, params),
76
+ getMany: (resource, params) => baseDataProvider.getMany(resource, params),
77
+ getManyReference: (resource, params) =>
78
+ baseDataProvider.getManyReference(resource, params).catch((error) => {
79
+ if (error.code === 1) {
80
+ // undefined collection error: hide the error and return an empty list instead
81
+ return { data: [], total: 0 };
82
+ } else {
83
+ throw error;
84
+ }
85
+ }),
86
+
87
+ // update methods need to persist changes in localStorage
88
+ update: (resource, params) => {
89
+ updateLocalStorage(() => {
90
+ const index = data[resource].findIndex((item) => item.id === params.data.id);
91
+ data[resource][index] = {
92
+ ...params.data,
93
+ };
94
+ });
95
+ return baseDataProvider.update(resource, params);
96
+ },
97
+ updateMany: (resource, params) => {
98
+ updateLocalStorage(() => {
99
+ params.ids.forEach((id) => {
100
+ const index = data[resource]?.findIndex((record) => record.id === id);
101
+ data[resource][index] = {
102
+ ...data[resource][index],
103
+ ...params.data,
104
+ };
105
+ });
106
+ });
107
+ return baseDataProvider.updateMany(resource, params);
108
+ },
109
+ create: (resource, params) => {
110
+ // we need to call the fakerest provider first to get the generated id
111
+ return baseDataProvider.create(resource, params).then((response) => {
112
+ updateLocalStorage(() => {
113
+ if (!Object.prototype.hasOwnProperty.call(data, resource)) {
114
+ data[resource] = [];
115
+ }
116
+ data[resource].push(response.data);
117
+ });
118
+ return response;
119
+ });
120
+ },
121
+ delete: (resource, params) => {
122
+ updateLocalStorage(() => {
123
+ const index = data[resource]?.findIndex((record) => record.id === params.id);
124
+ pullAt(data[resource], [index]);
125
+ });
126
+ return baseDataProvider.delete(resource, params);
127
+ },
128
+ deleteMany: (resource, params) => {
129
+ updateLocalStorage(() => {
130
+ const indexes = params.ids.map((id) =>
131
+ data[resource]?.findIndex((record) => record.id === id)
132
+ );
133
+ pullAt(data[resource], indexes);
134
+ });
135
+ return baseDataProvider.deleteMany(resource, params);
136
+ },
137
+ };
138
+ }
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import DataContextProvider from '../contexts/DataContext';
3
+ import { MapComponentsProvider, MapLibreMap } from '@mapcomponents/react-maplibre';
4
+ import { Admin, CustomRoutes, defaultLightTheme } from 'react-admin';
5
+ import { dataProvider } from '../contexts/dataProvider';
6
+ import { Route } from 'react-router-dom';
7
+
8
+ export const ReactAdminDefaultDecorator = (Story: React.ComponentType, context: any) => (
9
+ <DataContextProvider>
10
+ <MapComponentsProvider>
11
+ <Admin
12
+ dataProvider={dataProvider}
13
+ layout={context.parameters?.layout}
14
+ theme={defaultLightTheme}
15
+ key={context.parameters?.name}
16
+ >
17
+ <CustomRoutes>
18
+ <Route path={'/'} element={<Story />} />
19
+ </CustomRoutes>
20
+ </Admin>
21
+ {!context.args.embeddedMap && (
22
+ <MapLibreMap
23
+ mapId="map_1"
24
+ options={{
25
+ zoom: 14.5,
26
+ style: 'https://wms.wheregroup.com/tileserver/style/klokantech-basic.json',
27
+ center: [7.080590113226776, 50.740545567043426],
28
+ }}
29
+ style={{
30
+ position: 'absolute',
31
+ top: 0,
32
+ right: 0,
33
+ left: 0,
34
+ bottom: 0,
35
+ }}
36
+ />
37
+ )}
38
+ </MapComponentsProvider>
39
+ </DataContextProvider>
40
+ );
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export {default as RaGeospatialInput} from "./components/GeospatialInput.js";
2
- export {default as RaGeospatialShow} from "./components/GeospatialShow.js";
1
+ export { default as RaGeospatialInput } from './components/GeospatialInput.js';
2
+ export { default as RaGeospatialShow } from './components/GeospatialShow.js';
@@ -0,0 +1,90 @@
1
+ import * as React from 'react';
2
+ import { useState } from 'react';
3
+ import { Box, IconButton, styled } from '@mui/material';
4
+ import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
5
+ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
6
+ import { AppBar, Menu, Sidebar, useSidebarState } from 'react-admin';
7
+
8
+ const Root = styled('div')(() => ({
9
+ display: 'flex',
10
+ flexDirection: 'column',
11
+ zIndex: 1,
12
+ minHeight: '100%',
13
+ position: 'relative',
14
+ backgroundColor: 'transparent',
15
+ pointerEvents: 'none',
16
+ }));
17
+
18
+ const AppFrame = styled('div')(() => ({
19
+ display: 'flex',
20
+ flexDirection: 'column',
21
+ }));
22
+
23
+ const ContentWithSidebar = styled('main')(() => ({
24
+ display: 'flex',
25
+ flexGrow: 1,
26
+ marginTop: '3em',
27
+ }));
28
+
29
+ const Content = styled('div')(() => ({
30
+ display: 'flex',
31
+ flexDirection: 'row',
32
+ justifyContent: 'center',
33
+ maxHeight: '50vh',
34
+ position: 'fixed',
35
+ bottom: '0',
36
+ width: '100%',
37
+ backgroundColor: '#fafafa',
38
+ overflow: 'auto',
39
+ pointerEvents: 'all',
40
+ boxShadow: '0px 0px 8px rgba(0,0,0,0.2)',
41
+ }));
42
+
43
+ const ContentWrapper = styled(Box)(() => ({
44
+ maxWidth: '600px',
45
+ width: '100%',
46
+ height: '100%',
47
+ }));
48
+
49
+ const GisLayout = ({ children, title }) => {
50
+ const [open] = useSidebarState();
51
+ const [contentOpen, setContentOpen] = useState(true);
52
+
53
+ React.useEffect(() => {
54
+ setContentOpen(true);
55
+ }, [children]);
56
+ return (
57
+ <Root>
58
+ <AppFrame>
59
+ <AppBar title={title} open={open} sx={{ pointerEvents: 'all' }} />
60
+ <ContentWithSidebar>
61
+ <Sidebar
62
+ sx={{
63
+ backgroundColor: '#f0f0f0',
64
+ pointerEvents: 'all',
65
+ overflow: 'hidden',
66
+ }}
67
+ >
68
+ <Menu />
69
+ </Sidebar>
70
+ <Content
71
+ sx={{
72
+ ...(contentOpen ? {} : { height: '40px', overflow: 'hidden' }),
73
+ }}
74
+ >
75
+ <IconButton
76
+ onClick={() => setContentOpen((val) => !val)}
77
+ sx={{ position: 'absolute', top: 0, zIndex: 100 }}
78
+ >
79
+ {contentOpen ? <KeyboardArrowDownIcon /> : <KeyboardArrowUpIcon />}
80
+ </IconButton>
81
+
82
+ <ContentWrapper>{children}</ContentWrapper>
83
+ </Content>
84
+ </ContentWithSidebar>
85
+ </AppFrame>
86
+ </Root>
87
+ );
88
+ };
89
+
90
+ export default GisLayout;
@@ -0,0 +1,42 @@
1
+ import { Edit, SimpleForm, TextInput, Show, SimpleShowLayout, TextField } from 'react-admin';
2
+ import GeospatialInput from '../components/GeospatialInput';
3
+ import GeospatialShow from '../components/GeospatialShow';
4
+ import raGeospatialProps from './raGeospatialProps';
5
+ import raGeospatialWebGisProps from './raGeospatialWebGisProps';
6
+
7
+ export const PoiEdit = () => (
8
+ <Edit mutationMode="optimistic" resource="pois" id="0" redirect={false}>
9
+ <SimpleForm>
10
+ <TextInput source="title" />
11
+ <TextInput source="geom" />
12
+ <GeospatialInput {...raGeospatialProps} type="point" />
13
+ </SimpleForm>
14
+ </Edit>
15
+ );
16
+ export const PoiEditWebGis = () => (
17
+ <Edit mutationMode="optimistic" resource="pois" id="0" redirect={false}>
18
+ <SimpleForm>
19
+ <TextInput source="title" />
20
+ <TextInput source="geom" />
21
+ <GeospatialInput {...raGeospatialWebGisProps} type="point" />
22
+ </SimpleForm>
23
+ </Edit>
24
+ );
25
+ export const PoiShow = () => (
26
+ <Show resource="pois" id="0">
27
+ <SimpleShowLayout>
28
+ <TextField source="id" />
29
+ <TextField source="title" />
30
+ <GeospatialShow {...raGeospatialProps} />
31
+ </SimpleShowLayout>
32
+ </Show>
33
+ );
34
+ export const PoiShowWebGis = () => (
35
+ <Show resource="pois" id="0">
36
+ <SimpleShowLayout>
37
+ <TextField source="id" />
38
+ <TextField source="title" />
39
+ <GeospatialShow {...raGeospatialWebGisProps} />
40
+ </SimpleShowLayout>
41
+ </Show>
42
+ );
@@ -0,0 +1,42 @@
1
+ import { Edit, SimpleForm, TextInput, Show, SimpleShowLayout, TextField } from 'react-admin';
2
+ import GeospatialInput from '../components/GeospatialInput';
3
+ import GeospatialShow from '../components/GeospatialShow';
4
+ import raGeospatialProps from './raGeospatialProps';
5
+ import raGeospatialWebGisProps from './raGeospatialWebGisProps';
6
+
7
+ export const PropertyEdit = () => (
8
+ <Edit mutationMode="optimistic" resource="properties" id="0" redirect={false}>
9
+ <SimpleForm>
10
+ <TextInput source="title" />
11
+ <TextInput source="geom" />
12
+ <GeospatialInput {...raGeospatialProps} type="polygon" />
13
+ </SimpleForm>
14
+ </Edit>
15
+ );
16
+ export const PropertyEditWebGis = () => (
17
+ <Edit mutationMode="optimistic" resource="properties" id="0" redirect={false}>
18
+ <SimpleForm>
19
+ <TextInput source="title" />
20
+ <TextInput source="geom" />
21
+ <GeospatialInput {...raGeospatialWebGisProps} type="polygon" />
22
+ </SimpleForm>
23
+ </Edit>
24
+ );
25
+ export const PropertyShow = () => (
26
+ <Show resource="properties" id="0">
27
+ <SimpleShowLayout>
28
+ <TextField source="id" />
29
+ <TextField source="title" />
30
+ <GeospatialShow {...raGeospatialProps} />
31
+ </SimpleShowLayout>
32
+ </Show>
33
+ );
34
+ export const PropertyShowWebGis = () => (
35
+ <Show resource="properties" id="0">
36
+ <SimpleShowLayout>
37
+ <TextField source="id" />
38
+ <TextField source="title" />
39
+ <GeospatialShow {...raGeospatialWebGisProps} />
40
+ </SimpleShowLayout>
41
+ </Show>
42
+ );
@@ -0,0 +1,42 @@
1
+ import { Edit, Show, SimpleForm, SimpleShowLayout, TextField, TextInput } from 'react-admin';
2
+ import GeospatialInput from '../components/GeospatialInput';
3
+ import GeospatialShow from '../components/GeospatialShow';
4
+ import raGeospatialProps from './raGeospatialProps';
5
+ import raGeospatialWebGisProps from './raGeospatialWebGisProps';
6
+
7
+ export const RouteEdit = () => (
8
+ <Edit mutationMode="optimistic" resource="routes" id="0" redirect={false}>
9
+ <SimpleForm>
10
+ <TextInput source="title" />
11
+ <TextInput source="geom" />
12
+ <GeospatialInput {...raGeospatialProps} type="line" />
13
+ </SimpleForm>
14
+ </Edit>
15
+ );
16
+ export const RouteEditWebGis = () => (
17
+ <Edit mutationMode="optimistic" resource="routes" id="0" redirect={false}>
18
+ <SimpleForm>
19
+ <TextInput source="title" />
20
+ <TextInput source="geom" />
21
+ <GeospatialInput {...raGeospatialWebGisProps} type="line" />
22
+ </SimpleForm>
23
+ </Edit>
24
+ );
25
+ export const RouteShow = () => (
26
+ <Show resource="routes" id="0">
27
+ <SimpleShowLayout>
28
+ <TextField source="id" />
29
+ <TextField source="title" />
30
+ <GeospatialShow {...raGeospatialProps} />
31
+ </SimpleShowLayout>
32
+ </Show>
33
+ );
34
+ export const RouteShowWebGis = () => (
35
+ <Show resource="routes" id="0">
36
+ <SimpleShowLayout>
37
+ <TextField source="id" />
38
+ <TextField source="title" />
39
+ <GeospatialShow {...raGeospatialWebGisProps} />
40
+ </SimpleShowLayout>
41
+ </Show>
42
+ );
@@ -0,0 +1,5 @@
1
+ export default {
2
+ MapLibreMapProps: { options: { zoom: 14, center: [7.0851268, 50.73884] as [number, number] } },
3
+ embeddedMap: true,
4
+ source: 'geom',
5
+ };
@@ -0,0 +1,5 @@
1
+ export default {
2
+ MapLibreMapProps: { options: { zoom: 14, center: [7.0851268, 50.73884] as [number, number] } },
3
+ embeddedMap: false,
4
+ source: 'geom',
5
+ };
package/src/types.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- declare module "@turf/helpers";
2
- declare module "@turf/turf";
1
+ declare module '@turf/helpers';
2
+ declare module '@turf/turf';
3
+ declare module 'wellknown';
@@ -0,0 +1,29 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "types": [
6
+ "node",
7
+ "@nx/react/typings/cssmodule.d.ts",
8
+ "@nx/react/typings/image.d.ts",
9
+ "vite/client"
10
+ ]
11
+ },
12
+ "exclude": [
13
+ "**/*.spec.ts",
14
+ "**/*.test.ts",
15
+ "**/*.spec.tsx",
16
+ "**/*.test.tsx",
17
+ "**/*.spec.js",
18
+ "**/*.test.js",
19
+ "**/*.spec.jsx",
20
+ "**/*.test.jsx",
21
+ "src/**/*.spec.ts",
22
+ "src/**/*.test.ts",
23
+ "**/*.stories.ts",
24
+ "**/*.stories.js",
25
+ "**/*.stories.jsx",
26
+ "**/*.stories.tsx"
27
+ ],
28
+ "include": ["src/**/*", "../react-maplibre/src/**/*"]
29
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,58 @@
1
+ /// <reference types='vitest' />
2
+ import { defineConfig } from 'vite';
3
+ import react from '@vitejs/plugin-react';
4
+ import dts from 'vite-plugin-dts';
5
+ import * as path from 'path';
6
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
7
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
8
+
9
+ export default defineConfig(() => ({
10
+ root: __dirname,
11
+ cacheDir: '../../node_modules/.vite/packages/ra-geospatial',
12
+ plugins: [
13
+ react(),
14
+ nxViteTsPaths(),
15
+ nxCopyAssetsPlugin(['*.md']),
16
+ dts({
17
+ entryRoot: 'src',
18
+ tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
19
+ pathsToAliases: false,
20
+ }),
21
+ ],
22
+ // Uncomment this if you are using workers.
23
+ // worker: {
24
+ // plugins: [ nxViteTsPaths() ],
25
+ // },
26
+ // Configuration for building your library.
27
+ // See: https://vitejs.dev/guide/build.html#library-mode
28
+ build: {
29
+ outDir: 'dist',
30
+ emptyOutDir: true,
31
+ reportCompressedSize: true,
32
+ commonjsOptions: {
33
+ transformMixedEsModules: true,
34
+ },
35
+ lib: {
36
+ // Could also be a dictionary or array of multiple entry points.
37
+ entry: 'src/index.ts',
38
+ name: '@mapcomponents/ra-geospatial',
39
+ fileName: 'index',
40
+ // Change this to the formats you want to support.
41
+ // Don't forget to update your package.json as well.
42
+ formats: ['es' as const, 'cjs' as const],
43
+ },
44
+ sourcemap: true,
45
+ rollupOptions: {
46
+ // External packages that should not be bundled into your library.
47
+ external: [
48
+ 'react',
49
+ 'react-dom',
50
+ 'd3',
51
+ 'sql.js',
52
+ /* ...Object.keys(pkg.dependencies),
53
+ ...Object.keys(pkg.devDependencies),*/
54
+ ],
55
+ input: [path.join(__dirname, 'src/index.ts')],
56
+ },
57
+ },
58
+ }));