@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.
Files changed (283) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +35 -0
  3. package/lib/common/categories/config/types.d.ts +28 -0
  4. package/lib/common/categories/config/utils.d.ts +31 -0
  5. package/lib/common/categories/config/utils.js +29 -0
  6. package/lib/common/categories/models/range/typeGuards.d.ts +14 -0
  7. package/lib/common/categories/models/range/typeGuards.js +18 -0
  8. package/lib/common/categories/models/range/types.d.ts +15 -0
  9. package/lib/common/categories/models/range/types.js +1 -0
  10. package/lib/common/categories/models/range/utils.d.ts +23 -0
  11. package/lib/common/categories/models/range/utils.js +41 -0
  12. package/lib/common/categories/models/select/utils.d.ts +8 -0
  13. package/lib/common/categories/models/select/utils.js +16 -0
  14. package/lib/common/categories/models/types.d.ts +6 -0
  15. package/lib/common/categories/models/types.js +1 -0
  16. package/lib/common/categories/views/common/types.d.ts +10 -0
  17. package/lib/common/categories/views/common/types.js +1 -0
  18. package/lib/common/categories/views/range/typeGuards.d.ts +8 -0
  19. package/lib/common/categories/views/range/typeGuards.js +8 -0
  20. package/lib/common/categories/views/range/types.d.ts +19 -0
  21. package/lib/common/categories/views/range/types.js +1 -0
  22. package/lib/common/categories/views/range/utils.d.ts +12 -0
  23. package/lib/common/categories/views/range/utils.js +24 -0
  24. package/lib/common/categories/views/select/typeGuards.d.ts +8 -0
  25. package/lib/common/categories/views/select/typeGuards.js +8 -0
  26. package/lib/common/categories/views/select/types.d.ts +7 -0
  27. package/lib/common/categories/views/select/types.js +1 -0
  28. package/lib/common/categories/views/types.d.ts +13 -0
  29. package/lib/common/categories/views/types.js +8 -0
  30. package/lib/common/entities.d.ts +8 -23
  31. package/lib/components/DataDictionary/components/Entities/entities.d.ts +3 -1
  32. package/lib/components/DataDictionary/components/Entities/entities.js +1 -1
  33. package/lib/components/DataDictionary/components/Entities/types.d.ts +5 -5
  34. package/lib/components/DataDictionary/components/Entity/entity.d.ts +3 -1
  35. package/lib/components/DataDictionary/components/Entity/entity.js +6 -6
  36. package/lib/components/DataDictionary/components/Entity/types.d.ts +5 -5
  37. package/lib/components/DataDictionary/components/Outline/utils.d.ts +3 -2
  38. package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.d.ts +3 -2
  39. package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.js +6 -2
  40. package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.d.ts +9 -0
  41. package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.js +12 -0
  42. package/lib/components/DataDictionary/components/Table/hook.d.ts +3 -3
  43. package/lib/components/DataDictionary/components/Table/hook.js +3 -1
  44. package/lib/components/DataDictionary/components/Table/options/core/constants.d.ts +2 -3
  45. package/lib/components/DataDictionary/components/Table/options/hook.d.ts +2 -2
  46. package/lib/components/DataDictionary/components/Table/options/sorting/constants.d.ts +2 -3
  47. package/lib/components/DataDictionary/components/Table/table.d.ts +2 -1
  48. package/lib/components/DataDictionary/components/Table/table.js +1 -1
  49. package/lib/components/DataDictionary/components/Table/types.d.ts +3 -4
  50. package/lib/components/DataDictionary/dataDictionary.d.ts +3 -1
  51. package/lib/components/DataDictionary/dataDictionary.styles.js +2 -3
  52. package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.d.ts +3 -1
  53. package/lib/components/DataDictionary/hooks/UseDataDictionary/types.d.ts +5 -5
  54. package/lib/components/Filter/components/Filter/filter.d.ts +2 -2
  55. package/lib/components/Filter/components/Filter/filter.js +11 -3
  56. package/lib/components/Filter/components/Filter/stories/args.d.ts +5 -0
  57. package/lib/components/Filter/components/Filter/stories/args.js +19 -0
  58. package/lib/components/Filter/components/Filter/stories/filter.stories.d.ts +8 -0
  59. package/lib/components/Filter/components/Filter/stories/filter.stories.js +21 -0
  60. package/lib/components/Filter/components/FilterMenu/filterMenu.js +2 -2
  61. package/lib/components/Filter/components/FilterMenu/filterMenu.styles.d.ts +1 -1
  62. package/lib/components/Filter/components/FilterMenu/filterMenu.styles.js +1 -1
  63. package/lib/components/Filter/components/FilterRange/constants.d.ts +0 -2
  64. package/lib/components/Filter/components/FilterRange/constants.js +0 -5
  65. package/lib/components/Filter/components/FilterRange/filterRange.d.ts +1 -1
  66. package/lib/components/Filter/components/FilterRange/filterRange.js +50 -21
  67. package/lib/components/Filter/components/FilterRange/filterRange.styles.js +58 -10
  68. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.d.ts +5 -0
  69. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.js +5 -0
  70. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.d.ts +2 -2
  71. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.js +32 -7
  72. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.d.ts +6 -0
  73. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.js +50 -0
  74. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.d.ts +26 -3
  75. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.js +6 -1
  76. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.d.ts +15 -0
  77. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.js +25 -0
  78. package/lib/components/Filter/components/FilterRange/stories/args.d.ts +3 -0
  79. package/lib/components/Filter/components/FilterRange/stories/args.js +13 -0
  80. package/lib/components/Filter/components/FilterRange/stories/filterRange.stories.js +2 -2
  81. package/lib/components/Filter/components/FilterRange/types.d.ts +10 -6
  82. package/lib/components/Filter/components/FilterRange/types.js +1 -6
  83. package/lib/components/Filter/components/FilterRange/utils.d.ts +8 -0
  84. package/lib/components/Filter/components/FilterRange/utils.js +15 -0
  85. package/lib/components/Filter/components/FilterTag/stories/args.d.ts +5 -0
  86. package/lib/components/Filter/components/FilterTag/stories/args.js +17 -0
  87. package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.d.ts +8 -0
  88. package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.js +21 -0
  89. package/lib/components/Filter/components/FilterTag/utils.d.ts +10 -0
  90. package/lib/components/Filter/components/FilterTag/utils.js +40 -0
  91. package/lib/components/Filter/components/Filters/filters.d.ts +2 -2
  92. package/lib/components/Filter/components/Filters/filters.js +15 -8
  93. package/lib/components/Filter/components/Filters/stories/args.d.ts +3 -0
  94. package/lib/components/Filter/components/Filters/stories/args.js +15 -0
  95. package/lib/components/Filter/components/Filters/stories/constants.d.ts +22 -0
  96. package/lib/components/Filter/components/Filters/stories/constants.js +134 -0
  97. package/lib/components/Filter/components/Filters/stories/filters.stories.d.ts +6 -0
  98. package/lib/components/Filter/components/Filters/stories/filters.stories.js +15 -0
  99. package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.d.ts +1 -1
  100. package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.js +5 -5
  101. package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.js +2 -1
  102. package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.d.ts +3 -2
  103. package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.js +6 -4
  104. package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.js +2 -1
  105. package/lib/components/Index/components/EntitiesView/components/ChartView/utils.js +2 -0
  106. package/lib/components/Index/table/hook.js +4 -0
  107. package/lib/components/MarkdownRenderer/components/Anchor/anchor.d.ts +19 -0
  108. package/lib/components/MarkdownRenderer/components/Anchor/anchor.js +21 -0
  109. package/lib/components/MarkdownRenderer/components/Table/table.d.ts +3 -0
  110. package/lib/components/MarkdownRenderer/components/Table/table.js +5 -0
  111. package/lib/components/MarkdownRenderer/components/Table/table.styles.d.ts +4 -0
  112. package/lib/components/MarkdownRenderer/components/Table/table.styles.js +40 -0
  113. package/lib/components/MarkdownRenderer/constants.d.ts +2 -0
  114. package/lib/components/MarkdownRenderer/constants.js +6 -0
  115. package/lib/components/MarkdownRenderer/markdownRenderer.d.ts +2 -0
  116. package/lib/components/MarkdownRenderer/markdownRenderer.js +45 -0
  117. package/lib/components/MarkdownRenderer/markdownRenderer.styles.d.ts +4 -0
  118. package/lib/components/MarkdownRenderer/markdownRenderer.styles.js +13 -0
  119. package/lib/components/MarkdownRenderer/types.d.ts +6 -0
  120. package/lib/components/MarkdownRenderer/types.js +1 -0
  121. package/lib/components/Table/columnDef/accessorFn/typeGuards.d.ts +9 -0
  122. package/lib/components/Table/columnDef/accessorFn/typeGuards.js +10 -0
  123. package/lib/components/Table/common/utils.d.ts +2 -2
  124. package/lib/components/Table/common/utils.js +28 -13
  125. package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.d.ts +4 -0
  126. package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.js +8 -0
  127. package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.d.ts +4 -0
  128. package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.js +21 -0
  129. package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.d.ts +6 -0
  130. package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.js +27 -0
  131. package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.d.ts +9 -0
  132. package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.js +18 -0
  133. package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.d.ts +3 -0
  134. package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.js +1 -0
  135. package/lib/components/Table/components/TableCell/components/LinkCell/utils.d.ts +22 -0
  136. package/lib/components/Table/components/TableCell/components/LinkCell/utils.js +45 -0
  137. package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.d.ts +4 -0
  138. package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.js +13 -0
  139. package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.d.ts +3 -0
  140. package/lib/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.js +30 -0
  141. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.d.ts +4 -0
  142. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/args.js +10 -0
  143. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.d.ts +5 -0
  144. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/constants.js +9 -0
  145. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.d.ts +7 -0
  146. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.js +25 -0
  147. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.d.ts +3 -0
  148. package/lib/components/Table/components/TableCell/components/MarkdownCell/stories/types.js +1 -0
  149. package/lib/components/Table/components/TableCell/components/MarkdownCell/types.d.ts +3 -0
  150. package/lib/components/Table/components/TableCell/components/MarkdownCell/types.js +1 -0
  151. package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.d.ts +8 -0
  152. package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.js +46 -0
  153. package/lib/components/common/Link/typeGuards.d.ts +13 -0
  154. package/lib/components/common/Link/typeGuards.js +21 -0
  155. package/lib/config/entities.d.ts +2 -11
  156. package/lib/hooks/useCategoryFilter.d.ts +8 -13
  157. package/lib/hooks/useCategoryFilter.js +31 -28
  158. package/lib/providers/exploreState/entities.d.ts +5 -3
  159. package/lib/providers/exploreState/payloads/entities.d.ts +6 -2
  160. package/lib/providers/exploreState.d.ts +3 -2
  161. package/lib/providers/exploreState.js +1 -1
  162. package/lib/styles/common/mui/typography.js +1 -0
  163. package/lib/tests/utils.d.ts +24 -0
  164. package/lib/tests/utils.js +34 -0
  165. package/lib/theme/common/components.js +19 -1
  166. package/lib/views/ExploreView/exploreView.js +10 -8
  167. package/package.json +7 -1
  168. package/src/common/categories/config/types.ts +42 -0
  169. package/src/common/categories/config/utils.ts +47 -0
  170. package/src/common/categories/models/range/typeGuards.ts +24 -0
  171. package/src/common/categories/models/range/types.ts +17 -0
  172. package/src/common/categories/models/range/utils.ts +51 -0
  173. package/src/common/categories/models/select/utils.ts +23 -0
  174. package/src/common/categories/models/types.ts +7 -0
  175. package/src/common/categories/views/common/types.ts +11 -0
  176. package/src/common/categories/views/range/typeGuards.ts +13 -0
  177. package/src/common/categories/views/range/types.ts +21 -0
  178. package/src/common/categories/views/range/utils.ts +35 -0
  179. package/src/common/categories/views/select/typeGuards.ts +13 -0
  180. package/src/common/categories/views/select/types.ts +8 -0
  181. package/src/common/categories/views/types.ts +15 -0
  182. package/src/common/entities.ts +8 -26
  183. package/src/components/DataDictionary/components/Entities/entities.tsx +7 -5
  184. package/src/components/DataDictionary/components/Entities/types.ts +5 -9
  185. package/src/components/DataDictionary/components/Entity/entity.tsx +9 -7
  186. package/src/components/DataDictionary/components/Entity/types.ts +5 -9
  187. package/src/components/DataDictionary/components/Outline/utils.ts +5 -2
  188. package/src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx +12 -4
  189. package/src/components/DataDictionary/components/Table/components/BasicCell/utils.ts +13 -0
  190. package/src/components/DataDictionary/components/Table/hook.ts +16 -8
  191. package/src/components/DataDictionary/components/Table/options/core/constants.ts +2 -3
  192. package/src/components/DataDictionary/components/Table/options/hook.ts +3 -3
  193. package/src/components/DataDictionary/components/Table/options/sorting/constants.ts +2 -6
  194. package/src/components/DataDictionary/components/Table/table.tsx +4 -1
  195. package/src/components/DataDictionary/components/Table/types.ts +3 -4
  196. package/src/components/DataDictionary/dataDictionary.styles.ts +2 -3
  197. package/src/components/DataDictionary/dataDictionary.tsx +4 -2
  198. package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +9 -2
  199. package/src/components/DataDictionary/hooks/UseDataDictionary/types.ts +5 -9
  200. package/src/components/Filter/components/Filter/filter.tsx +38 -13
  201. package/src/components/Filter/components/Filter/stories/args.ts +24 -0
  202. package/src/components/Filter/components/Filter/stories/filter.stories.tsx +32 -0
  203. package/src/components/Filter/components/FilterMenu/filterMenu.styles.ts +1 -1
  204. package/src/components/Filter/components/FilterMenu/filterMenu.tsx +7 -3
  205. package/src/components/Filter/components/FilterRange/constants.ts +0 -7
  206. package/src/components/Filter/components/FilterRange/filterRange.styles.ts +58 -14
  207. package/src/components/Filter/components/FilterRange/filterRange.tsx +112 -40
  208. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.ts +5 -0
  209. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.ts +51 -10
  210. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.ts +60 -0
  211. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/types.ts +34 -3
  212. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.ts +32 -0
  213. package/src/components/Filter/components/FilterRange/stories/args.ts +16 -0
  214. package/src/components/Filter/components/FilterRange/stories/filterRange.stories.tsx +2 -2
  215. package/src/components/Filter/components/FilterRange/types.ts +12 -6
  216. package/src/components/Filter/components/FilterRange/utils.ts +16 -0
  217. package/src/components/Filter/components/FilterTag/stories/args.ts +22 -0
  218. package/src/components/Filter/components/FilterTag/stories/filterTag.stories.tsx +32 -0
  219. package/src/components/Filter/components/FilterTag/utils.ts +57 -0
  220. package/src/components/Filter/components/Filters/filters.tsx +21 -12
  221. package/src/components/Filter/components/Filters/stories/args.ts +24 -0
  222. package/src/components/Filter/components/Filters/stories/constants.ts +151 -0
  223. package/src/components/Filter/components/Filters/stories/filters.stories.tsx +24 -0
  224. package/src/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.tsx +32 -29
  225. package/src/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.tsx +9 -1
  226. package/src/components/Filter/components/SearchAllFilters/searchAllFilters.tsx +12 -6
  227. package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +2 -1
  228. package/src/components/Index/components/EntitiesView/components/ChartView/utils.ts +2 -0
  229. package/src/components/Index/table/hook.ts +4 -0
  230. package/src/components/MarkdownRenderer/components/Anchor/anchor.tsx +34 -0
  231. package/src/components/MarkdownRenderer/components/Table/table.styles.ts +41 -0
  232. package/src/components/MarkdownRenderer/components/Table/table.tsx +13 -0
  233. package/src/components/MarkdownRenderer/constants.ts +8 -0
  234. package/src/components/MarkdownRenderer/markdownRenderer.styles.ts +16 -0
  235. package/src/components/MarkdownRenderer/markdownRenderer.tsx +62 -0
  236. package/src/components/MarkdownRenderer/types.ts +7 -0
  237. package/src/components/Table/columnDef/accessorFn/typeGuards.ts +15 -0
  238. package/src/components/Table/common/utils.ts +37 -16
  239. package/src/components/Table/components/TableCell/components/ChipCell/chipCell.tsx +16 -0
  240. package/src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx +64 -0
  241. package/src/components/Table/components/TableCell/components/LinkCell/stories/args.ts +35 -0
  242. package/src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx +32 -0
  243. package/src/components/Table/components/TableCell/components/LinkCell/stories/types.ts +4 -0
  244. package/src/components/Table/components/TableCell/components/LinkCell/utils.ts +59 -0
  245. package/src/components/Table/components/TableCell/components/MarkdownCell/markdownCell.styles.ts +31 -0
  246. package/src/components/Table/components/TableCell/components/MarkdownCell/markdownCell.tsx +29 -0
  247. package/src/components/Table/components/TableCell/components/MarkdownCell/stories/args.ts +17 -0
  248. package/src/components/Table/components/TableCell/components/MarkdownCell/stories/constants.ts +11 -0
  249. package/src/components/Table/components/TableCell/components/MarkdownCell/stories/markdownCell.stories.tsx +37 -0
  250. package/src/components/Table/components/TableCell/components/MarkdownCell/stories/types.ts +4 -0
  251. package/src/components/Table/components/TableCell/components/MarkdownCell/types.ts +3 -0
  252. package/src/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.ts +64 -0
  253. package/src/components/common/Link/typeGuards.ts +35 -0
  254. package/src/config/entities.ts +1 -14
  255. package/src/hooks/useCategoryFilter.ts +56 -53
  256. package/src/providers/exploreState/entities.ts +3 -3
  257. package/src/providers/exploreState/initializer/utils.ts +1 -1
  258. package/src/providers/exploreState/payloads/entities.ts +5 -2
  259. package/src/providers/exploreState.tsx +5 -3
  260. package/src/styles/common/mui/typography.ts +1 -0
  261. package/src/tests/utils.ts +44 -0
  262. package/src/theme/common/components.ts +19 -1
  263. package/src/views/ExploreView/exploreView.tsx +17 -22
  264. package/tests/filter.test.tsx +100 -0
  265. package/tests/filterRange.test.tsx +331 -46
  266. package/tests/filters.test.tsx +61 -0
  267. package/tests/getFacetedMinMaxValues.test.ts +166 -0
  268. package/tests/linkCell.test.tsx +89 -0
  269. package/tests/markdownCell.test.tsx +53 -0
  270. package/types/data-explorer-ui.d.ts +2 -0
  271. package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +0 -3
  272. package/lib/components/Filter/components/Filter/filter.stories.d.ts +0 -25
  273. package/lib/components/Filter/components/Filter/filter.stories.js +0 -42
  274. package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +0 -16
  275. package/lib/components/Filter/components/FilterTag/filterTag.stories.js +0 -17
  276. package/lib/components/Filter/components/Filters/filters.stories.d.ts +0 -6
  277. package/lib/components/Filter/components/Filters/filters.stories.js +0 -91
  278. package/src/components/DataDictionary/components/Table/components/BasicCell/types.ts +0 -7
  279. package/src/components/Filter/components/Filter/filter.stories.tsx +0 -52
  280. package/src/components/Filter/components/FilterTag/filterTag.stories.tsx +0 -23
  281. package/src/components/Filter/components/Filters/filters.stories.tsx +0 -101
  282. package/tests/filterRangeMock.test.tsx +0 -38
  283. /package/lib/{components/DataDictionary/components/Table/components/BasicCell → common/categories/config}/types.js +0 -0
@@ -9,7 +9,7 @@ import {
9
9
  sortingFns,
10
10
  Table,
11
11
  } from "@tanstack/react-table";
12
- import { SelectCategory } from "../../../common/entities";
12
+ import { Category } from "../../../common/categories/models/types";
13
13
  import { EXPLORE_MODE, ExploreMode } from "../../../hooks/useExploreMode/types";
14
14
  import { COLUMN_IDENTIFIER } from "./columnIdentifier";
15
15
 
@@ -38,26 +38,47 @@ type TableData = number | string | string[];
38
38
  export function buildCategoryViews<T extends RowData>(
39
39
  columns: Column<T>[],
40
40
  columnFilters: ColumnFiltersState
41
- ): SelectCategory[] {
42
- const categoryViews: SelectCategory[] = [];
41
+ ): Category[] {
42
+ const categoryViews: Category[] = [];
43
43
  for (const column of columns) {
44
- const { columnDef, getCanFilter, getFacetedUniqueValues, id } = column;
44
+ const {
45
+ columnDef,
46
+ getCanFilter,
47
+ getFacetedMinMaxValues,
48
+ getFacetedUniqueValues,
49
+ id,
50
+ } = column;
45
51
  const { header: columnHeader } = columnDef;
46
52
  if (getCanFilter()) {
47
- updateFacetedUniqueValues(getFacetedUniqueValues(), columnFilters, id);
48
53
  const key = id;
49
54
  const label = columnHeader as string;
50
- const values = [...getFacetedUniqueValues()].map(([value, count]) => ({
51
- count,
52
- key: value,
53
- label: String(value ?? ""),
54
- selected: false, // Selected state updated in reducer.
55
- }));
56
- categoryViews.push({
57
- key,
58
- label,
59
- values: values,
60
- });
55
+ // Handle range categories.
56
+ if (columnDef.filterFn === "inNumberRange") {
57
+ const minMax = getFacetedMinMaxValues();
58
+ categoryViews.push({
59
+ key,
60
+ label,
61
+ max: minMax?.[1] || Infinity,
62
+ min: minMax?.[0] || -Infinity,
63
+ selectedMax: null, // Selected state updated in reducer.
64
+ selectedMin: null, // Selected state updated in reducer.
65
+ });
66
+ }
67
+ // Handle select categories.
68
+ if (columnDef.filterFn === "arrIncludesSome") {
69
+ updateFacetedUniqueValues(getFacetedUniqueValues(), columnFilters, id);
70
+ const values = [...getFacetedUniqueValues()].map(([value, count]) => ({
71
+ count,
72
+ key: value,
73
+ label: String(value ?? ""),
74
+ selected: false, // Selected state updated in reducer.
75
+ }));
76
+ categoryViews.push({
77
+ key,
78
+ label,
79
+ values: values,
80
+ });
81
+ }
61
82
  }
62
83
  }
63
84
  return categoryViews;
@@ -0,0 +1,16 @@
1
+ import { Chip, ChipProps } from "@mui/material";
2
+ import { CellContext, RowData } from "@tanstack/react-table";
3
+ import React from "react";
4
+ import { BaseComponentProps } from "../../../../../types";
5
+
6
+ export const ChipCell = <
7
+ T extends RowData,
8
+ TValue extends ChipProps = ChipProps
9
+ >({
10
+ className,
11
+ getValue,
12
+ }: BaseComponentProps & CellContext<T, TValue>): JSX.Element | null => {
13
+ const props = getValue();
14
+ if (!props) return null;
15
+ return <Chip className={className} {...props} />;
16
+ };
@@ -0,0 +1,64 @@
1
+ import { LinkProps, Link as MLink, Typography } from "@mui/material";
2
+ import { CellContext, RowData } from "@tanstack/react-table";
3
+ import { BaseComponentProps } from "components/types";
4
+ import React from "react";
5
+ import { isValidUrl } from "../../../../../../common/utils";
6
+ import { TYPOGRAPHY_PROPS } from "../../../../../../styles/common/mui/typography";
7
+ import { isClientSideNavigation } from "../../../../../Links/common/utils";
8
+ import { getComponent, getRelAttribute, getTargetAttribute } from "./utils";
9
+
10
+ export const LinkCell = <
11
+ T extends RowData,
12
+ TValue extends LinkProps = LinkProps
13
+ >({
14
+ className,
15
+ getValue,
16
+ }: BaseComponentProps & CellContext<T, TValue>): JSX.Element | null => {
17
+ const props = getValue();
18
+ if (!props) return null;
19
+ const {
20
+ children,
21
+ color,
22
+ href = "",
23
+ rel,
24
+ target,
25
+ underline,
26
+ ...linkProps
27
+ } = props;
28
+
29
+ // Determine if the href should use client-side navigation.
30
+ const isClientSide = isClientSideNavigation(href);
31
+
32
+ // Determine if the href is valid.
33
+ const isValid = isClientSide || isValidUrl(href);
34
+
35
+ // If the href is invalid, return a Typography component.
36
+ if (!isValid)
37
+ return (
38
+ <Typography
39
+ className={className}
40
+ color={TYPOGRAPHY_PROPS.COLOR.INHERIT}
41
+ component="span"
42
+ variant={TYPOGRAPHY_PROPS.VARIANT.INHERIT}
43
+ {...linkProps}
44
+ >
45
+ {children}
46
+ </Typography>
47
+ );
48
+
49
+ // If the href is valid, return a Link component.
50
+ return (
51
+ <MLink
52
+ className={className}
53
+ color={color}
54
+ component={getComponent(href, isClientSide)}
55
+ href={href}
56
+ rel={getRelAttribute(rel, isClientSide)}
57
+ target={getTargetAttribute(target, isClientSide)}
58
+ underline={underline}
59
+ {...linkProps}
60
+ >
61
+ {children}
62
+ </MLink>
63
+ );
64
+ };
@@ -0,0 +1,35 @@
1
+ import { ComponentProps } from "react";
2
+ import { TYPOGRAPHY_PROPS } from "../../../../../../../styles/common/mui/typography";
3
+ import { LinkCell } from "../linkCell";
4
+ import { GetValue } from "./types";
5
+
6
+ export const CLIENT_SIDE_ARGS: Partial<ComponentProps<typeof LinkCell>> = {
7
+ getValue: (() => ({
8
+ children: "Explore",
9
+ href: "/",
10
+ })) as GetValue,
11
+ };
12
+
13
+ export const EXTERNAL_ARGS: Partial<ComponentProps<typeof LinkCell>> = {
14
+ getValue: (() => ({
15
+ children: "Explore",
16
+ href: "https://www.example.com",
17
+ })) as GetValue,
18
+ };
19
+
20
+ export const INVALID_ARGS: Partial<ComponentProps<typeof LinkCell>> = {
21
+ getValue: (() => ({
22
+ children: "Explore",
23
+ })) as GetValue,
24
+ };
25
+
26
+ export const WITH_CUSTOM_STYLE_ARGS: Partial<ComponentProps<typeof LinkCell>> =
27
+ {
28
+ getValue: (() => ({
29
+ children: "Explore",
30
+ color: "success",
31
+ href: "/",
32
+ underline: "none",
33
+ variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_SMALL_400,
34
+ })) as GetValue,
35
+ };
@@ -0,0 +1,32 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { LinkCell } from "../linkCell";
3
+ import {
4
+ CLIENT_SIDE_ARGS,
5
+ EXTERNAL_ARGS,
6
+ INVALID_ARGS,
7
+ WITH_CUSTOM_STYLE_ARGS,
8
+ } from "./args";
9
+
10
+ const meta: Meta<typeof LinkCell> = {
11
+ component: LinkCell,
12
+ };
13
+
14
+ export default meta;
15
+
16
+ type Story = StoryObj<typeof meta>;
17
+
18
+ export const ClientSide: Story = {
19
+ args: CLIENT_SIDE_ARGS,
20
+ };
21
+
22
+ export const External: Story = {
23
+ args: EXTERNAL_ARGS,
24
+ };
25
+
26
+ export const Invalid: Story = {
27
+ args: INVALID_ARGS,
28
+ };
29
+
30
+ export const WithCustomStyle: Story = {
31
+ args: WITH_CUSTOM_STYLE_ARGS,
32
+ };
@@ -0,0 +1,4 @@
1
+ import { LinkProps } from "@mui/material";
2
+ import { CellContext, RowData } from "@tanstack/react-table";
3
+
4
+ export type GetValue = CellContext<RowData, LinkProps>["getValue"];
@@ -0,0 +1,59 @@
1
+ import Link from "next/link";
2
+ import { ElementType } from "react";
3
+ import { isValidUrl } from "../../../../../../common/utils";
4
+ import {
5
+ ANCHOR_TARGET,
6
+ REL_ATTRIBUTE,
7
+ } from "../../../../../Links/common/entities";
8
+ import {
9
+ assertAnchorRelAttribute,
10
+ assertAnchorTargetAttribute,
11
+ } from "../../../../../common/Link/typeGuards";
12
+
13
+ /**
14
+ * Returns the component to use for a link based on the given href and client-side navigation flag.
15
+ * @param href - The href attribute to use.
16
+ * @param isClientSide - Whether the link is a client-side navigation.
17
+ * @returns The component to use for the link.
18
+ */
19
+ export function getComponent(href: string, isClientSide: boolean): ElementType {
20
+ if (isClientSide) return Link; // Use Next/Link for client-side navigation.
21
+ if (isValidUrl(href)) return "a"; // Use anchor tag for external links.
22
+ return "span"; // Use span for invalid links.
23
+ }
24
+
25
+ /**
26
+ * Returns the rel attribute for a link based on the given rel and client-side navigation flag.
27
+ * @param rel - The rel attribute to use.
28
+ * @param isClientSideNavigation - Whether the link is a client-side navigation.
29
+ * @returns The rel attribute for the link.
30
+ */
31
+ export function getRelAttribute(
32
+ rel: string | undefined,
33
+ isClientSideNavigation: boolean
34
+ ): string {
35
+ if (rel) {
36
+ assertAnchorRelAttribute(rel);
37
+ return rel;
38
+ }
39
+ return isClientSideNavigation
40
+ ? REL_ATTRIBUTE.NO_OPENER
41
+ : REL_ATTRIBUTE.NO_OPENER_NO_REFERRER;
42
+ }
43
+
44
+ /**
45
+ * Returns the target attribute for a link based on the given target and client-side navigation flag.
46
+ * @param target - The target attribute to use.
47
+ * @param isClientSideNavigation - Whether the link is a client-side navigation.
48
+ * @returns The target attribute for the link.
49
+ */
50
+ export function getTargetAttribute(
51
+ target: string | undefined,
52
+ isClientSideNavigation: boolean
53
+ ): string {
54
+ if (target) {
55
+ assertAnchorTargetAttribute(target);
56
+ return target;
57
+ }
58
+ return isClientSideNavigation ? ANCHOR_TARGET.SELF : ANCHOR_TARGET.BLANK;
59
+ }
@@ -0,0 +1,31 @@
1
+ import styled from "@emotion/styled";
2
+ import { PALETTE } from "../../../../../../styles/common/constants/palette";
3
+ import { MarkdownRenderer } from "../../../../../MarkdownRenderer/markdownRenderer";
4
+
5
+ export const StyledMarkdownRenderer = styled(MarkdownRenderer)`
6
+ align-self: flex-start;
7
+
8
+ code {
9
+ all: unset;
10
+ font: inherit;
11
+ font-family: Roboto Mono, monospace;
12
+ }
13
+
14
+ h2,
15
+ h3,
16
+ h4,
17
+ h5,
18
+ h6 {
19
+ margin: 8px 0;
20
+ }
21
+
22
+ hr {
23
+ border: none;
24
+ border-bottom: 1px solid ${PALETTE.SMOKE_MAIN};
25
+ margin: 16px 0;
26
+ }
27
+
28
+ p {
29
+ font: inherit;
30
+ }
31
+ `;
@@ -0,0 +1,29 @@
1
+ import { CellContext, RowData } from "@tanstack/react-table";
2
+ import { BaseComponentProps } from "components/types";
3
+ import React from "react";
4
+ import { COMPONENTS } from "../../../../../MarkdownRenderer/constants";
5
+ import { StyledMarkdownRenderer } from "./markdownCell.styles";
6
+ import { MarkdownCellProps } from "./types";
7
+
8
+ export const MarkdownCell = <
9
+ T extends RowData,
10
+ TValue extends MarkdownCellProps = MarkdownCellProps
11
+ >({
12
+ className,
13
+ column,
14
+ getValue,
15
+ }: BaseComponentProps & CellContext<T, TValue>): JSX.Element | null => {
16
+ const props = getValue();
17
+ if (!props) return null;
18
+ const { values } = props;
19
+ const columnDef = column?.columnDef;
20
+ const columnMeta = columnDef?.meta;
21
+ const components = columnMeta?.components;
22
+ return (
23
+ <StyledMarkdownRenderer
24
+ className={className}
25
+ components={{ ...COMPONENTS, ...components }}
26
+ value={values}
27
+ />
28
+ );
29
+ };
@@ -0,0 +1,17 @@
1
+ import { ComponentProps } from "react";
2
+ import { MarkdownCell } from "../markdownCell";
3
+ import { GetValue } from "./types";
4
+
5
+ export const DEFAULT_ARGS: Partial<ComponentProps<typeof MarkdownCell>> = {
6
+ getValue: (() => ({
7
+ values:
8
+ '| Key | Annotator | Value |\n| --- | --- | --- |\n| `tissue_ontology_term_id` | Curator | categorical with `str` categories. This **MUST** be the UBERON or CL term that best describes the tissue the cell was derived from, depending on the sample type. |\n\n**Mapping guidance**\n\n| For | Use |\n| --- | --- |\n| Tissue | STRONGLY RECOMMENDED to be an UBERON term&nbsp;<br />(e.g. [`UBERON:0008930`](http://purl.obolibrary.org/obo/UBERON_0008930) for a *somatosensory cortex* tissue sample) |\n| Cell culture | MUST be a CL term appended with \\" (cell culture)\\"&nbsp;<br />(e.g. [`CL:0000057`](http://purl.obolibrary.org/obo/CL_0000057) **(cell culture)** for the *WTC-11* cell line) |\n| Organoid | MUST be an UBERON term appended with \\" (organoid)\\"&nbsp;<br />(e.g. [`UBERON:0000955`](http://purl.obolibrary.org/obo/UBERON_0000955) **(organoid)** for a *brain organoid*) |\n| Enriched / sorted / isolated cells from a tissue | MUST be an UBERON or CL term and **SHOULD NOT** use terms that do not capture the tissue of origin.<br /><br />• *CD3+ kidney cells* → [`UBERON:0002113`](https://www.ebi.ac.uk/ols/ontologies/uberon/terms?iri=http://purl.obolibrary.org/obo/UBERON_0002113) (*kidney*) instead of [`CL:000084`](https://www.ebi.ac.uk/ols/ontologies/cl/terms?iri=http://purl.obolibrary.org/obo/CL_0000084) (*T cell*).<br />• *EPCAM+ cervical cells* → [`CL:0000066`](https://www.ebi.ac.uk/ols/ontologies/cl/terms?iri=http://purl.obolibrary.org/obo/CL_0000066) (*epithelial cell* of the cervix). |\n\n---\n\nWhen a dataset is uploaded, the **cellxgene Data Portal** MUST automatically add the matching human-readable name for the corresponding ontology term to the `obs` dataframe. Curators **MUST NOT** annotate the following columns.\n\n### `assay`\n\n| Key | Annotator | Value |\n| --- | --- | --- |\n| `assay` | Data Portal | categorical with `str` categories. This **MUST** be the human-readable name assigned to the value of `assay_ontology_term_id`. |',
9
+ })) as GetValue,
10
+ };
11
+
12
+ export const WITH_HTML_ARGS: Partial<ComponentProps<typeof MarkdownCell>> = {
13
+ getValue: (() => ({
14
+ values:
15
+ "Hello <br />World <a href='https://www.example.com'>example link</a>",
16
+ })) as GetValue,
17
+ };
@@ -0,0 +1,11 @@
1
+ import styled from "@emotion/styled";
2
+ import { Anchor } from "../../../../../../MarkdownRenderer/components/Anchor/anchor";
3
+
4
+ /**
5
+ * Styled anchor component for testing purposes.
6
+ */
7
+
8
+ export const STYLED_ANCHOR = styled(Anchor)`
9
+ background-color: green;
10
+ color: white;
11
+ ` as typeof Anchor;
@@ -0,0 +1,37 @@
1
+ import { Box } from "@mui/material";
2
+ import { Meta, StoryObj } from "@storybook/react";
3
+ import React from "react";
4
+ import { PALETTE } from "../../../../../../../styles/common/constants/palette";
5
+ import { MarkdownCell } from "../markdownCell";
6
+ import { DEFAULT_ARGS, WITH_HTML_ARGS } from "./args";
7
+
8
+ const meta: Meta<typeof MarkdownCell> = {
9
+ component: MarkdownCell,
10
+ decorators: [
11
+ (Story): JSX.Element => (
12
+ <Box
13
+ sx={{
14
+ backgroundColor: PALETTE.COMMON_WHITE,
15
+ fontSize: "14px",
16
+ lineHeight: "20px",
17
+ padding: 3,
18
+ width: 480,
19
+ }}
20
+ >
21
+ <Story />
22
+ </Box>
23
+ ),
24
+ ],
25
+ };
26
+
27
+ export default meta;
28
+
29
+ type Story = StoryObj<typeof meta>;
30
+
31
+ export const Default: Story = {
32
+ args: DEFAULT_ARGS,
33
+ };
34
+
35
+ export const WithHtml: Story = {
36
+ args: WITH_HTML_ARGS,
37
+ };
@@ -0,0 +1,4 @@
1
+ import { CellContext, RowData } from "@tanstack/react-table";
2
+ import { MarkdownCellProps } from "../types";
3
+
4
+ export type GetValue = CellContext<RowData, MarkdownCellProps>["getValue"];
@@ -0,0 +1,3 @@
1
+ export type MarkdownCellProps = {
2
+ values: string;
3
+ };
@@ -0,0 +1,64 @@
1
+ import { getMemoOptions, memo, RowData, Table } from "@tanstack/react-table";
2
+
3
+ /**
4
+ * Returns an array of two numbers, the minimum and maximum values for the column, or undefined if the column does not exist or has no values.
5
+ * Customized version of the default getFacetedMinMaxValues function from tanstack table handling mixed null and possible NaN values.
6
+ * See https://tanstack.com/table/v8/docs/api/features/column-faceting#getfacetedminmaxvalues.
7
+ * @returns An array of two numbers, the minimum and maximum values for the column, or undefined if the column does not exist or has no values.
8
+ */
9
+ export function getFacetedMinMaxValues<TData extends RowData>(): (
10
+ table: Table<TData>,
11
+ columnId: string
12
+ ) => () => undefined | [number, number] {
13
+ // eslint-disable-next-line sonarjs/cognitive-complexity -- Customized copy of tanstack table function.
14
+ return (table, columnId) =>
15
+ memo(
16
+ () => [table.getColumn(columnId)?.getFacetedRowModel()],
17
+ (facetedRowModel) => {
18
+ if (!facetedRowModel) return undefined;
19
+
20
+ // Initialize with the smallest and largest possible numbers.
21
+ const facetedMinMaxValues: [number, number] = [Infinity, -Infinity];
22
+
23
+ for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
24
+ const values =
25
+ facetedRowModel.flatRows[i]!.getUniqueValues<number>(columnId);
26
+
27
+ for (let j = 0; j < values.length; j++) {
28
+ const value = values[j]!;
29
+ // Convert value to a number.
30
+ const numericValue = Number(value);
31
+
32
+ // Skip null and NaN values.
33
+ if (value === null || isNaN(numericValue)) continue;
34
+
35
+ if (numericValue < facetedMinMaxValues[0]) {
36
+ facetedMinMaxValues[0] = numericValue;
37
+ }
38
+ if (numericValue > facetedMinMaxValues[1]) {
39
+ facetedMinMaxValues[1] = numericValue;
40
+ }
41
+ }
42
+ }
43
+
44
+ // Return undefined if all values are null or NaN.
45
+ if (
46
+ facetedMinMaxValues[0] === Infinity &&
47
+ facetedMinMaxValues[1] === -Infinity
48
+ ) {
49
+ return undefined;
50
+ }
51
+
52
+ // Normalize -0 to 0.
53
+ if (Object.is(facetedMinMaxValues[0], -0)) {
54
+ facetedMinMaxValues[0] = 0;
55
+ }
56
+ if (Object.is(facetedMinMaxValues[1], -0)) {
57
+ facetedMinMaxValues[1] = 0;
58
+ }
59
+
60
+ return facetedMinMaxValues;
61
+ },
62
+ getMemoOptions(table.options, "debugTable", "getFacetedMinMaxValues")
63
+ );
64
+ }
@@ -0,0 +1,35 @@
1
+ import { ANCHOR_TARGET, REL_ATTRIBUTE } from "../../Links/common/entities";
2
+
3
+ /**
4
+ * Asserts that the given value is a valid REL_ATTRIBUTE.
5
+ * @param value - Value to assert.
6
+ * @throws Error if the value is not a valid REL_ATTRIBUTE.
7
+ */
8
+ export function assertAnchorRelAttribute(
9
+ value: string
10
+ ): asserts value is REL_ATTRIBUTE {
11
+ if (!Object.values(REL_ATTRIBUTE).includes(value as REL_ATTRIBUTE)) {
12
+ throw new Error(
13
+ `Expecting rel attribute: ${value} to be one of ${Object.values(
14
+ REL_ATTRIBUTE
15
+ )}`
16
+ );
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Asserts that the given value is a valid ANCHOR_TARGET.
22
+ * @param value - Value to assert.
23
+ * @throws Error if the value is not a valid ANCHOR_TARGET.
24
+ */
25
+ export function assertAnchorTargetAttribute(
26
+ value: string
27
+ ): asserts value is ANCHOR_TARGET {
28
+ if (!Object.values(ANCHOR_TARGET).includes(value as ANCHOR_TARGET)) {
29
+ throw new Error(
30
+ `Expecting anchor target: ${value} to be one of ${Object.values(
31
+ ANCHOR_TARGET
32
+ )}`
33
+ );
34
+ }
35
+ }
@@ -10,10 +10,10 @@ import {
10
10
  TableOptions,
11
11
  } from "@tanstack/react-table";
12
12
  import { JSXElementConstructor, ReactNode } from "react";
13
+ import { CategoryConfig } from "../common/categories/config/types";
13
14
  import {
14
15
  DataDictionaryAnnotation,
15
16
  DataDictionaryConfig,
16
- SelectCategoryValueView,
17
17
  SelectedFilter,
18
18
  } from "../common/entities";
19
19
  import { HeroTitle } from "../components/common/Title/title";
@@ -88,19 +88,6 @@ export interface CategoryGroup {
88
88
  label?: string;
89
89
  }
90
90
 
91
- /**
92
- * Model of category configured in site config.
93
- */
94
- export interface CategoryConfig {
95
- annotation?: DataDictionaryAnnotation;
96
- enableChartView?: boolean;
97
- key: string;
98
- label: string;
99
- mapSelectCategoryValue?: (
100
- selectCategoryValue: SelectCategoryValueView
101
- ) => SelectCategoryValueView;
102
- }
103
-
104
91
  /**
105
92
  * Column configuration.
106
93
  * TanStack ColumnDef properties not currently supported include: