@red-hat-developer-hub/backstage-plugin-adoption-insights 0.0.4 → 0.2.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.
- package/CHANGELOG.md +25 -0
- package/dist/components/ActiveUsers/ActiveUsers.esm.js +106 -89
- package/dist/components/ActiveUsers/ActiveUsers.esm.js.map +1 -1
- package/dist/components/ActiveUsers/CustomLegend.esm.js +40 -35
- package/dist/components/ActiveUsers/CustomLegend.esm.js.map +1 -1
- package/dist/components/ActiveUsers/CustomTooltip.esm.js +68 -57
- package/dist/components/ActiveUsers/CustomTooltip.esm.js.map +1 -1
- package/dist/components/ActiveUsers/ExportCSVButton.esm.js +26 -25
- package/dist/components/ActiveUsers/ExportCSVButton.esm.js.map +1 -1
- package/dist/components/AdoptionInsightsPage/AdoptionInsightsPage.esm.js +13 -2
- package/dist/components/AdoptionInsightsPage/AdoptionInsightsPage.esm.js.map +1 -1
- package/dist/components/CardFooter/TableFooterPagination.esm.js +42 -42
- package/dist/components/CardFooter/TableFooterPagination.esm.js.map +1 -1
- package/dist/components/CardWrapper/CardWrapper.esm.js +29 -24
- package/dist/components/CardWrapper/CardWrapper.esm.js.map +1 -1
- package/dist/components/CatalogEntities/CatalogEntities.esm.js +96 -92
- package/dist/components/CatalogEntities/CatalogEntities.esm.js.map +1 -1
- package/dist/components/CatalogEntities/FilterDropdown.esm.js +22 -17
- package/dist/components/CatalogEntities/FilterDropdown.esm.js.map +1 -1
- package/dist/components/Common/CustomCursor.esm.js +2 -2
- package/dist/components/Common/CustomCursor.esm.js.map +1 -1
- package/dist/components/Common/EmptyChartState.esm.js +2 -2
- package/dist/components/Common/EmptyChartState.esm.js.map +1 -1
- package/dist/components/Common/PermissionRequiredIcon.esm.js +2 -2
- package/dist/components/Common/PermissionRequiredIcon.esm.js.map +1 -1
- package/dist/components/Common/PermissionRequiredState.esm.js +29 -23
- package/dist/components/Common/PermissionRequiredState.esm.js.map +1 -1
- package/dist/components/Header/DateRangeContext.esm.js +7 -6
- package/dist/components/Header/DateRangeContext.esm.js.map +1 -1
- package/dist/components/Header/DateRangePicker.esm.js +67 -59
- package/dist/components/Header/DateRangePicker.esm.js.map +1 -1
- package/dist/components/Header/Header.esm.js +116 -106
- package/dist/components/Header/Header.esm.js.map +1 -1
- package/dist/components/Plugins/Plugins.esm.js +74 -64
- package/dist/components/Plugins/Plugins.esm.js.map +1 -1
- package/dist/components/Searches/CustomTooltip.esm.js +41 -36
- package/dist/components/Searches/CustomTooltip.esm.js.map +1 -1
- package/dist/components/Searches/Searches.esm.js +85 -74
- package/dist/components/Searches/Searches.esm.js.map +1 -1
- package/dist/components/Techdocs/Techdocs.esm.js +85 -81
- package/dist/components/Techdocs/Techdocs.esm.js.map +1 -1
- package/dist/components/Templates/Templates.esm.js +74 -70
- package/dist/components/Templates/Templates.esm.js.map +1 -1
- package/dist/components/Users/Info.esm.js +12 -12
- package/dist/components/Users/Info.esm.js.map +1 -1
- package/dist/components/Users/Tooltip.esm.js +27 -23
- package/dist/components/Users/Tooltip.esm.js.map +1 -1
- package/dist/components/Users/Users.esm.js +119 -95
- package/dist/components/Users/Users.esm.js.map +1 -1
- package/dist/hooks/useActiveUsers.esm.js +5 -5
- package/dist/hooks/useActiveUsers.esm.js.map +1 -1
- package/dist/hooks/useCatalogEntities.esm.js +5 -5
- package/dist/hooks/useCatalogEntities.esm.js.map +1 -1
- package/dist/hooks/usePlugins.esm.js +5 -5
- package/dist/hooks/usePlugins.esm.js.map +1 -1
- package/dist/hooks/useSearches.esm.js +5 -5
- package/dist/hooks/useSearches.esm.js.map +1 -1
- package/dist/hooks/useTechdocs.esm.js +5 -5
- package/dist/hooks/useTechdocs.esm.js.map +1 -1
- package/dist/hooks/useTemplates.esm.js +5 -5
- package/dist/hooks/useTemplates.esm.js.map +1 -1
- package/dist/hooks/useUsers.esm.js +5 -5
- package/dist/hooks/useUsers.esm.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/package.json +18 -17
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CatalogEntities.esm.js","sources":["../../../src/components/CatalogEntities/CatalogEntities.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport { ResponseErrorPanel } from '@backstage/core-components';\nimport Box from '@mui/material/Box';\nimport { SelectChangeEvent } from '@mui/material/Select';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableFooter from '@mui/material/TableFooter';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Link from '@mui/material/Link';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport { useRouteRef } from '@backstage/core-plugin-api';\n\nimport CardWrapper from '../CardWrapper';\nimport {\n CATALOG_ENTITIES_TABLE_HEADERS,\n CATALOG_ENTITIES_TITLE,\n} from '../../utils/constants';\nimport { useCatalogEntities } from '../../hooks/useCatalogEntities';\nimport TableFooterPagination from '../CardFooter';\nimport { getLastUsedDay, getUniqueCatalogEntityKinds } from '../../utils/utils';\nimport FilterDropdown from './FilterDropdown';\nimport EmptyChartState from '../Common/EmptyChartState';\n\nconst CatalogEntities = () => {\n const [page, setPage] = React.useState(0);\n const [limit] = React.useState(20);\n const [rowsPerPage, setRowsPerPage] = React.useState(3);\n const [selectedOption, setSelectedOption] = React.useState('');\n const [uniqueCatalogEntityKinds, setUniqueCatalogEntityKinds] =\n React.useState<string[]>([]);\n\n const entityLink = useRouteRef(entityRouteRef);\n\n const { catalogEntities, loading, error } = useCatalogEntities({\n limit,\n kind: selectedOption === 'All' ? '' : selectedOption.toLocaleLowerCase(),\n });\n\n React.useEffect(() => {\n if (\n catalogEntities?.data?.length > 0 &&\n uniqueCatalogEntityKinds?.length === 0\n ) {\n const uniqueKinds = getUniqueCatalogEntityKinds(catalogEntities.data);\n setUniqueCatalogEntityKinds(uniqueKinds);\n }\n }, [catalogEntities, uniqueCatalogEntityKinds]);\n\n const handleChangePage = React.useCallback(\n (_event: unknown, newPage: number) => {\n setPage(newPage);\n },\n [],\n );\n\n const handleChangeRowsPerPage = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setRowsPerPage(+event.target.value);\n setPage(0);\n },\n [],\n );\n\n const handleChange = React.useCallback((event: SelectChangeEvent<string>) => {\n setSelectedOption(event.target.value);\n }, []);\n\n const visibleCatalogEntities = React.useMemo(() => {\n return catalogEntities.data\n ?.filter(entity => {\n if (selectedOption && selectedOption !== 'All') {\n return (\n entity.kind.toLocaleLowerCase() ===\n selectedOption.toLocaleLowerCase()\n );\n }\n return true;\n })\n .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage);\n }, [catalogEntities, page, rowsPerPage, selectedOption]);\n\n if (error) {\n return (\n <CardWrapper title={CATALOG_ENTITIES_TITLE}>\n <ResponseErrorPanel error={error} />\n </CardWrapper>\n );\n }\n\n if (\n (!visibleCatalogEntities || visibleCatalogEntities?.length === 0) &&\n !loading\n ) {\n return (\n <CardWrapper title={CATALOG_ENTITIES_TITLE}>\n <Box\n display=\"flex\"\n justifyContent=\"center\"\n alignItems=\"center\"\n height={200}\n >\n <EmptyChartState />\n </Box>\n </CardWrapper>\n );\n }\n\n return (\n <CardWrapper\n title={CATALOG_ENTITIES_TITLE}\n filter={\n <FilterDropdown\n selectedOption={selectedOption}\n handleChange={handleChange}\n uniqueCatalogEntityKinds={uniqueCatalogEntityKinds}\n />\n }\n >\n <Table aria-labelledby=\"Catalog entities\" sx={{ width: '100%' }}>\n <TableHead>\n <TableRow>\n {CATALOG_ENTITIES_TABLE_HEADERS.map(header => (\n <TableCell\n key={header.id}\n align=\"left\"\n sx={{\n borderBottom: theme => `1px solid ${theme.palette.grey[300]}`,\n width: '25%',\n }}\n >\n {header.title}\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {loading ? (\n <TableRow>\n <TableCell\n colSpan={CATALOG_ENTITIES_TABLE_HEADERS.length}\n align=\"center\"\n >\n <CircularProgress />\n </TableCell>\n </TableRow>\n ) : (\n visibleCatalogEntities?.map(entity => (\n <TableRow\n key={`${entity.kind}-${entity.name}`}\n sx={{\n '&:nth-of-type(odd)': { backgroundColor: 'inherit' },\n borderBottom: theme => `1px solid ${theme.palette.grey[300]}`,\n }}\n >\n <TableCell sx={{ width: '25%' }}>\n <Link\n component=\"a\"\n href={entityLink({\n kind: entity.kind,\n namespace: entity.namespace,\n name: entity.name,\n })}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n sx={{\n textDecoration: 'none',\n '&:hover': {\n textDecoration: 'none',\n },\n }}\n >\n {entity.name ?? '--'}\n </Link>\n </TableCell>\n <TableCell sx={{ width: '25%' }}>\n {entity.kind?.charAt(0).toLocaleUpperCase('en-US') +\n entity.kind?.slice(1) || '--'}\n </TableCell>\n <TableCell sx={{ width: '25%' }}>\n {getLastUsedDay(entity.last_used) ?? '--'}\n </TableCell>\n <TableCell sx={{ width: '25%' }}>\n {Number(entity.count).toLocaleString() ?? '--'}\n </TableCell>\n </TableRow>\n ))\n )}\n </TableBody>\n <TableFooter>\n <TableRow>\n <TableCell\n colSpan={CATALOG_ENTITIES_TABLE_HEADERS.length}\n sx={{ padding: 0 }}\n >\n <TableFooterPagination\n count={catalogEntities.data?.length}\n rowsPerPage={rowsPerPage}\n page={page}\n handleChangePage={handleChangePage}\n handleChangeRowsPerPage={handleChangeRowsPerPage}\n />\n </TableCell>\n </TableRow>\n </TableFooter>\n </Table>\n </CardWrapper>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,EAAI,EAAE,KAAA,EAAO,KAAM,EAAA,EAAA,EAC3B,cAAe,CAAA,MAAA,CAAO,SAAS,CAAA,IAAK,IACvC,CAAA;AAAA,sBACCA,cAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAU,EAAI,EAAA,EAAE,KAAO,EAAA,KAAA,EACrB,EAAA,EAAA,MAAA,CAAO,MAAO,CAAA,KAAK,CAAE,CAAA,cAAA,MAAoB,IAC5C;AAAA,KAEH,CAEL,CAAA,kBACCA,cAAA,CAAA,aAAA,CAAA,WAAA,EAAA,IAAA,+CACE,QACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,SAAS,8BAA+B,CAAA,MAAA;AAAA,QACxC,EAAA,EAAI,EAAE,OAAA,EAAS,CAAE;AAAA,OAAA;AAAA,sBAEjBA,cAAA,CAAA,aAAA;AAAA,QAAC,qBAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAO,gBAAgB,IAAM,EAAA,MAAA;AAAA,UAC7B,WAAA;AAAA,UACA,IAAA;AAAA,UACA,gBAAA;AAAA,UACA;AAAA;AAAA;AACF,KAEJ,CACF,CACF;AAAA,GACF;AAEJ;;;;"}
|
1
|
+
{"version":3,"file":"CatalogEntities.esm.js","sources":["../../../src/components/CatalogEntities/CatalogEntities.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useEffect, useMemo, useCallback } from 'react';\nimport type { ChangeEvent } from 'react';\n\nimport { ResponseErrorPanel } from '@backstage/core-components';\nimport Box from '@mui/material/Box';\nimport { SelectChangeEvent } from '@mui/material/Select';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableFooter from '@mui/material/TableFooter';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Link from '@mui/material/Link';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport { useRouteRef } from '@backstage/core-plugin-api';\n\nimport CardWrapper from '../CardWrapper';\nimport {\n CATALOG_ENTITIES_TABLE_HEADERS,\n CATALOG_ENTITIES_TITLE,\n} from '../../utils/constants';\nimport { useCatalogEntities } from '../../hooks/useCatalogEntities';\nimport TableFooterPagination from '../CardFooter';\nimport { getLastUsedDay, getUniqueCatalogEntityKinds } from '../../utils/utils';\nimport FilterDropdown from './FilterDropdown';\nimport EmptyChartState from '../Common/EmptyChartState';\n\nconst CatalogEntities = () => {\n const [page, setPage] = useState(0);\n const [limit] = useState(20);\n const [rowsPerPage, setRowsPerPage] = useState(3);\n const [selectedOption, setSelectedOption] = useState('');\n const [uniqueCatalogEntityKinds, setUniqueCatalogEntityKinds] = useState<\n string[]\n >([]);\n\n const entityLink = useRouteRef(entityRouteRef);\n\n const { catalogEntities, loading, error } = useCatalogEntities({\n limit,\n kind: selectedOption === 'All' ? '' : selectedOption.toLocaleLowerCase(),\n });\n\n useEffect(() => {\n if (\n catalogEntities?.data?.length > 0 &&\n uniqueCatalogEntityKinds?.length === 0\n ) {\n const uniqueKinds = getUniqueCatalogEntityKinds(catalogEntities.data);\n setUniqueCatalogEntityKinds(uniqueKinds);\n }\n }, [catalogEntities, uniqueCatalogEntityKinds]);\n\n const handleChangePage = useCallback((_event: unknown, newPage: number) => {\n setPage(newPage);\n }, []);\n\n const handleChangeRowsPerPage = useCallback(\n (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setRowsPerPage(+event.target.value);\n setPage(0);\n },\n [],\n );\n\n const handleChange = useCallback((event: SelectChangeEvent<string>) => {\n setSelectedOption(event.target.value);\n }, []);\n\n const visibleCatalogEntities = useMemo(() => {\n return catalogEntities.data\n ?.filter(entity => {\n if (selectedOption && selectedOption !== 'All') {\n return (\n entity.kind.toLocaleLowerCase() ===\n selectedOption.toLocaleLowerCase()\n );\n }\n return true;\n })\n .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage);\n }, [catalogEntities, page, rowsPerPage, selectedOption]);\n\n if (error) {\n return (\n <CardWrapper title={CATALOG_ENTITIES_TITLE}>\n <ResponseErrorPanel error={error} />\n </CardWrapper>\n );\n }\n\n if (\n (!visibleCatalogEntities || visibleCatalogEntities?.length === 0) &&\n !loading\n ) {\n return (\n <CardWrapper title={CATALOG_ENTITIES_TITLE}>\n <Box\n display=\"flex\"\n justifyContent=\"center\"\n alignItems=\"center\"\n height={200}\n >\n <EmptyChartState />\n </Box>\n </CardWrapper>\n );\n }\n\n return (\n <CardWrapper\n title={CATALOG_ENTITIES_TITLE}\n filter={\n <FilterDropdown\n selectedOption={selectedOption}\n handleChange={handleChange}\n uniqueCatalogEntityKinds={uniqueCatalogEntityKinds}\n />\n }\n >\n <Table aria-labelledby=\"Catalog entities\" sx={{ width: '100%' }}>\n <TableHead>\n <TableRow>\n {CATALOG_ENTITIES_TABLE_HEADERS.map(header => (\n <TableCell\n key={header.id}\n align=\"left\"\n sx={{\n borderBottom: theme => `1px solid ${theme.palette.grey[300]}`,\n width: '25%',\n }}\n >\n {header.title}\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {loading ? (\n <TableRow>\n <TableCell\n colSpan={CATALOG_ENTITIES_TABLE_HEADERS.length}\n align=\"center\"\n >\n <CircularProgress />\n </TableCell>\n </TableRow>\n ) : (\n visibleCatalogEntities?.map(entity => (\n <TableRow\n key={`${entity.kind}-${entity.name}`}\n sx={{\n '&:nth-of-type(odd)': { backgroundColor: 'inherit' },\n borderBottom: theme => `1px solid ${theme.palette.grey[300]}`,\n }}\n >\n <TableCell sx={{ width: '25%' }}>\n <Link\n component=\"a\"\n href={entityLink({\n kind: entity.kind,\n namespace: entity.namespace,\n name: entity.name,\n })}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n sx={{\n textDecoration: 'none',\n '&:hover': {\n textDecoration: 'none',\n },\n }}\n >\n {entity.name ?? '--'}\n </Link>\n </TableCell>\n <TableCell sx={{ width: '25%' }}>\n {entity.kind?.charAt(0).toLocaleUpperCase('en-US') +\n entity.kind?.slice(1) || '--'}\n </TableCell>\n <TableCell sx={{ width: '25%' }}>\n {getLastUsedDay(entity.last_used) ?? '--'}\n </TableCell>\n <TableCell sx={{ width: '25%' }}>\n {Number(entity.count).toLocaleString() ?? '--'}\n </TableCell>\n </TableRow>\n ))\n )}\n </TableBody>\n <TableFooter>\n <TableRow>\n <TableCell\n colSpan={CATALOG_ENTITIES_TABLE_HEADERS.length}\n sx={{ padding: 0 }}\n >\n <TableFooterPagination\n count={catalogEntities.data?.length}\n rowsPerPage={rowsPerPage}\n page={page}\n handleChangePage={handleChangePage}\n handleChangeRowsPerPage={handleChangeRowsPerPage}\n />\n </TableCell>\n </TableRow>\n </TableFooter>\n </Table>\n </CardWrapper>\n );\n};\n\nexport default CatalogEntities;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,kBAAkB,MAAM;AAC5B,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,CAAC,CAAA;AAClC,EAAA,MAAM,CAAC,KAAK,CAAI,GAAA,QAAA,CAAS,EAAE,CAAA;AAC3B,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAChD,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAS,EAAE,CAAA;AACvD,EAAA,MAAM,CAAC,wBAA0B,EAAA,2BAA2B,CAAI,GAAA,QAAA,CAE9D,EAAE,CAAA;AAEJ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QAAA,kBAAA,GAAA;AAAA,cAAC,qBAAA;AAAA,cAAA;AAAA,gBACC,KAAA,EAAO,gBAAgB,IAAM,EAAA,MAAA;AAAA,gBAC7B,WAAA;AAAA,gBACA,IAAA;AAAA,gBACA,gBAAA;AAAA,gBACA;AAAA;AAAA;AACF;AAAA,WAEJ,CACF,EAAA;AAAA,OACF,EAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
2
2
|
import Box from '@mui/material/Box';
|
3
3
|
import FormControl from '@mui/material/FormControl';
|
4
4
|
import InputLabel from '@mui/material/InputLabel';
|
@@ -10,23 +10,28 @@ const FilterDropdown = ({
|
|
10
10
|
handleChange,
|
11
11
|
uniqueCatalogEntityKinds
|
12
12
|
}) => {
|
13
|
-
return /* @__PURE__ */
|
14
|
-
Select,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
return /* @__PURE__ */ jsx(Box, { sx: { m: 2, minWidth: 160 }, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, children: [
|
14
|
+
/* @__PURE__ */ jsx(InputLabel, { id: "kind-select", children: "Select kind" }),
|
15
|
+
/* @__PURE__ */ jsxs(
|
16
|
+
Select,
|
17
|
+
{
|
18
|
+
labelId: "kind-select",
|
19
|
+
renderValue: (selected) => selected.length === 0 ? "Select kind" : selected,
|
20
|
+
value: selectedOption,
|
21
|
+
onChange: handleChange,
|
22
|
+
label: "Select kind",
|
23
|
+
MenuProps: {
|
24
|
+
MenuListProps: {
|
25
|
+
autoFocusItem: false
|
26
|
+
}
|
27
|
+
},
|
28
|
+
children: [
|
29
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "All", children: "All" }, "All"),
|
30
|
+
uniqueCatalogEntityKinds?.map((kind) => /* @__PURE__ */ jsx(MenuItem, { value: kind, children: kind }, kind))
|
31
|
+
]
|
25
32
|
}
|
26
|
-
|
27
|
-
|
28
|
-
uniqueCatalogEntityKinds?.map((kind) => /* @__PURE__ */ React__default.createElement(MenuItem, { key: kind, value: kind }, kind))
|
29
|
-
)));
|
33
|
+
)
|
34
|
+
] }) });
|
30
35
|
};
|
31
36
|
|
32
37
|
export { FilterDropdown as default };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FilterDropdown.esm.js","sources":["../../../src/components/CatalogEntities/FilterDropdown.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
1
|
+
{"version":3,"file":"FilterDropdown.esm.js","sources":["../../../src/components/CatalogEntities/FilterDropdown.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Box from '@mui/material/Box';\nimport FormControl from '@mui/material/FormControl';\nimport InputLabel from '@mui/material/InputLabel';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select, { SelectChangeEvent } from '@mui/material/Select';\n\nconst FilterDropdown = ({\n selectedOption,\n handleChange,\n uniqueCatalogEntityKinds,\n}: {\n selectedOption: string;\n handleChange: (event: SelectChangeEvent<string>) => void;\n uniqueCatalogEntityKinds: string[];\n}) => {\n return (\n <Box sx={{ m: 2, minWidth: 160 }}>\n <FormControl fullWidth>\n <InputLabel id=\"kind-select\">Select kind</InputLabel>\n <Select\n labelId=\"kind-select\"\n renderValue={(selected: string) =>\n selected.length === 0 ? 'Select kind' : selected\n }\n value={selectedOption}\n onChange={handleChange}\n label=\"Select kind\"\n MenuProps={{\n MenuListProps: {\n autoFocusItem: false,\n },\n }}\n >\n <MenuItem key=\"All\" value=\"All\">\n All\n </MenuItem>\n {uniqueCatalogEntityKinds?.map(kind => (\n <MenuItem key={kind} value={kind}>\n {kind}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Box>\n );\n};\n\nexport default FilterDropdown;\n"],"names":[],"mappings":";;;;;;;AAqBA,MAAM,iBAAiB,CAAC;AAAA,EACtB,cAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,uBACG,GAAA,CAAA,GAAA,EAAA,EAAI,EAAI,EAAA,EAAE,CAAG,EAAA,CAAA,EAAG,QAAU,EAAA,GAAA,EACzB,EAAA,QAAA,kBAAA,IAAA,CAAC,WAAY,EAAA,EAAA,SAAA,EAAS,IACpB,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,UAAA,EAAA,EAAW,EAAG,EAAA,aAAA,EAAc,QAAW,EAAA,aAAA,EAAA,CAAA;AAAA,oBACxC,IAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,aAAA;AAAA,QACR,aAAa,CAAC,QAAA,KACZ,QAAS,CAAA,MAAA,KAAW,IAAI,aAAgB,GAAA,QAAA;AAAA,QAE1C,KAAO,EAAA,cAAA;AAAA,QACP,QAAU,EAAA,YAAA;AAAA,QACV,KAAM,EAAA,aAAA;AAAA,QACN,SAAW,EAAA;AAAA,UACT,aAAe,EAAA;AAAA,YACb,aAAe,EAAA;AAAA;AACjB,SACF;AAAA,QAEA,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,QAAmB,EAAA,EAAA,KAAA,EAAM,KAAM,EAAA,QAAA,EAAA,KAAA,EAAA,EAAlB,KAEd,CAAA;AAAA,UACC,wBAAA,EAA0B,IAAI,CAC7B,IAAA,qBAAA,GAAA,CAAC,YAAoB,KAAO,EAAA,IAAA,EACzB,QADY,EAAA,IAAA,EAAA,EAAA,IAEf,CACD;AAAA;AAAA;AAAA;AACH,GAAA,EACF,CACF,EAAA,CAAA;AAEJ;;;;"}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
2
2
|
|
3
3
|
const CustomCursor = (props) => {
|
4
4
|
const { points, cursorHeight = 250 } = props;
|
5
5
|
if (!points || points.length === 0) return null;
|
6
|
-
return /* @__PURE__ */
|
6
|
+
return /* @__PURE__ */ jsx(
|
7
7
|
"line",
|
8
8
|
{
|
9
9
|
"data-testid": "custom-cursor-line",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CustomCursor.esm.js","sources":["../../../src/components/Common/CustomCursor.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\
|
1
|
+
{"version":3,"file":"CustomCursor.esm.js","sources":["../../../src/components/Common/CustomCursor.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst CustomCursor = (props: any) => {\n const { points, cursorHeight = 250 } = props;\n if (!points || points.length === 0) return null;\n\n return (\n <line\n data-testid=\"custom-cursor-line\"\n x1={points[0].x}\n y1={10}\n x2={points[0].x}\n y2={cursorHeight}\n stroke=\"gray\"\n strokeWidth={1}\n strokeDasharray=\"3 3\"\n />\n );\n};\n\nexport default CustomCursor;\n"],"names":[],"mappings":";;AAeM,MAAA,YAAA,GAAe,CAAC,KAAe,KAAA;AACnC,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAe,GAAA,GAAA,EAAQ,GAAA,KAAA;AACvC,EAAA,IAAI,CAAC,MAAA,IAAU,MAAO,CAAA,MAAA,KAAW,GAAU,OAAA,IAAA;AAE3C,EACE,uBAAA,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,aAAY,EAAA,oBAAA;AAAA,MACZ,EAAA,EAAI,MAAO,CAAA,CAAC,CAAE,CAAA,CAAA;AAAA,MACd,EAAI,EAAA,EAAA;AAAA,MACJ,EAAA,EAAI,MAAO,CAAA,CAAC,CAAE,CAAA,CAAA;AAAA,MACd,EAAI,EAAA,YAAA;AAAA,MACJ,MAAO,EAAA,MAAA;AAAA,MACP,WAAa,EAAA,CAAA;AAAA,MACb,eAAgB,EAAA;AAAA;AAAA,GAClB;AAEJ;;;;"}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
2
2
|
import Typography from '@mui/material/Typography';
|
3
3
|
|
4
4
|
const EmptyChartState = () => {
|
5
|
-
return /* @__PURE__ */
|
5
|
+
return /* @__PURE__ */ jsx(Typography, { children: "No results for this date range." });
|
6
6
|
};
|
7
7
|
|
8
8
|
export { EmptyChartState as default };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EmptyChartState.esm.js","sources":["../../../src/components/Common/EmptyChartState.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
1
|
+
{"version":3,"file":"EmptyChartState.esm.js","sources":["../../../src/components/Common/EmptyChartState.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Typography from '@mui/material/Typography';\n\nconst EmptyChartState = () => {\n return <Typography>No results for this date range.</Typography>;\n};\n\nexport default EmptyChartState;\n"],"names":[],"mappings":";;;AAiBA,MAAM,kBAAkB,MAAM;AAC5B,EAAO,uBAAA,GAAA,CAAC,cAAW,QAA+B,EAAA,iCAAA,EAAA,CAAA;AACpD;;;;"}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
2
2
|
import permissionRequired from '../../images/permission-required.svg';
|
3
3
|
|
4
4
|
const PermissionRequiredIcon = () => {
|
5
|
-
return /* @__PURE__ */
|
5
|
+
return /* @__PURE__ */ jsx("img", { src: permissionRequired, alt: "permission required icon" });
|
6
6
|
};
|
7
7
|
|
8
8
|
export { PermissionRequiredIcon };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PermissionRequiredIcon.esm.js","sources":["../../../src/components/Common/PermissionRequiredIcon.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
1
|
+
{"version":3,"file":"PermissionRequiredIcon.esm.js","sources":["../../../src/components/Common/PermissionRequiredIcon.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport permissionRequired from '../../images/permission-required.svg';\n\nexport const PermissionRequiredIcon = () => {\n return <img src={permissionRequired as any} alt=\"permission required icon\" />;\n};\n"],"names":[],"mappings":";;;AAiBO,MAAM,yBAAyB,MAAM;AAC1C,EAAA,uBAAQ,GAAA,CAAA,KAAA,EAAA,EAAI,GAAK,EAAA,kBAAA,EAA2B,KAAI,0BAA2B,EAAA,CAAA;AAC7E;;;;"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
2
2
|
import { EmptyState } from '@backstage/core-components';
|
3
3
|
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
4
4
|
import Box from '@mui/material/Box';
|
@@ -7,7 +7,7 @@ import Button from '@mui/material/Button';
|
|
7
7
|
import { PermissionRequiredIcon } from './PermissionRequiredIcon.esm.js';
|
8
8
|
|
9
9
|
const PermissionRequiredState = () => {
|
10
|
-
return /* @__PURE__ */
|
10
|
+
return /* @__PURE__ */ jsx(
|
11
11
|
Box,
|
12
12
|
{
|
13
13
|
sx: {
|
@@ -15,27 +15,33 @@ const PermissionRequiredState = () => {
|
|
15
15
|
height: "100%",
|
16
16
|
alignItems: "center",
|
17
17
|
padding: "100px"
|
18
|
-
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
{
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
18
|
+
},
|
19
|
+
children: /* @__PURE__ */ jsx(
|
20
|
+
EmptyState,
|
21
|
+
{
|
22
|
+
title: "Missing permissions",
|
23
|
+
description: /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", component: "span", children: [
|
24
|
+
"To view Adoption Insights plugin, contact your administrator to give the ",
|
25
|
+
/* @__PURE__ */ jsx("b", { children: "adoption-insights.events.read" }),
|
26
|
+
" permissions."
|
27
|
+
] }),
|
28
|
+
missing: { customImage: /* @__PURE__ */ jsx(PermissionRequiredIcon, {}) },
|
29
|
+
action: /* @__PURE__ */ jsxs(
|
30
|
+
Button,
|
31
|
+
{
|
32
|
+
variant: "outlined",
|
33
|
+
color: "primary",
|
34
|
+
target: "_blank",
|
35
|
+
href: "https://github.com/redhat-developer/rhdh-plugins/blob/main/workspaces/adoption-insights/plugins/adoption-insights/README.md#permission-framework-support",
|
36
|
+
children: [
|
37
|
+
"Read more \xA0 ",
|
38
|
+
/* @__PURE__ */ jsx(OpenInNewIcon, {})
|
39
|
+
]
|
40
|
+
}
|
41
|
+
)
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
39
45
|
);
|
40
46
|
};
|
41
47
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PermissionRequiredState.esm.js","sources":["../../../src/components/Common/PermissionRequiredState.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
1
|
+
{"version":3,"file":"PermissionRequiredState.esm.js","sources":["../../../src/components/Common/PermissionRequiredState.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { EmptyState } from '@backstage/core-components';\nimport OpenInNewIcon from '@mui/icons-material/OpenInNew';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport Button from '@mui/material/Button';\n\nimport { PermissionRequiredIcon } from './PermissionRequiredIcon';\n\nconst PermissionRequiredState = () => {\n return (\n <Box\n sx={{\n display: 'flex',\n height: '100%',\n alignItems: 'center',\n padding: '100px',\n }}\n >\n <EmptyState\n title=\"Missing permissions\"\n description={\n <Typography variant=\"subtitle1\" component=\"span\">\n To view Adoption Insights plugin, contact your administrator to give\n the <b>adoption-insights.events.read</b> permissions.\n </Typography>\n }\n missing={{ customImage: <PermissionRequiredIcon /> }}\n action={\n <Button\n variant=\"outlined\"\n color=\"primary\"\n target=\"_blank\"\n href=\"https://github.com/redhat-developer/rhdh-plugins/blob/main/workspaces/adoption-insights/plugins/adoption-insights/README.md#permission-framework-support\"\n >\n Read more <OpenInNewIcon />\n </Button>\n }\n />\n </Box>\n );\n};\n\nexport default PermissionRequiredState;\n"],"names":[],"mappings":";;;;;;;;AAuBA,MAAM,0BAA0B,MAAM;AACpC,EACE,uBAAA,GAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,OAAS,EAAA,MAAA;AAAA,QACT,MAAQ,EAAA,MAAA;AAAA,QACR,UAAY,EAAA,QAAA;AAAA,QACZ,OAAS,EAAA;AAAA,OACX;AAAA,MAEA,QAAA,kBAAA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,KAAM,EAAA,qBAAA;AAAA,UACN,6BACG,IAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,WAAA,EAAY,WAAU,MAAO,EAAA,QAAA,EAAA;AAAA,YAAA,2EAAA;AAAA,4BAE3C,GAAA,CAAC,OAAE,QAA6B,EAAA,+BAAA,EAAA,CAAA;AAAA,YAAI;AAAA,WAC1C,EAAA,CAAA;AAAA,UAEF,OAAS,EAAA,EAAE,WAAa,kBAAA,GAAA,CAAC,0BAAuB,CAAG,EAAA;AAAA,UACnD,MACE,kBAAA,IAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,OAAQ,EAAA,UAAA;AAAA,cACR,KAAM,EAAA,SAAA;AAAA,cACN,MAAO,EAAA,QAAA;AAAA,cACP,IAAK,EAAA,0JAAA;AAAA,cACN,QAAA,EAAA;AAAA,gBAAA,iBAAA;AAAA,oCACmB,aAAc,EAAA,EAAA;AAAA;AAAA;AAAA;AAClC;AAAA;AAEJ;AAAA,GACF;AAEJ;;;;"}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
2
|
+
import { useState, useMemo, createContext, useContext } from 'react';
|
2
3
|
|
3
4
|
const DateRangeContext = createContext(
|
4
5
|
void 0
|
@@ -6,10 +7,10 @@ const DateRangeContext = createContext(
|
|
6
7
|
const DateRangeProvider = ({
|
7
8
|
children
|
8
9
|
}) => {
|
9
|
-
const [startDateRange, setStartDateRange] =
|
10
|
-
const [endDateRange, setEndDateRange] =
|
11
|
-
const [isDefaultDateRange, setIsDefaultDateRange] =
|
12
|
-
const value =
|
10
|
+
const [startDateRange, setStartDateRange] = useState(null);
|
11
|
+
const [endDateRange, setEndDateRange] = useState(null);
|
12
|
+
const [isDefaultDateRange, setIsDefaultDateRange] = useState(true);
|
13
|
+
const value = useMemo(
|
13
14
|
() => ({
|
14
15
|
startDateRange,
|
15
16
|
endDateRange,
|
@@ -20,7 +21,7 @@ const DateRangeProvider = ({
|
|
20
21
|
}),
|
21
22
|
[startDateRange, endDateRange, isDefaultDateRange]
|
22
23
|
);
|
23
|
-
return /* @__PURE__ */
|
24
|
+
return /* @__PURE__ */ jsx(DateRangeContext.Provider, { value, children });
|
24
25
|
};
|
25
26
|
const useDateRange = () => {
|
26
27
|
const context = useContext(DateRangeContext);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DateRangeContext.esm.js","sources":["../../../src/components/Header/DateRangeContext.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
1
|
+
{"version":3,"file":"DateRangeContext.esm.js","sources":["../../../src/components/Header/DateRangeContext.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useState, useMemo, createContext, useContext } from 'react';\nimport type { FC, ReactNode } from 'react';\n\ninterface DateRange {\n startDateRange: Date | null;\n endDateRange: Date | null;\n setStartDateRange: (date: Date | null) => void;\n setEndDateRange: (date: Date | null) => void;\n isDefaultDateRange: boolean;\n setIsDefaultDateRange: (val: boolean) => void;\n}\n\nexport const DateRangeContext = createContext<DateRange | undefined>(\n undefined as any,\n);\n\nexport const DateRangeProvider: FC<{ children: ReactNode }> = ({\n children,\n}) => {\n const [startDateRange, setStartDateRange] = useState<Date | null>(null);\n const [endDateRange, setEndDateRange] = useState<Date | null>(null);\n const [isDefaultDateRange, setIsDefaultDateRange] = useState<boolean>(true);\n\n const value = useMemo(\n () => ({\n startDateRange,\n endDateRange,\n isDefaultDateRange,\n setStartDateRange,\n setEndDateRange,\n setIsDefaultDateRange,\n }),\n [startDateRange, endDateRange, isDefaultDateRange],\n );\n\n return (\n <DateRangeContext.Provider value={value}>\n {children}\n </DateRangeContext.Provider>\n );\n};\n\nexport const useDateRange = () => {\n const context = useContext(DateRangeContext);\n if (!context) {\n throw new Error('useDateRange must be used within a DateRangeProvider');\n }\n\n return context;\n};\n"],"names":[],"mappings":";;;AA2BO,MAAM,gBAAmB,GAAA,aAAA;AAAA,EAC9B;AACF;AAEO,MAAM,oBAAiD,CAAC;AAAA,EAC7D;AACF,CAAM,KAAA;AACJ,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAsB,IAAI,CAAA;AACtE,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAsB,IAAI,CAAA;AAClE,EAAA,MAAM,CAAC,kBAAA,EAAoB,qBAAqB,CAAA,GAAI,SAAkB,IAAI,CAAA;AAE1E,EAAA,MAAM,KAAQ,GAAA,OAAA;AAAA,IACZ,OAAO;AAAA,MACL,cAAA;AAAA,MACA,YAAA;AAAA,MACA,kBAAA;AAAA,MACA,iBAAA;AAAA,MACA,eAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,cAAgB,EAAA,YAAA,EAAc,kBAAkB;AAAA,GACnD;AAEA,EAAA,uBACG,GAAA,CAAA,gBAAA,CAAiB,QAAjB,EAAA,EAA0B,OACxB,QACH,EAAA,CAAA;AAEJ;AAEO,MAAM,eAAe,MAAM;AAChC,EAAM,MAAA,OAAA,GAAU,WAAW,gBAAgB,CAAA;AAC3C,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAM,MAAA,IAAI,MAAM,sDAAsD,CAAA;AAAA;AAGxE,EAAO,OAAA,OAAA;AACT;;;;"}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
2
|
+
import { useCallback } from 'react';
|
2
3
|
import Box from '@mui/material/Box';
|
3
4
|
import Grid from '@mui/material/Grid';
|
4
5
|
import TextField from '@mui/material/TextField';
|
@@ -17,7 +18,7 @@ const DateRangePicker = ({
|
|
17
18
|
endDate,
|
18
19
|
setEndDate
|
19
20
|
}) => {
|
20
|
-
const handleDateChange =
|
21
|
+
const handleDateChange = useCallback(
|
21
22
|
(date) => {
|
22
23
|
if (!date) return;
|
23
24
|
if (!startDate || startDate && endDate) {
|
@@ -31,7 +32,7 @@ const DateRangePicker = ({
|
|
31
32
|
},
|
32
33
|
[startDate, endDate, setStartDate, setEndDate]
|
33
34
|
);
|
34
|
-
const handleStartDateChange =
|
35
|
+
const handleStartDateChange = useCallback(
|
35
36
|
(date) => {
|
36
37
|
if (!date) return;
|
37
38
|
if (date) {
|
@@ -46,7 +47,7 @@ const DateRangePicker = ({
|
|
46
47
|
},
|
47
48
|
[endDate, setStartDate, setEndDate]
|
48
49
|
);
|
49
|
-
const handleEndDateChange =
|
50
|
+
const handleEndDateChange = useCallback(
|
50
51
|
(date) => {
|
51
52
|
if (!date) return;
|
52
53
|
if (date) {
|
@@ -62,12 +63,12 @@ const DateRangePicker = ({
|
|
62
63
|
[startDate, setStartDate, setEndDate]
|
63
64
|
);
|
64
65
|
const renderDay = (day, _value, pickersDayProps) => {
|
65
|
-
if (!startDate) return /* @__PURE__ */
|
66
|
+
if (!startDate) return /* @__PURE__ */ jsx(PickersDay, { ...pickersDayProps, disableMargin: true });
|
66
67
|
const isStart = isSameDay(day, startDate);
|
67
68
|
const isEnd = endDate && isSameDay(day, endDate);
|
68
69
|
const inRange = startDate && endDate && isAfter(day, startDate) && isBefore(day, endDate);
|
69
70
|
if (isStart || isEnd) {
|
70
|
-
return /* @__PURE__ */
|
71
|
+
return /* @__PURE__ */ jsx(
|
71
72
|
PickersDay,
|
72
73
|
{
|
73
74
|
...pickersDayProps,
|
@@ -84,7 +85,7 @@ const DateRangePicker = ({
|
|
84
85
|
);
|
85
86
|
}
|
86
87
|
if (inRange) {
|
87
|
-
return /* @__PURE__ */
|
88
|
+
return /* @__PURE__ */ jsx(
|
88
89
|
PickersDay,
|
89
90
|
{
|
90
91
|
...pickersDayProps,
|
@@ -96,64 +97,71 @@ const DateRangePicker = ({
|
|
96
97
|
}
|
97
98
|
);
|
98
99
|
}
|
99
|
-
return /* @__PURE__ */
|
100
|
+
return /* @__PURE__ */ jsx(PickersDay, { ...pickersDayProps, disableMargin: true });
|
100
101
|
};
|
101
|
-
return /* @__PURE__ */
|
102
|
-
|
103
|
-
{
|
104
|
-
|
105
|
-
|
106
|
-
sx: { width: "100%", margin: "unset" }
|
107
|
-
},
|
108
|
-
/* @__PURE__ */ React__default.createElement(Grid, { item: true, xs: 6, sx: { padding: "16px 8px 16px 24px !important" } }, /* @__PURE__ */ React__default.createElement(
|
109
|
-
DatePicker,
|
102
|
+
return /* @__PURE__ */ jsx(LocalizationProvider, { dateAdapter: AdapterDateFns, children: /* @__PURE__ */ jsxs(Box, { children: [
|
103
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", p: 2, pb: 0, fontWeight: "400", children: "Date range" }),
|
104
|
+
/* @__PURE__ */ jsx(Divider, { sx: { mt: 2 } }),
|
105
|
+
/* @__PURE__ */ jsxs(
|
106
|
+
Grid,
|
110
107
|
{
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
108
|
+
container: true,
|
109
|
+
justifyContent: "space-between",
|
110
|
+
sx: { width: "100%", margin: "unset" },
|
111
|
+
children: [
|
112
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 6, sx: { padding: "16px 8px 16px 24px !important" }, children: /* @__PURE__ */ jsx(
|
113
|
+
DatePicker,
|
114
|
+
{
|
115
|
+
label: "Start date",
|
116
|
+
value: startDate,
|
117
|
+
onChange: handleStartDateChange,
|
118
|
+
renderInput: (params) => /* @__PURE__ */ jsx(
|
119
|
+
TextField,
|
120
|
+
{
|
121
|
+
...params,
|
122
|
+
sx: { width: 172 },
|
123
|
+
autoFocus: Boolean(!startDate)
|
124
|
+
}
|
125
|
+
),
|
126
|
+
maxDate: /* @__PURE__ */ new Date(),
|
127
|
+
views: ["day"]
|
128
|
+
}
|
129
|
+
) }),
|
130
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 6, sx: { padding: "16px 24px 16px 8px !important" }, children: /* @__PURE__ */ jsx(
|
131
|
+
DatePicker,
|
132
|
+
{
|
133
|
+
label: "End date",
|
134
|
+
value: endDate,
|
135
|
+
onChange: handleEndDateChange,
|
136
|
+
renderInput: (params) => /* @__PURE__ */ jsx(
|
137
|
+
TextField,
|
138
|
+
{
|
139
|
+
...params,
|
140
|
+
sx: { width: 172 },
|
141
|
+
focused: Boolean(startDate && !endDate)
|
142
|
+
}
|
143
|
+
),
|
144
|
+
maxDate: /* @__PURE__ */ new Date(),
|
145
|
+
views: ["day"]
|
146
|
+
}
|
147
|
+
) })
|
148
|
+
]
|
124
149
|
}
|
125
|
-
)
|
126
|
-
/* @__PURE__ */
|
127
|
-
|
150
|
+
),
|
151
|
+
/* @__PURE__ */ jsx(
|
152
|
+
StaticDatePicker,
|
128
153
|
{
|
129
|
-
|
130
|
-
|
131
|
-
onChange: handleEndDateChange,
|
132
|
-
renderInput: (params) => /* @__PURE__ */ React__default.createElement(
|
133
|
-
TextField,
|
134
|
-
{
|
135
|
-
...params,
|
136
|
-
sx: { width: 172 },
|
137
|
-
focused: Boolean(startDate && !endDate)
|
138
|
-
}
|
139
|
-
),
|
154
|
+
displayStaticWrapperAs: "desktop",
|
155
|
+
showDaysOutsideCurrentMonth: true,
|
140
156
|
maxDate: /* @__PURE__ */ new Date(),
|
141
|
-
views: ["day"]
|
157
|
+
views: ["day"],
|
158
|
+
renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params }),
|
159
|
+
onChange: handleDateChange,
|
160
|
+
value: null,
|
161
|
+
renderDay
|
142
162
|
}
|
143
|
-
)
|
144
|
-
)
|
145
|
-
StaticDatePicker,
|
146
|
-
{
|
147
|
-
displayStaticWrapperAs: "desktop",
|
148
|
-
showDaysOutsideCurrentMonth: true,
|
149
|
-
maxDate: /* @__PURE__ */ new Date(),
|
150
|
-
views: ["day"],
|
151
|
-
renderInput: (params) => /* @__PURE__ */ React__default.createElement(TextField, { ...params }),
|
152
|
-
onChange: handleDateChange,
|
153
|
-
value: null,
|
154
|
-
renderDay
|
155
|
-
}
|
156
|
-
)));
|
163
|
+
)
|
164
|
+
] }) });
|
157
165
|
};
|
158
166
|
|
159
167
|
export { DateRangePicker as default };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DateRangePicker.esm.js","sources":["../../../src/components/Header/DateRangePicker.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\n\nimport Box from '@mui/material/Box';\nimport Grid from '@mui/material/Grid';\nimport TextField from '@mui/material/TextField';\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';\nimport { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { PickersDay, PickersDayProps } from '@mui/x-date-pickers/PickersDay';\nimport { isAfter, isBefore, isSameDay } from 'date-fns';\nimport { DatePicker } from '@mui/x-date-pickers';\nimport Divider from '@mui/material/Divider';\nimport Typography from '@mui/material/Typography';\n\ninterface DateRangePickerProps {\n startDate: Date | null;\n setStartDate: React.Dispatch<React.SetStateAction<Date | null>>;\n endDate: Date | null;\n setEndDate: React.Dispatch<React.SetStateAction<Date | null>>;\n}\n\nconst DateRangePicker: React.FC<DateRangePickerProps> = ({\n startDate,\n setStartDate,\n endDate,\n setEndDate,\n}) => {\n const handleDateChange = React.useCallback(\n (date: Date | null) => {\n if (!date) return;\n\n if (!startDate || (startDate && endDate)) {\n setStartDate(date);\n setEndDate(null);\n } else if (isBefore(date, startDate)) {\n setStartDate(date);\n } else {\n setEndDate(date);\n }\n },\n [startDate, endDate, setStartDate, setEndDate],\n );\n\n const handleStartDateChange = React.useCallback(\n (date: Date | null) => {\n if (!date) return;\n\n if (date) {\n const year = date.getFullYear();\n if (year >= 1900 && year <= 2100) {\n if (endDate && isAfter(date, endDate)) {\n setEndDate(null);\n }\n setStartDate(date);\n }\n }\n },\n [endDate, setStartDate, setEndDate],\n );\n\n const handleEndDateChange = React.useCallback(\n (date: Date | null) => {\n if (!date) return;\n\n if (date) {\n const year = date.getFullYear();\n if (year >= 1900 && year <= 2100) {\n if (startDate && isBefore(date, startDate)) {\n setStartDate(null);\n }\n setEndDate(date);\n }\n }\n },\n [startDate, setStartDate, setEndDate],\n );\n\n const renderDay = (\n day: Date,\n _value: Date[],\n pickersDayProps: PickersDayProps<Date>,\n ) => {\n if (!startDate) return <PickersDay {...pickersDayProps} disableMargin />;\n\n const isStart = isSameDay(day, startDate);\n const isEnd = endDate && isSameDay(day, endDate);\n const inRange =\n startDate && endDate && isAfter(day, startDate) && isBefore(day, endDate);\n\n if (isStart || isEnd) {\n return (\n <PickersDay\n {...pickersDayProps}\n sx={{\n backgroundColor: theme => theme.palette.primary.main,\n color: theme => theme.palette.primary.contrastText,\n borderRadius: '50%',\n margin: 0,\n '&:focus': {\n backgroundColor: theme => theme.palette.primary.dark,\n },\n }}\n />\n );\n }\n\n if (inRange) {\n return (\n <PickersDay\n {...pickersDayProps}\n sx={{\n backgroundColor: theme => theme.palette.action.hover,\n borderRadius: 0,\n margin: 0,\n }}\n />\n );\n }\n\n return <PickersDay {...pickersDayProps} disableMargin />;\n };\n\n return (\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <Box>\n <Typography variant=\"h5\" p={2} pb={0} fontWeight=\"400\">\n Date range\n </Typography>\n <Divider sx={{ mt: 2 }} />\n <Grid\n container\n justifyContent=\"space-between\"\n sx={{ width: '100%', margin: 'unset' }}\n >\n <Grid item xs={6} sx={{ padding: '16px 8px 16px 24px !important' }}>\n <DatePicker\n label=\"Start date\"\n value={startDate}\n onChange={handleStartDateChange}\n renderInput={params => (\n <TextField\n {...params}\n sx={{ width: 172 }}\n autoFocus={Boolean(!startDate)}\n />\n )}\n maxDate={new Date()}\n views={['day']}\n />\n </Grid>\n\n <Grid item xs={6} sx={{ padding: '16px 24px 16px 8px !important' }}>\n <DatePicker\n label=\"End date\"\n value={endDate}\n onChange={handleEndDateChange}\n renderInput={params => (\n <TextField\n {...params}\n sx={{ width: 172 }}\n focused={Boolean(startDate && !endDate)}\n />\n )}\n maxDate={new Date()}\n views={['day']}\n />\n </Grid>\n </Grid>\n\n <StaticDatePicker\n displayStaticWrapperAs=\"desktop\"\n showDaysOutsideCurrentMonth\n maxDate={new Date()}\n views={['day']}\n renderInput={params => <TextField {...params} />}\n onChange={handleDateChange}\n value={null}\n renderDay={renderDay}\n />\n </Box>\n </LocalizationProvider>\n );\n};\n\nexport default DateRangePicker;\n"],"names":["React"],"mappings":";;;;;;;;;;;;;AAqCA,MAAM,kBAAkD,CAAC;AAAA,EACvD,SAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EAAA,MAAM,mBAAmBA,cAAM,CAAA,WAAA;AAAA,IAC7B,CAAC,IAAsB,KAAA;AACrB,MAAA,IAAI,CAAC,IAAM,EAAA;AAEX,MAAI,IAAA,CAAC,SAAc,IAAA,SAAA,IAAa,OAAU,EAAA;AACxC,QAAA,YAAA,CAAa,IAAI,CAAA;AACjB,QAAA,UAAA,CAAW,IAAI,CAAA;AAAA,OACN,MAAA,IAAA,QAAA,CAAS,IAAM,EAAA,SAAS,CAAG,EAAA;AACpC,QAAA,YAAA,CAAa,IAAI,CAAA;AAAA,OACZ,MAAA;AACL,QAAA,UAAA,CAAW,IAAI,CAAA;AAAA;AACjB,KACF;AAAA,IACA,CAAC,SAAA,EAAW,OAAS,EAAA,YAAA,EAAc,UAAU;AAAA,GAC/C;AAEA,EAAA,MAAM,wBAAwBA,cAAM,CAAA,WAAA;AAAA,IAClC,CAAC,IAAsB,KAAA;AACrB,MAAA,IAAI,CAAC,IAAM,EAAA;AAEX,MAAA,IAAI,IAAM,EAAA;AACR,QAAM,MAAA,IAAA,GAAO,KAAK,WAAY,EAAA;AAC9B,QAAI,IAAA,IAAA,IAAQ,IAAQ,IAAA,IAAA,IAAQ,IAAM,EAAA;AAChC,UAAA,IAAI,OAAW,IAAA,OAAA,CAAQ,IAAM,EAAA,OAAO,CAA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AE,KAAA,EAAO,GAAI,EAAA;AAAA,YACjB,OAAS,EAAA,OAAA,CAAQ,SAAa,IAAA,CAAC,OAAO;AAAA;AAAA,SACxC;AAAA,QAEF,OAAA,sBAAa,IAAK,EAAA;AAAA,QAClB,KAAA,EAAO,CAAC,KAAK;AAAA;AAAA,KAEjB;AAAA,GAGF,kBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,sBAAuB,EAAA,SAAA;AAAA,MACvB,2BAA2B,EAAA,IAAA;AAAA,MAC3B,OAAA,sBAAa,IAAK,EAAA;AAAA,MAClB,KAAA,EAAO,CAAC,KAAK,CAAA;AAAA,MACb,WAAa,EAAA,CAAA,MAAA,qBAAWA,cAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAW,GAAG,MAAQ,EAAA,CAAA;AAAA,MAC9C,QAAU,EAAA,gBAAA;AAAA,MACV,KAAO,EAAA,IAAA;AAAA,MACP;AAAA;AAAA,GAEJ,CACF,CAAA;AAEJ;;;;"}
|
1
|
+
{"version":3,"file":"DateRangePicker.esm.js","sources":["../../../src/components/Header/DateRangePicker.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useCallback } from 'react';\nimport type { FC, Dispatch, SetStateAction } from 'react';\n\nimport Box from '@mui/material/Box';\nimport Grid from '@mui/material/Grid';\nimport TextField from '@mui/material/TextField';\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';\nimport { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker';\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';\nimport { PickersDay, PickersDayProps } from '@mui/x-date-pickers/PickersDay';\nimport { isAfter, isBefore, isSameDay } from 'date-fns';\nimport { DatePicker } from '@mui/x-date-pickers';\nimport Divider from '@mui/material/Divider';\nimport Typography from '@mui/material/Typography';\n\ninterface DateRangePickerProps {\n startDate: Date | null;\n setStartDate: Dispatch<SetStateAction<Date | null>>;\n endDate: Date | null;\n setEndDate: Dispatch<SetStateAction<Date | null>>;\n}\n\nconst DateRangePicker: FC<DateRangePickerProps> = ({\n startDate,\n setStartDate,\n endDate,\n setEndDate,\n}) => {\n const handleDateChange = useCallback(\n (date: Date | null) => {\n if (!date) return;\n\n if (!startDate || (startDate && endDate)) {\n setStartDate(date);\n setEndDate(null);\n } else if (isBefore(date, startDate)) {\n setStartDate(date);\n } else {\n setEndDate(date);\n }\n },\n [startDate, endDate, setStartDate, setEndDate],\n );\n\n const handleStartDateChange = useCallback(\n (date: Date | null) => {\n if (!date) return;\n\n if (date) {\n const year = date.getFullYear();\n if (year >= 1900 && year <= 2100) {\n if (endDate && isAfter(date, endDate)) {\n setEndDate(null);\n }\n setStartDate(date);\n }\n }\n },\n [endDate, setStartDate, setEndDate],\n );\n\n const handleEndDateChange = useCallback(\n (date: Date | null) => {\n if (!date) return;\n\n if (date) {\n const year = date.getFullYear();\n if (year >= 1900 && year <= 2100) {\n if (startDate && isBefore(date, startDate)) {\n setStartDate(null);\n }\n setEndDate(date);\n }\n }\n },\n [startDate, setStartDate, setEndDate],\n );\n\n const renderDay = (\n day: Date,\n _value: Date[],\n pickersDayProps: PickersDayProps<Date>,\n ) => {\n if (!startDate) return <PickersDay {...pickersDayProps} disableMargin />;\n\n const isStart = isSameDay(day, startDate);\n const isEnd = endDate && isSameDay(day, endDate);\n const inRange =\n startDate && endDate && isAfter(day, startDate) && isBefore(day, endDate);\n\n if (isStart || isEnd) {\n return (\n <PickersDay\n {...pickersDayProps}\n sx={{\n backgroundColor: theme => theme.palette.primary.main,\n color: theme => theme.palette.primary.contrastText,\n borderRadius: '50%',\n margin: 0,\n '&:focus': {\n backgroundColor: theme => theme.palette.primary.dark,\n },\n }}\n />\n );\n }\n\n if (inRange) {\n return (\n <PickersDay\n {...pickersDayProps}\n sx={{\n backgroundColor: theme => theme.palette.action.hover,\n borderRadius: 0,\n margin: 0,\n }}\n />\n );\n }\n\n return <PickersDay {...pickersDayProps} disableMargin />;\n };\n\n return (\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <Box>\n <Typography variant=\"h5\" p={2} pb={0} fontWeight=\"400\">\n Date range\n </Typography>\n <Divider sx={{ mt: 2 }} />\n <Grid\n container\n justifyContent=\"space-between\"\n sx={{ width: '100%', margin: 'unset' }}\n >\n <Grid item xs={6} sx={{ padding: '16px 8px 16px 24px !important' }}>\n <DatePicker\n label=\"Start date\"\n value={startDate}\n onChange={handleStartDateChange}\n renderInput={params => (\n <TextField\n {...params}\n sx={{ width: 172 }}\n autoFocus={Boolean(!startDate)}\n />\n )}\n maxDate={new Date()}\n views={['day']}\n />\n </Grid>\n\n <Grid item xs={6} sx={{ padding: '16px 24px 16px 8px !important' }}>\n <DatePicker\n label=\"End date\"\n value={endDate}\n onChange={handleEndDateChange}\n renderInput={params => (\n <TextField\n {...params}\n sx={{ width: 172 }}\n focused={Boolean(startDate && !endDate)}\n />\n )}\n maxDate={new Date()}\n views={['day']}\n />\n </Grid>\n </Grid>\n\n <StaticDatePicker\n displayStaticWrapperAs=\"desktop\"\n showDaysOutsideCurrentMonth\n maxDate={new Date()}\n views={['day']}\n renderInput={params => <TextField {...params} />}\n onChange={handleDateChange}\n value={null}\n renderDay={renderDay}\n />\n </Box>\n </LocalizationProvider>\n );\n};\n\nexport default DateRangePicker;\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,kBAA4C,CAAC;AAAA,EACjD,SAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAA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