@databiosphere/findable-ui 2.2.0 → 3.1.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 (127) hide show
  1. package/lib/components/Detail/components/DetailViewTable/detailViewTable.js +1 -1
  2. package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
  3. package/lib/components/Index/index.d.ts +2 -1
  4. package/lib/components/Index/index.js +2 -2
  5. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.styles.d.ts +3 -3
  6. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +1 -1
  7. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/searchBar.styles.d.ts +1 -1
  8. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +1 -1
  9. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
  10. package/lib/components/Layout/components/Outline/outline.styles.d.ts +1 -1
  11. package/lib/components/Table/common/utils.d.ts +6 -0
  12. package/lib/components/Table/common/utils.js +12 -1
  13. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +2 -2
  14. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +1 -1
  15. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +3 -3
  16. package/lib/components/Table/components/TableCell/common/utils.d.ts +8 -0
  17. package/lib/components/Table/components/TableCell/common/utils.js +15 -0
  18. package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.d.ts +6 -0
  19. package/lib/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.js +15 -0
  20. package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.d.ts +6 -0
  21. package/lib/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.js +16 -0
  22. package/lib/components/Table/components/TableHead/tableHead.js +2 -2
  23. package/lib/components/Table/components/TableRows/tableRows.js +2 -3
  24. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.d.ts +10 -0
  25. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.js +37 -0
  26. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.d.ts +3 -0
  27. package/lib/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.js +13 -0
  28. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.d.ts +9 -0
  29. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.js +19 -0
  30. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.d.ts +5 -0
  31. package/lib/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.js +13 -0
  32. package/lib/components/Table/components/TableToolbar/tableToolbar.js +5 -5
  33. package/lib/components/Table/components/TableToolbar/tableToolbar.styles.d.ts +1 -5
  34. package/lib/components/Table/components/TableToolbar/tableToolbar.styles.js +10 -7
  35. package/lib/components/Table/table.d.ts +5 -2
  36. package/lib/components/Table/table.js +13 -2
  37. package/lib/components/TableCreator/common/constants.d.ts +6 -0
  38. package/lib/components/TableCreator/common/constants.js +22 -0
  39. package/lib/components/TableCreator/common/entities.d.ts +5 -0
  40. package/lib/components/TableCreator/common/entities.js +2 -0
  41. package/lib/components/TableCreator/common/utils.d.ts +8 -0
  42. package/lib/components/TableCreator/common/utils.js +24 -0
  43. package/lib/components/TableCreator/tableCreator.d.ts +3 -1
  44. package/lib/components/TableCreator/tableCreator.js +19 -34
  45. package/lib/components/common/Alert/components/AlertText/alertText.styles.d.ts +5 -0
  46. package/lib/components/common/Alert/components/AlertText/alertText.styles.js +25 -0
  47. package/lib/components/common/Button/components/DropdownButton/dropdownButton.d.ts +4 -2
  48. package/lib/components/common/Button/components/DropdownButton/dropdownButton.js +2 -2
  49. package/lib/components/common/Button/components/DropdownButton/dropdownButton.styles.d.ts +5 -1
  50. package/lib/components/common/Button/components/DropdownButton/dropdownButton.styles.js +24 -1
  51. package/lib/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.d.ts +6 -0
  52. package/lib/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.js +29 -0
  53. package/lib/components/common/Dialog/dialog.d.ts +7 -0
  54. package/lib/components/common/Dialog/dialog.js +24 -0
  55. package/lib/components/common/DropdownMenu/common/constants.d.ts +2 -0
  56. package/lib/components/common/DropdownMenu/common/constants.js +8 -0
  57. package/lib/components/common/DropdownMenu/common/entities.d.ts +10 -0
  58. package/lib/components/common/DropdownMenu/common/entities.js +2 -0
  59. package/lib/components/common/DropdownMenu/components/MenuItem/menuItem.d.ts +7 -0
  60. package/lib/components/common/DropdownMenu/components/MenuItem/menuItem.js +25 -0
  61. package/lib/components/common/DropdownMenu/dropdownMenu.d.ts +9 -0
  62. package/lib/components/common/DropdownMenu/dropdownMenu.js +49 -0
  63. package/lib/components/common/DropdownMenu/dropdownMenu.styles.d.ts +3 -0
  64. package/lib/components/common/DropdownMenu/dropdownMenu.styles.js +13 -0
  65. package/lib/components/common/IconButton/iconButton.d.ts +4 -3
  66. package/lib/components/common/IconButton/iconButton.js +4 -4
  67. package/lib/components/common/IconButton/iconButton.styles.d.ts +34 -0
  68. package/lib/components/common/IconButton/iconButton.styles.js +27 -1
  69. package/lib/components/common/Tabs/tabs.styles.d.ts +1 -1
  70. package/lib/config/entities.d.ts +4 -1
  71. package/lib/hooks/useCategoryFilter.d.ts +7 -1
  72. package/lib/hooks/useCategoryFilter.js +25 -6
  73. package/lib/providers/exploreState/entities.d.ts +6 -2
  74. package/lib/providers/exploreState/initializer/utils.js +20 -7
  75. package/lib/providers/exploreState/payloads/entities.d.ts +24 -6
  76. package/lib/providers/exploreState/utils.d.ts +24 -2
  77. package/lib/providers/exploreState/utils.js +52 -3
  78. package/lib/providers/exploreState.d.ts +29 -5
  79. package/lib/providers/exploreState.js +28 -7
  80. package/lib/theme/common/components.js +4 -0
  81. package/lib/views/ExploreView/exploreView.d.ts +3 -1
  82. package/lib/views/ExploreView/exploreView.js +3 -3
  83. package/package.json +1 -1
  84. package/src/components/Detail/components/DetailViewTable/detailViewTable.tsx +2 -2
  85. package/src/components/Index/index.tsx +3 -1
  86. package/src/components/Table/common/utils.ts +17 -0
  87. package/src/components/Table/components/CheckboxMenu/checkboxMenu.styles.ts +3 -3
  88. package/src/components/Table/components/CheckboxMenu/checkboxMenu.tsx +4 -2
  89. package/src/components/Table/components/TableCell/common/utils.ts +16 -0
  90. package/src/components/Table/components/TableCell/components/RowSelectionCell/rowSelectionCell.tsx +24 -0
  91. package/src/components/Table/components/TableHead/components/HeadSelectionCell/headSelectionCell.tsx +31 -0
  92. package/src/components/Table/components/TableHead/tableHead.tsx +18 -7
  93. package/src/components/Table/components/TableRows/tableRows.tsx +10 -8
  94. package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.styles.ts +8 -0
  95. package/src/components/Table/components/TableToolbar/components/RowSelection/components/DropdownMenu/dropdownMenu.tsx +50 -0
  96. package/src/components/Table/components/TableToolbar/components/RowSelection/rowSelection.styles.ts +8 -0
  97. package/src/components/Table/components/TableToolbar/components/RowSelection/rowSelection.tsx +30 -0
  98. package/src/components/Table/components/TableToolbar/tableToolbar.styles.ts +10 -7
  99. package/src/components/Table/components/TableToolbar/tableToolbar.tsx +11 -8
  100. package/src/components/Table/table.tsx +18 -1
  101. package/src/components/TableCreator/common/constants.ts +26 -0
  102. package/src/components/TableCreator/common/entities.ts +6 -0
  103. package/src/components/TableCreator/common/utils.ts +33 -0
  104. package/src/components/TableCreator/tableCreator.tsx +38 -17
  105. package/src/components/common/Alert/components/AlertText/alertText.styles.ts +20 -0
  106. package/src/components/common/Button/components/DropdownButton/dropdownButton.styles.ts +15 -1
  107. package/src/components/common/Button/components/DropdownButton/dropdownButton.tsx +10 -2
  108. package/src/components/common/CustomIcon/components/IndeterminateIcon/indeterminateIcon.tsx +23 -0
  109. package/src/components/common/Dialog/dialog.tsx +21 -0
  110. package/src/components/common/DropdownMenu/common/constants.ts +7 -0
  111. package/src/components/common/DropdownMenu/common/entities.ts +11 -0
  112. package/src/components/common/DropdownMenu/components/MenuItem/menuItem.tsx +24 -0
  113. package/src/components/common/DropdownMenu/dropdownMenu.styles.ts +8 -0
  114. package/src/components/common/DropdownMenu/dropdownMenu.tsx +48 -0
  115. package/src/components/common/IconButton/iconButton.styles.ts +18 -0
  116. package/src/components/common/IconButton/iconButton.tsx +10 -11
  117. package/src/config/entities.ts +6 -0
  118. package/src/hooks/useCategoryFilter.ts +31 -7
  119. package/src/providers/exploreState/entities.ts +8 -2
  120. package/src/providers/exploreState/initializer/utils.ts +21 -1
  121. package/src/providers/exploreState/payloads/entities.ts +32 -7
  122. package/src/providers/exploreState/utils.ts +81 -1
  123. package/src/providers/exploreState.tsx +88 -11
  124. package/src/theme/common/components.ts +4 -0
  125. package/src/views/ExploreView/exploreView.tsx +6 -2
  126. package/types/data-explorer-ui.d.ts +10 -0
  127. package/src/components/Table/components/EntityViewToggle/entityViewToggle.tsx +0 -36
@@ -1,4 +1,37 @@
1
1
  /// <reference types="react" />
2
+ interface Props {
3
+ open: boolean;
4
+ }
5
+ export declare const Button: import("@emotion/styled").StyledComponent<{
6
+ children?: import("react").ReactNode;
7
+ classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
8
+ color?: "inherit" | "default" | "primary" | "secondary" | "error" | "info" | "success" | "warning" | "inkLight" | "ink" | undefined;
9
+ disabled?: boolean | undefined;
10
+ disableFocusRipple?: boolean | undefined;
11
+ edge?: false | "end" | "start" | undefined;
12
+ size?: "large" | "medium" | "small" | "xsmall" | "xxsmall" | "xlarge" | undefined;
13
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
14
+ } & Omit<{
15
+ action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
16
+ centerRipple?: boolean | undefined;
17
+ children?: import("react").ReactNode;
18
+ classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
19
+ disabled?: boolean | undefined;
20
+ disableRipple?: boolean | undefined;
21
+ disableTouchRipple?: boolean | undefined;
22
+ focusRipple?: boolean | undefined;
23
+ focusVisibleClassName?: string | undefined;
24
+ LinkComponent?: import("react").ElementType<any> | undefined;
25
+ onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
26
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
27
+ tabIndex?: number | undefined;
28
+ TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
29
+ touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
30
+ }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
31
+ ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
32
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "color" | "children" | "sx" | "disabled" | "action" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "edge"> & {
33
+ theme?: import("@emotion/react").Theme | undefined;
34
+ } & Props, {}, {}>;
2
35
  export declare const IconButtonPrimary: import("@emotion/styled").StyledComponent<import("./iconButton").IconButtonProps & {
3
36
  theme?: import("@emotion/react").Theme | undefined;
4
37
  }, {}, {}>;
@@ -14,3 +47,4 @@ export declare const CloseDrawerIconButton: import("@emotion/styled").StyledComp
14
47
  }, {}, {}>;
15
48
  export declare const IconButtonSocials: import("@mui/material").ExtendButtonBase<import("@mui/material").IconButtonTypeMap<{}, "button">>;
16
49
  export declare const IconButtonSocialsFooter: import("@mui/material").ExtendButtonBase<import("@mui/material").IconButtonTypeMap<{}, "button">>;
50
+ export {};
@@ -1,12 +1,38 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IconButtonSocialsFooter = exports.IconButtonSocials = exports.CloseDrawerIconButton = exports.MockIconButtonPrimary = exports.IconButtonSecondary = exports.IconButtonPrimary = void 0;
17
+ exports.IconButtonSocialsFooter = exports.IconButtonSocials = exports.CloseDrawerIconButton = exports.MockIconButtonPrimary = exports.IconButtonSecondary = exports.IconButtonPrimary = exports.Button = void 0;
18
+ const react_1 = require("@emotion/react");
7
19
  const styled_1 = __importDefault(require("@emotion/styled"));
8
20
  const material_1 = require("@mui/material");
21
+ const colors_1 = require("../../../styles/common/mixins/colors");
9
22
  const iconButton_1 = require("./iconButton");
23
+ exports.Button = (0, styled_1.default)(material_1.IconButton, {
24
+ shouldForwardProp: (prop) => prop !== "open",
25
+ }) `
26
+ ${(_a) => {
27
+ var { open } = _a, props = __rest(_a, ["open"]);
28
+ return open &&
29
+ (0, react_1.css) `
30
+ &.MuiIconButton-root {
31
+ background-color: ${(0, colors_1.smokeLightest)(props)};
32
+ }
33
+ `;
34
+ }}
35
+ `;
10
36
  // Primary icon button.
11
37
  exports.IconButtonPrimary = (0, styled_1.default)(iconButton_1.IconButton) `
12
38
  background-color: ${({ theme }) => theme.palette.primary.main};
@@ -37,7 +37,7 @@ export declare const Tab: import("@emotion/styled").StyledComponent<{
37
37
  touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
38
38
  }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
39
39
  ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
40
- }, "label" | keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "children" | "sx" | "disabled" | "value" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "icon" | "wrapped" | "iconPosition"> & {
40
+ }, "label" | keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "children" | "sx" | "disabled" | "value" | "action" | "icon" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "wrapped" | "iconPosition"> & {
41
41
  theme?: import("@emotion/react").Theme | undefined;
42
42
  }, {}, {}>;
43
43
  export {};
@@ -1,7 +1,7 @@
1
1
  import { TabProps as MTabProps, Theme, ThemeOptions } from "@mui/material";
2
2
  import { ColumnSort } from "@tanstack/react-table";
3
3
  import { JSXElementConstructor, ReactNode } from "react";
4
- import { CategoryKey, SelectedFilter, SelectedFilterValue } from "../common/entities";
4
+ import { CategoryKey, SelectCategoryValueView, SelectedFilter, SelectedFilterValue } from "../common/entities";
5
5
  import { HeroTitle } from "../components/common/Title/title";
6
6
  import { FooterProps } from "../components/Layout/components/Footer/footer";
7
7
  import { HeaderProps } from "../components/Layout/components/Header/header";
@@ -66,6 +66,7 @@ export interface CategoryGroup {
66
66
  export interface CategoryConfig {
67
67
  key: string;
68
68
  label: string;
69
+ mapSelectCategoryValue?: (selectCategoryValue: SelectCategoryValueView) => SelectCategoryValueView;
69
70
  }
70
71
  /**
71
72
  * Column configuration.
@@ -209,8 +210,10 @@ export interface ListConfig<T = any> {
209
210
  export interface ListViewConfig {
210
211
  disablePagination?: boolean;
211
212
  enableDownload?: boolean;
213
+ enableRowSelection?: boolean;
212
214
  listHero?: ComponentsConfig;
213
215
  relatedView?: RelatedViewConfig;
216
+ rowSelectionView?: ComponentsConfig;
214
217
  subTitleHero?: ComponentsConfig;
215
218
  }
216
219
  /**
@@ -1,4 +1,4 @@
1
- import { CategoryKey, CategoryValueKey, Filters, SelectCategory, SelectCategoryView } from "../common/entities";
1
+ import { CategoryKey, CategoryValueKey, Filters, SelectCategory, SelectCategoryValue, SelectCategoryView } from "../common/entities";
2
2
  import { CategoryConfig } from "../config/entities";
3
3
  /**
4
4
  * State backing filter functionality and calculations. Converted to view model for display.
@@ -33,3 +33,9 @@ export declare function buildCategoryViews(categories: SelectCategory[], categor
33
33
  * @returns New filter state generated from the current set of selected values and the newly selected value.
34
34
  */
35
35
  export declare function buildNextFilterState(filterState: FilterState, categoryKey: CategoryKey, selectedValue: CategoryValueKey, selected: boolean): FilterState;
36
+ /**
37
+ * Default function returning select category value, unmodified.
38
+ * @param selectCategoryValue - Select category value.
39
+ * @returns original select category value.
40
+ */
41
+ export declare function getSelectCategoryValue(selectCategoryValue: SelectCategoryValue): SelectCategoryValue;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildNextFilterState = exports.buildCategoryViews = void 0;
3
+ exports.getSelectCategoryValue = exports.buildNextFilterState = exports.buildCategoryViews = void 0;
4
4
  const constants_1 = require("../common/constants");
5
5
  /**
6
6
  * Build the view-specific model of the given category value.
@@ -27,11 +27,13 @@ function buildCategoryValueView(categoryValue, categorySelectedFilter) {
27
27
  * @returns Full built category value view, ready for display.
28
28
  */
29
29
  function buildCategoryView(category, categoryValueViews, categoryConfigs) {
30
+ const categoryConfig = findCategoryConfig(category.key, categoryConfigs);
31
+ const mapSelectCategoryValue = (categoryConfig === null || categoryConfig === void 0 ? void 0 : categoryConfig.mapSelectCategoryValue) || getSelectCategoryValue;
30
32
  return {
31
33
  isDisabled: false,
32
34
  key: category.key,
33
- label: getCategoryLabel(category.key, categoryConfigs),
34
- values: categoryValueViews,
35
+ label: getCategoryLabel(category.key, categoryConfig),
36
+ values: categoryValueViews.map(mapSelectCategoryValue),
35
37
  };
36
38
  }
37
39
  /**
@@ -107,16 +109,33 @@ function getCategorySelectedFilter(categoryKey, filterState) {
107
109
  /**
108
110
  * Get the label for the given category key as per the config.
109
111
  * @param key - Key of category to find label of.
110
- * @param categoryConfigs - Category accept list.
112
+ * @param categoryConfig - Category.
111
113
  * @returns the display value for the given category.
112
114
  */
113
- function getCategoryLabel(key, categoryConfigs) {
114
- const categoryConfig = categoryConfigs.find((categoryConfig) => categoryConfig.key === key);
115
+ function getCategoryLabel(key, categoryConfig) {
115
116
  if (!categoryConfig) {
116
117
  return key;
117
118
  }
118
119
  return categoryConfig.label;
119
120
  }
121
+ /**
122
+ * Default function returning select category value, unmodified.
123
+ * @param selectCategoryValue - Select category value.
124
+ * @returns original select category value.
125
+ */
126
+ function getSelectCategoryValue(selectCategoryValue) {
127
+ return selectCategoryValue;
128
+ }
129
+ exports.getSelectCategoryValue = getSelectCategoryValue;
130
+ /**
131
+ * Returns the category config for the given category config key.
132
+ * @param key - Category config key.
133
+ * @param categoryConfigs - Category configs.
134
+ * @returns category config.
135
+ */
136
+ function findCategoryConfig(key, categoryConfigs) {
137
+ return categoryConfigs.find((categoryConfig) => categoryConfig.key === key);
138
+ }
120
139
  /**
121
140
  * Determine if given category value is selected.
122
141
  * @param categoryValueKey - The key of the category value to check if selected in the filter state.
@@ -1,9 +1,12 @@
1
- import { ColumnSort } from "@tanstack/react-table";
1
+ import { ColumnSort, RowSelectionState } from "@tanstack/react-table";
2
+ import { VisibilityState } from "@tanstack/table-core/src/features/Visibility";
2
3
  import { CategoryValueKey, SelectCategory, SelectCategoryView, SelectedFilter } from "../../common/entities";
3
4
  import { CategoryConfig, CategoryGroup, CategoryGroupConfig, EntityPath, SavedFilter } from "../../config/entities";
4
5
  export interface EntityPageState {
5
6
  categoryGroupConfigKey: CategoryGroupConfigKey;
6
- columnsVisibility: Record<string, boolean>;
7
+ columnsVisibility: VisibilityState;
8
+ enableRowSelection: boolean;
9
+ rowSelection: RowSelectionState;
7
10
  sorting: ColumnSort[];
8
11
  }
9
12
  export interface EntityPageStateMapper {
@@ -23,4 +26,5 @@ export declare type CategoryGroupConfigKey = CategoryGroupConfig["key"];
23
26
  export interface EntityStateSavedFilter extends Omit<SavedFilter, "sort"> {
24
27
  sorting?: ColumnSort[];
25
28
  }
29
+ export declare type ListItem = any;
26
30
  export declare type SavedFilterByCategoryValueKey = Map<CategoryValueKey, EntityStateSavedFilter>;
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initReducerArguments = void 0;
4
4
  const utils_1 = require("../../../components/Table/common/utils");
5
+ const constants_1 = require("../../../components/TableCreator/common/constants");
5
6
  const utils_2 = require("../../../config/utils");
6
- const constants_1 = require("../constants");
7
+ const constants_2 = require("../constants");
7
8
  const utils_3 = require("../utils");
8
- const constants_2 = require("./constants");
9
+ const constants_3 = require("./constants");
9
10
  /**
10
11
  * Builds category groups from the given category group config (adds the saved filters category to the category groups).
11
12
  * @param categoryGroupConfig - Category group config.
@@ -18,7 +19,7 @@ function buildCategoryGroups(categoryGroupConfig) {
18
19
  const clonedCategoryGroups = [...categoryGroups];
19
20
  const savedFiltersCategoryGroup = {
20
21
  categoryConfigs: [
21
- { key: constants_1.SELECT_CATEGORY_KEY.SAVED_FILTERS, label: "Saved Filters" },
22
+ { key: constants_2.SELECT_CATEGORY_KEY.SAVED_FILTERS, label: "Saved Filters" },
22
23
  ],
23
24
  };
24
25
  clonedCategoryGroups.unshift(savedFiltersCategoryGroup);
@@ -34,7 +35,7 @@ function buildSavedSelectCategories(savedFilters) {
34
35
  return [];
35
36
  return [
36
37
  {
37
- key: constants_1.SELECT_CATEGORY_KEY.SAVED_FILTERS,
38
+ key: constants_2.SELECT_CATEGORY_KEY.SAVED_FILTERS,
38
39
  label: "",
39
40
  values: savedFilters.map(({ title }) => ({
40
41
  count: 1,
@@ -99,6 +100,15 @@ function initCategoryGroups(entityStateByCategoryGroupConfigKey, categoryGroupCo
99
100
  var _a;
100
101
  return (_a = entityStateByCategoryGroupConfigKey.get(categoryGroupConfigKey)) === null || _a === void 0 ? void 0 : _a.categoryGroups;
101
102
  }
103
+ /**
104
+ * Initializes column visibility for the given entity.
105
+ * @param entityConfig - Entity config.
106
+ * @returns column visibility.
107
+ */
108
+ function initColumnVisibility(entityConfig) {
109
+ const { list: { columns }, listView: { enableRowSelection = false } = {}, } = entityConfig;
110
+ return Object.assign({ [constants_1.ACCESSOR_KEYS.SELECT]: enableRowSelection }, (0, utils_1.getInitialTableColumnVisibility)(columns));
111
+ }
102
112
  /**
103
113
  * Initializes entity page state.
104
114
  * @param config - Site config.
@@ -106,9 +116,12 @@ function initCategoryGroups(entityStateByCategoryGroupConfigKey, categoryGroupCo
106
116
  */
107
117
  function initEntityPageState(config) {
108
118
  return config.entities.reduce((acc, entity) => {
119
+ var _a;
109
120
  return Object.assign(Object.assign({}, acc), { [entity.route]: {
110
121
  categoryGroupConfigKey: initCategoryGroupConfigKey(config, entity),
111
- columnsVisibility: (0, utils_1.getInitialTableColumnVisibility)(entity.list.columns),
122
+ columnsVisibility: initColumnVisibility(entity),
123
+ enableRowSelection: Boolean((_a = entity.listView) === null || _a === void 0 ? void 0 : _a.enableRowSelection),
124
+ rowSelection: {},
112
125
  sorting: (0, utils_2.getDefaultSorting)(entity),
113
126
  } });
114
127
  }, {});
@@ -132,7 +145,7 @@ function initEntityStateByCategoryGroupConfigKey(config, categoryGroupConfigKey,
132
145
  const categoryGroups = buildCategoryGroups(categoryGroupConfig);
133
146
  const savedSelectCategories = buildSavedSelectCategories(savedFilters);
134
147
  const savedFilterByCategoryValueKey = buildSavedFilterByCategoryValueKey(savedFilters);
135
- entityStateByCategoryGroupConfigKey.set(key, Object.assign(Object.assign({}, constants_2.DEFAULT_ENTITY_STATE), { categoryConfigs: flattenCategoryGroups(categoryGroups), categoryGroups, filterState: key === categoryGroupConfigKey ? filterState : [], savedFilterByCategoryValueKey,
148
+ entityStateByCategoryGroupConfigKey.set(key, Object.assign(Object.assign({}, constants_3.DEFAULT_ENTITY_STATE), { categoryConfigs: flattenCategoryGroups(categoryGroups), categoryGroups, filterState: key === categoryGroupConfigKey ? filterState : [], savedFilterByCategoryValueKey,
136
149
  savedSelectCategories }));
137
150
  }
138
151
  return entityStateByCategoryGroupConfigKey;
@@ -168,7 +181,7 @@ function initReducerArguments(config, entityListType, decodedFilterParam, decode
168
181
  const categoryGroupConfigKey = (0, utils_3.getEntityCategoryGroupConfigKey)(entityListType, entityPageState);
169
182
  const entityStateByCategoryGroupConfigKey = initEntityStateByCategoryGroupConfigKey(config, categoryGroupConfigKey, filterState);
170
183
  const categoryGroups = initCategoryGroups(entityStateByCategoryGroupConfigKey, categoryGroupConfigKey);
171
- return Object.assign(Object.assign({}, constants_2.INITIAL_STATE), { catalogState: decodedCatalogParam, categoryGroups,
184
+ return Object.assign(Object.assign({}, constants_3.INITIAL_STATE), { catalogState: decodedCatalogParam, categoryGroups,
172
185
  entityPageState,
173
186
  entityStateByCategoryGroupConfigKey, featureFlagState: decodedFeatureFlagParam, filterCount: (0, utils_3.getFilterCount)(filterState), filterState, tabValue: entityListType });
174
187
  }
@@ -1,6 +1,7 @@
1
- import { ColumnSort } from "@tanstack/react-table";
1
+ import { ColumnSort, RowSelectionState, VisibilityState } from "@tanstack/react-table";
2
2
  import { CategoryKey, CategoryValueKey, PaginationDirectionType, SelectCategory } from "../../../common/entities";
3
3
  import { ENTITY_VIEW, ListItems, PaginationResponse, RelatedListItems } from "../../exploreState";
4
+ import { ListItem } from "../entities";
4
5
  /**
5
6
  * Apply saved filter payload.
6
7
  */
@@ -9,6 +10,17 @@ export interface ApplySavedFilterPayload {
9
10
  selected: boolean;
10
11
  selectedValue: CategoryValueKey;
11
12
  }
13
+ /**
14
+ * Paginate table payload.
15
+ */
16
+ export declare type PaginateTablePayload = PaginationDirectionType;
17
+ /**
18
+ * Patch explore response payload.
19
+ */
20
+ export interface PatchExploreResponsePayload {
21
+ listItemKey: keyof ListItem;
22
+ updatedListItems: ListItems;
23
+ }
12
24
  /**
13
25
  * Process explore response payload.
14
26
  */
@@ -24,10 +36,6 @@ export interface ProcessExploreResponsePayload {
24
36
  export interface ProcessRelatedResponsePayload {
25
37
  relatedListItems: RelatedListItems;
26
38
  }
27
- /**
28
- * Paginate table payload.
29
- */
30
- export declare type PaginateTablePayload = PaginationDirectionType;
31
39
  /**
32
40
  * Reset explore response payload.
33
41
  */
@@ -39,7 +47,13 @@ export declare type ToggleEntityViewPayload = ENTITY_VIEW;
39
47
  /**
40
48
  * Update column visibility payload.
41
49
  */
42
- export declare type UpdateColumnVisibilityPayload = Record<string, boolean>;
50
+ export declare type UpdateColumnVisibilityPayload = VisibilityState;
51
+ /**
52
+ * Update entity view access payload.
53
+ */
54
+ export interface UpdateEntityViewAccessPayload {
55
+ canEdit: boolean;
56
+ }
43
57
  /**
44
58
  * Update filter payload.
45
59
  */
@@ -48,6 +62,10 @@ export interface UpdateFilterPayload {
48
62
  selected: boolean;
49
63
  selectedValue: CategoryValueKey;
50
64
  }
65
+ /**
66
+ * Update row selection payload.
67
+ */
68
+ export declare type UpdateRowSelectionPayload = RowSelectionState;
51
69
  /**
52
70
  * Update sorting payload.
53
71
  */
@@ -1,7 +1,7 @@
1
1
  import { ColumnSort } from "@tanstack/react-table";
2
2
  import { CategoryKey, CategoryValueKey, SelectedFilter } from "../../common/entities";
3
- import { ExploreState, PaginationState } from "../exploreState";
4
- import { CategoryGroupConfigKey, EntityPageState, EntityPageStateMapper, EntityState, EntityStateSavedFilter } from "./entities";
3
+ import { ExploreState, ListItems, PaginationState } from "../exploreState";
4
+ import { CategoryGroupConfigKey, EntityPageState, EntityPageStateMapper, EntityState, EntityStateSavedFilter, ListItem } from "./entities";
5
5
  /**
6
6
  * Returns the entity state saved filter state for the given category key.
7
7
  * @param categoryKey - Category key.
@@ -53,12 +53,26 @@ export declare function getEntityStateSavedSorting(state: ExploreState, selected
53
53
  * @returns filter count.
54
54
  */
55
55
  export declare function getFilterCount(filterState: SelectedFilter[]): number;
56
+ /**
57
+ * Returns list items with updated list items patched.
58
+ * @param listItems - List items.
59
+ * @param updatedListItems - List items to patch.
60
+ * @param listItemKey - List item key identifier to map list items.
61
+ * @returns list items with updated list items patched.
62
+ */
63
+ export declare function patchEntityListItems(listItems: ListItems, updatedListItems: ListItems, listItemKey: keyof ListItem): ListItems;
56
64
  /**
57
65
  * Resets pagination.
58
66
  * @param paginationState - Pagination state.
59
67
  * @returns a reset pagination state.
60
68
  */
61
69
  export declare function resetPage(paginationState: PaginationState): PaginationState;
70
+ /**
71
+ * Resets row selection for the current entity and entities that share the same category group config key.
72
+ * @param state - Explore state.
73
+ * @returns entity page state mapper with row selection reset.
74
+ */
75
+ export declare function resetRowSelection(state: ExploreState): EntityPageStateMapper;
62
76
  /**
63
77
  * Updates entity page state for the given entity path.
64
78
  * @param entityPath - Entity path.
@@ -82,3 +96,11 @@ export declare function updateEntityPageStateSorting(state: ExploreState, sortin
82
96
  * @returns updated entity state by category group config key.
83
97
  */
84
98
  export declare function updateEntityStateByCategoryGroupConfigKey(state: ExploreState, nextEntityState: Partial<EntityState>): void;
99
+ /**
100
+ * Updates the entity page state for each entity with row selection enabled,
101
+ * by updating the visibility of the "select" column based on user access and resetting row selection state.
102
+ * @param state - Explore state.
103
+ * @param canEdit - User has edit access.
104
+ * @returns new entity page state mapper with updated column visibility and row selection state.
105
+ */
106
+ export declare function updateSelectColumnVisibility(state: ExploreState, canEdit: boolean): EntityPageStateMapper;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateEntityStateByCategoryGroupConfigKey = exports.updateEntityPageStateSorting = exports.updateEntityPageState = exports.resetPage = exports.getFilterCount = exports.getEntityStateSavedSorting = exports.getEntityStateSavedFilter = exports.getEntityState = exports.getEntityCategoryGroupConfigKey = exports.buildNextSavedFilterState = exports.buildEntityStateSavedFilterState = void 0;
4
- const constants_1 = require("./initializer/constants");
3
+ exports.updateSelectColumnVisibility = exports.updateEntityStateByCategoryGroupConfigKey = exports.updateEntityPageStateSorting = exports.updateEntityPageState = exports.resetRowSelection = exports.resetPage = exports.patchEntityListItems = exports.getFilterCount = exports.getEntityStateSavedSorting = exports.getEntityStateSavedFilter = exports.getEntityState = exports.getEntityCategoryGroupConfigKey = exports.buildNextSavedFilterState = exports.buildEntityStateSavedFilterState = void 0;
4
+ const constants_1 = require("../../components/TableCreator/common/constants");
5
+ const constants_2 = require("./initializer/constants");
5
6
  /**
6
7
  * Returns the entity state saved filter state for the given category key.
7
8
  * @param categoryKey - Category key.
@@ -47,7 +48,7 @@ exports.getEntityCategoryGroupConfigKey = getEntityCategoryGroupConfigKey;
47
48
  */
48
49
  function getEntityState(state, categoryGroupConfigKey = getEntityCategoryGroupConfigKey(state.tabValue, state.entityPageState)) {
49
50
  return (state.entityStateByCategoryGroupConfigKey.get(categoryGroupConfigKey) ||
50
- constants_1.DEFAULT_ENTITY_STATE);
51
+ constants_2.DEFAULT_ENTITY_STATE);
51
52
  }
52
53
  exports.getEntityState = getEntityState;
53
54
  /**
@@ -85,6 +86,23 @@ function getFilterCount(filterState) {
85
86
  return filterState.reduce((acc, filter) => acc + filter.value.length, 0);
86
87
  }
87
88
  exports.getFilterCount = getFilterCount;
89
+ /**
90
+ * Returns list items with updated list items patched.
91
+ * @param listItems - List items.
92
+ * @param updatedListItems - List items to patch.
93
+ * @param listItemKey - List item key identifier to map list items.
94
+ * @returns list items with updated list items patched.
95
+ */
96
+ function patchEntityListItems(listItems, updatedListItems, listItemKey) {
97
+ if (!listItems || !updatedListItems)
98
+ return listItems;
99
+ const listItemById = new Map(listItems.map((listItem) => [listItem[listItemKey], listItem]));
100
+ updatedListItems.forEach((listItem) => {
101
+ listItemById.set(listItem[listItemKey], listItem);
102
+ });
103
+ return [...listItemById.values()];
104
+ }
105
+ exports.patchEntityListItems = patchEntityListItems;
88
106
  /**
89
107
  * Resets pagination.
90
108
  * @param paginationState - Pagination state.
@@ -97,6 +115,21 @@ function resetPage(paginationState) {
97
115
  return nextPaginationState;
98
116
  }
99
117
  exports.resetPage = resetPage;
118
+ /**
119
+ * Resets row selection for the current entity and entities that share the same category group config key.
120
+ * @param state - Explore state.
121
+ * @returns entity page state mapper with row selection reset.
122
+ */
123
+ function resetRowSelection(state) {
124
+ const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(state.tabValue, state.entityPageState);
125
+ return Object.entries(state.entityPageState).reduce((acc, [entityPath, entityPageState]) => {
126
+ if (entityPageState.categoryGroupConfigKey === categoryGroupConfigKey) {
127
+ return Object.assign(Object.assign({}, acc), { [entityPath]: Object.assign(Object.assign({}, entityPageState), { rowSelection: {} }) });
128
+ }
129
+ return Object.assign(Object.assign({}, acc), { [entityPath]: entityPageState });
130
+ }, {});
131
+ }
132
+ exports.resetRowSelection = resetRowSelection;
100
133
  /**
101
134
  * Sets entity state for the given category group config key.
102
135
  * @param categoryGroupConfigKey - Category group config key.
@@ -150,3 +183,19 @@ function updateEntityStateByCategoryGroupConfigKey(state, nextEntityState) {
150
183
  }
151
184
  }
152
185
  exports.updateEntityStateByCategoryGroupConfigKey = updateEntityStateByCategoryGroupConfigKey;
186
+ /**
187
+ * Updates the entity page state for each entity with row selection enabled,
188
+ * by updating the visibility of the "select" column based on user access and resetting row selection state.
189
+ * @param state - Explore state.
190
+ * @param canEdit - User has edit access.
191
+ * @returns new entity page state mapper with updated column visibility and row selection state.
192
+ */
193
+ function updateSelectColumnVisibility(state, canEdit) {
194
+ return Object.entries(state.entityPageState).reduce((acc, [entityPath, entityPageState]) => {
195
+ if (entityPageState.enableRowSelection) {
196
+ return Object.assign(Object.assign({}, acc), { [entityPath]: Object.assign(Object.assign({}, entityPageState), { columnsVisibility: Object.assign(Object.assign({}, entityPageState.columnsVisibility), { [constants_1.ACCESSOR_KEYS.SELECT]: canEdit }), rowSelection: {} }) });
197
+ }
198
+ return Object.assign(Object.assign({}, acc), { [entityPath]: entityPageState });
199
+ }, {});
200
+ }
201
+ exports.updateSelectColumnVisibility = updateSelectColumnVisibility;
@@ -2,8 +2,8 @@ import React, { Dispatch, ReactNode } from "react";
2
2
  import { AzulSearchIndex } from "../apis/azul/common/entities";
3
3
  import { SelectCategoryView, SelectedFilter } from "../common/entities";
4
4
  import { CategoryGroup, SiteConfig } from "../config/entities";
5
- import { EntityPageStateMapper, EntityStateByCategoryGroupConfigKey } from "./exploreState/entities";
6
- import { ApplySavedFilterPayload, PaginateTablePayload, ProcessExploreResponsePayload, ProcessRelatedResponsePayload, ResetExploreResponsePayload, ToggleEntityViewPayload, UpdateColumnVisibilityPayload, UpdateFilterPayload, UpdateSortingPayload } from "./exploreState/payloads/entities";
5
+ import { EntityPageStateMapper, EntityStateByCategoryGroupConfigKey, ListItem } from "./exploreState/entities";
6
+ import { ApplySavedFilterPayload, PaginateTablePayload, PatchExploreResponsePayload, ProcessExploreResponsePayload, ProcessRelatedResponsePayload, ResetExploreResponsePayload, ToggleEntityViewPayload, UpdateColumnVisibilityPayload, UpdateEntityViewAccessPayload, UpdateFilterPayload, UpdateRowSelectionPayload, UpdateSortingPayload } from "./exploreState/payloads/entities";
7
7
  export declare type CatalogState = string | undefined;
8
8
  /**
9
9
  * Entity view.
@@ -50,7 +50,7 @@ export declare type FeatureFlagState = string | undefined;
50
50
  /**
51
51
  * List items.
52
52
  */
53
- export declare type ListItems = any[] | undefined;
53
+ export declare type ListItems = ListItem[] | undefined;
54
54
  /**
55
55
  * Pagination index.
56
56
  */
@@ -106,6 +106,7 @@ export declare enum ExploreActionKind {
106
106
  ApplySavedFilter = "APPLY_SAVED_FILTER",
107
107
  ClearFilters = "CLEAR_FILTERS",
108
108
  PaginateTable = "PAGINATE_TABLE",
109
+ PatchExploreResponse = "PATCH_EXPLORE_RESPONSE",
109
110
  ProcessExploreResponse = "PROCESS_EXPLORE_RESPONSE",
110
111
  ProcessRelatedResponse = "PROCESS_RELATED_RESPONSE",
111
112
  ResetExploreResponse = "RESET_EXPLORE_RESPONSE",
@@ -113,13 +114,15 @@ export declare enum ExploreActionKind {
113
114
  SelectEntityType = "SELECT_ENTITY_TYPE",
114
115
  ToggleEntityView = "TOGGLE_ENTITY_VIEW",
115
116
  UpdateColumnVisibility = "UPDATE_COLUMN_VISIBILITY",
117
+ UpdateEntityViewAccess = "UPDATE_ENTITY_VIEW_ACCESS",
116
118
  UpdateFilter = "UPDATE_FILTER",
119
+ UpdateRowSelection = "UPDATE_ROW_SELECTION",
117
120
  UpdateSorting = "UPDATE_SORTING"
118
121
  }
119
122
  /**
120
123
  * Explore action.
121
124
  */
122
- export declare type ExploreAction = ApplySavedFilterAction | ClearFiltersAction | PaginateTableAction | ProcessExploreResponseAction | ProcessRelatedResponseAction | ResetExploreResponseAction | ResetStateAction | SelectEntityTypeAction | ToggleEntityViewAction | UpdateColumnVisibilityAction | UpdateFilterAction | UpdateSortingAction;
125
+ export declare type ExploreAction = ApplySavedFilterAction | ClearFiltersAction | PaginateTableAction | PatchExploreResponseAction | ProcessExploreResponseAction | ProcessRelatedResponseAction | ResetExploreResponseAction | ResetStateAction | SelectEntityTypeAction | ToggleEntityViewAction | UpdateColumnVisibilityAction | UpdateEntityViewAccessAction | UpdateFilterAction | UpdateRowSelectionAction | UpdateSortingAction;
123
126
  /**
124
127
  * Apply saved filter action.
125
128
  */
@@ -141,6 +144,13 @@ declare type PaginateTableAction = {
141
144
  payload: PaginateTablePayload;
142
145
  type: ExploreActionKind.PaginateTable;
143
146
  };
147
+ /**
148
+ * Patch explore response action.
149
+ */
150
+ declare type PatchExploreResponseAction = {
151
+ payload: PatchExploreResponsePayload;
152
+ type: ExploreActionKind.PatchExploreResponse;
153
+ };
144
154
  /**
145
155
  * Process explore response action.
146
156
  */
@@ -177,7 +187,7 @@ declare type SelectEntityTypeAction = {
177
187
  type: ExploreActionKind.SelectEntityType;
178
188
  };
179
189
  /**
180
- * Toggle entity view.
190
+ * Toggle entity view action.
181
191
  */
182
192
  declare type ToggleEntityViewAction = {
183
193
  payload: ToggleEntityViewPayload;
@@ -190,6 +200,13 @@ declare type UpdateColumnVisibilityAction = {
190
200
  payload: UpdateColumnVisibilityPayload;
191
201
  type: ExploreActionKind.UpdateColumnVisibility;
192
202
  };
203
+ /**
204
+ * Update entity view access action.
205
+ */
206
+ declare type UpdateEntityViewAccessAction = {
207
+ payload: UpdateEntityViewAccessPayload;
208
+ type: ExploreActionKind.UpdateEntityViewAccess;
209
+ };
193
210
  /**
194
211
  * Update filter action.
195
212
  */
@@ -197,6 +214,13 @@ declare type UpdateFilterAction = {
197
214
  payload: UpdateFilterPayload;
198
215
  type: ExploreActionKind.UpdateFilter;
199
216
  };
217
+ /**
218
+ * Update row selection action.
219
+ */
220
+ declare type UpdateRowSelectionAction = {
221
+ payload: UpdateRowSelectionPayload;
222
+ type: ExploreActionKind.UpdateRowSelection;
223
+ };
200
224
  /**
201
225
  * Update sorting action.
202
226
  */