@databiosphere/findable-ui 3.0.0 → 3.2.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 (54) hide show
  1. package/lib/components/Links/common/constants.d.ts +1 -0
  2. package/lib/components/Links/common/constants.js +4 -0
  3. package/lib/components/Links/common/entities.d.ts +8 -0
  4. package/lib/components/Links/common/utils.d.ts +13 -0
  5. package/lib/components/Links/common/utils.js +21 -1
  6. package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.d.ts +7 -0
  7. package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +148 -0
  8. package/lib/components/Links/components/Link/link.d.ts +2 -2
  9. package/lib/components/Links/components/Link/link.js +22 -6
  10. package/lib/components/common/Progress/components/CircularProgress/circularProgress.d.ts +7 -0
  11. package/lib/components/common/Progress/components/CircularProgress/circularProgress.js +28 -0
  12. package/lib/components/common/Progress/components/CircularProgress/circularProgress.styles.d.ts +5 -0
  13. package/lib/components/common/Progress/components/CircularProgress/circularProgress.styles.js +11 -0
  14. package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.d.ts +7 -0
  15. package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.js +44 -0
  16. package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.styles.d.ts +3 -0
  17. package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.styles.js +32 -0
  18. package/lib/config/entities.d.ts +2 -1
  19. package/lib/hooks/useCategoryFilter.d.ts +7 -1
  20. package/lib/hooks/useCategoryFilter.js +25 -6
  21. package/lib/providers/exploreState/initializer/constants.d.ts +2 -0
  22. package/lib/providers/exploreState/initializer/constants.js +7 -1
  23. package/lib/providers/exploreState/initializer/utils.js +1 -8
  24. package/lib/providers/exploreState/payloads/entities.d.ts +8 -1
  25. package/lib/providers/exploreState/utils.d.ts +4 -2
  26. package/lib/providers/exploreState/utils.js +4 -4
  27. package/lib/providers/exploreState.d.ts +10 -2
  28. package/lib/providers/exploreState.js +13 -0
  29. package/lib/styles/common/mixins/colors.d.ts +3 -3
  30. package/lib/styles/common/mixins/colors.js +7 -7
  31. package/lib/theme/common/components.d.ts +6 -0
  32. package/lib/theme/common/components.js +31 -1
  33. package/lib/theme/theme.js +1 -0
  34. package/package.json +1 -1
  35. package/src/components/Links/common/constants.ts +1 -0
  36. package/src/components/Links/common/entities.ts +11 -0
  37. package/src/components/Links/common/utils.ts +28 -0
  38. package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +172 -0
  39. package/src/components/Links/components/Link/link.tsx +36 -14
  40. package/src/components/common/Progress/components/CircularProgress/circularProgress.styles.ts +6 -0
  41. package/src/components/common/Progress/components/CircularProgress/circularProgress.tsx +26 -0
  42. package/src/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.styles.ts +33 -0
  43. package/src/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.tsx +23 -0
  44. package/src/config/entities.ts +4 -0
  45. package/src/hooks/useCategoryFilter.ts +31 -7
  46. package/src/providers/exploreState/initializer/constants.ts +8 -0
  47. package/src/providers/exploreState/initializer/utils.ts +6 -9
  48. package/src/providers/exploreState/payloads/entities.ts +8 -0
  49. package/src/providers/exploreState/utils.ts +11 -7
  50. package/src/providers/exploreState.tsx +33 -0
  51. package/src/styles/common/mixins/colors.ts +6 -6
  52. package/src/theme/common/components.ts +32 -0
  53. package/src/theme/theme.ts +1 -0
  54. package/types/data-explorer-ui.d.ts +10 -0
@@ -73,11 +73,14 @@ function buildCategoryView(
73
73
  categoryValueViews: SelectCategoryValueView[],
74
74
  categoryConfigs: CategoryConfig[]
75
75
  ): SelectCategoryView {
76
+ const categoryConfig = findCategoryConfig(category.key, categoryConfigs);
77
+ const mapSelectCategoryValue =
78
+ categoryConfig?.mapSelectCategoryValue || getSelectCategoryValue;
76
79
  return {
77
80
  isDisabled: false,
78
81
  key: category.key,
79
- label: getCategoryLabel(category.key, categoryConfigs),
80
- values: categoryValueViews,
82
+ label: getCategoryLabel(category.key, categoryConfig),
83
+ values: categoryValueViews.map(mapSelectCategoryValue),
81
84
  };
82
85
  }
83
86
 
@@ -192,22 +195,43 @@ function getCategorySelectedFilter(
192
195
  /**
193
196
  * Get the label for the given category key as per the config.
194
197
  * @param key - Key of category to find label of.
195
- * @param categoryConfigs - Category accept list.
198
+ * @param categoryConfig - Category.
196
199
  * @returns the display value for the given category.
197
200
  */
198
201
  function getCategoryLabel(
199
202
  key: string,
200
- categoryConfigs: CategoryConfig[]
203
+ categoryConfig?: CategoryConfig
201
204
  ): string {
202
- const categoryConfig = categoryConfigs.find(
203
- (categoryConfig) => categoryConfig.key === key
204
- );
205
205
  if (!categoryConfig) {
206
206
  return key;
207
207
  }
208
208
  return categoryConfig.label;
209
209
  }
210
210
 
211
+ /**
212
+ * Default function returning select category value, unmodified.
213
+ * @param selectCategoryValue - Select category value.
214
+ * @returns original select category value.
215
+ */
216
+ export function getSelectCategoryValue(
217
+ selectCategoryValue: SelectCategoryValue
218
+ ): SelectCategoryValue {
219
+ return selectCategoryValue;
220
+ }
221
+
222
+ /**
223
+ * Returns the category config for the given category config key.
224
+ * @param key - Category config key.
225
+ * @param categoryConfigs - Category configs.
226
+ * @returns category config.
227
+ */
228
+ function findCategoryConfig(
229
+ key: string,
230
+ categoryConfigs: CategoryConfig[]
231
+ ): CategoryConfig | undefined {
232
+ return categoryConfigs.find((categoryConfig) => categoryConfig.key === key);
233
+ }
234
+
211
235
  /**
212
236
  * Determine if given category value is selected.
213
237
  * @param categoryValueKey - The key of the category value to check if selected in the filter state.
@@ -1,6 +1,14 @@
1
+ import { CategoryGroup } from "../../../config/entities";
1
2
  import { ExploreState, PaginationState } from "../../exploreState";
3
+ import { SELECT_CATEGORY_KEY } from "../constants";
2
4
  import { EntityState } from "../entities";
3
5
 
6
+ export const DEFAULT_CATEGORY_GROUP_SAVED_FILTERS: CategoryGroup = {
7
+ categoryConfigs: [
8
+ { key: SELECT_CATEGORY_KEY.SAVED_FILTERS, label: "Saved Filters" },
9
+ ],
10
+ };
11
+
4
12
  export const DEFAULT_ENTITY_STATE: EntityState = {
5
13
  categoryViews: [],
6
14
  filterState: [],
@@ -20,7 +20,11 @@ import {
20
20
  SavedFilterByCategoryValueKey,
21
21
  } from "../entities";
22
22
  import { getEntityCategoryGroupConfigKey, getFilterCount } from "../utils";
23
- import { DEFAULT_ENTITY_STATE, INITIAL_STATE } from "./constants";
23
+ import {
24
+ DEFAULT_CATEGORY_GROUP_SAVED_FILTERS,
25
+ DEFAULT_ENTITY_STATE,
26
+ INITIAL_STATE,
27
+ } from "./constants";
24
28
 
25
29
  /**
26
30
  * Builds category groups from the given category group config (adds the saved filters category to the category groups).
@@ -32,14 +36,7 @@ function buildCategoryGroups(
32
36
  ): CategoryGroup[] {
33
37
  const { categoryGroups, savedFilters } = categoryGroupConfig;
34
38
  if (!savedFilters) return categoryGroups;
35
- const clonedCategoryGroups = [...categoryGroups];
36
- const savedFiltersCategoryGroup: CategoryGroup = {
37
- categoryConfigs: [
38
- { key: SELECT_CATEGORY_KEY.SAVED_FILTERS, label: "Saved Filters" },
39
- ],
40
- };
41
- clonedCategoryGroups.unshift(savedFiltersCategoryGroup);
42
- return clonedCategoryGroups;
39
+ return [DEFAULT_CATEGORY_GROUP_SAVED_FILTERS, ...categoryGroups];
43
40
  }
44
41
 
45
42
  /**
@@ -8,6 +8,7 @@ import {
8
8
  CategoryValueKey,
9
9
  PaginationDirectionType,
10
10
  SelectCategory,
11
+ SelectedFilter,
11
12
  } from "../../../common/entities";
12
13
  import {
13
14
  ENTITY_VIEW,
@@ -71,6 +72,13 @@ export type ToggleEntityViewPayload = ENTITY_VIEW;
71
72
  */
72
73
  export type UpdateColumnVisibilityPayload = VisibilityState;
73
74
 
75
+ /**
76
+ * Update entity filters payload.
77
+ */
78
+ export interface UpdateEntityFiltersPayload {
79
+ entityListType: string;
80
+ filters: SelectedFilter[];
81
+ }
74
82
  /**
75
83
  * Update entity view access payload.
76
84
  */
@@ -158,13 +158,16 @@ export function resetPage(paginationState: PaginationState): PaginationState {
158
158
  /**
159
159
  * Resets row selection for the current entity and entities that share the same category group config key.
160
160
  * @param state - Explore state.
161
+ * @param categoryGroupConfigKey - Category group config key.
161
162
  * @returns entity page state mapper with row selection reset.
162
163
  */
163
- export function resetRowSelection(state: ExploreState): EntityPageStateMapper {
164
- const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
164
+ export function resetRowSelection(
165
+ state: ExploreState,
166
+ categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
165
167
  state.tabValue,
166
168
  state.entityPageState
167
- );
169
+ )
170
+ ): EntityPageStateMapper {
168
171
  return Object.entries(state.entityPageState).reduce(
169
172
  (acc, [entityPath, entityPageState]) => {
170
173
  if (entityPageState.categoryGroupConfigKey === categoryGroupConfigKey) {
@@ -247,16 +250,17 @@ export function updateEntityPageStateSorting(
247
250
  * Updates entity state by category group config key.
248
251
  * @param state - Explore state.
249
252
  * @param nextEntityState - Partial next entity state.
253
+ * @param categoryGroupConfigKey - Category group config key.
250
254
  * @returns updated entity state by category group config key.
251
255
  */
252
256
  export function updateEntityStateByCategoryGroupConfigKey(
253
257
  state: ExploreState,
254
- nextEntityState: Partial<EntityState>
255
- ): void {
256
- const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
258
+ nextEntityState: Partial<EntityState>,
259
+ categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
257
260
  state.tabValue,
258
261
  state.entityPageState
259
- );
262
+ )
263
+ ): void {
260
264
  const entityState = getEntityState(state, categoryGroupConfigKey);
261
265
  if (entityState) {
262
266
  setEntityStateByCategoryGroupConfigKey(categoryGroupConfigKey, state, {
@@ -36,6 +36,7 @@ import {
36
36
  ResetExploreResponsePayload,
37
37
  ToggleEntityViewPayload,
38
38
  UpdateColumnVisibilityPayload,
39
+ UpdateEntityFiltersPayload,
39
40
  UpdateEntityViewAccessPayload,
40
41
  UpdateFilterPayload,
41
42
  UpdateRowSelectionPayload,
@@ -239,6 +240,7 @@ export enum ExploreActionKind {
239
240
  SelectEntityType = "SELECT_ENTITY_TYPE",
240
241
  ToggleEntityView = "TOGGLE_ENTITY_VIEW",
241
242
  UpdateColumnVisibility = "UPDATE_COLUMN_VISIBILITY",
243
+ UpdateEntityFilters = "UPDATE_ENTITY_FILTERS",
242
244
  UpdateEntityViewAccess = "UPDATE_ENTITY_VIEW_ACCESS",
243
245
  UpdateFilter = "UPDATE_FILTER",
244
246
  UpdateRowSelection = "UPDATE_ROW_SELECTION",
@@ -260,6 +262,7 @@ export type ExploreAction =
260
262
  | SelectEntityTypeAction
261
263
  | ToggleEntityViewAction
262
264
  | UpdateColumnVisibilityAction
265
+ | UpdateEntityFiltersAction
263
266
  | UpdateEntityViewAccessAction
264
267
  | UpdateFilterAction
265
268
  | UpdateRowSelectionAction
@@ -353,6 +356,14 @@ type UpdateColumnVisibilityAction = {
353
356
  type: ExploreActionKind.UpdateColumnVisibility;
354
357
  };
355
358
 
359
+ /**
360
+ * Update entity filters action.
361
+ */
362
+ type UpdateEntityFiltersAction = {
363
+ payload: UpdateEntityFiltersPayload;
364
+ type: ExploreActionKind.UpdateEntityFilters;
365
+ };
366
+
356
367
  /**
357
368
  * Update entity view access action.
358
369
  */
@@ -586,6 +597,28 @@ function exploreReducer(
586
597
  ),
587
598
  };
588
599
  }
600
+ /**
601
+ * Update entity filters.
602
+ */
603
+ case ExploreActionKind.UpdateEntityFilters: {
604
+ const { entityListType, filters: filterState } = payload;
605
+ const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
606
+ entityListType,
607
+ state.entityPageState
608
+ );
609
+ updateEntityStateByCategoryGroupConfigKey(
610
+ state,
611
+ {
612
+ filterState,
613
+ savedFilterState: [], // Clear saved filter state.
614
+ },
615
+ categoryGroupConfigKey
616
+ );
617
+ return {
618
+ ...state,
619
+ entityPageState: resetRowSelection(state, categoryGroupConfigKey),
620
+ };
621
+ }
589
622
  /**
590
623
  * Update entity view access
591
624
  **/
@@ -2,6 +2,8 @@ import { CommonColors, PaletteColor } from "@mui/material/styles/createPalette";
2
2
  import { ThemeProps } from "../../../theme/theme";
3
3
 
4
4
  // Alert
5
+ export const alertLight = ({ theme }: ThemeProps): PaletteColor["light"] =>
6
+ theme.palette.alert.light;
5
7
  export const alertLightest = ({
6
8
  theme,
7
9
  }: ThemeProps): PaletteColor["lightest"] => theme.palette.alert.lightest;
@@ -13,8 +15,6 @@ export const errorMain = ({ theme }: ThemeProps): PaletteColor["main"] =>
13
15
  theme.palette.error.main;
14
16
 
15
17
  // Info
16
- export const infoDark = ({ theme }: ThemeProps): PaletteColor["dark"] =>
17
- theme.palette.info.dark;
18
18
  export const infoLight = ({ theme }: ThemeProps): PaletteColor["light"] =>
19
19
  theme.palette.info.light;
20
20
  export const infoLightest = ({ theme }: ThemeProps): PaletteColor["lightest"] =>
@@ -23,12 +23,8 @@ export const infoMain = ({ theme }: ThemeProps): PaletteColor["main"] =>
23
23
  theme.palette.info.main;
24
24
 
25
25
  // Ink
26
- export const inkDark = ({ theme }: ThemeProps): PaletteColor["dark"] =>
27
- theme.palette.ink.dark;
28
26
  export const inkLight = ({ theme }: ThemeProps): PaletteColor["light"] =>
29
27
  theme.palette.ink.light;
30
- export const inkLightest = ({ theme }: ThemeProps): PaletteColor["lightest"] =>
31
- theme.palette.ink.lightest;
32
28
  export const inkMain = ({ theme }: ThemeProps): PaletteColor["main"] =>
33
29
  theme.palette.ink.main;
34
30
 
@@ -50,6 +46,8 @@ export const smokeMain = ({ theme }: ThemeProps): PaletteColor["main"] =>
50
46
  theme.palette.smoke.main;
51
47
 
52
48
  // Success
49
+ export const successLight = ({ theme }: ThemeProps): PaletteColor["light"] =>
50
+ theme.palette.success.light;
53
51
  export const successLightest = ({
54
52
  theme,
55
53
  }: ThemeProps): PaletteColor["lightest"] => theme.palette.success.lightest;
@@ -57,6 +55,8 @@ export const successMain = ({ theme }: ThemeProps): PaletteColor["main"] =>
57
55
  theme.palette.success.main;
58
56
 
59
57
  // Warning
58
+ export const warningLight = ({ theme }: ThemeProps): PaletteColor["light"] =>
59
+ theme.palette.warning.light;
60
60
  export const warningLightest = ({
61
61
  theme,
62
62
  }: ThemeProps): PaletteColor["lightest"] => theme.palette.warning.lightest;
@@ -615,6 +615,33 @@ export const MuiChip = (theme: Theme): Components["MuiChip"] => {
615
615
  };
616
616
  };
617
617
 
618
+ /**
619
+ * MuiCircularProgress Component
620
+ * @param theme - Theme.
621
+ * @returns MuiCircularProgress component theme styles.
622
+ */
623
+ export const MuiCircularProgress = (
624
+ theme: Theme
625
+ ): Components["MuiCircularProgress"] => {
626
+ return {
627
+ styleOverrides: {
628
+ circle: {
629
+ strokeLinecap: "round",
630
+ },
631
+ },
632
+ variants: [
633
+ {
634
+ props: {
635
+ color: "alert",
636
+ },
637
+ style: {
638
+ color: theme.palette.alert.main,
639
+ },
640
+ },
641
+ ],
642
+ };
643
+ };
644
+
618
645
  /**
619
646
  * MuiCssBaseline Component
620
647
  * @param theme - Theme.
@@ -943,6 +970,11 @@ export const MuiLink: Components["MuiLink"] = {
943
970
  defaultProps: {
944
971
  underline: "hover",
945
972
  },
973
+ styleOverrides: {
974
+ root: {
975
+ cursor: "pointer",
976
+ },
977
+ },
946
978
  };
947
979
 
948
980
  /**
@@ -83,6 +83,7 @@ export function createAppTheme(customOptions?: ThemeOptions): Theme {
83
83
  MuiCard: C.MuiCard,
84
84
  MuiCheckbox: C.MuiCheckbox(theme),
85
85
  MuiChip: C.MuiChip(theme),
86
+ MuiCircularProgress: C.MuiCircularProgress(theme),
86
87
  MuiCssBaseline: C.MuiCssBaseline(theme),
87
88
  MuiDialog: C.MuiDialog(theme),
88
89
  MuiDialogActions: C.MuiDialogActions,
@@ -3,6 +3,7 @@ import type {} from "@mui/material/Alert";
3
3
  import type {} from "@mui/material/Button";
4
4
  import type {} from "@mui/material/Checkbox";
5
5
  import type {} from "@mui/material/Chip";
6
+ import type {} from "@mui/material/CircularProgress";
6
7
  import type {} from "@mui/material/IconButton";
7
8
  import type {} from "@mui/material/Paper";
8
9
  import type {} from "@mui/material/styles";
@@ -54,6 +55,15 @@ declare module "@mui/material/Button" {
54
55
  }
55
56
  }
56
57
 
58
+ /**
59
+ * CircularProgress prop options.
60
+ */
61
+ declare module "@mui/material/CircularProgress" {
62
+ interface CircularProgressPropsColorOverrides {
63
+ alert: true;
64
+ }
65
+ }
66
+
57
67
  /**
58
68
  * Checkbox prop options.
59
69
  */