@databiosphere/findable-ui 29.0.2 → 31.0.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +35 -0
- package/lib/common/categories/config/types.d.ts +28 -0
- package/lib/common/categories/config/utils.d.ts +31 -0
- package/lib/common/categories/config/utils.js +29 -0
- package/lib/common/categories/models/range/typeGuards.d.ts +14 -0
- package/lib/common/categories/models/range/typeGuards.js +18 -0
- package/lib/common/categories/models/range/types.d.ts +15 -0
- package/lib/common/categories/models/range/types.js +1 -0
- package/lib/common/categories/models/range/utils.d.ts +23 -0
- package/lib/common/categories/models/range/utils.js +41 -0
- package/lib/common/categories/models/select/utils.d.ts +8 -0
- package/lib/common/categories/models/select/utils.js +16 -0
- package/lib/common/categories/models/types.d.ts +6 -0
- package/lib/common/categories/models/types.js +1 -0
- package/lib/common/categories/views/common/types.d.ts +10 -0
- package/lib/common/categories/views/common/types.js +1 -0
- package/lib/common/categories/views/range/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/range/typeGuards.js +8 -0
- package/lib/common/categories/views/range/types.d.ts +19 -0
- package/lib/common/categories/views/range/types.js +1 -0
- package/lib/common/categories/views/range/utils.d.ts +12 -0
- package/lib/common/categories/views/range/utils.js +24 -0
- package/lib/common/categories/views/select/typeGuards.d.ts +8 -0
- package/lib/common/categories/views/select/typeGuards.js +8 -0
- package/lib/common/categories/views/select/types.d.ts +7 -0
- package/lib/common/categories/views/select/types.js +1 -0
- package/lib/common/categories/views/types.d.ts +13 -0
- package/lib/common/categories/views/types.js +8 -0
- package/lib/common/entities.d.ts +8 -23
- package/lib/components/DataDictionary/components/Entities/entities.d.ts +3 -1
- package/lib/components/DataDictionary/components/Entities/entities.js +1 -1
- package/lib/components/DataDictionary/components/Entities/types.d.ts +5 -5
- package/lib/components/DataDictionary/components/Entity/entity.d.ts +3 -1
- package/lib/components/DataDictionary/components/Entity/entity.js +6 -6
- package/lib/components/DataDictionary/components/Entity/types.d.ts +5 -5
- package/lib/components/DataDictionary/components/Outline/utils.d.ts +3 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.d.ts +3 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.js +6 -2
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.d.ts +9 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.js +12 -0
- package/lib/components/DataDictionary/components/Table/hook.d.ts +3 -3
- package/lib/components/DataDictionary/components/Table/hook.js +3 -1
- package/lib/components/DataDictionary/components/Table/options/core/constants.d.ts +2 -3
- package/lib/components/DataDictionary/components/Table/options/hook.d.ts +2 -2
- package/lib/components/DataDictionary/components/Table/options/sorting/constants.d.ts +2 -3
- package/lib/components/DataDictionary/components/Table/table.d.ts +2 -1
- package/lib/components/DataDictionary/components/Table/table.js +1 -1
- package/lib/components/DataDictionary/components/Table/types.d.ts +3 -4
- package/lib/components/DataDictionary/dataDictionary.d.ts +3 -1
- package/lib/components/DataDictionary/dataDictionary.styles.js +2 -3
- package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.d.ts +3 -1
- package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +5 -5
- package/lib/components/Filter/components/Filter/filter.d.ts +2 -2
- package/lib/components/Filter/components/Filter/filter.js +11 -3
- package/lib/components/Filter/components/Filter/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/Filter/stories/args.js +19 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.d.ts +8 -0
- package/lib/components/Filter/components/Filter/stories/filter.stories.js +21 -0
- package/lib/components/Filter/components/FilterMenu/filterMenu.js +2 -2
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.d.ts +1 -1
- package/lib/components/Filter/components/FilterMenu/filterMenu.styles.js +1 -1
- package/lib/components/Filter/components/FilterRange/constants.d.ts +0 -2
- package/lib/components/Filter/components/FilterRange/constants.js +0 -5
- package/lib/components/Filter/components/FilterRange/filterRange.d.ts +1 -1
- package/lib/components/Filter/components/FilterRange/filterRange.js +50 -21
- package/lib/components/Filter/components/FilterRange/filterRange.styles.js +58 -10
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.d.ts +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.js +5 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.d.ts +2 -2
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.js +32 -7
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.d.ts +6 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.js +50 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.d.ts +26 -3
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.js +6 -1
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.d.ts +15 -0
- package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.js +25 -0
- package/lib/components/Filter/components/FilterRange/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/FilterRange/stories/args.js +13 -0
- package/lib/components/Filter/components/FilterRange/stories/filterRange.stories.js +2 -2
- package/lib/components/Filter/components/FilterRange/types.d.ts +10 -6
- package/lib/components/Filter/components/FilterRange/types.js +1 -6
- package/lib/components/Filter/components/FilterRange/utils.d.ts +8 -0
- package/lib/components/Filter/components/FilterRange/utils.js +15 -0
- package/lib/components/Filter/components/FilterTag/stories/args.d.ts +5 -0
- package/lib/components/Filter/components/FilterTag/stories/args.js +17 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.d.ts +8 -0
- package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.js +21 -0
- package/lib/components/Filter/components/FilterTag/utils.d.ts +10 -0
- package/lib/components/Filter/components/FilterTag/utils.js +40 -0
- package/lib/components/Filter/components/Filters/filters.d.ts +2 -2
- package/lib/components/Filter/components/Filters/filters.js +15 -8
- package/lib/components/Filter/components/Filters/stories/args.d.ts +3 -0
- package/lib/components/Filter/components/Filters/stories/args.js +15 -0
- package/lib/components/Filter/components/Filters/stories/constants.d.ts +22 -0
- package/lib/components/Filter/components/Filters/stories/constants.js +134 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.d.ts +6 -0
- package/lib/components/Filter/components/Filters/stories/filters.stories.js +15 -0
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.d.ts +1 -1
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.js +5 -5
- package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.d.ts +3 -2
- package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.js +6 -4
- package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.js +2 -1
- package/lib/components/Index/components/EntitiesView/components/ChartView/utils.js +2 -0
- package/lib/components/Index/table/hook.js +4 -0
- package/lib/components/MarkdownRenderer/components/Anchor/anchor.d.ts +19 -0
- package/lib/components/MarkdownRenderer/components/Anchor/anchor.js +21 -0
- package/lib/components/MarkdownRenderer/components/Table/table.d.ts +3 -0
- package/lib/components/MarkdownRenderer/components/Table/table.js +5 -0
- package/lib/components/MarkdownRenderer/components/Table/table.styles.d.ts +4 -0
- package/lib/components/MarkdownRenderer/components/Table/table.styles.js +40 -0
- package/lib/components/MarkdownRenderer/constants.d.ts +2 -0
- package/lib/components/MarkdownRenderer/constants.js +6 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.d.ts +2 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.js +45 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.styles.d.ts +4 -0
- package/lib/components/MarkdownRenderer/markdownRenderer.styles.js +13 -0
- package/lib/components/MarkdownRenderer/types.d.ts +6 -0
- package/lib/components/MarkdownRenderer/types.js +1 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.d.ts +9 -0
- package/lib/components/Table/columnDef/accessorFn/typeGuards.js +10 -0
- package/lib/components/Table/common/utils.d.ts +2 -2
- package/lib/components/Table/common/utils.js +28 -13
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.js +8 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.js +21 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.d.ts +6 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.js +27 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.d.ts +9 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.js +18 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.d.ts +22 -0
- package/lib/components/Table/components/TableCell/components/LinkCell/utils.js +45 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.js +13 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.js +30 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.d.ts +4 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.js +10 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.d.ts +5 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.js +9 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.d.ts +7 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.js +25 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.js +1 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.d.ts +3 -0
- package/lib/components/Table/components/TableCell/components/MarkdownCell/types.js +1 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.d.ts +8 -0
- package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.js +46 -0
- package/lib/components/common/Link/typeGuards.d.ts +13 -0
- package/lib/components/common/Link/typeGuards.js +21 -0
- package/lib/config/entities.d.ts +2 -11
- package/lib/hooks/useCategoryFilter.d.ts +8 -13
- package/lib/hooks/useCategoryFilter.js +31 -28
- package/lib/providers/exploreState/entities.d.ts +5 -3
- package/lib/providers/exploreState/payloads/entities.d.ts +6 -2
- package/lib/providers/exploreState.d.ts +3 -2
- package/lib/providers/exploreState.js +1 -1
- package/lib/styles/common/mui/typography.js +1 -0
- package/lib/tests/utils.d.ts +24 -0
- package/lib/tests/utils.js +34 -0
- package/lib/theme/common/components.js +19 -1
- package/lib/views/ExploreView/exploreView.js +10 -8
- package/package.json +7 -1
- package/src/common/categories/config/types.ts +42 -0
- package/src/common/categories/config/utils.ts +47 -0
- package/src/common/categories/models/range/typeGuards.ts +24 -0
- package/src/common/categories/models/range/types.ts +17 -0
- package/src/common/categories/models/range/utils.ts +51 -0
- package/src/common/categories/models/select/utils.ts +23 -0
- package/src/common/categories/models/types.ts +7 -0
- package/src/common/categories/views/common/types.ts +11 -0
- package/src/common/categories/views/range/typeGuards.ts +13 -0
- package/src/common/categories/views/range/types.ts +21 -0
- package/src/common/categories/views/range/utils.ts +35 -0
- package/src/common/categories/views/select/typeGuards.ts +13 -0
- package/src/common/categories/views/select/types.ts +8 -0
- package/src/common/categories/views/types.ts +15 -0
- package/src/common/entities.ts +8 -26
- package/src/components/DataDictionary/components/Entities/entities.tsx +7 -5
- package/src/components/DataDictionary/components/Entities/types.ts +5 -9
- package/src/components/DataDictionary/components/Entity/entity.tsx +9 -7
- package/src/components/DataDictionary/components/Entity/types.ts +5 -9
- package/src/components/DataDictionary/components/Outline/utils.ts +5 -2
- package/src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx +12 -4
- package/src/components/DataDictionary/components/Table/components/BasicCell/utils.ts +13 -0
- package/src/components/DataDictionary/components/Table/hook.ts +16 -8
- package/src/components/DataDictionary/components/Table/options/core/constants.ts +2 -3
- package/src/components/DataDictionary/components/Table/options/hook.ts +3 -3
- package/src/components/DataDictionary/components/Table/options/sorting/constants.ts +2 -6
- package/src/components/DataDictionary/components/Table/table.tsx +4 -1
- package/src/components/DataDictionary/components/Table/types.ts +3 -4
- package/src/components/DataDictionary/dataDictionary.styles.ts +2 -3
- package/src/components/DataDictionary/dataDictionary.tsx +4 -2
- package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +9 -2
- package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -9
- package/src/components/Filter/components/Filter/filter.tsx +38 -13
- package/src/components/Filter/components/Filter/stories/args.ts +24 -0
- package/src/components/Filter/components/Filter/stories/filter.stories.tsx +32 -0
- package/src/components/Filter/components/FilterMenu/filterMenu.styles.ts +1 -1
- package/src/components/Filter/components/FilterMenu/filterMenu.tsx +7 -3
- package/src/components/Filter/components/FilterRange/constants.ts +0 -7
- package/src/components/Filter/components/FilterRange/filterRange.styles.ts +58 -14
- package/src/components/Filter/components/FilterRange/filterRange.tsx +112 -40
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.ts +5 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.ts +51 -10
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.ts +60 -0
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/types.ts +34 -3
- package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.ts +32 -0
- package/src/components/Filter/components/FilterRange/stories/args.ts +16 -0
- package/src/components/Filter/components/FilterRange/stories/filterRange.stories.tsx +2 -2
- package/src/components/Filter/components/FilterRange/types.ts +12 -6
- package/src/components/Filter/components/FilterRange/utils.ts +16 -0
- package/src/components/Filter/components/FilterTag/stories/args.ts +22 -0
- package/src/components/Filter/components/FilterTag/stories/filterTag.stories.tsx +32 -0
- package/src/components/Filter/components/FilterTag/utils.ts +57 -0
- package/src/components/Filter/components/Filters/filters.tsx +21 -12
- package/src/components/Filter/components/Filters/stories/args.ts +24 -0
- package/src/components/Filter/components/Filters/stories/constants.ts +151 -0
- package/src/components/Filter/components/Filters/stories/filters.stories.tsx +24 -0
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.tsx +32 -29
- package/src/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.tsx +9 -1
- package/src/components/Filter/components/SearchAllFilters/searchAllFilters.tsx +12 -6
- package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +2 -1
- package/src/components/Index/components/EntitiesView/components/ChartView/utils.ts +2 -0
- package/src/components/Index/table/hook.ts +4 -0
- package/src/components/MarkdownRenderer/components/Anchor/anchor.tsx +34 -0
- package/src/components/MarkdownRenderer/components/Table/table.styles.ts +41 -0
- package/src/components/MarkdownRenderer/components/Table/table.tsx +13 -0
- package/src/components/MarkdownRenderer/constants.ts +8 -0
- package/src/components/MarkdownRenderer/markdownRenderer.styles.ts +16 -0
- package/src/components/MarkdownRenderer/markdownRenderer.tsx +62 -0
- package/src/components/MarkdownRenderer/types.ts +7 -0
- package/src/components/Table/columnDef/accessorFn/typeGuards.ts +15 -0
- package/src/components/Table/common/utils.ts +37 -16
- package/src/components/Table/components/TableCell/components/ChipCell/chipCell.tsx +16 -0
- package/src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx +64 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/args.ts +35 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx +32 -0
- package/src/components/Table/components/TableCell/components/LinkCell/stories/types.ts +4 -0
- package/src/components/Table/components/TableCell/components/LinkCell/utils.ts +59 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.ts +31 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/markdownCell.tsx +29 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/args.ts +17 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/constants.ts +11 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.tsx +37 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/stories/types.ts +4 -0
- package/src/components/Table/components/TableCell/components/MarkdownCell/types.ts +3 -0
- package/src/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.ts +64 -0
- package/src/components/common/Link/typeGuards.ts +35 -0
- package/src/config/entities.ts +1 -14
- package/src/hooks/useCategoryFilter.ts +56 -53
- package/src/providers/exploreState/entities.ts +3 -3
- package/src/providers/exploreState/initializer/utils.ts +1 -1
- package/src/providers/exploreState/payloads/entities.ts +5 -2
- package/src/providers/exploreState.tsx +5 -3
- package/src/styles/common/mui/typography.ts +1 -0
- package/src/tests/utils.ts +44 -0
- package/src/theme/common/components.ts +19 -1
- package/src/views/ExploreView/exploreView.tsx +17 -22
- package/tests/filter.test.tsx +100 -0
- package/tests/filterRange.test.tsx +331 -46
- package/tests/filters.test.tsx +61 -0
- package/tests/getFacetedMinMaxValues.test.ts +166 -0
- package/tests/linkCell.test.tsx +89 -0
- package/tests/markdownCell.test.tsx +53 -0
- package/types/data-explorer-ui.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +0 -3
- package/lib/components/Filter/components/Filter/filter.stories.d.ts +0 -25
- package/lib/components/Filter/components/Filter/filter.stories.js +0 -42
- package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +0 -16
- package/lib/components/Filter/components/FilterTag/filterTag.stories.js +0 -17
- package/lib/components/Filter/components/Filters/filters.stories.d.ts +0 -6
- package/lib/components/Filter/components/Filters/filters.stories.js +0 -91
- package/src/components/DataDictionary/components/Table/components/BasicCell/types.ts +0 -7
- package/src/components/Filter/components/Filter/filter.stories.tsx +0 -52
- package/src/components/Filter/components/FilterTag/filterTag.stories.tsx +0 -23
- package/src/components/Filter/components/Filters/filters.stories.tsx +0 -101
- package/tests/filterRangeMock.test.tsx +0 -38
- /package/lib/{components/DataDictionary/components/Table/components/BasicCell → common/categories/config}/types.js +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Checkbox, ListItemButton, ListItemText, ListSubheader, Typography, } from "@mui/material";
|
|
2
2
|
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import { VIEW_KIND } from "../../../../../../common/categories/views/types";
|
|
3
4
|
import { TEST_IDS } from "../../../../../../tests/testIds";
|
|
4
5
|
import { TEXT_BODY_SMALL_400 } from "../../../../../../theme/common/typography";
|
|
5
6
|
import { CheckedIcon } from "../../../../../common/CustomIcon/components/CheckedIcon/checkedIcon";
|
|
@@ -19,7 +20,7 @@ export default function VariableSizeListItem({ item, onFilter, onUpdateItemSizeB
|
|
|
19
20
|
}, [key, onUpdateItemSizeByItemKey]);
|
|
20
21
|
if (item.type === ITEM_TYPE.VALUE) {
|
|
21
22
|
const { categoryKey, matchRanges, value: { count, key: valueKey, label, selected }, } = item;
|
|
22
|
-
return (React.createElement(ListItemButton, { "data-testid": TEST_IDS.FILTER_ITEM, ref: setRef, key: key, onClick: () => onFilter(categoryKey, valueKey, !selected, undefined, searchTerm), selected: selected, style: style },
|
|
23
|
+
return (React.createElement(ListItemButton, { "data-testid": TEST_IDS.FILTER_ITEM, ref: setRef, key: key, onClick: () => onFilter(categoryKey, valueKey, !selected, undefined, VIEW_KIND.SELECT, searchTerm), selected: selected, style: style },
|
|
23
24
|
React.createElement(Checkbox, { checked: selected, checkedIcon: React.createElement(CheckedIcon, null), icon: React.createElement(UncheckedIcon, null) }),
|
|
24
25
|
React.createElement(ListItemText, { disableTypography: true, primary: React.createElement(HighlightedLabel, { label: label, ranges: matchRanges, testId: TEST_IDS.FILTER_TERM }), secondary: React.createElement(Typography, { color: "ink.light", "data-testid": TEST_IDS.FILTER_COUNT, variant: TEXT_BODY_SMALL_400 }, count) })));
|
|
25
26
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { CategoryView } from "../../../../common/categories/views/types";
|
|
2
3
|
import { SelectCategoryView } from "../../../../common/entities";
|
|
3
4
|
import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
|
|
4
5
|
export interface SearchAllFiltersProps {
|
|
5
|
-
categoryViews:
|
|
6
|
+
categoryViews: CategoryView[];
|
|
6
7
|
drawerOpen?: boolean;
|
|
7
8
|
onFilter: OnFilterFn;
|
|
8
9
|
}
|
|
9
10
|
interface ListboxContextValue {
|
|
10
|
-
categoryViews: SelectCategoryView[];
|
|
11
11
|
onClearSearch: () => void;
|
|
12
12
|
onCloseSearch: () => void;
|
|
13
13
|
onFilter: OnFilterFn;
|
|
14
14
|
open: boolean;
|
|
15
15
|
searchTerm: string;
|
|
16
|
+
selectCategoryViews: SelectCategoryView[];
|
|
16
17
|
}
|
|
17
18
|
export declare const ListboxContext: React.Context<ListboxContextValue>;
|
|
18
19
|
export declare const SearchAllFilters: ({ categoryViews, drawerOpen, onFilter, }: SearchAllFiltersProps) => JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useContext, useEffect, useRef, useState, } from "react";
|
|
2
|
+
import { isSelectCategoryView } from "../../../../common/categories/views/select/typeGuards";
|
|
2
3
|
import { SELECTOR } from "../../../../common/selectors";
|
|
3
4
|
import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../hooks/useBreakpointHelper";
|
|
4
5
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
@@ -13,25 +14,26 @@ import { VariableSizeList } from "./components/VariableSizeList/VariableSizeList
|
|
|
13
14
|
import { Autocomplete } from "./searchAllFilters.styles";
|
|
14
15
|
const renderInput = (params) => (React.createElement(SearchAllFiltersSearch, { ...params }));
|
|
15
16
|
export const ListboxContext = createContext({
|
|
16
|
-
categoryViews: [],
|
|
17
17
|
onClearSearch: () => undefined,
|
|
18
18
|
onCloseSearch: () => undefined,
|
|
19
19
|
onFilter: () => undefined,
|
|
20
20
|
open: false,
|
|
21
21
|
searchTerm: "",
|
|
22
|
+
selectCategoryViews: [],
|
|
22
23
|
});
|
|
23
24
|
const Listbox = React.forwardRef(function Listbox(props, ref) {
|
|
24
25
|
props = Object.assign({}, props, {
|
|
25
26
|
children: undefined, // Content is controlled by VariableSizeList
|
|
26
27
|
});
|
|
27
|
-
const {
|
|
28
|
-
return (React.createElement(VariableSizeList, { autocompleteListProps: props,
|
|
28
|
+
const { onFilter, searchTerm, selectCategoryViews } = useContext(ListboxContext);
|
|
29
|
+
return (React.createElement(VariableSizeList, { autocompleteListProps: props, onFilter: onFilter, ref: ref, searchTerm: searchTerm, selectCategoryViews: selectCategoryViews }));
|
|
29
30
|
});
|
|
30
31
|
export const SearchAllFilters = ({ categoryViews, drawerOpen = false, onFilter, }) => {
|
|
31
32
|
const desktopSmUp = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
|
|
32
33
|
const autocompleteRef = useRef(null);
|
|
33
34
|
const [open, setOpen] = useState(false);
|
|
34
35
|
const [searchTerm, setSearchTerm] = useState("");
|
|
36
|
+
const selectCategoryViews = categoryViews.filter((view) => isSelectCategoryView(view));
|
|
35
37
|
// Handles background scroll action (desktop only).
|
|
36
38
|
const handleBackgroundScroll = (overflowStyle) => {
|
|
37
39
|
if (desktopSmUp) {
|
|
@@ -79,12 +81,12 @@ export const SearchAllFilters = ({ categoryViews, drawerOpen = false, onFilter,
|
|
|
79
81
|
}
|
|
80
82
|
}, [drawerOpen]);
|
|
81
83
|
return (React.createElement(ListboxContext.Provider, { value: {
|
|
82
|
-
categoryViews,
|
|
83
84
|
onClearSearch,
|
|
84
85
|
onCloseSearch,
|
|
85
86
|
onFilter,
|
|
86
87
|
open,
|
|
87
88
|
searchTerm,
|
|
89
|
+
selectCategoryViews,
|
|
88
90
|
} },
|
|
89
91
|
React.createElement(Autocomplete, { clearOnBlur: desktopSmUp, "data-testid": TEST_IDS.SEARCH_ALL_FILTERS, filterOptions: (options) => options, freeSolo: true, ListboxComponent: Listbox, onBlur: desktopSmUp ? onCloseSearch : undefined, onClose: desktopSmUp ? onCloseSearch : undefined, onFocus: onOpenSearch, onOpen: onOpen, open: open, options: [""], PopperComponent: AutocompletePopper, ref: autocompleteRef, renderInput: (props) => renderInput({
|
|
90
92
|
...props,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Checkbox, ListItemButton, ListItemText, Typography, } from "@mui/material";
|
|
2
2
|
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import { VIEW_KIND } from "../../../../common/categories/views/types";
|
|
3
4
|
import { SELECT_CATEGORY_KEY } from "../../../../providers/exploreState/constants";
|
|
4
5
|
import { TEST_IDS } from "../../../../tests/testIds";
|
|
5
6
|
import { TEXT_BODY_SMALL_400 } from "../../../../theme/common/typography";
|
|
@@ -15,7 +16,7 @@ export default function VariableSizeListItem({ categoryKey, categorySection, mat
|
|
|
15
16
|
onUpdateItemSizeByItemKey(key, listItemRef.current?.clientHeight || 0);
|
|
16
17
|
}, [key, onUpdateItemSizeByItemKey]);
|
|
17
18
|
const handleItemClicked = () => {
|
|
18
|
-
onFilter(categoryKey, key, !selected, categorySection);
|
|
19
|
+
onFilter(categoryKey, key, !selected, categorySection, VIEW_KIND.SELECT);
|
|
19
20
|
};
|
|
20
21
|
return (React.createElement(ListItemButton, { "data-testid": TEST_IDS.FILTER_ITEM, ref: listItemRef, onClick: handleItemClicked, selected: selected, style: style },
|
|
21
22
|
React.createElement(Checkbox, { checked: selected, checkedIcon: React.createElement(CheckedIcon, null), icon: React.createElement(UncheckedIcon, null) }),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isSelectCategoryView } from "../../../../../../common/categories/views/select/typeGuards";
|
|
1
2
|
/**
|
|
2
3
|
* Returns the set of select category views that have chart view enabled.
|
|
3
4
|
* @param categoryFilters - Category filters.
|
|
@@ -6,6 +7,7 @@
|
|
|
6
7
|
export function getSelectCategoryViews(categoryFilters) {
|
|
7
8
|
return categoryFilters
|
|
8
9
|
.flatMap(({ categoryViews }) => categoryViews)
|
|
10
|
+
.filter(isSelectCategoryView)
|
|
9
11
|
.filter(({ enableChartView = true }) => enableChartView)
|
|
10
12
|
.filter(({ values }) => values.length > 0);
|
|
11
13
|
}
|
|
@@ -10,6 +10,7 @@ import { DEFAULT_PAGINATION_STATE } from "../../../providers/exploreState/initia
|
|
|
10
10
|
import { arrIncludesSome } from "../../Table/columnDef/columnFilters/filterFn";
|
|
11
11
|
import { COLUMN_DEF } from "../../Table/common/columnDef";
|
|
12
12
|
import { buildCategoryViews, getFacetedUniqueValuesWithArrayValues, getTableStatePagination, isClientFilteringEnabled, sortingFn, } from "../../Table/common/utils";
|
|
13
|
+
import { getFacetedMinMaxValues } from "../../Table/featureOptions/facetedColumn/getFacetedMinMaxValues";
|
|
13
14
|
import { ROW_POSITION } from "../../Table/features/RowPosition/constants";
|
|
14
15
|
import { ROW_PREVIEW } from "../../Table/features/RowPreview/constants";
|
|
15
16
|
import { buildBaseColumnDef } from "../../TableCreator/common/utils";
|
|
@@ -105,6 +106,9 @@ export const useTable = () => {
|
|
|
105
106
|
enableMultiSort: clientFiltering, // TODO(cc) move to sorting options; default to false and let the table options in config flag this value.
|
|
106
107
|
filterFns: { arrIncludesSome },
|
|
107
108
|
getCoreRowModel: getCoreRowModel(),
|
|
109
|
+
getFacetedMinMaxValues: clientFiltering
|
|
110
|
+
? getFacetedMinMaxValues()
|
|
111
|
+
: undefined,
|
|
108
112
|
getFacetedRowModel: clientFiltering ? getFacetedRowModel() : undefined,
|
|
109
113
|
getFacetedUniqueValues: clientFiltering
|
|
110
114
|
? getFacetedUniqueValuesWithArrayValues()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ClassAttributes } from "react";
|
|
2
|
+
import { BaseComponentProps } from "../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* rehype-sanitize's default schema allows only a limited set of attributes on <a> elements:
|
|
5
|
+
* - aria-*
|
|
6
|
+
* - className
|
|
7
|
+
* - data-footnote-backref
|
|
8
|
+
* - data-footnote-ref
|
|
9
|
+
* - href
|
|
10
|
+
*
|
|
11
|
+
* By default, attributes such as:
|
|
12
|
+
* - download
|
|
13
|
+
* - rel
|
|
14
|
+
* - target
|
|
15
|
+
* are not permitted and will be stripped from anchor tags during sanitization.
|
|
16
|
+
*
|
|
17
|
+
* Note: This component currently does not support these excluded attributes.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Anchor: (props: BaseComponentProps & ClassAttributes<HTMLAnchorElement> & AnchorHTMLAttributes<HTMLAnchorElement>) => JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Link } from "../../../Links/components/Link/link";
|
|
3
|
+
/**
|
|
4
|
+
* rehype-sanitize's default schema allows only a limited set of attributes on <a> elements:
|
|
5
|
+
* - aria-*
|
|
6
|
+
* - className
|
|
7
|
+
* - data-footnote-backref
|
|
8
|
+
* - data-footnote-ref
|
|
9
|
+
* - href
|
|
10
|
+
*
|
|
11
|
+
* By default, attributes such as:
|
|
12
|
+
* - download
|
|
13
|
+
* - rel
|
|
14
|
+
* - target
|
|
15
|
+
* are not permitted and will be stripped from anchor tags during sanitization.
|
|
16
|
+
*
|
|
17
|
+
* Note: This component currently does not support these excluded attributes.
|
|
18
|
+
*/
|
|
19
|
+
export const Anchor = (props) => {
|
|
20
|
+
return (React.createElement(Link, { className: props.className, label: props.children, url: props.href || "" }));
|
|
21
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { PALETTE } from "../../../../styles/common/constants/palette";
|
|
3
|
+
import { textBody500 } from "../../../../styles/common/mixins/fonts";
|
|
4
|
+
export const StyledTable = styled("table") `
|
|
5
|
+
border-collapse: collapse;
|
|
6
|
+
margin: 16px 0;
|
|
7
|
+
table-layout: fixed;
|
|
8
|
+
width: 100%;
|
|
9
|
+
|
|
10
|
+
thead {
|
|
11
|
+
all: unset;
|
|
12
|
+
display: table-header-group;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
tbody {
|
|
16
|
+
all: unset;
|
|
17
|
+
display: table-row-group;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
tr {
|
|
21
|
+
all: unset;
|
|
22
|
+
display: table-row;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
td,
|
|
26
|
+
th {
|
|
27
|
+
display: table-cell;
|
|
28
|
+
padding: 2px 4px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
th {
|
|
32
|
+
${textBody500}
|
|
33
|
+
border-bottom: 1px solid ${PALETTE.SMOKE_MAIN};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
td {
|
|
37
|
+
font: inherit;
|
|
38
|
+
overflow-wrap: break-word;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Typography } from "@mui/material";
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import * as production from "react/jsx-runtime";
|
|
4
|
+
import rehypeRaw from "rehype-raw";
|
|
5
|
+
import rehypeReact from "rehype-react";
|
|
6
|
+
import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
|
|
7
|
+
import remarkGfm from "remark-gfm";
|
|
8
|
+
import remarkParse from "remark-parse";
|
|
9
|
+
import remarkRehype from "remark-rehype";
|
|
10
|
+
import { unified } from "unified";
|
|
11
|
+
import { TYPOGRAPHY_PROPS } from "../../styles/common/mui/typography";
|
|
12
|
+
import { COMPONENTS } from "./constants";
|
|
13
|
+
import { StyledContainer } from "./markdownRenderer.styles";
|
|
14
|
+
export const MarkdownRenderer = ({ className, components = COMPONENTS, value, }) => {
|
|
15
|
+
const [element, setElement] = useState(null);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
17
|
+
const [componentOptions] = useState(components);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
let cancelled = false;
|
|
20
|
+
setError(null);
|
|
21
|
+
const processor = unified()
|
|
22
|
+
.use(remarkParse)
|
|
23
|
+
.use(remarkGfm)
|
|
24
|
+
.use(remarkRehype, { allowDangerousHtml: true })
|
|
25
|
+
.use(rehypeRaw)
|
|
26
|
+
.use(rehypeSanitize, defaultSchema)
|
|
27
|
+
.use(rehypeReact, { ...production, components: componentOptions });
|
|
28
|
+
processor
|
|
29
|
+
.process(value)
|
|
30
|
+
.then((file) => {
|
|
31
|
+
if (!cancelled)
|
|
32
|
+
setElement(file?.result);
|
|
33
|
+
})
|
|
34
|
+
.catch((err) => {
|
|
35
|
+
if (!cancelled)
|
|
36
|
+
setError(err.message);
|
|
37
|
+
});
|
|
38
|
+
return () => {
|
|
39
|
+
cancelled = true;
|
|
40
|
+
};
|
|
41
|
+
}, [componentOptions, value]);
|
|
42
|
+
if (error)
|
|
43
|
+
return (React.createElement(Typography, { color: TYPOGRAPHY_PROPS.COLOR.ERROR, variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_SMALL_400 }, error));
|
|
44
|
+
return React.createElement(StyledContainer, { className: className }, element);
|
|
45
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
// See https://github.com/emotion-js/emotion/issues/1105.
|
|
3
|
+
// See https://github.com/emotion-js/emotion/releases/tag/%40emotion%2Fcache%4011.10.2.
|
|
4
|
+
const ignoreSsrWarning = "/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */";
|
|
5
|
+
export const StyledContainer = styled("div") `
|
|
6
|
+
> *:first-child:not(style)${ignoreSsrWarning} {
|
|
7
|
+
margin-top: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
> *:last-child:not(style)${ignoreSsrWarning} {
|
|
11
|
+
margin-bottom: 0;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RowData } from "@tanstack/react-table";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a row has a specific key.
|
|
4
|
+
* Useful for generic accessor functions.
|
|
5
|
+
* @param row - The row to check.
|
|
6
|
+
* @param key - The key to check.
|
|
7
|
+
* @returns True if the row has the specified key, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function rowHasKey<T extends RowData, K extends PropertyKey, TValue>(row: T, key: K): row is T & Record<K, TValue>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to check if a row has a specific key.
|
|
3
|
+
* Useful for generic accessor functions.
|
|
4
|
+
* @param row - The row to check.
|
|
5
|
+
* @param key - The key to check.
|
|
6
|
+
* @returns True if the row has the specified key, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export function rowHasKey(row, key) {
|
|
9
|
+
return row != null && typeof row === "object" && key in row;
|
|
10
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cell, Column, ColumnFiltersState, PaginationState, Row, RowData, Table } from "@tanstack/react-table";
|
|
2
|
-
import {
|
|
2
|
+
import { Category } from "../../../common/categories/models/types";
|
|
3
3
|
import { ExploreMode } from "../../../hooks/useExploreMode/types";
|
|
4
4
|
/**
|
|
5
5
|
* Internal model of a category term count keyed by category term.
|
|
@@ -15,7 +15,7 @@ type PinnedCell<T extends RowData> = [Cell<T, unknown>, number];
|
|
|
15
15
|
* @param columnFilters - Column filters state.
|
|
16
16
|
* @returns Array of category views objects.
|
|
17
17
|
*/
|
|
18
|
-
export declare function buildCategoryViews<T extends RowData>(columns: Column<T>[], columnFilters: ColumnFiltersState):
|
|
18
|
+
export declare function buildCategoryViews<T extends RowData>(columns: Column<T>[], columnFilters: ColumnFiltersState): Category[];
|
|
19
19
|
/**
|
|
20
20
|
* Returns filtered entity results as a blob.
|
|
21
21
|
* @param rows - Table rows.
|
|
@@ -10,23 +10,38 @@ import { COLUMN_IDENTIFIER } from "./columnIdentifier";
|
|
|
10
10
|
export function buildCategoryViews(columns, columnFilters) {
|
|
11
11
|
const categoryViews = [];
|
|
12
12
|
for (const column of columns) {
|
|
13
|
-
const { columnDef, getCanFilter, getFacetedUniqueValues, id } = column;
|
|
13
|
+
const { columnDef, getCanFilter, getFacetedMinMaxValues, getFacetedUniqueValues, id, } = column;
|
|
14
14
|
const { header: columnHeader } = columnDef;
|
|
15
15
|
if (getCanFilter()) {
|
|
16
|
-
updateFacetedUniqueValues(getFacetedUniqueValues(), columnFilters, id);
|
|
17
16
|
const key = id;
|
|
18
17
|
const label = columnHeader;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
// Handle range categories.
|
|
19
|
+
if (columnDef.filterFn === "inNumberRange") {
|
|
20
|
+
const minMax = getFacetedMinMaxValues();
|
|
21
|
+
categoryViews.push({
|
|
22
|
+
key,
|
|
23
|
+
label,
|
|
24
|
+
max: minMax?.[1] || Infinity,
|
|
25
|
+
min: minMax?.[0] || -Infinity,
|
|
26
|
+
selectedMax: null, // Selected state updated in reducer.
|
|
27
|
+
selectedMin: null, // Selected state updated in reducer.
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Handle select categories.
|
|
31
|
+
if (columnDef.filterFn === "arrIncludesSome") {
|
|
32
|
+
updateFacetedUniqueValues(getFacetedUniqueValues(), columnFilters, id);
|
|
33
|
+
const values = [...getFacetedUniqueValues()].map(([value, count]) => ({
|
|
34
|
+
count,
|
|
35
|
+
key: value,
|
|
36
|
+
label: String(value ?? ""),
|
|
37
|
+
selected: false, // Selected state updated in reducer.
|
|
38
|
+
}));
|
|
39
|
+
categoryViews.push({
|
|
40
|
+
key,
|
|
41
|
+
label,
|
|
42
|
+
values: values,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
30
45
|
}
|
|
31
46
|
}
|
|
32
47
|
return categoryViews;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChipProps } from "@mui/material";
|
|
2
|
+
import { CellContext, RowData } from "@tanstack/react-table";
|
|
3
|
+
import { BaseComponentProps } from "../../../../../types";
|
|
4
|
+
export declare const ChipCell: <T extends RowData, TValue extends ChipProps = ChipProps>({ className, getValue, }: BaseComponentProps & CellContext<T, TValue>) => JSX.Element | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LinkProps } from "@mui/material";
|
|
2
|
+
import { CellContext, RowData } from "@tanstack/react-table";
|
|
3
|
+
import { BaseComponentProps } from "components/types";
|
|
4
|
+
export declare const LinkCell: <T extends RowData, TValue extends LinkProps = LinkProps>({ className, getValue, }: BaseComponentProps & CellContext<T, TValue>) => JSX.Element | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Link as MLink, Typography } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { isValidUrl } from "../../../../../../common/utils";
|
|
4
|
+
import { TYPOGRAPHY_PROPS } from "../../../../../../styles/common/mui/typography";
|
|
5
|
+
import { isClientSideNavigation } from "../../../../../Links/common/utils";
|
|
6
|
+
import { getComponent, getRelAttribute, getTargetAttribute } from "./utils";
|
|
7
|
+
export const LinkCell = ({ className, getValue, }) => {
|
|
8
|
+
const props = getValue();
|
|
9
|
+
if (!props)
|
|
10
|
+
return null;
|
|
11
|
+
const { children, color, href = "", rel, target, underline, ...linkProps } = props;
|
|
12
|
+
// Determine if the href should use client-side navigation.
|
|
13
|
+
const isClientSide = isClientSideNavigation(href);
|
|
14
|
+
// Determine if the href is valid.
|
|
15
|
+
const isValid = isClientSide || isValidUrl(href);
|
|
16
|
+
// If the href is invalid, return a Typography component.
|
|
17
|
+
if (!isValid)
|
|
18
|
+
return (React.createElement(Typography, { className: className, color: TYPOGRAPHY_PROPS.COLOR.INHERIT, component: "span", variant: TYPOGRAPHY_PROPS.VARIANT.INHERIT, ...linkProps }, children));
|
|
19
|
+
// If the href is valid, return a Link component.
|
|
20
|
+
return (React.createElement(MLink, { className: className, color: color, component: getComponent(href, isClientSide), href: href, rel: getRelAttribute(rel, isClientSide), target: getTargetAttribute(target, isClientSide), underline: underline, ...linkProps }, children));
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { LinkCell } from "../linkCell";
|
|
3
|
+
export declare const CLIENT_SIDE_ARGS: Partial<ComponentProps<typeof LinkCell>>;
|
|
4
|
+
export declare const EXTERNAL_ARGS: Partial<ComponentProps<typeof LinkCell>>;
|
|
5
|
+
export declare const INVALID_ARGS: Partial<ComponentProps<typeof LinkCell>>;
|
|
6
|
+
export declare const WITH_CUSTOM_STYLE_ARGS: Partial<ComponentProps<typeof LinkCell>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TYPOGRAPHY_PROPS } from "../../../../../../../styles/common/mui/typography";
|
|
2
|
+
export const CLIENT_SIDE_ARGS = {
|
|
3
|
+
getValue: (() => ({
|
|
4
|
+
children: "Explore",
|
|
5
|
+
href: "/",
|
|
6
|
+
})),
|
|
7
|
+
};
|
|
8
|
+
export const EXTERNAL_ARGS = {
|
|
9
|
+
getValue: (() => ({
|
|
10
|
+
children: "Explore",
|
|
11
|
+
href: "https://www.example.com",
|
|
12
|
+
})),
|
|
13
|
+
};
|
|
14
|
+
export const INVALID_ARGS = {
|
|
15
|
+
getValue: (() => ({
|
|
16
|
+
children: "Explore",
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
19
|
+
export const WITH_CUSTOM_STYLE_ARGS = {
|
|
20
|
+
getValue: (() => ({
|
|
21
|
+
children: "Explore",
|
|
22
|
+
color: "success",
|
|
23
|
+
href: "/",
|
|
24
|
+
underline: "none",
|
|
25
|
+
variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_SMALL_400,
|
|
26
|
+
})),
|
|
27
|
+
};
|
package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { LinkCell } from "../linkCell";
|
|
3
|
+
declare const meta: Meta<typeof LinkCell>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const ClientSide: Story;
|
|
7
|
+
export declare const External: Story;
|
|
8
|
+
export declare const Invalid: Story;
|
|
9
|
+
export declare const WithCustomStyle: Story;
|
package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LinkCell } from "../linkCell";
|
|
2
|
+
import { CLIENT_SIDE_ARGS, EXTERNAL_ARGS, INVALID_ARGS, WITH_CUSTOM_STYLE_ARGS, } from "./args";
|
|
3
|
+
const meta = {
|
|
4
|
+
component: LinkCell,
|
|
5
|
+
};
|
|
6
|
+
export default meta;
|
|
7
|
+
export const ClientSide = {
|
|
8
|
+
args: CLIENT_SIDE_ARGS,
|
|
9
|
+
};
|
|
10
|
+
export const External = {
|
|
11
|
+
args: EXTERNAL_ARGS,
|
|
12
|
+
};
|
|
13
|
+
export const Invalid = {
|
|
14
|
+
args: INVALID_ARGS,
|
|
15
|
+
};
|
|
16
|
+
export const WithCustomStyle = {
|
|
17
|
+
args: WITH_CUSTOM_STYLE_ARGS,
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ElementType } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the component to use for a link based on the given href and client-side navigation flag.
|
|
4
|
+
* @param href - The href attribute to use.
|
|
5
|
+
* @param isClientSide - Whether the link is a client-side navigation.
|
|
6
|
+
* @returns The component to use for the link.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getComponent(href: string, isClientSide: boolean): ElementType;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the rel attribute for a link based on the given rel and client-side navigation flag.
|
|
11
|
+
* @param rel - The rel attribute to use.
|
|
12
|
+
* @param isClientSideNavigation - Whether the link is a client-side navigation.
|
|
13
|
+
* @returns The rel attribute for the link.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getRelAttribute(rel: string | undefined, isClientSideNavigation: boolean): string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the target attribute for a link based on the given target and client-side navigation flag.
|
|
18
|
+
* @param target - The target attribute to use.
|
|
19
|
+
* @param isClientSideNavigation - Whether the link is a client-side navigation.
|
|
20
|
+
* @returns The target attribute for the link.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTargetAttribute(target: string | undefined, isClientSideNavigation: boolean): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import { isValidUrl } from "../../../../../../common/utils";
|
|
3
|
+
import { ANCHOR_TARGET, REL_ATTRIBUTE, } from "../../../../../Links/common/entities";
|
|
4
|
+
import { assertAnchorRelAttribute, assertAnchorTargetAttribute, } from "../../../../../common/Link/typeGuards";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the component to use for a link based on the given href and client-side navigation flag.
|
|
7
|
+
* @param href - The href attribute to use.
|
|
8
|
+
* @param isClientSide - Whether the link is a client-side navigation.
|
|
9
|
+
* @returns The component to use for the link.
|
|
10
|
+
*/
|
|
11
|
+
export function getComponent(href, isClientSide) {
|
|
12
|
+
if (isClientSide)
|
|
13
|
+
return Link; // Use Next/Link for client-side navigation.
|
|
14
|
+
if (isValidUrl(href))
|
|
15
|
+
return "a"; // Use anchor tag for external links.
|
|
16
|
+
return "span"; // Use span for invalid links.
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the rel attribute for a link based on the given rel and client-side navigation flag.
|
|
20
|
+
* @param rel - The rel attribute to use.
|
|
21
|
+
* @param isClientSideNavigation - Whether the link is a client-side navigation.
|
|
22
|
+
* @returns The rel attribute for the link.
|
|
23
|
+
*/
|
|
24
|
+
export function getRelAttribute(rel, isClientSideNavigation) {
|
|
25
|
+
if (rel) {
|
|
26
|
+
assertAnchorRelAttribute(rel);
|
|
27
|
+
return rel;
|
|
28
|
+
}
|
|
29
|
+
return isClientSideNavigation
|
|
30
|
+
? REL_ATTRIBUTE.NO_OPENER
|
|
31
|
+
: REL_ATTRIBUTE.NO_OPENER_NO_REFERRER;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the target attribute for a link based on the given target and client-side navigation flag.
|
|
35
|
+
* @param target - The target attribute to use.
|
|
36
|
+
* @param isClientSideNavigation - Whether the link is a client-side navigation.
|
|
37
|
+
* @returns The target attribute for the link.
|
|
38
|
+
*/
|
|
39
|
+
export function getTargetAttribute(target, isClientSideNavigation) {
|
|
40
|
+
if (target) {
|
|
41
|
+
assertAnchorTargetAttribute(target);
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
return isClientSideNavigation ? ANCHOR_TARGET.SELF : ANCHOR_TARGET.BLANK;
|
|
45
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CellContext, RowData } from "@tanstack/react-table";
|
|
2
|
+
import { BaseComponentProps } from "components/types";
|
|
3
|
+
import { MarkdownCellProps } from "./types";
|
|
4
|
+
export declare const MarkdownCell: <T extends RowData, TValue extends MarkdownCellProps = MarkdownCellProps>({ className, column, getValue, }: BaseComponentProps & CellContext<T, TValue>) => JSX.Element | null;
|