@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,9 @@
1
+ import { ReactNode } from "react";
2
+ /**
3
+ * Returns a parsed value based on the original value.
4
+ * If the value is a boolean, it is converted to its string representation ("true" or "false").
5
+ * For all other types of ReactNode, the value is returned unchanged.
6
+ * @param value - The original value.
7
+ * @returns Parsed value or original value.
8
+ */
9
+ export declare function parseValue(value: ReactNode): ReactNode;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns a parsed value based on the original value.
3
+ * If the value is a boolean, it is converted to its string representation ("true" or "false").
4
+ * For all other types of ReactNode, the value is returned unchanged.
5
+ * @param value - The original value.
6
+ * @returns Parsed value or original value.
7
+ */
8
+ export function parseValue(value) {
9
+ if (typeof value === "boolean")
10
+ return value.toString();
11
+ return value;
12
+ }
@@ -1,3 +1,3 @@
1
- import { ColumnDef, Table } from "@tanstack/react-table";
2
- import { Attribute, AttributeValueTypes } from "../../../../common/entities";
3
- export declare const useTable: (data: Attribute[], columnDefs: ColumnDef<Attribute, AttributeValueTypes>[]) => Table<Attribute>;
1
+ import { ColumnDef, RowData, Table } from "@tanstack/react-table";
2
+ import { Attribute } from "../../../../common/entities";
3
+ export declare const useTable: <T extends RowData = Attribute>(data: T[], columnDefs: ColumnDef<T, T[keyof T]>[]) => Table<T>;
@@ -1,7 +1,9 @@
1
- import { useReactTable } from "@tanstack/react-table";
1
+ import { useReactTable, } from "@tanstack/react-table";
2
2
  import { useTableOptions } from "./options/hook";
3
3
  export const useTable = (data, columnDefs) => {
4
+ // Table options.
4
5
  const tableOptions = useTableOptions();
6
+ // Table instance.
5
7
  return useReactTable({
6
8
  ...tableOptions,
7
9
  columns: columnDefs,
@@ -1,3 +1,2 @@
1
- import { CoreOptions } from "@tanstack/react-table";
2
- import { Attribute } from "../../../../../../common/entities";
3
- export declare const CORE_OPTIONS: Pick<CoreOptions<Attribute>, "_features" | "getCoreRowModel">;
1
+ import { CoreOptions, RowData } from "@tanstack/react-table";
2
+ export declare const CORE_OPTIONS: Pick<CoreOptions<RowData>, "_features" | "getCoreRowModel">;
@@ -1,3 +1,3 @@
1
- import { TableOptions } from "@tanstack/react-table";
1
+ import { RowData, TableOptions } from "@tanstack/react-table";
2
2
  import { Attribute } from "../../../../../common/entities";
3
- export declare const useTableOptions: () => Omit<TableOptions<Attribute>, "columns" | "data">;
3
+ export declare const useTableOptions: <T extends RowData = Attribute>() => Omit<TableOptions<T>, "columns" | "data">;
@@ -1,3 +1,2 @@
1
- import { SortingOptions } from "@tanstack/react-table";
2
- import { Attribute } from "../../../../../../common/entities";
3
- export declare const SORTING_OPTIONS: Pick<SortingOptions<Attribute>, "enableSorting">;
1
+ import { RowData, SortingOptions } from "@tanstack/react-table";
2
+ export declare const SORTING_OPTIONS: Pick<SortingOptions<RowData>, "enableSorting">;
@@ -1,2 +1,3 @@
1
+ import { RowData } from "@tanstack/react-table";
1
2
  import { TableProps } from "./types";
2
- export declare const Table: ({ table }: TableProps) => JSX.Element;
3
+ export declare const Table: <T extends RowData>({ table, }: TableProps<T>) => JSX.Element;
@@ -7,7 +7,7 @@ import { GridTable } from "../../../Table/table.styles";
7
7
  import { getColumnTrackSizing } from "../../../TableCreator/options/columnTrackSizing/utils";
8
8
  import { GridPaper } from "../../../common/Paper/paper.styles";
9
9
  import { StyledRoundedPaper } from "./table.styles";
10
- export const Table = ({ table }) => {
10
+ export const Table = ({ table, }) => {
11
11
  return (React.createElement(StyledRoundedPaper, { variant: "table" },
12
12
  React.createElement(GridPaper, null,
13
13
  React.createElement(TableContainer, null,
@@ -1,5 +1,4 @@
1
- import { Table } from "@tanstack/react-table";
2
- import { Attribute } from "../../../../common/entities";
3
- export interface TableProps {
4
- table: Table<Attribute>;
1
+ import { RowData, Table } from "@tanstack/react-table";
2
+ export interface TableProps<T extends RowData> {
3
+ table: Table<T>;
5
4
  }
@@ -1,2 +1,4 @@
1
+ import { RowData } from "@tanstack/react-table";
2
+ import { Attribute } from "../../common/entities";
1
3
  import { DataDictionaryProps } from "./types";
2
- export declare const DataDictionary: ({ className, EntitiesLayout, Outline, OutlineLayout, Title, TitleLayout, }: DataDictionaryProps) => JSX.Element;
4
+ export declare const DataDictionary: <T extends RowData = Attribute>({ className, EntitiesLayout, Outline, OutlineLayout, Title, TitleLayout, }: DataDictionaryProps) => JSX.Element;
@@ -9,12 +9,11 @@ export const grid = css `
9
9
  export const View = styled("div") `
10
10
  ${grid};
11
11
  flex: 1;
12
- margin: 0 auto;
13
- max-width: min(calc(100vw - 48px), 1392px);
12
+ margin: 0 24px;
14
13
  position: relative;
15
14
 
16
15
  ${mediaTabletDown} {
17
16
  grid-template-columns: 1fr;
18
- max-width: calc(100vw - 32px);
17
+ margin: 0 16px;
19
18
  }
20
19
  `;
@@ -1,2 +1,4 @@
1
+ import { RowData } from "@tanstack/react-table";
2
+ import { Attribute } from "../../../../common/entities";
1
3
  import { UseDataDictionary } from "./types";
2
- export declare const useDataDictionary: () => UseDataDictionary;
4
+ export declare const useDataDictionary: <T extends RowData = Attribute>() => UseDataDictionary<T>;
@@ -1,6 +1,6 @@
1
- import { ColumnDef } from "@tanstack/react-table";
2
- import { Attribute, AttributeValueTypes, Class } from "../../../../common/entities";
3
- export interface UseDataDictionary {
4
- classes: Class[];
5
- columnDefs: ColumnDef<Attribute, AttributeValueTypes>[];
1
+ import { ColumnDef, RowData } from "@tanstack/react-table";
2
+ import { Attribute, Class } from "../../../../common/entities";
3
+ export interface UseDataDictionary<T extends RowData = Attribute> {
4
+ classes: Class<T>[];
5
+ columnDefs: ColumnDef<T, T[keyof T]>[];
6
6
  }
@@ -1,10 +1,10 @@
1
1
  import { ReactNode } from "react";
2
- import { SelectCategoryView } from "../../../../common/entities";
2
+ import { CategoryView } from "../../../../common/categories/views/types";
3
3
  import { TrackFilterOpenedFunction } from "../../../../config/entities";
4
4
  import { OnFilterFn } from "../../../../hooks/useCategoryFilter";
5
5
  export interface FilterProps {
6
6
  categorySection?: string;
7
- categoryView: SelectCategoryView;
7
+ categoryView: CategoryView;
8
8
  closeAncestor?: () => void;
9
9
  isFilterDrawer: boolean;
10
10
  onFilter: OnFilterFn;
@@ -1,11 +1,18 @@
1
1
  import { CloseRounded } from "@mui/icons-material";
2
2
  import { Grow } from "@mui/material";
3
3
  import React, { useState } from "react";
4
+ import { isRangeCategoryView } from "../../../../common/categories/views/range/typeGuards";
4
5
  import { TEST_IDS } from "../../../../tests/testIds";
5
6
  import { FilterLabel } from "../FilterLabel/filterLabel";
6
7
  import { FilterMenu } from "../FilterMenu/filterMenu";
8
+ import { FilterRange } from "../FilterRange/filterRange";
7
9
  import { DrawerTransition } from "./components/DrawerTransition/drawerTransition";
8
10
  import { FilterPopover, IconButton } from "./filter.styles";
11
+ /**
12
+ * Filter component.
13
+ * TODO(cc) refactor: build tags from categoryView for selected values.
14
+ * TODO(cc) tests: add tests for selected values (rending of tags) for select and range categories.
15
+ */
9
16
  const DEFAULT_POSITION = { left: 0, top: 0 };
10
17
  const DEFAULT_SLOT_PROPS = {
11
18
  paper: { variant: "menu" },
@@ -21,6 +28,7 @@ export const Filter = ({ categorySection, categoryView, closeAncestor, isFilterD
21
28
  const TransitionComponent = isFilterDrawer ? DrawerTransition : Grow;
22
29
  const transitionDuration = isOpen ? 250 : 300;
23
30
  const TransitionDuration = isFilterDrawer ? transitionDuration : undefined;
31
+ const isRangeView = isRangeCategoryView(categoryView);
24
32
  /**
25
33
  * Closes filter popover.
26
34
  */
@@ -49,9 +57,9 @@ export const Filter = ({ categorySection, categoryView, closeAncestor, isFilterD
49
57
  trackFilterOpened?.({ category: categoryView.key });
50
58
  };
51
59
  return (React.createElement(React.Fragment, null,
52
- React.createElement(FilterLabel, { annotation: categoryView.annotation, count: categoryView.values.length, disabled: categoryView.isDisabled, isOpen: isOpen, label: categoryView.label, onClick: onOpenFilter }),
53
- React.createElement(FilterPopover, { anchorPosition: anchorPosition, anchorReference: "anchorPosition", "data-testid": TEST_IDS.FILTER_POPOVER, marginThreshold: 0, onClose: onCloseFilters, open: isOpen, slotProps: slotProps, TransitionComponent: TransitionComponent, transitionDuration: TransitionDuration },
60
+ React.createElement(FilterLabel, { annotation: categoryView.annotation, count: isRangeView ? undefined : categoryView.values.length, disabled: categoryView.isDisabled, isOpen: isOpen, label: categoryView.label, onClick: onOpenFilter }),
61
+ React.createElement(FilterPopover, { anchorPosition: anchorPosition, anchorReference: "anchorPosition", "data-testid": TEST_IDS.FILTER_POPOVER, marginThreshold: 0, onClose: onCloseFilters, open: isOpen, slotProps: slotProps, slots: { transition: TransitionComponent }, transitionDuration: TransitionDuration },
54
62
  isOpen && isFilterDrawer && (React.createElement(IconButton, { Icon: CloseRounded, onClick: onCloseFilters, size: "medium" })),
55
- React.createElement(FilterMenu, { categorySection: categorySection, categoryKey: categoryView.key, categoryLabel: categoryView.label, isFilterDrawer: isFilterDrawer, onFilter: onFilter, onCloseFilter: onCloseFilter, values: categoryView.values })),
63
+ isRangeView ? (React.createElement(FilterRange, { categoryKey: categoryView.key, categoryLabel: categoryView.label, categorySection: categorySection, isFilterDrawer: isFilterDrawer, max: categoryView.max, min: categoryView.min, selectedMax: categoryView.selectedMax, selectedMin: categoryView.selectedMin, onCloseFilter: onCloseFilter, onFilter: onFilter, unit: categoryView.unit })) : (React.createElement(FilterMenu, { categoryKey: categoryView.key, categoryLabel: categoryView.label, categorySection: categorySection, isFilterDrawer: isFilterDrawer, onCloseFilter: onCloseFilter, onFilter: onFilter, values: categoryView.values }))),
56
64
  tags));
57
65
  };
@@ -0,0 +1,5 @@
1
+ import { ComponentProps } from "react";
2
+ import { Filter } from "../filter";
3
+ export declare const SELECT_ARGS: ComponentProps<typeof Filter>;
4
+ export declare const DISABLED_SELECT_ARGS: ComponentProps<typeof Filter>;
5
+ export declare const RANGE_ARGS: ComponentProps<typeof Filter>;
@@ -0,0 +1,19 @@
1
+ import { fn } from "@storybook/test";
2
+ import { DONOR_COUNT, GENUS_SPECIES } from "../../Filters/stories/constants";
3
+ export const SELECT_ARGS = {
4
+ categoryView: GENUS_SPECIES,
5
+ isFilterDrawer: false,
6
+ onFilter: fn(),
7
+ };
8
+ export const DISABLED_SELECT_ARGS = {
9
+ ...SELECT_ARGS,
10
+ categoryView: {
11
+ ...SELECT_ARGS.categoryView,
12
+ isDisabled: true,
13
+ },
14
+ };
15
+ export const RANGE_ARGS = {
16
+ categoryView: DONOR_COUNT,
17
+ isFilterDrawer: false,
18
+ onFilter: fn(),
19
+ };
@@ -0,0 +1,8 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { Filter } from "../filter";
3
+ declare const meta: Meta<typeof Filter>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const SelectCategory: Story;
7
+ export declare const DisabledSelectCategory: Story;
8
+ export declare const RangeCategory: Story;
@@ -0,0 +1,21 @@
1
+ import { Box } from "@mui/material";
2
+ import React from "react";
3
+ import { Filter } from "../filter";
4
+ import { DISABLED_SELECT_ARGS, RANGE_ARGS, SELECT_ARGS } from "./args";
5
+ const meta = {
6
+ component: Filter,
7
+ decorators: [
8
+ (Story) => (React.createElement(Box, { sx: { width: 248 } },
9
+ React.createElement(Story, null))),
10
+ ],
11
+ };
12
+ export default meta;
13
+ export const SelectCategory = {
14
+ args: SELECT_ARGS,
15
+ };
16
+ export const DisabledSelectCategory = {
17
+ args: DISABLED_SELECT_ARGS,
18
+ };
19
+ export const RangeCategory = {
20
+ args: RANGE_ARGS,
21
+ };
@@ -6,14 +6,14 @@ import { List } from "../FilterList/filterList.styles";
6
6
  import { FilterMenuSearch } from "../FilterMenuSearch/filterMenuSearch";
7
7
  import { FilterNoResultsFound } from "../FilterNoResultsFound/filterNoResultsFound";
8
8
  import { VariableSizeList } from "../VariableSizeList/VariableSizeList";
9
- import { Button, FilterView, FilterViewTools } from "./filterMenu.styles";
9
+ import { FilterView, FilterViewTools, StyledButtonBase, } from "./filterMenu.styles";
10
10
  export const FilterMenu = ({ categoryKey, categoryLabel, categorySection, isFilterDrawer, menuWidth = 312, onCloseFilter, onFilter, values, }) => {
11
11
  const [searchTerm, setSearchTerm] = useState("");
12
12
  const isSearchable = isFilterDrawer || values.length > MAX_DISPLAYABLE_LIST_ITEMS;
13
13
  const matchedItems = applyMenuFilter(values, isSearchable ? searchTerm : "");
14
14
  return (React.createElement(FilterView, { menuWidth: menuWidth },
15
15
  React.createElement(FilterViewTools, null,
16
- isFilterDrawer && (React.createElement(Button, { onClick: onCloseFilter },
16
+ isFilterDrawer && (React.createElement(StyledButtonBase, { onClick: onCloseFilter },
17
17
  React.createElement(SouthIcon, { fontSize: "small" }),
18
18
  categoryLabel)),
19
19
  isSearchable && (React.createElement(FilterMenuSearch, { searchTerm: searchTerm, setSearchTerm: setSearchTerm }))),
@@ -9,7 +9,7 @@ export declare const FilterViewTools: import("@emotion/styled").StyledComponent<
9
9
  theme?: import("@emotion/react").Theme;
10
10
  as?: React.ElementType;
11
11
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
12
- export declare const Button: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonBaseOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
12
+ export declare const StyledButtonBase: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonBaseOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
13
13
  ref?: ((instance: HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLButtonElement> | null | undefined;
14
14
  }, "style" | "className" | "classes" | "tabIndex" | "children" | "sx" | "disabled" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & {
15
15
  theme?: import("@emotion/react").Theme;
@@ -13,7 +13,7 @@ export const FilterViewTools = styled.div `
13
13
  }
14
14
  }
15
15
  `;
16
- export const Button = styled(ButtonBase) `
16
+ export const StyledButtonBase = styled(ButtonBase) `
17
17
  ${textBodyLarge500};
18
18
  align-items: center;
19
19
  display: flex;
@@ -1,8 +1,6 @@
1
1
  import { ButtonProps, DividerProps, InputLabelProps, OutlinedInputProps, ToggleButtonGroupProps } from "@mui/material";
2
- import { RANGE_OPERATOR } from "./types";
3
2
  export declare const BUTTON_PROPS: ButtonProps;
4
3
  export declare const DIVIDER_PROPS: DividerProps;
5
4
  export declare const INPUT_PROPS: OutlinedInputProps;
6
5
  export declare const INPUT_LABEL_PROPS: InputLabelProps;
7
- export declare const RANGE_OPERATOR_DISPLAY: Record<RANGE_OPERATOR, string>;
8
6
  export declare const TOGGLE_BUTTON_GROUP_PROPS: ToggleButtonGroupProps;
@@ -16,11 +16,6 @@ export const INPUT_LABEL_PROPS = {
16
16
  disableAnimation: true,
17
17
  shrink: true,
18
18
  };
19
- export const RANGE_OPERATOR_DISPLAY = {
20
- between: "From",
21
- greaterThan: "Greater Than",
22
- lessThan: "Less Than",
23
- };
24
19
  export const TOGGLE_BUTTON_GROUP_PROPS = {
25
20
  exclusive: true,
26
21
  fullWidth: true,
@@ -1,2 +1,2 @@
1
1
  import { FilterRangeProps } from "./types";
2
- export declare const FilterRange: ({ className }: FilterRangeProps) => JSX.Element;
2
+ export declare const FilterRange: ({ categoryKey, categoryLabel, categorySection, className, isFilterDrawer, max, min, onCloseFilter, onFilter, selectedMax, selectedMin, unit, }: FilterRangeProps) => JSX.Element;
@@ -1,26 +1,55 @@
1
- import { Button, Divider, FormControl, Grid, InputLabel, OutlinedInput, ToggleButton, ToggleButtonGroup, } from "@mui/material";
1
+ import { Button, Divider, FormControl, FormHelperText, Grid, InputLabel, OutlinedInput, ToggleButton, ToggleButtonGroup, } from "@mui/material";
2
2
  import React, { Fragment } from "react";
3
3
  import { TEST_IDS } from "../../../../tests/testIds";
4
- import { BUTTON_PROPS, DIVIDER_PROPS, INPUT_LABEL_PROPS, INPUT_PROPS, RANGE_OPERATOR_DISPLAY, TOGGLE_BUTTON_GROUP_PROPS, } from "./constants";
4
+ import { SouthIcon } from "../../../common/CustomIcon/components/SouthIcon/southIcon";
5
+ import { FilterViewTools, StyledButtonBase, } from "../FilterMenu/filterMenu.styles";
6
+ import { BUTTON_PROPS, DIVIDER_PROPS, INPUT_LABEL_PROPS, INPUT_PROPS, TOGGLE_BUTTON_GROUP_PROPS, } from "./constants";
5
7
  import { StyledForm } from "./filterRange.styles";
8
+ import { FIELD_NAME } from "./hooks/UseFilterRange/constants";
6
9
  import { useFilterRange } from "./hooks/UseFilterRange/hook";
7
- import { RANGE_OPERATOR } from "./types";
8
- export const FilterRange = ({ className }) => {
9
- const { onChange, onSubmit, value } = useFilterRange();
10
- return (React.createElement(StyledForm, { className: className, "data-testid": TEST_IDS.FILTER_RANGE, onSubmit: onSubmit },
11
- React.createElement(ToggleButtonGroup, { ...TOGGLE_BUTTON_GROUP_PROPS, onChange: onChange, value: value },
12
- React.createElement(ToggleButton, { value: RANGE_OPERATOR.BETWEEN }, "Between"),
13
- React.createElement(ToggleButton, { value: RANGE_OPERATOR.LESS_THAN }, "Less Than"),
14
- React.createElement(Divider, { ...DIVIDER_PROPS }),
15
- React.createElement(ToggleButton, { value: RANGE_OPERATOR.GREATER_THAN }, "Greater Than")),
16
- React.createElement(Grid, null,
17
- React.createElement(FormControl, null,
18
- React.createElement(InputLabel, { ...INPUT_LABEL_PROPS, htmlFor: value }, RANGE_OPERATOR_DISPLAY[value]),
19
- React.createElement(OutlinedInput, { ...INPUT_PROPS, name: value, placeholder: "eg. 1" })),
20
- value === RANGE_OPERATOR.BETWEEN && (React.createElement(Fragment, null,
21
- React.createElement(Divider, null),
22
- React.createElement(FormControl, null,
23
- React.createElement(InputLabel, { ...INPUT_LABEL_PROPS, htmlFor: "between-to" }, "To"),
24
- React.createElement(OutlinedInput, { ...INPUT_PROPS, name: "between-to", placeholder: "eg. 2" }))))),
25
- React.createElement(Button, { ...BUTTON_PROPS }, "Filter")));
10
+ import { RANGE_OPERATOR } from "./hooks/UseFilterRange/types";
11
+ import { getRangeOperator } from "./utils";
12
+ export const FilterRange = ({ categoryKey, categoryLabel, categorySection, className, isFilterDrawer, max, min, onCloseFilter, onFilter, selectedMax, selectedMin, unit, }) => {
13
+ const rangeOperator = getRangeOperator({ selectedMax, selectedMin });
14
+ const { clearErrors, formState: { errors }, handleSubmit, onChange, value, } = useFilterRange(rangeOperator);
15
+ return (React.createElement(Fragment, null,
16
+ isFilterDrawer && (React.createElement(FilterViewTools, null,
17
+ React.createElement(StyledButtonBase, { onClick: onCloseFilter },
18
+ React.createElement(SouthIcon, { fontSize: "small" }),
19
+ categoryLabel))),
20
+ React.createElement(StyledForm, { className: className, "data-testid": TEST_IDS.FILTER_RANGE, onSubmit: handleSubmit(onFilter, {
21
+ categoryKey,
22
+ categorySection,
23
+ }) },
24
+ React.createElement(ToggleButtonGroup, { ...TOGGLE_BUTTON_GROUP_PROPS, onChange: (e, value) => {
25
+ clearErrors();
26
+ onChange?.(e, value);
27
+ }, value: value },
28
+ React.createElement(ToggleButton, { value: RANGE_OPERATOR.BETWEEN }, "Between"),
29
+ React.createElement(ToggleButton, { value: RANGE_OPERATOR.LESS_THAN }, "Less Than"),
30
+ React.createElement(Divider, { ...DIVIDER_PROPS }),
31
+ React.createElement(ToggleButton, { value: RANGE_OPERATOR.GREATER_THAN }, "Greater Than")),
32
+ React.createElement(Grid, null,
33
+ value !== RANGE_OPERATOR.LESS_THAN && (React.createElement(FormControl, { error: !!errors[FIELD_NAME.MIN] },
34
+ React.createElement(InputLabel, { ...INPUT_LABEL_PROPS, htmlFor: FIELD_NAME.MIN },
35
+ value === RANGE_OPERATOR.BETWEEN ? "Min" : "Greater Than",
36
+ unit && ` (${unit})`),
37
+ React.createElement(OutlinedInput, { ...INPUT_PROPS, defaultValue: selectedMin, id: FIELD_NAME.MIN, name: FIELD_NAME.MIN, onFocus: clearErrors, placeholder: "eg. 1" }),
38
+ React.createElement(FormHelperText, null, errors[FIELD_NAME.MIN]
39
+ ? errors[FIELD_NAME.MIN]
40
+ : value === RANGE_OPERATOR.BETWEEN
41
+ ? `Min allowed: ${min}`
42
+ : `Allowed values: \u2265 ${min} and \u2264 ${max}`))),
43
+ value === RANGE_OPERATOR.BETWEEN && React.createElement(Divider, null),
44
+ value !== RANGE_OPERATOR.GREATER_THAN && (React.createElement(FormControl, { error: !!errors[FIELD_NAME.MAX] },
45
+ React.createElement(InputLabel, { ...INPUT_LABEL_PROPS, htmlFor: FIELD_NAME.MAX },
46
+ value === RANGE_OPERATOR.BETWEEN ? "Max" : "Less Than",
47
+ unit && ` (${unit})`),
48
+ React.createElement(OutlinedInput, { ...INPUT_PROPS, defaultValue: selectedMax, id: FIELD_NAME.MAX, name: FIELD_NAME.MAX, onFocus: clearErrors, placeholder: "eg. 20" }),
49
+ React.createElement(FormHelperText, { color: "inkLight" }, errors[FIELD_NAME.MAX]
50
+ ? errors[FIELD_NAME.MAX]
51
+ : value === RANGE_OPERATOR.BETWEEN
52
+ ? `Max allowed: ${max}`
53
+ : `Allowed values: \u2265 ${min} and \u2264 ${max}`)))),
54
+ React.createElement(Button, { ...BUTTON_PROPS }, "Filter"))));
26
55
  };
@@ -1,5 +1,6 @@
1
1
  import styled from "@emotion/styled";
2
- import { inkLight, inkMain, smokeDark, } from "../../../../styles/common/mixins/colors";
2
+ import { PALETTE } from "../../../../styles/common/constants/palette";
3
+ import { mediaDesktopSmallDown } from "../../../../styles/common/mixins/breakpoints";
3
4
  import { textBody400 } from "../../../../styles/common/mixins/fonts";
4
5
  export const StyledForm = styled("form") `
5
6
  padding: 16px;
@@ -10,16 +11,16 @@ export const StyledForm = styled("form") `
10
11
  width: 100%;
11
12
 
12
13
  .MuiToggleButton-root {
13
- color: ${inkLight};
14
+ color: ${PALETTE.INK_LIGHT};
14
15
  text-transform: capitalize;
15
16
 
16
17
  &.Mui-selected {
17
- color: ${inkMain};
18
+ color: ${PALETTE.INK_MAIN};
18
19
  }
19
20
  }
20
21
 
21
22
  .MuiDivider-root {
22
- border-color: ${smokeDark};
23
+ border-color: ${PALETTE.SMOKE_DARK};
23
24
  border-radius: 4px;
24
25
  margin: 6px 0;
25
26
  }
@@ -29,31 +30,58 @@ export const StyledForm = styled("form") `
29
30
  display: grid;
30
31
  gap: 4px 0;
31
32
  grid-auto-flow: column;
32
- grid-template-rows: auto auto;
33
+ grid-template-rows: auto auto auto;
33
34
  margin: 12px 0 16px 0;
34
35
 
35
36
  .MuiFormControl-root {
36
37
  display: grid;
37
- gap: inherit;
38
+ gap: 4px 0;
38
39
  grid-row: 1 / -1;
39
40
  grid-template-rows: subgrid;
40
41
 
41
42
  .MuiInputLabel-root {
42
43
  ${textBody400};
43
- color: ${inkMain};
44
+ color: ${PALETTE.INK_MAIN};
44
45
  max-width: unset;
45
46
  position: relative;
46
47
  transform: unset;
47
48
  }
48
49
 
49
- .MuiOutlinedInput-input {
50
- padding-right: 10px;
50
+ .MuiOutlinedInput-root {
51
+ .MuiOutlinedInput-input {
52
+ padding-right: 10px;
53
+ }
54
+
55
+ input::placeholder {
56
+ color: ${PALETTE.INK_LIGHT};
57
+ opacity: 0.8;
58
+ }
59
+
60
+ &.Mui-focused {
61
+ input::placeholder {
62
+ opacity: 0;
63
+ }
64
+ }
65
+ }
66
+
67
+ .MuiFormLabel-filled + .MuiOutlinedInput-root {
68
+ .MuiOutlinedInput-input {
69
+ color: ${PALETTE.INK_MAIN};
70
+ }
71
+ }
72
+
73
+ .MuiFormHelperText-root {
74
+ color: ${PALETTE.INK_LIGHT};
75
+
76
+ &.Mui-error {
77
+ color: ${PALETTE.ALERT_MAIN};
78
+ }
51
79
  }
52
80
  }
53
81
 
54
82
  .MuiDivider-root {
55
83
  align-self: center;
56
- border-color: ${inkLight};
84
+ border-color: ${PALETTE.INK_LIGHT};
57
85
  grid-row: 2;
58
86
  margin: 0 4px;
59
87
  width: 8px;
@@ -63,4 +91,24 @@ export const StyledForm = styled("form") `
63
91
  .MuiButton-root {
64
92
  grid-column: 1 / -1;
65
93
  }
94
+
95
+ ${mediaDesktopSmallDown} {
96
+ padding: 0 16px;
97
+ width: 312px;
98
+
99
+ .MuiGrid-root {
100
+ gap: 16px 0;
101
+ grid-template-rows: auto auto;
102
+ margin: 16px 0;
103
+
104
+ .MuiFormControl-root {
105
+ grid-row: unset;
106
+ grid-template-rows: unset;
107
+ }
108
+
109
+ .MuiDivider-root {
110
+ display: none;
111
+ }
112
+ }
113
+ }
66
114
  `;
@@ -0,0 +1,5 @@
1
+ export declare const FIELD_NAME: {
2
+ MAX: string;
3
+ MIN: string;
4
+ RANGE_OPERATOR: string;
5
+ };
@@ -0,0 +1,5 @@
1
+ export const FIELD_NAME = {
2
+ MAX: "max",
3
+ MIN: "min",
4
+ RANGE_OPERATOR: "rangeOperator",
5
+ };
@@ -1,2 +1,2 @@
1
- import { UseFilterRange } from "./types";
2
- export declare const useFilterRange: () => UseFilterRange;
1
+ import { RANGE_OPERATOR, UseFilterRange } from "./types";
2
+ export declare const useFilterRange: (initialValue?: RANGE_OPERATOR) => UseFilterRange;
@@ -1,14 +1,39 @@
1
- import { useCallback } from "react";
1
+ import { useCallback, useState } from "react";
2
+ import { VIEW_KIND } from "../../../../../../common/categories/views/types";
2
3
  import { useToggleButtonGroup } from "../../../../../common/ToggleButtonGroup/hooks/UseToggleButtonGroup/hook";
3
- import { RANGE_OPERATOR } from "../../types";
4
- export const useFilterRange = () => {
5
- const { onChange, value } = useToggleButtonGroup(RANGE_OPERATOR.BETWEEN);
6
- const onSubmit = useCallback((e) => {
7
- e.preventDefault();
4
+ import { SCHEMA } from "./schema";
5
+ import { RANGE_OPERATOR, } from "./types";
6
+ import { getFormValues } from "./utils";
7
+ export const useFilterRange = (initialValue = RANGE_OPERATOR.BETWEEN) => {
8
+ const [errors, setErrors] = useState({});
9
+ const { onChange, value } = useToggleButtonGroup(initialValue);
10
+ const clearErrors = useCallback(() => {
11
+ setErrors({});
8
12
  }, []);
13
+ const handleSubmit = useCallback((onSubmit, parameters) => {
14
+ return (e) => {
15
+ e.preventDefault();
16
+ const fieldValues = getFormValues(e.currentTarget, value); // `value` is current range operator.
17
+ SCHEMA.validate(fieldValues, { abortEarly: false })
18
+ .then((result) => {
19
+ setErrors({});
20
+ onSubmit(parameters.categoryKey, [result.min, result.max], true, parameters.categorySection, VIEW_KIND.RANGE);
21
+ })
22
+ .catch((validationError) => {
23
+ const fieldErrors = {};
24
+ for (const error of validationError.inner) {
25
+ if (error.path)
26
+ fieldErrors[error.path] = error.message;
27
+ }
28
+ setErrors(fieldErrors);
29
+ });
30
+ };
31
+ }, [value]);
9
32
  return {
33
+ clearErrors,
34
+ formState: { errors },
35
+ handleSubmit,
10
36
  onChange,
11
- onSubmit,
12
37
  value,
13
38
  };
14
39
  };
@@ -0,0 +1,6 @@
1
+ import { RANGE_OPERATOR } from "./types";
2
+ export declare const SCHEMA: import("yup").ObjectSchema<{
3
+ [x: string]: number | RANGE_OPERATOR | undefined;
4
+ }, import("yup").AnyObject, {
5
+ [x: string]: RANGE_OPERATOR.BETWEEN | undefined;
6
+ }, "">;