@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
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from "react";
2
+
3
+ /**
4
+ * Returns a parsed value based on the original value.
5
+ * If the value is a boolean, it is converted to its string representation ("true" or "false").
6
+ * For all other types of ReactNode, the value is returned unchanged.
7
+ * @param value - The original value.
8
+ * @returns Parsed value or original value.
9
+ */
10
+ export function parseValue(value: ReactNode): ReactNode {
11
+ if (typeof value === "boolean") return value.toString();
12
+ return value;
13
+ }
@@ -1,13 +1,21 @@
1
- import { ColumnDef, Table, useReactTable } from "@tanstack/react-table";
2
- import { Attribute, AttributeValueTypes } from "../../../../common/entities";
1
+ import {
2
+ ColumnDef,
3
+ RowData,
4
+ Table,
5
+ useReactTable,
6
+ } from "@tanstack/react-table";
7
+ import { Attribute } from "../../../../common/entities";
3
8
  import { useTableOptions } from "./options/hook";
4
9
 
5
- export const useTable = (
6
- data: Attribute[],
7
- columnDefs: ColumnDef<Attribute, AttributeValueTypes>[]
8
- ): Table<Attribute> => {
9
- const tableOptions = useTableOptions();
10
- return useReactTable<Attribute>({
10
+ export const useTable = <T extends RowData = Attribute>(
11
+ data: T[],
12
+ columnDefs: ColumnDef<T, T[keyof T]>[]
13
+ ): Table<T> => {
14
+ // Table options.
15
+ const tableOptions = useTableOptions<T>();
16
+
17
+ // Table instance.
18
+ return useReactTable<T>({
11
19
  ...tableOptions,
12
20
  columns: columnDefs,
13
21
  data,
@@ -1,10 +1,9 @@
1
- import { CoreOptions, getCoreRowModel } from "@tanstack/react-table";
2
- import { Attribute } from "../../../../../../common/entities";
1
+ import { CoreOptions, getCoreRowModel, RowData } from "@tanstack/react-table";
3
2
  import { ROW_POSITION } from "../../../../../Table/features/RowPosition/constants";
4
3
  import { ROW_PREVIEW } from "../../../../../Table/features/RowPreview/constants";
5
4
 
6
5
  export const CORE_OPTIONS: Pick<
7
- CoreOptions<Attribute>,
6
+ CoreOptions<RowData>,
8
7
  "_features" | "getCoreRowModel"
9
8
  > = {
10
9
  _features: [ROW_POSITION, ROW_PREVIEW],
@@ -1,10 +1,10 @@
1
- import { TableOptions } from "@tanstack/react-table";
1
+ import { RowData, TableOptions } from "@tanstack/react-table";
2
2
  import { Attribute } from "../../../../../common/entities";
3
3
  import { CORE_OPTIONS } from "./core/constants";
4
4
  import { SORTING_OPTIONS } from "./sorting/constants";
5
5
 
6
- export const useTableOptions = (): Omit<
7
- TableOptions<Attribute>,
6
+ export const useTableOptions = <T extends RowData = Attribute>(): Omit<
7
+ TableOptions<T>,
8
8
  "columns" | "data"
9
9
  > => {
10
10
  return {
@@ -1,9 +1,5 @@
1
- import { SortingOptions } from "@tanstack/react-table";
2
- import { Attribute } from "../../../../../../common/entities";
1
+ import { RowData, SortingOptions } from "@tanstack/react-table";
3
2
 
4
- export const SORTING_OPTIONS: Pick<
5
- SortingOptions<Attribute>,
6
- "enableSorting"
7
- > = {
3
+ export const SORTING_OPTIONS: Pick<SortingOptions<RowData>, "enableSorting"> = {
8
4
  enableSorting: false,
9
5
  };
@@ -1,4 +1,5 @@
1
1
  import { TableContainer } from "@mui/material";
2
+ import { RowData } from "@tanstack/react-table";
2
3
  import React from "react";
3
4
  import { TableBody } from "../../../Detail/components/Table/components/TableBody/tableBody";
4
5
  import { ROW_DIRECTION } from "../../../Table/common/entities";
@@ -9,7 +10,9 @@ import { GridPaper } from "../../../common/Paper/paper.styles";
9
10
  import { StyledRoundedPaper } from "./table.styles";
10
11
  import { TableProps } from "./types";
11
12
 
12
- export const Table = ({ table }: TableProps): JSX.Element => {
13
+ export const Table = <T extends RowData>({
14
+ table,
15
+ }: TableProps<T>): JSX.Element => {
13
16
  return (
14
17
  <StyledRoundedPaper variant="table">
15
18
  <GridPaper>
@@ -1,6 +1,5 @@
1
- import { Table } from "@tanstack/react-table";
2
- import { Attribute } from "../../../../common/entities";
1
+ import { RowData, Table } from "@tanstack/react-table";
3
2
 
4
- export interface TableProps {
5
- table: Table<Attribute>;
3
+ export interface TableProps<T extends RowData> {
4
+ table: Table<T>;
6
5
  }
@@ -11,12 +11,11 @@ export const grid = css`
11
11
  export const View = styled("div")`
12
12
  ${grid};
13
13
  flex: 1;
14
- margin: 0 auto;
15
- max-width: min(calc(100vw - 48px), 1392px);
14
+ margin: 0 24px;
16
15
  position: relative;
17
16
 
18
17
  ${mediaTabletDown} {
19
18
  grid-template-columns: 1fr;
20
- max-width: calc(100vw - 32px);
19
+ margin: 0 16px;
21
20
  }
22
21
  `;
@@ -1,4 +1,6 @@
1
+ import { RowData } from "@tanstack/react-table";
1
2
  import React, { useMemo } from "react";
3
+ import { Attribute } from "../../common/entities";
2
4
  import { Entities } from "./components/Entities/entities";
3
5
  import { EntitiesLayout as DefaultEntitiesLayout } from "./components/Layout/components/EntitiesLayout/entitiesLayout";
4
6
  import { OutlineLayout as DefaultOutlineLayout } from "./components/Layout/components/OutlineLayout/outlineLayout";
@@ -11,7 +13,7 @@ import { useDataDictionary } from "./hooks/UseDataDictionary/hook";
11
13
  import { useLayoutSpacing } from "./hooks/UseLayoutSpacing/hook";
12
14
  import { DataDictionaryProps } from "./types";
13
15
 
14
- export const DataDictionary = ({
16
+ export const DataDictionary = <T extends RowData = Attribute>({
15
17
  className,
16
18
  EntitiesLayout = DefaultEntitiesLayout,
17
19
  Outline = DefaultOutline,
@@ -19,7 +21,7 @@ export const DataDictionary = ({
19
21
  Title = DefaultTitle,
20
22
  TitleLayout = DefaultTitleLayout,
21
23
  }: DataDictionaryProps): JSX.Element => {
22
- const { classes, columnDefs } = useDataDictionary();
24
+ const { classes, columnDefs } = useDataDictionary<T>();
23
25
  const { spacing } = useLayoutSpacing();
24
26
  const outline = useMemo(() => buildClassesOutline(classes), [classes]);
25
27
  return (
@@ -1,13 +1,20 @@
1
+ import { RowData } from "@tanstack/react-table";
1
2
  import { useMemo } from "react";
3
+ import { Attribute, DataDictionaryConfig } from "../../../../common/entities";
2
4
  import { useConfig } from "../../../../hooks/useConfig";
3
5
  import { UseDataDictionary } from "./types";
4
6
 
5
- export const useDataDictionary = (): UseDataDictionary => {
7
+ export const useDataDictionary = <
8
+ T extends RowData = Attribute
9
+ >(): UseDataDictionary<T> => {
6
10
  const {
7
11
  config: { dataDictionaries: dataDictionaryConfigs },
8
12
  } = useConfig();
9
13
 
10
- const dataDictionaryConfig = dataDictionaryConfigs?.[0]; // TODO: Handle multiple data dictionaries
14
+ const dataDictionaryConfig = dataDictionaryConfigs?.[0] as
15
+ | DataDictionaryConfig<T>
16
+ | undefined; // TODO: Handle multiple data dictionaries
17
+
11
18
  return useMemo(() => {
12
19
  const classes = dataDictionaryConfig?.dataDictionary?.classes || [];
13
20
  const columnDefs = dataDictionaryConfig?.columnDefs || [];
@@ -1,11 +1,7 @@
1
- import { ColumnDef } from "@tanstack/react-table";
2
- import {
3
- Attribute,
4
- AttributeValueTypes,
5
- Class,
6
- } from "../../../../common/entities";
1
+ import { ColumnDef, RowData } from "@tanstack/react-table";
2
+ import { Attribute, Class } from "../../../../common/entities";
7
3
 
8
- export interface UseDataDictionary {
9
- classes: Class[];
10
- columnDefs: ColumnDef<Attribute, AttributeValueTypes>[];
4
+ export interface UseDataDictionary<T extends RowData = Attribute> {
5
+ classes: Class<T>[];
6
+ columnDefs: ColumnDef<T, T[keyof T]>[];
11
7
  }
@@ -1,15 +1,23 @@
1
1
  import { CloseRounded } from "@mui/icons-material";
2
2
  import { Grow, PopoverPosition, PopoverProps } from "@mui/material";
3
3
  import React, { MouseEvent, ReactNode, useState } from "react";
4
- import { SelectCategoryView } from "../../../../common/entities";
4
+ import { isRangeCategoryView } from "../../../../common/categories/views/range/typeGuards";
5
+ import { CategoryView } from "../../../../common/categories/views/types";
5
6
  import { TrackFilterOpenedFunction } from "../../../../config/entities";
6
7
  import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
7
8
  import { TEST_IDS } from "../../../../tests/testIds";
8
9
  import { FilterLabel } from "../FilterLabel/filterLabel";
9
10
  import { FilterMenu } from "../FilterMenu/filterMenu";
11
+ import { FilterRange } from "../FilterRange/filterRange";
10
12
  import { DrawerTransition } from "./components/DrawerTransition/drawerTransition";
11
13
  import { FilterPopover, IconButton } from "./filter.styles";
12
14
 
15
+ /**
16
+ * Filter component.
17
+ * TODO(cc) refactor: build tags from categoryView for selected values.
18
+ * TODO(cc) tests: add tests for selected values (rending of tags) for select and range categories.
19
+ */
20
+
13
21
  const DEFAULT_POSITION: PopoverPosition = { left: 0, top: 0 };
14
22
  const DEFAULT_SLOT_PROPS: PopoverProps["slotProps"] = {
15
23
  paper: { variant: "menu" },
@@ -20,7 +28,7 @@ const DRAWER_SLOT_PROPS: PopoverProps["slotProps"] = {
20
28
 
21
29
  export interface FilterProps {
22
30
  categorySection?: string;
23
- categoryView: SelectCategoryView;
31
+ categoryView: CategoryView;
24
32
  closeAncestor?: () => void;
25
33
  isFilterDrawer: boolean;
26
34
  onFilter: OnFilterFn;
@@ -44,6 +52,7 @@ export const Filter = ({
44
52
  const TransitionComponent = isFilterDrawer ? DrawerTransition : Grow;
45
53
  const transitionDuration = isOpen ? 250 : 300;
46
54
  const TransitionDuration = isFilterDrawer ? transitionDuration : undefined;
55
+ const isRangeView = isRangeCategoryView(categoryView);
47
56
 
48
57
  /**
49
58
  * Closes filter popover.
@@ -79,7 +88,7 @@ export const Filter = ({
79
88
  <>
80
89
  <FilterLabel
81
90
  annotation={categoryView.annotation}
82
- count={categoryView.values.length}
91
+ count={isRangeView ? undefined : categoryView.values.length}
83
92
  disabled={categoryView.isDisabled}
84
93
  isOpen={isOpen}
85
94
  label={categoryView.label}
@@ -93,7 +102,7 @@ export const Filter = ({
93
102
  onClose={onCloseFilters}
94
103
  open={isOpen}
95
104
  slotProps={slotProps}
96
- TransitionComponent={TransitionComponent}
105
+ slots={{ transition: TransitionComponent }}
97
106
  transitionDuration={TransitionDuration}
98
107
  >
99
108
  {isOpen && isFilterDrawer && (
@@ -103,15 +112,31 @@ export const Filter = ({
103
112
  size="medium"
104
113
  />
105
114
  )}
106
- <FilterMenu
107
- categorySection={categorySection}
108
- categoryKey={categoryView.key}
109
- categoryLabel={categoryView.label}
110
- isFilterDrawer={isFilterDrawer}
111
- onFilter={onFilter}
112
- onCloseFilter={onCloseFilter}
113
- values={categoryView.values}
114
- />
115
+ {isRangeView ? (
116
+ <FilterRange
117
+ categoryKey={categoryView.key}
118
+ categoryLabel={categoryView.label}
119
+ categorySection={categorySection}
120
+ isFilterDrawer={isFilterDrawer}
121
+ max={categoryView.max}
122
+ min={categoryView.min}
123
+ selectedMax={categoryView.selectedMax}
124
+ selectedMin={categoryView.selectedMin}
125
+ onCloseFilter={onCloseFilter}
126
+ onFilter={onFilter}
127
+ unit={categoryView.unit}
128
+ />
129
+ ) : (
130
+ <FilterMenu
131
+ categoryKey={categoryView.key}
132
+ categoryLabel={categoryView.label}
133
+ categorySection={categorySection}
134
+ isFilterDrawer={isFilterDrawer}
135
+ onCloseFilter={onCloseFilter}
136
+ onFilter={onFilter}
137
+ values={categoryView.values}
138
+ />
139
+ )}
115
140
  </FilterPopover>
116
141
  {tags}
117
142
  </>
@@ -0,0 +1,24 @@
1
+ import { fn } from "@storybook/test";
2
+ import { ComponentProps } from "react";
3
+ import { DONOR_COUNT, GENUS_SPECIES } from "../../Filters/stories/constants";
4
+ import { Filter } from "../filter";
5
+
6
+ export const SELECT_ARGS: ComponentProps<typeof Filter> = {
7
+ categoryView: GENUS_SPECIES,
8
+ isFilterDrawer: false,
9
+ onFilter: fn(),
10
+ };
11
+
12
+ export const DISABLED_SELECT_ARGS: ComponentProps<typeof Filter> = {
13
+ ...SELECT_ARGS,
14
+ categoryView: {
15
+ ...SELECT_ARGS.categoryView,
16
+ isDisabled: true,
17
+ },
18
+ };
19
+
20
+ export const RANGE_ARGS: ComponentProps<typeof Filter> = {
21
+ categoryView: DONOR_COUNT,
22
+ isFilterDrawer: false,
23
+ onFilter: fn(),
24
+ };
@@ -0,0 +1,32 @@
1
+ import { Box } from "@mui/material";
2
+ import { Meta, StoryObj } from "@storybook/react";
3
+ import React from "react";
4
+ import { Filter } from "../filter";
5
+ import { DISABLED_SELECT_ARGS, RANGE_ARGS, SELECT_ARGS } from "./args";
6
+
7
+ const meta: Meta<typeof Filter> = {
8
+ component: Filter,
9
+ decorators: [
10
+ (Story): JSX.Element => (
11
+ <Box sx={{ width: 248 }}>
12
+ <Story />
13
+ </Box>
14
+ ),
15
+ ],
16
+ };
17
+
18
+ export default meta;
19
+
20
+ type Story = StoryObj<typeof meta>;
21
+
22
+ export const SelectCategory: Story = {
23
+ args: SELECT_ARGS,
24
+ };
25
+
26
+ export const DisabledSelectCategory: Story = {
27
+ args: DISABLED_SELECT_ARGS,
28
+ };
29
+
30
+ export const RangeCategory: Story = {
31
+ args: RANGE_ARGS,
32
+ };
@@ -20,7 +20,7 @@ export const FilterViewTools = styled.div`
20
20
  }
21
21
  `;
22
22
 
23
- export const Button = styled(ButtonBase)`
23
+ export const StyledButtonBase = styled(ButtonBase)`
24
24
  ${textBodyLarge500};
25
25
  align-items: center;
26
26
  display: flex;
@@ -12,7 +12,11 @@ import { List } from "../FilterList/filterList.styles";
12
12
  import { FilterMenuSearch } from "../FilterMenuSearch/filterMenuSearch";
13
13
  import { FilterNoResultsFound } from "../FilterNoResultsFound/filterNoResultsFound";
14
14
  import { VariableSizeList } from "../VariableSizeList/VariableSizeList";
15
- import { Button, FilterView, FilterViewTools } from "./filterMenu.styles";
15
+ import {
16
+ FilterView,
17
+ FilterViewTools,
18
+ StyledButtonBase,
19
+ } from "./filterMenu.styles";
16
20
 
17
21
  export interface FilterMenuProps {
18
22
  categoryKey: CategoryKey;
@@ -43,10 +47,10 @@ export const FilterMenu = ({
43
47
  <FilterView menuWidth={menuWidth}>
44
48
  <FilterViewTools>
45
49
  {isFilterDrawer && (
46
- <Button onClick={onCloseFilter}>
50
+ <StyledButtonBase onClick={onCloseFilter}>
47
51
  <SouthIcon fontSize="small" />
48
52
  {categoryLabel}
49
- </Button>
53
+ </StyledButtonBase>
50
54
  )}
51
55
  {isSearchable && (
52
56
  <FilterMenuSearch
@@ -6,7 +6,6 @@ import {
6
6
  ToggleButtonGroupProps,
7
7
  } from "@mui/material";
8
8
  import { BUTTON_PROPS as DX_BUTTON_PROPS } from "../../../common/Button/constants";
9
- import { RANGE_OPERATOR } from "./types";
10
9
 
11
10
  export const BUTTON_PROPS: ButtonProps = {
12
11
  ...DX_BUTTON_PROPS.PRIMARY_MEDIUM_CONTAINED,
@@ -29,12 +28,6 @@ export const INPUT_LABEL_PROPS: InputLabelProps = {
29
28
  shrink: true,
30
29
  };
31
30
 
32
- export const RANGE_OPERATOR_DISPLAY: Record<RANGE_OPERATOR, string> = {
33
- between: "From",
34
- greaterThan: "Greater Than",
35
- lessThan: "Less Than",
36
- };
37
-
38
31
  export const TOGGLE_BUTTON_GROUP_PROPS: ToggleButtonGroupProps = {
39
32
  exclusive: true,
40
33
  fullWidth: true,
@@ -1,9 +1,6 @@
1
1
  import styled from "@emotion/styled";
2
- import {
3
- inkLight,
4
- inkMain,
5
- smokeDark,
6
- } from "../../../../styles/common/mixins/colors";
2
+ import { PALETTE } from "../../../../styles/common/constants/palette";
3
+ import { mediaDesktopSmallDown } from "../../../../styles/common/mixins/breakpoints";
7
4
  import { textBody400 } from "../../../../styles/common/mixins/fonts";
8
5
 
9
6
  export const StyledForm = styled("form")`
@@ -15,16 +12,16 @@ export const StyledForm = styled("form")`
15
12
  width: 100%;
16
13
 
17
14
  .MuiToggleButton-root {
18
- color: ${inkLight};
15
+ color: ${PALETTE.INK_LIGHT};
19
16
  text-transform: capitalize;
20
17
 
21
18
  &.Mui-selected {
22
- color: ${inkMain};
19
+ color: ${PALETTE.INK_MAIN};
23
20
  }
24
21
  }
25
22
 
26
23
  .MuiDivider-root {
27
- border-color: ${smokeDark};
24
+ border-color: ${PALETTE.SMOKE_DARK};
28
25
  border-radius: 4px;
29
26
  margin: 6px 0;
30
27
  }
@@ -34,31 +31,58 @@ export const StyledForm = styled("form")`
34
31
  display: grid;
35
32
  gap: 4px 0;
36
33
  grid-auto-flow: column;
37
- grid-template-rows: auto auto;
34
+ grid-template-rows: auto auto auto;
38
35
  margin: 12px 0 16px 0;
39
36
 
40
37
  .MuiFormControl-root {
41
38
  display: grid;
42
- gap: inherit;
39
+ gap: 4px 0;
43
40
  grid-row: 1 / -1;
44
41
  grid-template-rows: subgrid;
45
42
 
46
43
  .MuiInputLabel-root {
47
44
  ${textBody400};
48
- color: ${inkMain};
45
+ color: ${PALETTE.INK_MAIN};
49
46
  max-width: unset;
50
47
  position: relative;
51
48
  transform: unset;
52
49
  }
53
50
 
54
- .MuiOutlinedInput-input {
55
- padding-right: 10px;
51
+ .MuiOutlinedInput-root {
52
+ .MuiOutlinedInput-input {
53
+ padding-right: 10px;
54
+ }
55
+
56
+ input::placeholder {
57
+ color: ${PALETTE.INK_LIGHT};
58
+ opacity: 0.8;
59
+ }
60
+
61
+ &.Mui-focused {
62
+ input::placeholder {
63
+ opacity: 0;
64
+ }
65
+ }
66
+ }
67
+
68
+ .MuiFormLabel-filled + .MuiOutlinedInput-root {
69
+ .MuiOutlinedInput-input {
70
+ color: ${PALETTE.INK_MAIN};
71
+ }
72
+ }
73
+
74
+ .MuiFormHelperText-root {
75
+ color: ${PALETTE.INK_LIGHT};
76
+
77
+ &.Mui-error {
78
+ color: ${PALETTE.ALERT_MAIN};
79
+ }
56
80
  }
57
81
  }
58
82
 
59
83
  .MuiDivider-root {
60
84
  align-self: center;
61
- border-color: ${inkLight};
85
+ border-color: ${PALETTE.INK_LIGHT};
62
86
  grid-row: 2;
63
87
  margin: 0 4px;
64
88
  width: 8px;
@@ -68,4 +92,24 @@ export const StyledForm = styled("form")`
68
92
  .MuiButton-root {
69
93
  grid-column: 1 / -1;
70
94
  }
95
+
96
+ ${mediaDesktopSmallDown} {
97
+ padding: 0 16px;
98
+ width: 312px;
99
+
100
+ .MuiGrid-root {
101
+ gap: 16px 0;
102
+ grid-template-rows: auto auto;
103
+ margin: 16px 0;
104
+
105
+ .MuiFormControl-root {
106
+ grid-row: unset;
107
+ grid-template-rows: unset;
108
+ }
109
+
110
+ .MuiDivider-root {
111
+ display: none;
112
+ }
113
+ }
114
+ }
71
115
  `;