@mapcomponents/ra-geospatial 1.5.3 → 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.
Files changed (36) hide show
  1. package/.babelrc +12 -0
  2. package/.storybook/main.ts +19 -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 +1 -2
  9. package/assets/ra_geospatial_screenshots.png +0 -0
  10. package/eslint.config.cjs +3 -0
  11. package/package.json +28 -42
  12. package/project.json +8 -0
  13. package/src/components/GeospatialInput.stories.tsx +83 -0
  14. package/src/components/GeospatialInput.tsx +14 -17
  15. package/src/components/GeospatialInputMap.tsx +168 -163
  16. package/src/components/GeospatialShow.stories.tsx +84 -0
  17. package/src/components/GeospatialShow.tsx +15 -17
  18. package/src/components/GeospatialShowMap.tsx +53 -58
  19. package/src/contexts/DataContext.jsx +66 -0
  20. package/src/contexts/dataProvider.tsx +30 -0
  21. package/src/contexts/lsDataProvider.js +142 -0
  22. package/src/decorators/ReactAdminDefaultDecorator.tsx +41 -0
  23. package/src/index.ts +2 -2
  24. package/src/layout/GisLayout.jsx +97 -0
  25. package/src/ra_components/Poi.tsx +42 -0
  26. package/src/ra_components/Property.tsx +42 -0
  27. package/src/ra_components/Route.tsx +42 -0
  28. package/src/ra_components/raGeospatialProps.ts +5 -0
  29. package/src/ra_components/raGeospatialWebGisProps.ts +5 -0
  30. package/src/types.d.ts +3 -2
  31. package/tsconfig.json +7 -101
  32. package/tsconfig.lib.json +29 -0
  33. package/vite.config.ts +49 -0
  34. package/dist/index.esm.js +0 -157
  35. package/dist/index.esm.js.map +0 -1
  36. package/rollup.config.js +0 -50
@@ -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,142 @@
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
+
91
+ const index = data[resource].findIndex(item => item.id === params.data.id);
92
+ data[resource][index] = {
93
+ ...params.data,
94
+ };
95
+
96
+ });
97
+ return baseDataProvider.update(resource, params);
98
+ },
99
+ updateMany: (resource, params) => {
100
+ updateLocalStorage(() => {
101
+ params.ids.forEach((id) => {
102
+ const index = data[resource]?.findIndex((record) => record.id === id);
103
+ data[resource][index] = {
104
+ ...data[resource][index],
105
+ ...params.data,
106
+ };
107
+ });
108
+ });
109
+ return baseDataProvider.updateMany(resource, params);
110
+ },
111
+ create: (resource, params) => {
112
+ // we need to call the fakerest provider first to get the generated id
113
+ return baseDataProvider.create(resource, params).then((response) => {
114
+ updateLocalStorage(() => {
115
+ if (!Object.prototype.hasOwnProperty.call(data, resource)) {
116
+ data[resource] = [];
117
+ }
118
+ data[resource].push(response.data);
119
+ });
120
+ return response;
121
+ });
122
+ },
123
+ delete: (resource, params) => {
124
+ updateLocalStorage(() => {
125
+ const index = data[resource]?.findIndex(
126
+ (record) => record.id === params.id
127
+ );
128
+ pullAt(data[resource], [index]);
129
+ });
130
+ return baseDataProvider.delete(resource, params);
131
+ },
132
+ deleteMany: (resource, params) => {
133
+ updateLocalStorage(() => {
134
+ const indexes = params.ids.map((id) =>
135
+ data[resource]?.findIndex((record) => record.id === id)
136
+ );
137
+ pullAt(data[resource], indexes);
138
+ });
139
+ return baseDataProvider.deleteMany(resource, params);
140
+ },
141
+ };
142
+ };
@@ -0,0 +1,41 @@
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
+
9
+ export const ReactAdminDefaultDecorator = (Story: React.ComponentType, context: any) => (
10
+ <DataContextProvider>
11
+ <MapComponentsProvider>
12
+ <Admin
13
+ dataProvider={dataProvider}
14
+ layout={context.parameters?.layout}
15
+ theme={defaultLightTheme}
16
+ key={context.parameters?.name}
17
+ >
18
+ <CustomRoutes>
19
+ <Route path={'/'} element={<Story />} />
20
+ </CustomRoutes>
21
+ </Admin>
22
+ {!context.args.embeddedMap && (
23
+ <MapLibreMap
24
+ mapId="map_1"
25
+ options={{
26
+ zoom: 14.5,
27
+ style: 'https://wms.wheregroup.com/tileserver/style/klokantech-basic.json',
28
+ center: [7.080590113226776, 50.740545567043426],
29
+ }}
30
+ style={{
31
+ position: 'absolute',
32
+ top: 0,
33
+ right: 0,
34
+ left: 0,
35
+ bottom: 0,
36
+ }}
37
+ />
38
+ )}
39
+ </MapComponentsProvider>
40
+ </DataContextProvider>
41
+ );
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,97 @@
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')(({ theme }) => ({
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')(({ theme }) => ({
19
+ display: 'flex',
20
+ flexDirection: 'column',
21
+ }));
22
+
23
+ const ContentWithSidebar = styled('main')(({ theme }) => ({
24
+ display: 'flex',
25
+ flexGrow: 1,
26
+ marginTop: '3em',
27
+ }));
28
+
29
+ const Content = styled('div')(({ theme }) => ({
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)(({ theme }) => ({
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 ? (
80
+ <KeyboardArrowDownIcon />
81
+ ) : (
82
+ <KeyboardArrowUpIcon />
83
+ )}
84
+ </IconButton>
85
+
86
+ <ContentWrapper>
87
+ {children}
88
+ </ContentWrapper>
89
+ </Content>
90
+ </ContentWithSidebar>
91
+ </AppFrame>
92
+ </Root>
93
+ );
94
+ };
95
+
96
+
97
+ 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';
package/tsconfig.json CHANGED
@@ -1,103 +1,9 @@
1
1
  {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- "jsx": "react", /* Specify what JSX code is generated. */
17
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
- "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
-
27
- /* Modules */
28
- "module": "ES2015", /* Specify what module code is generated. */
29
- // "rootDir": "./", /* Specify the root folder within your source files. */
30
- "moduleResolution": "node16", /* Specify how TypeScript looks up a file from a given module specifier. */
31
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
- // "resolveJsonModule": true, /* Enable importing .json files. */
39
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
-
41
- /* JavaScript Support */
42
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
-
46
- /* Emit */
47
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
- "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
- // "outDir": "./", /* Specify an output folder for all emitted files. */
53
- // "removeComments": true, /* Disable emitting comments. */
54
- // "noEmit": true, /* Disable emitting files from a compilation. */
55
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
- // "newLine": "crlf", /* Set the newline character for emitting files. */
64
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
-
71
- /* Interop Constraints */
72
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
-
78
- /* Type Checking */
79
- "strict": true, /* Enable all strict type-checking options. */
80
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
-
99
- /* Completeness */
100
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
- }
2
+ "include": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.lib.json"
6
+ }
7
+ ],
8
+ "extends": "../../tsconfig.base.json"
103
9
  }
@@ -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/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
29
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,49 @@
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/libs/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/libs/ra-geospatial',
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],
43
+ },
44
+ rollupOptions: {
45
+ // External packages that should not be bundled into your library.
46
+ external: ['react', 'react-dom', 'react/jsx-runtime'],
47
+ },
48
+ },
49
+ }));