diff --git a/packages/geoview-core/public/locales/en/translation.json b/packages/geoview-core/public/locales/en/translation.json index ff1a9da905a..329baea0710 100644 --- a/packages/geoview-core/public/locales/en/translation.json +++ b/packages/geoview-core/public/locales/en/translation.json @@ -139,6 +139,7 @@ "reduceBtn": "Reduce", "features": "feature(s)", "featureFiltered": "features filtered", - "images": "Images" + "images": "Images", + "close": "Close" } } \ No newline at end of file diff --git a/packages/geoview-core/public/locales/fr/translation.json b/packages/geoview-core/public/locales/fr/translation.json index 4e0e0e1eba8..dc46b7294f3 100644 --- a/packages/geoview-core/public/locales/fr/translation.json +++ b/packages/geoview-core/public/locales/fr/translation.json @@ -137,6 +137,7 @@ "reduceBtn": "Réduire", "features": "Item(s)", "featureFiltered": "Item filtrée(s)", - "images": "Images" + "images": "Images", + "close": "Fermer" } } \ No newline at end of file diff --git a/packages/geoview-core/src/core/components/data-table/data-panel.tsx b/packages/geoview-core/src/core/components/data-table/data-panel.tsx index 078cd3a3b4e..5e5c92ce9e9 100644 --- a/packages/geoview-core/src/core/components/data-table/data-panel.tsx +++ b/packages/geoview-core/src/core/components/data-table/data-panel.tsx @@ -1,10 +1,9 @@ -import React, { useCallback, useEffect, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { useTheme } from '@mui/material/styles'; import { Projection } from 'ol/proj'; import { useTranslation } from 'react-i18next'; import { Box, - Grid, Typography, Paper, List, @@ -25,6 +24,7 @@ import MapDataTable, { MapDataTableData as MapDataTableDataProps } from './map-d import { getSxClasses } from './data-table-style'; import { GroupLayers } from './data-table-api'; import { TypeDisplayLanguage, TypeLocalizedString } from '@/geo/map/map-schema-types'; +import { DataTableGrid } from './data-table-grid'; import { useDataTableStoreActions, useDataTableStoreIsEnlargeDataTable, @@ -51,9 +51,11 @@ interface DatapanelProps { export function Datapanel({ layerData, mapId, projectionConfig, language }: DatapanelProps) { const { t } = useTranslation(); const theme = useTheme(); + const sxClasses = getSxClasses(theme); const [isLoading, setIsLoading] = useState(false); + const [isLayersPanelVisible, setIsLayersPanelVisible] = useState(false); const selectedLayerIndex = useDataTableStoreSelectedLayerIndex(); const isEnlargeDataTable = useDataTableStoreIsEnlargeDataTable(); @@ -64,6 +66,7 @@ export function Datapanel({ layerData, mapId, projectionConfig, language }: Data const handleListItemClick = useCallback((event: React.MouseEvent, index: number) => { setSelectedLayerIndex(index); setIsLoading(true); + setIsLayersPanelVisible(false); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -115,49 +118,52 @@ export function Datapanel({ layerData, mapId, projectionConfig, language }: Data sx={{ ...sxClasses.paper, border: selectedLayerIndex === index ? sxClasses.borderWithIndex : sxClasses.borderNone }} key={layerKey} > - - handleListItemClick(event, index)} - > - - - - - - {layerName![language]} - - - {getFeaturesOfLayer(layerKey, index)} - - {isMapFilteredSelectedForLayer(layerKey) && } - - - - - + + + handleListItemClick(event, index)} > - - - - - + + + + + {layerName![language]} + + + {getFeaturesOfLayer(layerKey, index)} + + {isMapFilteredSelectedForLayer(layerKey) && } + + + + + + + + + + + + ))} @@ -176,25 +182,63 @@ export function Datapanel({ layerData, mapId, projectionConfig, language }: Data return ( - - + + {t('dataTable.leftPanelHeading')} - - - - - - - - + {!isLoading && ( + + )} + + + + + {renderList()} - - + + ( - + {index === selectedLayerIndex ? ( {layerData[index].features.length ? ( @@ -224,8 +268,8 @@ export function Datapanel({ layerData, mapId, projectionConfig, language }: Data )} ))} - - + + ); } diff --git a/packages/geoview-core/src/core/components/data-table/data-table-grid.tsx b/packages/geoview-core/src/core/components/data-table/data-table-grid.tsx new file mode 100644 index 00000000000..3116cd65c7d --- /dev/null +++ b/packages/geoview-core/src/core/components/data-table/data-table-grid.tsx @@ -0,0 +1,77 @@ +import { ReactNode } from 'react'; +import { GridProps } from '@mui/material'; +import { useTheme } from '@mui/material/styles'; +import { Grid } from '@/ui'; + +interface DataTableGridProps extends GridProps { + children: ReactNode; +} + +interface DataTableGridPanelProps extends GridProps { + children: ReactNode; + isLayersPanelVisible: boolean; +} + +/** + * Create Grid Container + * @param {ReactNode} children children to be renderer + * @returns JSX.Element + */ +function DataTableGridRoot({ children, ...rest }: DataTableGridProps) { + return ( + + {children} + + ); +} + +/** + * Create Left Panel for Data table grid. + * @param {ReactNode} children child elements to be rendered + * @param {boolean} isLayersPanelVisible panel visibility + * @returns JSX.Element + */ +function DataTableGridLeftPanel({ children, isLayersPanelVisible = false, ...rest }: DataTableGridPanelProps) { + const theme = useTheme(); + + return ( + + {children} + + ); +} + +/** + * Create Right Panel for Data table grid. + * @param {ReactNode} children child elements to be rendered + * @param {boolean} isLayersPanelVisible panel visibility + * @returns JSX.Element + */ +function DataTableGridRightPanel({ children, isLayersPanelVisible = false, ...rest }: DataTableGridPanelProps) { + const theme = useTheme(); + return ( + + {children} + + ); +} + +export const DataTableGrid = { + Root: DataTableGridRoot, + Left: DataTableGridLeftPanel, + Right: DataTableGridRightPanel, +}; diff --git a/packages/geoview-core/src/core/components/data-table/data-table.tsx b/packages/geoview-core/src/core/components/data-table/data-table.tsx index 80fbbd6c2e2..eb64f207ff5 100644 --- a/packages/geoview-core/src/core/components/data-table/data-table.tsx +++ b/packages/geoview-core/src/core/components/data-table/data-table.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useRef, useState } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { MaterialReactTable, diff --git a/packages/geoview-core/src/core/components/data-table/export-button.tsx b/packages/geoview-core/src/core/components/data-table/export-button.tsx index 2b52a0380b4..779da02538b 100644 --- a/packages/geoview-core/src/core/components/data-table/export-button.tsx +++ b/packages/geoview-core/src/core/components/data-table/export-button.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement } from 'react'; +import { ReactElement, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { ExportToCsv } from 'export-to-csv'; import { type MRT_ColumnDef as MRTColumnDef } from 'material-react-table'; @@ -22,7 +22,7 @@ interface ExportButtonProps { */ function ExportButton({ rows, columns, children }: ExportButtonProps): JSX.Element { const { t } = useTranslation(); - const [anchorEl, setAnchorEl] = React.useState(null); + const [anchorEl, setAnchorEl] = useState(null); const open = Boolean(anchorEl); /** diff --git a/packages/geoview-core/src/core/components/data-table/filter-map.tsx b/packages/geoview-core/src/core/components/data-table/filter-map.tsx index 20832a49b22..272b3dbe9a7 100644 --- a/packages/geoview-core/src/core/components/data-table/filter-map.tsx +++ b/packages/geoview-core/src/core/components/data-table/filter-map.tsx @@ -1,6 +1,6 @@ -import React from 'react'; import { useTranslation } from 'react-i18next'; -import { Switch, useTheme } from '@mui/material'; +import { Switch } from '@mui/material'; +import { useTheme } from '@mui/material/styles'; import { Tooltip } from '@/ui'; import { getSxClasses } from './data-table-style'; import { diff --git a/packages/geoview-core/src/core/components/data-table/json-export-button.tsx b/packages/geoview-core/src/core/components/data-table/json-export-button.tsx index 6a3224e2a47..e8f70750aa6 100644 --- a/packages/geoview-core/src/core/components/data-table/json-export-button.tsx +++ b/packages/geoview-core/src/core/components/data-table/json-export-button.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { useTranslation } from 'react-i18next'; import { toLonLat, Projection } from 'ol/proj'; import { Geometry, Point, Polygon, LineString, MultiPoint } from 'ol/geom'; diff --git a/packages/geoview-core/src/core/components/data-table/map-data-table.tsx b/packages/geoview-core/src/core/components/data-table/map-data-table.tsx index 02fac5ac6df..95396d6d408 100644 --- a/packages/geoview-core/src/core/components/data-table/map-data-table.tsx +++ b/packages/geoview-core/src/core/components/data-table/map-data-table.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useMemo, useRef, useState, memo, ReactNode } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState, memo, ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; import debounce from 'lodash/debounce'; import startCase from 'lodash/startCase'; @@ -26,7 +26,8 @@ import { } from 'material-react-table'; import { Projection } from 'ol/proj'; import { Extent } from 'ol/extent'; -import { darken, useTheme } from '@mui/material'; +import { darken } from '@mui/material'; +import { useTheme } from '@mui/material/styles'; import { difference } from 'lodash'; import { getUid } from 'ol/util'; import { Box, Button, IconButton, Tooltip, ZoomInSearchIcon } from '@/ui'; diff --git a/packages/geoview-core/src/core/components/layers/layers-style.ts b/packages/geoview-core/src/core/components/layers/layers-style.ts index fd791cebfad..d69d5e937d1 100644 --- a/packages/geoview-core/src/core/components/layers/layers-style.ts +++ b/packages/geoview-core/src/core/components/layers/layers-style.ts @@ -141,6 +141,6 @@ export const getSxClasses = (theme: Theme) => ({ fontSize: 16, noWrap: true, marginLeft: 20, - } - } + }, + }, });