@databiosphere/findable-ui 29.0.2 → 30.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 (205) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +22 -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 +5 -2
  31. package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.d.ts +3 -2
  32. package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.js +6 -2
  33. package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.d.ts +9 -0
  34. package/lib/components/DataDictionary/components/Table/components/BasicCell/utils.js +12 -0
  35. package/lib/components/DataDictionary/dataDictionary.styles.js +2 -3
  36. package/lib/components/Filter/components/Filter/filter.d.ts +2 -2
  37. package/lib/components/Filter/components/Filter/filter.js +11 -3
  38. package/lib/components/Filter/components/Filter/stories/args.d.ts +5 -0
  39. package/lib/components/Filter/components/Filter/stories/args.js +19 -0
  40. package/lib/components/Filter/components/Filter/stories/filter.stories.d.ts +8 -0
  41. package/lib/components/Filter/components/Filter/stories/filter.stories.js +21 -0
  42. package/lib/components/Filter/components/FilterMenu/filterMenu.js +2 -2
  43. package/lib/components/Filter/components/FilterMenu/filterMenu.styles.d.ts +1 -1
  44. package/lib/components/Filter/components/FilterMenu/filterMenu.styles.js +1 -1
  45. package/lib/components/Filter/components/FilterRange/constants.d.ts +0 -2
  46. package/lib/components/Filter/components/FilterRange/constants.js +0 -5
  47. package/lib/components/Filter/components/FilterRange/filterRange.d.ts +1 -1
  48. package/lib/components/Filter/components/FilterRange/filterRange.js +50 -21
  49. package/lib/components/Filter/components/FilterRange/filterRange.styles.js +58 -10
  50. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.d.ts +5 -0
  51. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.js +5 -0
  52. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.d.ts +2 -2
  53. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.js +32 -7
  54. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.d.ts +6 -0
  55. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.js +50 -0
  56. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.d.ts +26 -3
  57. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/types.js +6 -1
  58. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.d.ts +15 -0
  59. package/lib/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.js +25 -0
  60. package/lib/components/Filter/components/FilterRange/stories/args.d.ts +3 -0
  61. package/lib/components/Filter/components/FilterRange/stories/args.js +13 -0
  62. package/lib/components/Filter/components/FilterRange/stories/filterRange.stories.js +2 -2
  63. package/lib/components/Filter/components/FilterRange/types.d.ts +10 -6
  64. package/lib/components/Filter/components/FilterRange/types.js +1 -6
  65. package/lib/components/Filter/components/FilterRange/utils.d.ts +8 -0
  66. package/lib/components/Filter/components/FilterRange/utils.js +15 -0
  67. package/lib/components/Filter/components/FilterTag/stories/args.d.ts +5 -0
  68. package/lib/components/Filter/components/FilterTag/stories/args.js +17 -0
  69. package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.d.ts +8 -0
  70. package/lib/components/Filter/components/FilterTag/stories/filterTag.stories.js +21 -0
  71. package/lib/components/Filter/components/FilterTag/utils.d.ts +10 -0
  72. package/lib/components/Filter/components/FilterTag/utils.js +40 -0
  73. package/lib/components/Filter/components/Filters/filters.d.ts +2 -2
  74. package/lib/components/Filter/components/Filters/filters.js +15 -8
  75. package/lib/components/Filter/components/Filters/stories/args.d.ts +3 -0
  76. package/lib/components/Filter/components/Filters/stories/args.js +15 -0
  77. package/lib/components/Filter/components/Filters/stories/constants.d.ts +22 -0
  78. package/lib/components/Filter/components/Filters/stories/constants.js +134 -0
  79. package/lib/components/Filter/components/Filters/stories/filters.stories.d.ts +6 -0
  80. package/lib/components/Filter/components/Filters/stories/filters.stories.js +15 -0
  81. package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.d.ts +1 -1
  82. package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.js +5 -5
  83. package/lib/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.js +2 -1
  84. package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.d.ts +3 -2
  85. package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.js +6 -4
  86. package/lib/components/Filter/components/VariableSizeListItem/variableSizeListItem.js +2 -1
  87. package/lib/components/Index/components/EntitiesView/components/ChartView/utils.js +2 -0
  88. package/lib/components/Index/table/hook.js +4 -0
  89. package/lib/components/Table/columnDef/accessorFn/typeGuards.d.ts +9 -0
  90. package/lib/components/Table/columnDef/accessorFn/typeGuards.js +10 -0
  91. package/lib/components/Table/common/utils.d.ts +2 -2
  92. package/lib/components/Table/common/utils.js +28 -13
  93. package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.d.ts +3 -0
  94. package/lib/components/Table/components/TableCell/components/ChipCell/chipCell.js +8 -0
  95. package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.d.ts +4 -0
  96. package/lib/components/Table/components/TableCell/components/LinkCell/linkCell.js +21 -0
  97. package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.d.ts +6 -0
  98. package/lib/components/Table/components/TableCell/components/LinkCell/stories/args.js +27 -0
  99. package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.d.ts +9 -0
  100. package/lib/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.js +18 -0
  101. package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.d.ts +3 -0
  102. package/lib/components/Table/components/TableCell/components/LinkCell/stories/types.js +1 -0
  103. package/lib/components/Table/components/TableCell/components/LinkCell/utils.d.ts +22 -0
  104. package/lib/components/Table/components/TableCell/components/LinkCell/utils.js +45 -0
  105. package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.d.ts +8 -0
  106. package/lib/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.js +46 -0
  107. package/lib/components/common/Link/typeGuards.d.ts +13 -0
  108. package/lib/components/common/Link/typeGuards.js +21 -0
  109. package/lib/config/entities.d.ts +2 -11
  110. package/lib/hooks/useCategoryFilter.d.ts +8 -13
  111. package/lib/hooks/useCategoryFilter.js +31 -28
  112. package/lib/providers/exploreState/entities.d.ts +5 -3
  113. package/lib/providers/exploreState/payloads/entities.d.ts +6 -2
  114. package/lib/providers/exploreState.d.ts +3 -2
  115. package/lib/providers/exploreState.js +1 -1
  116. package/lib/tests/utils.d.ts +24 -0
  117. package/lib/tests/utils.js +34 -0
  118. package/lib/theme/common/components.js +19 -1
  119. package/lib/views/ExploreView/exploreView.js +10 -8
  120. package/package.json +2 -1
  121. package/src/common/categories/config/types.ts +42 -0
  122. package/src/common/categories/config/utils.ts +47 -0
  123. package/src/common/categories/models/range/typeGuards.ts +24 -0
  124. package/src/common/categories/models/range/types.ts +17 -0
  125. package/src/common/categories/models/range/utils.ts +51 -0
  126. package/src/common/categories/models/select/utils.ts +23 -0
  127. package/src/common/categories/models/types.ts +7 -0
  128. package/src/common/categories/views/common/types.ts +11 -0
  129. package/src/common/categories/views/range/typeGuards.ts +13 -0
  130. package/src/common/categories/views/range/types.ts +21 -0
  131. package/src/common/categories/views/range/utils.ts +35 -0
  132. package/src/common/categories/views/select/typeGuards.ts +13 -0
  133. package/src/common/categories/views/select/types.ts +8 -0
  134. package/src/common/categories/views/types.ts +15 -0
  135. package/src/common/entities.ts +10 -5
  136. package/src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx +12 -4
  137. package/src/components/DataDictionary/components/Table/components/BasicCell/utils.ts +13 -0
  138. package/src/components/DataDictionary/dataDictionary.styles.ts +2 -3
  139. package/src/components/Filter/components/Filter/filter.tsx +38 -13
  140. package/src/components/Filter/components/Filter/stories/args.ts +24 -0
  141. package/src/components/Filter/components/Filter/stories/filter.stories.tsx +32 -0
  142. package/src/components/Filter/components/FilterMenu/filterMenu.styles.ts +1 -1
  143. package/src/components/Filter/components/FilterMenu/filterMenu.tsx +7 -3
  144. package/src/components/Filter/components/FilterRange/constants.ts +0 -7
  145. package/src/components/Filter/components/FilterRange/filterRange.styles.ts +58 -14
  146. package/src/components/Filter/components/FilterRange/filterRange.tsx +112 -40
  147. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/constants.ts +5 -0
  148. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/hook.ts +51 -10
  149. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/schema.ts +60 -0
  150. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/types.ts +34 -3
  151. package/src/components/Filter/components/FilterRange/hooks/UseFilterRange/utils.ts +32 -0
  152. package/src/components/Filter/components/FilterRange/stories/args.ts +16 -0
  153. package/src/components/Filter/components/FilterRange/stories/filterRange.stories.tsx +2 -2
  154. package/src/components/Filter/components/FilterRange/types.ts +12 -6
  155. package/src/components/Filter/components/FilterRange/utils.ts +16 -0
  156. package/src/components/Filter/components/FilterTag/stories/args.ts +22 -0
  157. package/src/components/Filter/components/FilterTag/stories/filterTag.stories.tsx +32 -0
  158. package/src/components/Filter/components/FilterTag/utils.ts +57 -0
  159. package/src/components/Filter/components/Filters/filters.tsx +21 -12
  160. package/src/components/Filter/components/Filters/stories/args.ts +24 -0
  161. package/src/components/Filter/components/Filters/stories/constants.ts +151 -0
  162. package/src/components/Filter/components/Filters/stories/filters.stories.tsx +24 -0
  163. package/src/components/Filter/components/SearchAllFilters/components/VariableSizeList/VariableSizeList.tsx +32 -29
  164. package/src/components/Filter/components/SearchAllFilters/components/VariableSizeListItem/variableSizeListItem.tsx +9 -1
  165. package/src/components/Filter/components/SearchAllFilters/searchAllFilters.tsx +12 -6
  166. package/src/components/Filter/components/VariableSizeListItem/variableSizeListItem.tsx +2 -1
  167. package/src/components/Index/components/EntitiesView/components/ChartView/utils.ts +2 -0
  168. package/src/components/Index/table/hook.ts +4 -0
  169. package/src/components/Table/columnDef/accessorFn/typeGuards.ts +15 -0
  170. package/src/components/Table/common/utils.ts +37 -16
  171. package/src/components/Table/components/TableCell/components/ChipCell/chipCell.tsx +14 -0
  172. package/src/components/Table/components/TableCell/components/LinkCell/linkCell.tsx +64 -0
  173. package/src/components/Table/components/TableCell/components/LinkCell/stories/args.ts +35 -0
  174. package/src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories.tsx +32 -0
  175. package/src/components/Table/components/TableCell/components/LinkCell/stories/types.ts +4 -0
  176. package/src/components/Table/components/TableCell/components/LinkCell/utils.ts +59 -0
  177. package/src/components/Table/featureOptions/facetedColumn/getFacetedMinMaxValues.ts +64 -0
  178. package/src/components/common/Link/typeGuards.ts +35 -0
  179. package/src/config/entities.ts +1 -14
  180. package/src/hooks/useCategoryFilter.ts +56 -53
  181. package/src/providers/exploreState/entities.ts +3 -3
  182. package/src/providers/exploreState/initializer/utils.ts +1 -1
  183. package/src/providers/exploreState/payloads/entities.ts +5 -2
  184. package/src/providers/exploreState.tsx +5 -3
  185. package/src/tests/utils.ts +44 -0
  186. package/src/theme/common/components.ts +19 -1
  187. package/src/views/ExploreView/exploreView.tsx +17 -22
  188. package/tests/filter.test.tsx +100 -0
  189. package/tests/filterRange.test.tsx +331 -46
  190. package/tests/filters.test.tsx +61 -0
  191. package/tests/getFacetedMinMaxValues.test.ts +166 -0
  192. package/tests/linkCell.test.tsx +89 -0
  193. package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +0 -3
  194. package/lib/components/Filter/components/Filter/filter.stories.d.ts +0 -25
  195. package/lib/components/Filter/components/Filter/filter.stories.js +0 -42
  196. package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +0 -16
  197. package/lib/components/Filter/components/FilterTag/filterTag.stories.js +0 -17
  198. package/lib/components/Filter/components/Filters/filters.stories.d.ts +0 -6
  199. package/lib/components/Filter/components/Filters/filters.stories.js +0 -91
  200. package/src/components/DataDictionary/components/Table/components/BasicCell/types.ts +0 -7
  201. package/src/components/Filter/components/Filter/filter.stories.tsx +0 -52
  202. package/src/components/Filter/components/FilterTag/filterTag.stories.tsx +0 -23
  203. package/src/components/Filter/components/Filters/filters.stories.tsx +0 -101
  204. package/tests/filterRangeMock.test.tsx +0 -38
  205. /package/lib/{components/DataDictionary/components/Table/components/BasicCell → common/categories/config}/types.js +0 -0
@@ -0,0 +1,89 @@
1
+ import { matchers } from "@emotion/jest";
2
+ import { composeStories } from "@storybook/react";
3
+ import "@testing-library/jest-dom";
4
+ import { render, screen } from "@testing-library/react";
5
+ import React from "react";
6
+ import {
7
+ ANCHOR_TARGET,
8
+ REL_ATTRIBUTE,
9
+ } from "../src/components/Links/common/entities";
10
+ import * as stories from "../src/components/Table/components/TableCell/components/LinkCell/stories/linkCell.stories";
11
+
12
+ expect.extend(matchers);
13
+
14
+ const { ClientSide, External, Invalid, WithCustomStyle } =
15
+ composeStories(stories);
16
+
17
+ const STYLE_RULE_PROPERTIES = {
18
+ TEXT_DECORATION: "text-decoration",
19
+ };
20
+
21
+ const STYLE_RULE_VALUES = {
22
+ NONE: "none",
23
+ UNDERLINE: "underline",
24
+ };
25
+
26
+ describe("TableCell, LinkCell", () => {
27
+ it("renders client-side link", async () => {
28
+ render(<ClientSide />);
29
+ const anchorEl = screen.getByText("Explore");
30
+ expect(anchorEl).toBeDefined();
31
+ expect(anchorEl?.getAttribute("href")).toBe("/");
32
+ expect(anchorEl?.getAttribute("rel")).toBe(REL_ATTRIBUTE.NO_OPENER);
33
+ expect(anchorEl?.getAttribute("target")).toBe(ANCHOR_TARGET.SELF);
34
+ // Expect MuiLink-underlineAlways class and underline style.
35
+ expect(anchorEl).toHaveClass("MuiLink-underlineAlways");
36
+ expect(anchorEl).toHaveStyleRule(
37
+ STYLE_RULE_PROPERTIES.TEXT_DECORATION,
38
+ STYLE_RULE_VALUES.UNDERLINE
39
+ );
40
+ });
41
+
42
+ it("renders external link", async () => {
43
+ render(<External />);
44
+ const anchorEl = screen.getByText("Explore");
45
+ expect(anchorEl).toBeDefined();
46
+ expect(anchorEl?.getAttribute("href")).toBe("https://www.example.com");
47
+ expect(anchorEl?.getAttribute("rel")).toBe(
48
+ REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
49
+ );
50
+ expect(anchorEl?.getAttribute("target")).toBe(ANCHOR_TARGET.BLANK);
51
+ // Expect MuiLink-underlineAlways class and underline style.
52
+ expect(anchorEl).toHaveClass("MuiLink-underlineAlways");
53
+ expect(anchorEl).toHaveStyleRule(
54
+ STYLE_RULE_PROPERTIES.TEXT_DECORATION,
55
+ STYLE_RULE_VALUES.UNDERLINE
56
+ );
57
+ });
58
+
59
+ it("renders plain text for invalid link", () => {
60
+ render(<Invalid />);
61
+ const spanEl = screen.getByText("Explore");
62
+ expect(spanEl.tagName).toBe("SPAN");
63
+ expect(spanEl.getAttribute("href")).toBeNull();
64
+ expect(spanEl.getAttribute("rel")).toBeNull();
65
+ expect(spanEl.getAttribute("target")).toBeNull();
66
+ // Expect no MuiLink-root class and no underline style.
67
+ expect(spanEl).not.toHaveClass("MuiLink-root");
68
+ expect(spanEl).not.toHaveStyleRule(
69
+ STYLE_RULE_PROPERTIES.TEXT_DECORATION,
70
+ STYLE_RULE_VALUES.UNDERLINE
71
+ );
72
+ });
73
+
74
+ it("renders link with custom link props", async () => {
75
+ render(<WithCustomStyle />);
76
+ const anchorEl = screen.getByText("Explore");
77
+ // Expect MuiLink-underlineNone class and no underline style.
78
+ expect(anchorEl).toHaveClass("MuiLink-underlineNone");
79
+ expect(anchorEl).toHaveStyleRule(
80
+ STYLE_RULE_PROPERTIES.TEXT_DECORATION,
81
+ STYLE_RULE_VALUES.NONE
82
+ );
83
+ expect(anchorEl).toHaveStyleRule(
84
+ STYLE_RULE_PROPERTIES.TEXT_DECORATION,
85
+ STYLE_RULE_VALUES.NONE,
86
+ { target: ":hover" }
87
+ );
88
+ });
89
+ });
@@ -1,3 +0,0 @@
1
- import { CellContext } from "@tanstack/react-table";
2
- import { Attribute, AttributeValueTypes } from "../../../../../../common/entities";
3
- export type BasicCellProps = CellContext<Attribute, AttributeValueTypes>;
@@ -1,25 +0,0 @@
1
- import { StoryObj } from "@storybook/react";
2
- import React from "react";
3
- declare const meta: {
4
- argTypes: {
5
- tags: {
6
- control: {
7
- disable: true;
8
- };
9
- };
10
- };
11
- component: ({ categorySection, categoryView, closeAncestor, isFilterDrawer, onFilter, tags, trackFilterOpened, }: import("./filter").FilterProps) => JSX.Element;
12
- decorators: ((Story: import("@storybook/core/csf").PartialStoryFn<import("@storybook/react").ReactRenderer, {
13
- categorySection?: string | undefined;
14
- categoryView: import("../../../../common/entities").SelectCategoryView;
15
- closeAncestor?: (() => void) | undefined;
16
- isFilterDrawer: boolean;
17
- onFilter: import("../../../../hooks/useCategoryFilter").OnFilterFn;
18
- tags?: React.ReactNode;
19
- trackFilterOpened?: import("../../../../config/entities").TrackFilterOpenedFunction | undefined;
20
- }>) => JSX.Element)[];
21
- title: string;
22
- };
23
- export default meta;
24
- type Story = StoryObj<typeof meta>;
25
- export declare const FilterStory: Story;
@@ -1,42 +0,0 @@
1
- import React from "react";
2
- import { Filter } from "./filter";
3
- const meta = {
4
- argTypes: {
5
- tags: { control: { disable: true } },
6
- },
7
- component: Filter,
8
- decorators: [
9
- (Story) => (React.createElement("div", { style: { padding: "8px 12px 8px 16px", width: 264 } },
10
- React.createElement(Story, null))),
11
- ],
12
- title: "Components/Filter/Filter",
13
- };
14
- export default meta;
15
- const onFilter = () => {
16
- // onFilter function
17
- };
18
- export const FilterStory = {
19
- args: {
20
- categoryView: {
21
- isDisabled: false,
22
- key: "genusSpecies",
23
- label: "Genus Species",
24
- values: [
25
- {
26
- count: 12,
27
- key: "homoSapiens",
28
- label: "Homo sapiens",
29
- selected: false,
30
- },
31
- {
32
- count: 6,
33
- key: "musMusculus",
34
- label: "Mus musculus",
35
- selected: false,
36
- },
37
- ],
38
- },
39
- isFilterDrawer: false,
40
- onFilter,
41
- },
42
- };
@@ -1,16 +0,0 @@
1
- import { StoryObj } from "@storybook/react";
2
- declare const meta: {
3
- argTypes: {
4
- label: {
5
- control: "text";
6
- };
7
- superseded: {
8
- control: "boolean";
9
- };
10
- };
11
- component: ({ label, onRemove, superseded, }: import("./filterTag").FilterTagProps) => JSX.Element;
12
- title: string;
13
- };
14
- export default meta;
15
- type Story = StoryObj<typeof meta>;
16
- export declare const FilterTagStory: Story;
@@ -1,17 +0,0 @@
1
- import { FilterTag } from "./filterTag";
2
- const meta = {
3
- argTypes: {
4
- label: { control: "text" },
5
- superseded: { control: "boolean" },
6
- },
7
- component: FilterTag,
8
- title: "Components/Filter/FilterTag",
9
- };
10
- export default meta;
11
- export const FilterTagStory = {
12
- args: {
13
- label: "Male",
14
- onRemove: () => { },
15
- superseded: false,
16
- },
17
- };
@@ -1,6 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import { Filters } from "./filters";
3
- declare const _default: Meta<typeof Filters>;
4
- export default _default;
5
- type Story = StoryObj<typeof Filters>;
6
- export declare const FiltersStory: Story;
@@ -1,91 +0,0 @@
1
- import React from "react";
2
- import { FilterMenuStory } from "../FilterMenu/filterMenu.stories";
3
- import { Filters } from "./filters";
4
- export default {
5
- argTypes: {
6
- categories: { control: { disable: true } },
7
- onFilter: { control: { disable: true } },
8
- },
9
- component: Filters,
10
- decorators: [
11
- (Story) => (React.createElement("div", { style: { width: 264 } },
12
- React.createElement(Story, null))),
13
- ],
14
- title: "Components/Filter/Filters",
15
- };
16
- const onFilter = () => {
17
- // onFilter function
18
- };
19
- const defaultValues = [
20
- {
21
- count: 1,
22
- key: "item1",
23
- label: "Item 1",
24
- selected: false,
25
- },
26
- {
27
- count: 10,
28
- key: "item2",
29
- label: "Item 2",
30
- selected: false,
31
- },
32
- ];
33
- export const FiltersStory = {
34
- args: {
35
- categoryFilters: [
36
- {
37
- categoryViews: [
38
- {
39
- isDisabled: false,
40
- key: "genusSpecies",
41
- label: "Genus Species",
42
- values: [
43
- {
44
- count: 12,
45
- key: "homoSapiens",
46
- label: "Homo sapiens",
47
- selected: false,
48
- },
49
- {
50
- count: 6,
51
- key: "musMusculus",
52
- label: "Mus musculus",
53
- selected: false,
54
- },
55
- ],
56
- },
57
- ],
58
- },
59
- {
60
- categoryViews: [
61
- {
62
- isDisabled: false,
63
- key: "donorDisease",
64
- label: "Donor Disease",
65
- values: FilterMenuStory.args?.values || defaultValues,
66
- },
67
- {
68
- isDisabled: true,
69
- key: "anatomicalEntity",
70
- label: "Anatomical Entity",
71
- values: [
72
- {
73
- count: 12,
74
- key: "oralCavity",
75
- label: "oral cavity",
76
- selected: true,
77
- },
78
- {
79
- count: 6,
80
- key: "pancreas",
81
- label: "pancreas",
82
- selected: false,
83
- },
84
- ],
85
- },
86
- ],
87
- },
88
- ],
89
- onFilter: onFilter,
90
- },
91
- };
@@ -1,7 +0,0 @@
1
- import { CellContext } from "@tanstack/react-table";
2
- import {
3
- Attribute,
4
- AttributeValueTypes,
5
- } from "../../../../../../common/entities";
6
-
7
- export type BasicCellProps = CellContext<Attribute, AttributeValueTypes>;
@@ -1,52 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import React from "react";
3
- import { Filter } from "./filter";
4
-
5
- const meta = {
6
- argTypes: {
7
- tags: { control: { disable: true } },
8
- },
9
- component: Filter,
10
- decorators: [
11
- (Story): JSX.Element => (
12
- <div style={{ padding: "8px 12px 8px 16px", width: 264 }}>
13
- <Story />
14
- </div>
15
- ),
16
- ],
17
- title: "Components/Filter/Filter",
18
- } satisfies Meta<typeof Filter>;
19
-
20
- export default meta;
21
-
22
- type Story = StoryObj<typeof meta>;
23
-
24
- const onFilter = (): void => {
25
- // onFilter function
26
- };
27
-
28
- export const FilterStory: Story = {
29
- args: {
30
- categoryView: {
31
- isDisabled: false,
32
- key: "genusSpecies",
33
- label: "Genus Species",
34
- values: [
35
- {
36
- count: 12,
37
- key: "homoSapiens",
38
- label: "Homo sapiens",
39
- selected: false,
40
- },
41
- {
42
- count: 6,
43
- key: "musMusculus",
44
- label: "Mus musculus",
45
- selected: false,
46
- },
47
- ],
48
- },
49
- isFilterDrawer: false,
50
- onFilter,
51
- },
52
- };
@@ -1,23 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import { FilterTag } from "./filterTag";
3
-
4
- const meta = {
5
- argTypes: {
6
- label: { control: "text" },
7
- superseded: { control: "boolean" },
8
- },
9
- component: FilterTag,
10
- title: "Components/Filter/FilterTag",
11
- } satisfies Meta<typeof FilterTag>;
12
-
13
- export default meta;
14
-
15
- type Story = StoryObj<typeof meta>;
16
-
17
- export const FilterTagStory: Story = {
18
- args: {
19
- label: "Male",
20
- onRemove: () => {},
21
- superseded: false,
22
- },
23
- };
@@ -1,101 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import React from "react";
3
- import { FilterMenuStory } from "../FilterMenu/filterMenu.stories";
4
- import { Filters } from "./filters";
5
-
6
- export default {
7
- argTypes: {
8
- categories: { control: { disable: true } },
9
- onFilter: { control: { disable: true } },
10
- },
11
- component: Filters,
12
- decorators: [
13
- (Story): JSX.Element => (
14
- <div style={{ width: 264 }}>
15
- <Story />
16
- </div>
17
- ),
18
- ],
19
- title: "Components/Filter/Filters",
20
- } as Meta<typeof Filters>;
21
-
22
- type Story = StoryObj<typeof Filters>;
23
-
24
- const onFilter = (): void => {
25
- // onFilter function
26
- };
27
-
28
- const defaultValues = [
29
- {
30
- count: 1,
31
- key: "item1",
32
- label: "Item 1",
33
- selected: false,
34
- },
35
- {
36
- count: 10,
37
- key: "item2",
38
- label: "Item 2",
39
- selected: false,
40
- },
41
- ];
42
-
43
- export const FiltersStory: Story = {
44
- args: {
45
- categoryFilters: [
46
- {
47
- categoryViews: [
48
- {
49
- isDisabled: false,
50
- key: "genusSpecies",
51
- label: "Genus Species",
52
- values: [
53
- {
54
- count: 12,
55
- key: "homoSapiens",
56
- label: "Homo sapiens",
57
- selected: false,
58
- },
59
- {
60
- count: 6,
61
- key: "musMusculus",
62
- label: "Mus musculus",
63
- selected: false,
64
- },
65
- ],
66
- },
67
- ],
68
- },
69
- {
70
- categoryViews: [
71
- {
72
- isDisabled: false,
73
- key: "donorDisease",
74
- label: "Donor Disease",
75
- values: FilterMenuStory.args?.values || defaultValues,
76
- },
77
- {
78
- isDisabled: true,
79
- key: "anatomicalEntity",
80
- label: "Anatomical Entity",
81
- values: [
82
- {
83
- count: 12,
84
- key: "oralCavity",
85
- label: "oral cavity",
86
- selected: true,
87
- },
88
- {
89
- count: 6,
90
- key: "pancreas",
91
- label: "pancreas",
92
- selected: false,
93
- },
94
- ],
95
- },
96
- ],
97
- },
98
- ],
99
- onFilter: onFilter,
100
- },
101
- };
@@ -1,38 +0,0 @@
1
- import { jest } from "@jest/globals";
2
- import { composeStories } from "@storybook/react";
3
- import { render, screen } from "@testing-library/react";
4
- import React, { FormEvent } from "react";
5
- import { RANGE_OPERATOR } from "../src/components/Filter/components/FilterRange/types";
6
-
7
- const ON_SUBMIT = jest.fn();
8
-
9
- jest.unstable_mockModule(
10
- "../src/components/Filter/components/FilterRange/hooks/UseFilterRange/hook",
11
- () => ({
12
- useFilterRange: jest.fn(() => ({
13
- onChange: jest.fn(),
14
- onSubmit: (e: FormEvent): void => {
15
- e.preventDefault();
16
- ON_SUBMIT(e);
17
- },
18
- value: RANGE_OPERATOR.BETWEEN,
19
- })),
20
- })
21
- );
22
-
23
- const stories = await import(
24
- "../src/components/Filter/components/FilterRange/stories/filterRange.stories"
25
- );
26
- const { Default } = composeStories(stories);
27
-
28
- describe("FilterRangeWithMockedHook", () => {
29
- describe("submit button", () => {
30
- beforeEach(() => {
31
- render(<Default />);
32
- });
33
- it("has a submit button that can be clicked", () => {
34
- screen.getByText("Filter").click();
35
- expect(ON_SUBMIT).toHaveBeenCalledTimes(1);
36
- });
37
- });
38
- });