@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.
- package/lib/components/Links/common/constants.d.ts +1 -0
- package/lib/components/Links/common/constants.js +4 -0
- package/lib/components/Links/common/entities.d.ts +8 -0
- package/lib/components/Links/common/utils.d.ts +13 -0
- package/lib/components/Links/common/utils.js +21 -1
- package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.d.ts +7 -0
- package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +148 -0
- package/lib/components/Links/components/Link/link.d.ts +2 -2
- package/lib/components/Links/components/Link/link.js +22 -6
- package/lib/components/common/Progress/components/CircularProgress/circularProgress.d.ts +7 -0
- package/lib/components/common/Progress/components/CircularProgress/circularProgress.js +28 -0
- package/lib/components/common/Progress/components/CircularProgress/circularProgress.styles.d.ts +5 -0
- package/lib/components/common/Progress/components/CircularProgress/circularProgress.styles.js +11 -0
- package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.d.ts +7 -0
- package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.js +44 -0
- package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.styles.d.ts +3 -0
- package/lib/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.styles.js +32 -0
- package/lib/config/entities.d.ts +2 -1
- package/lib/hooks/useCategoryFilter.d.ts +7 -1
- package/lib/hooks/useCategoryFilter.js +25 -6
- package/lib/providers/exploreState/initializer/constants.d.ts +2 -0
- package/lib/providers/exploreState/initializer/constants.js +7 -1
- package/lib/providers/exploreState/initializer/utils.js +1 -8
- package/lib/providers/exploreState/payloads/entities.d.ts +8 -1
- package/lib/providers/exploreState/utils.d.ts +4 -2
- package/lib/providers/exploreState/utils.js +4 -4
- package/lib/providers/exploreState.d.ts +10 -2
- package/lib/providers/exploreState.js +13 -0
- package/lib/styles/common/mixins/colors.d.ts +3 -3
- package/lib/styles/common/mixins/colors.js +7 -7
- package/lib/theme/common/components.d.ts +6 -0
- package/lib/theme/common/components.js +31 -1
- package/lib/theme/theme.js +1 -0
- package/package.json +1 -1
- package/src/components/Links/common/constants.ts +1 -0
- package/src/components/Links/common/entities.ts +11 -0
- package/src/components/Links/common/utils.ts +28 -0
- package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +172 -0
- package/src/components/Links/components/Link/link.tsx +36 -14
- package/src/components/common/Progress/components/CircularProgress/circularProgress.styles.ts +6 -0
- package/src/components/common/Progress/components/CircularProgress/circularProgress.tsx +26 -0
- package/src/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.styles.ts +33 -0
- package/src/components/common/Progress/components/CircularProgress/components/CircularProgressTrack/circularProgressTrack.tsx +23 -0
- package/src/config/entities.ts +4 -0
- package/src/hooks/useCategoryFilter.ts +31 -7
- package/src/providers/exploreState/initializer/constants.ts +8 -0
- package/src/providers/exploreState/initializer/utils.ts +6 -9
- package/src/providers/exploreState/payloads/entities.ts +8 -0
- package/src/providers/exploreState/utils.ts +11 -7
- package/src/providers/exploreState.tsx +33 -0
- package/src/styles/common/mixins/colors.ts +6 -6
- package/src/theme/common/components.ts +32 -0
- package/src/theme/theme.ts +1 -0
- package/types/data-explorer-ui.d.ts +10 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const URL_OBJECT_KEYS: string[];
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { UrlObject } from "url";
|
|
1
3
|
export declare enum ANCHOR_TARGET {
|
|
2
4
|
BLANK = "_blank",
|
|
3
5
|
SELF = "_self"
|
|
4
6
|
}
|
|
7
|
+
export declare type StrictUrlObject = Omit<UrlObject, "href" | "query"> & {
|
|
8
|
+
href: string;
|
|
9
|
+
query: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type Url = string | UrlObjectWithHrefAndQuery;
|
|
12
|
+
export declare type UrlObjectWithHrefAndQuery = Pick<StrictUrlObject, "href" | "query">;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { Url, UrlObjectWithHrefAndQuery } from "./entities";
|
|
1
2
|
/**
|
|
2
3
|
* Returns true if the given link is an internal link.
|
|
3
4
|
* @param link - Link.
|
|
4
5
|
* @returns true if the given link is an internal link.
|
|
5
6
|
*/
|
|
6
7
|
export declare function isClientSideNavigation(link: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if the given url is a URL object with href and query.
|
|
10
|
+
* @param value - URL.
|
|
11
|
+
* @returns true if the given url is a URL object with href and query.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isURLObjectWithHrefAndQuery(value: Url): value is UrlObjectWithHrefAndQuery;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the given url is a string.
|
|
16
|
+
* @param value - URL.
|
|
17
|
+
* @returns true if the given url is a string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isURLString(value: Url): value is string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isClientSideNavigation = void 0;
|
|
3
|
+
exports.isURLString = exports.isURLObjectWithHrefAndQuery = exports.isClientSideNavigation = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
4
5
|
/**
|
|
5
6
|
* Returns true if the given link is an internal link.
|
|
6
7
|
* @param link - Link.
|
|
@@ -10,3 +11,22 @@ function isClientSideNavigation(link) {
|
|
|
10
11
|
return /^\/(?!\/)/.test(link);
|
|
11
12
|
}
|
|
12
13
|
exports.isClientSideNavigation = isClientSideNavigation;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the given url is a URL object with href and query.
|
|
16
|
+
* @param value - URL.
|
|
17
|
+
* @returns true if the given url is a URL object with href and query.
|
|
18
|
+
*/
|
|
19
|
+
function isURLObjectWithHrefAndQuery(value) {
|
|
20
|
+
return (typeof value !== "string" &&
|
|
21
|
+
Object.entries(value).every(([key, value]) => constants_1.URL_OBJECT_KEYS.includes(key) && !!value));
|
|
22
|
+
}
|
|
23
|
+
exports.isURLObjectWithHrefAndQuery = isURLObjectWithHrefAndQuery;
|
|
24
|
+
/**
|
|
25
|
+
* Returns true if the given url is a string.
|
|
26
|
+
* @param value - URL.
|
|
27
|
+
* @returns true if the given url is a string.
|
|
28
|
+
*/
|
|
29
|
+
function isURLString(value) {
|
|
30
|
+
return typeof value === "string";
|
|
31
|
+
}
|
|
32
|
+
exports.isURLString = isURLString;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { UrlObjectWithHrefAndQuery } from "../../../../common/entities";
|
|
3
|
+
import { LinkProps } from "../../link";
|
|
4
|
+
export interface ExploreViewLinkProps extends Omit<LinkProps, "copyable" | "noWrap" | "url"> {
|
|
5
|
+
url: UrlObjectWithHrefAndQuery;
|
|
6
|
+
}
|
|
7
|
+
export declare const ExploreViewLink: ({ className, label, onClick, target, url, }: ExploreViewLinkProps) => JSX.Element;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ExploreViewLink = void 0;
|
|
30
|
+
const link_1 = __importDefault(require("next/link"));
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const useExploreState_1 = require("../../../../../../hooks/useExploreState");
|
|
33
|
+
const exploreState_1 = require("../../../../../../providers/exploreState");
|
|
34
|
+
const entities_1 = require("../../../../common/entities");
|
|
35
|
+
const PARAM_FILTER = "filter";
|
|
36
|
+
const ExploreViewLink = ({ className, label, onClick, target = entities_1.ANCHOR_TARGET.SELF, url, }) => {
|
|
37
|
+
const { exploreDispatch, exploreState } = (0, useExploreState_1.useExploreState)();
|
|
38
|
+
if (!isValidExploreURL(url, exploreState)) {
|
|
39
|
+
throwError(url);
|
|
40
|
+
}
|
|
41
|
+
const onNavigate = (0, react_1.useCallback)(() => {
|
|
42
|
+
const entityListType = getEntityListType(url.href);
|
|
43
|
+
const filters = getSelectedFilters(url.query);
|
|
44
|
+
exploreDispatch({
|
|
45
|
+
payload: { entityListType, filters },
|
|
46
|
+
type: exploreState_1.ExploreActionKind.UpdateEntityFilters,
|
|
47
|
+
});
|
|
48
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
49
|
+
}, [exploreDispatch, onClick, url]);
|
|
50
|
+
return (react_1.default.createElement(link_1.default, { className: className, href: url.href, onClick: onNavigate, rel: "noopener", target: target }, label));
|
|
51
|
+
};
|
|
52
|
+
exports.ExploreViewLink = ExploreViewLink;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the entity list type "entityListType" inferred from the given href.
|
|
55
|
+
* @param href - Href.
|
|
56
|
+
* @returns entity list type.
|
|
57
|
+
*/
|
|
58
|
+
function getEntityListType(href) {
|
|
59
|
+
return href.substring(1);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the selected filters from the given query.
|
|
63
|
+
* @param query - Query.
|
|
64
|
+
* @returns selected filters.
|
|
65
|
+
*/
|
|
66
|
+
function getSelectedFilters(query) {
|
|
67
|
+
const decodedQuery = decodeURIComponent(query);
|
|
68
|
+
const parsedQuery = JSON.parse(decodedQuery);
|
|
69
|
+
return parsedQuery[PARAM_FILTER];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns true if the given value is a SelectedFilter.
|
|
73
|
+
* @param value - Value.
|
|
74
|
+
* @returns true if the given value is a SelectedFilter.
|
|
75
|
+
*/
|
|
76
|
+
function isSelectedFilter(value) {
|
|
77
|
+
return (typeof value === "object" &&
|
|
78
|
+
value !== null &&
|
|
79
|
+
"categoryKey" in value &&
|
|
80
|
+
"value" in value);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns true if the given query string is a valid JSON string.
|
|
84
|
+
* @param query - Query string.
|
|
85
|
+
* @returns true if the given query string is a valid JSON string.
|
|
86
|
+
*/
|
|
87
|
+
function isValidJsonString(query) {
|
|
88
|
+
try {
|
|
89
|
+
JSON.parse(query);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns true if the given explore link is valid.
|
|
98
|
+
* @param url - Explore link URL.
|
|
99
|
+
* @param exploreState - Explore state.
|
|
100
|
+
* @returns true if the given explore link is valid.
|
|
101
|
+
*/
|
|
102
|
+
function isValidExploreURL(url, exploreState) {
|
|
103
|
+
const validHref = isValidHref(url, exploreState);
|
|
104
|
+
const validQuery = isValidQuery(url);
|
|
105
|
+
return validHref && validQuery;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns true if the given href is a configured key in the explore state's entityPageState.
|
|
109
|
+
* @param url - Explore link URL.
|
|
110
|
+
* @param exploreState - Explore state.
|
|
111
|
+
* @returns true if the given href is configured in the explore state.
|
|
112
|
+
*/
|
|
113
|
+
function isValidHref(url, exploreState) {
|
|
114
|
+
const { entityPageState } = exploreState;
|
|
115
|
+
const { href } = url;
|
|
116
|
+
return href.startsWith("/") && href.substring(1) in entityPageState;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns true if the given explore query is valid.
|
|
120
|
+
* @param url - Explore link URL.
|
|
121
|
+
* @returns true if the given explore query is valid.
|
|
122
|
+
*/
|
|
123
|
+
function isValidQuery(url) {
|
|
124
|
+
const { query } = url;
|
|
125
|
+
// Decode and parse the query.
|
|
126
|
+
const decodedQuery = decodeURIComponent(query);
|
|
127
|
+
// Query should be a valid JSON string.
|
|
128
|
+
if (isValidJsonString(decodedQuery)) {
|
|
129
|
+
const parsedQuery = JSON.parse(decodedQuery);
|
|
130
|
+
// Query should contain "filter" key.
|
|
131
|
+
if (PARAM_FILTER in parsedQuery) {
|
|
132
|
+
const filters = parsedQuery[PARAM_FILTER];
|
|
133
|
+
// Filter should be an array.
|
|
134
|
+
if (Array.isArray(filters)) {
|
|
135
|
+
// Filter should contain only SelectedFilter objects.
|
|
136
|
+
return filters.every(isSelectedFilter);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Throws an error with the given URL object.
|
|
144
|
+
* @param url - URL object.
|
|
145
|
+
*/
|
|
146
|
+
function throwError(url) {
|
|
147
|
+
throw new Error(`Invalid explore URL href or query: ${url.href}, ${url.query}`);
|
|
148
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LinkProps as MLinkProps } from "@mui/material";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
import { ANCHOR_TARGET } from "../../common/entities";
|
|
3
|
+
import { ANCHOR_TARGET, Url } from "../../common/entities";
|
|
4
4
|
export interface LinkProps {
|
|
5
5
|
className?: string;
|
|
6
6
|
copyable?: boolean;
|
|
@@ -8,6 +8,6 @@ export interface LinkProps {
|
|
|
8
8
|
noWrap?: MLinkProps["noWrap"];
|
|
9
9
|
onClick?: () => void;
|
|
10
10
|
target?: ANCHOR_TARGET;
|
|
11
|
-
url:
|
|
11
|
+
url: Url;
|
|
12
12
|
}
|
|
13
13
|
export declare const Link: ({ className, copyable, label, noWrap, onClick, target, url, }: LinkProps) => JSX.Element;
|
|
@@ -11,12 +11,28 @@ const utils_1 = require("../../../../common/utils");
|
|
|
11
11
|
const copyToClipboard_1 = require("../../../common/CopyToClipboard/copyToClipboard");
|
|
12
12
|
const entities_1 = require("../../common/entities");
|
|
13
13
|
const utils_2 = require("../../common/utils");
|
|
14
|
+
const exploreViewLink_1 = require("./components/ExploreViewLink/exploreViewLink");
|
|
14
15
|
const Link = ({ className, copyable = false, label, noWrap = false, onClick, target, url, }) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
if ((0, utils_2.isURLObjectWithHrefAndQuery)(url)) {
|
|
17
|
+
/* Internal navigation - explore link */
|
|
18
|
+
return (react_1.default.createElement(exploreViewLink_1.ExploreViewLink, { className: className, label: label, onClick: onClick, target: target, url: url }));
|
|
19
|
+
}
|
|
20
|
+
if ((0, utils_2.isURLString)(url)) {
|
|
21
|
+
if ((0, utils_2.isClientSideNavigation)(url)) {
|
|
22
|
+
/* Client-side navigation */
|
|
23
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
24
|
+
react_1.default.createElement(link_1.default, { href: url, legacyBehavior: true, passHref: true },
|
|
25
|
+
react_1.default.createElement(material_1.Link, { className: className, rel: "noopener", noWrap: noWrap, target: target || entities_1.ANCHOR_TARGET.SELF, onClick: onClick }, label)),
|
|
26
|
+
copyable && react_1.default.createElement(copyToClipboard_1.CopyToClipboard, { copyStr: url })));
|
|
27
|
+
}
|
|
28
|
+
if ((0, utils_1.isValidUrl)(url)) {
|
|
29
|
+
/* External navigation */
|
|
30
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
31
|
+
react_1.default.createElement(material_1.Link, { className: className, href: url, noWrap: noWrap, onClick: onClick, rel: "noopener noreferrer", target: target || entities_1.ANCHOR_TARGET.BLANK }, label),
|
|
32
|
+
copyable && react_1.default.createElement(copyToClipboard_1.CopyToClipboard, { copyStr: url })));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/* Invalid URL */
|
|
36
|
+
return react_1.default.createElement(react_1.default.Fragment, null, label);
|
|
21
37
|
};
|
|
22
38
|
exports.Link = Link;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CircularProgressProps as MCircularProgressProps } from "@mui/material";
|
|
2
|
+
import { ElementType } from "react";
|
|
3
|
+
export interface CircularProgressProps extends MCircularProgressProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
Track?: ElementType<CircularProgressProps>;
|
|
6
|
+
}
|
|
7
|
+
export declare const CircularProgress: ({ className, value, Track, ...props }: CircularProgressProps) => JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CircularProgress = void 0;
|
|
18
|
+
const material_1 = require("@mui/material");
|
|
19
|
+
const react_1 = __importDefault(require("react"));
|
|
20
|
+
const circularProgress_styles_1 = require("./circularProgress.styles");
|
|
21
|
+
const circularProgressTrack_1 = require("./components/CircularProgressTrack/circularProgressTrack");
|
|
22
|
+
const CircularProgress = (_a) => {
|
|
23
|
+
var { className, value, Track = circularProgressTrack_1.CircularProgressTrack } = _a, props = __rest(_a, ["className", "value", "Track"]) /* Spread props to allow for CircularProgress specific props e.g. "disableShrink". */;
|
|
24
|
+
return (react_1.default.createElement(circularProgress_styles_1.ProgressPositioner, { className: className },
|
|
25
|
+
react_1.default.createElement(Track, Object.assign({}, props)),
|
|
26
|
+
react_1.default.createElement(material_1.CircularProgress, Object.assign({ value: value }, props))));
|
|
27
|
+
};
|
|
28
|
+
exports.CircularProgress = CircularProgress;
|
package/lib/components/common/Progress/components/CircularProgress/circularProgress.styles.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ProgressPositioner: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProgressPositioner = void 0;
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
exports.ProgressPositioner = styled_1.default.div `
|
|
9
|
+
display: flex;
|
|
10
|
+
position: relative; /* positions track */
|
|
11
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CircularProgressProps as MCircularProgressProps } from "@mui/material";
|
|
3
|
+
export interface CircularProgressTrackProps extends MCircularProgressProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
track?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const CircularProgressTrack: ({ className, track, value, ...props }: CircularProgressTrackProps) => JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.CircularProgressTrack = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const circularProgressTrack_styles_1 = require("./circularProgressTrack.styles");
|
|
40
|
+
const CircularProgressTrack = (_a) => {
|
|
41
|
+
var { className, track = true, value = 100 } = _a, props = __rest(_a, ["className", "track", "value"]) /* Spread props to allow for CircularProgress specific props e.g. "disableShrink". */;
|
|
42
|
+
return (react_1.default.createElement(react_1.Fragment, null, track && (react_1.default.createElement(circularProgressTrack_styles_1.CircularProgress, Object.assign({ className: className, value: value }, props)))));
|
|
43
|
+
};
|
|
44
|
+
exports.CircularProgressTrack = CircularProgressTrack;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CircularProgress = void 0;
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
const material_1 = require("@mui/material");
|
|
9
|
+
const colors_1 = require("../../../../../../../styles/common/mixins/colors");
|
|
10
|
+
exports.CircularProgress = (0, styled_1.default)(material_1.CircularProgress) `
|
|
11
|
+
color: ${colors_1.smokeLight};
|
|
12
|
+
left: 0;
|
|
13
|
+
position: absolute;
|
|
14
|
+
top: 0;
|
|
15
|
+
z-index: 0;
|
|
16
|
+
|
|
17
|
+
&.MuiCircularProgress-colorAlert {
|
|
18
|
+
color: ${colors_1.alertLight};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.MuiCircularProgress-colorInfo {
|
|
22
|
+
color: ${colors_1.infoLight};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.MuiCircularProgress-colorSuccess {
|
|
26
|
+
color: ${colors_1.successLight};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.MuiCircularProgress-colorWarning {
|
|
30
|
+
color: ${colors_1.warningLight};
|
|
31
|
+
}
|
|
32
|
+
`;
|
package/lib/config/entities.d.ts
CHANGED
|
@@ -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.
|
|
@@ -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,
|
|
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
|
|
112
|
+
* @param categoryConfig - Category.
|
|
111
113
|
* @returns the display value for the given category.
|
|
112
114
|
*/
|
|
113
|
-
function getCategoryLabel(key,
|
|
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,5 +1,7 @@
|
|
|
1
|
+
import { CategoryGroup } from "../../../config/entities";
|
|
1
2
|
import { ExploreState, PaginationState } from "../../exploreState";
|
|
2
3
|
import { EntityState } from "../entities";
|
|
4
|
+
export declare const DEFAULT_CATEGORY_GROUP_SAVED_FILTERS: CategoryGroup;
|
|
3
5
|
export declare const DEFAULT_ENTITY_STATE: EntityState;
|
|
4
6
|
export declare const DEFAULT_PAGINATION_STATE: PaginationState;
|
|
5
7
|
export declare const INITIAL_STATE: ExploreState;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INITIAL_STATE = exports.DEFAULT_PAGINATION_STATE = exports.DEFAULT_ENTITY_STATE = void 0;
|
|
3
|
+
exports.INITIAL_STATE = exports.DEFAULT_PAGINATION_STATE = exports.DEFAULT_ENTITY_STATE = exports.DEFAULT_CATEGORY_GROUP_SAVED_FILTERS = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
exports.DEFAULT_CATEGORY_GROUP_SAVED_FILTERS = {
|
|
6
|
+
categoryConfigs: [
|
|
7
|
+
{ key: constants_1.SELECT_CATEGORY_KEY.SAVED_FILTERS, label: "Saved Filters" },
|
|
8
|
+
],
|
|
9
|
+
};
|
|
4
10
|
exports.DEFAULT_ENTITY_STATE = {
|
|
5
11
|
categoryViews: [],
|
|
6
12
|
filterState: [],
|
|
@@ -16,14 +16,7 @@ function buildCategoryGroups(categoryGroupConfig) {
|
|
|
16
16
|
const { categoryGroups, savedFilters } = categoryGroupConfig;
|
|
17
17
|
if (!savedFilters)
|
|
18
18
|
return categoryGroups;
|
|
19
|
-
|
|
20
|
-
const savedFiltersCategoryGroup = {
|
|
21
|
-
categoryConfigs: [
|
|
22
|
-
{ key: constants_2.SELECT_CATEGORY_KEY.SAVED_FILTERS, label: "Saved Filters" },
|
|
23
|
-
],
|
|
24
|
-
};
|
|
25
|
-
clonedCategoryGroups.unshift(savedFiltersCategoryGroup);
|
|
26
|
-
return clonedCategoryGroups;
|
|
19
|
+
return [constants_3.DEFAULT_CATEGORY_GROUP_SAVED_FILTERS, ...categoryGroups];
|
|
27
20
|
}
|
|
28
21
|
/**
|
|
29
22
|
* Returns the saved filters as select categories.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnSort, RowSelectionState, VisibilityState } from "@tanstack/react-table";
|
|
2
|
-
import { CategoryKey, CategoryValueKey, PaginationDirectionType, SelectCategory } from "../../../common/entities";
|
|
2
|
+
import { CategoryKey, CategoryValueKey, PaginationDirectionType, SelectCategory, SelectedFilter } from "../../../common/entities";
|
|
3
3
|
import { ENTITY_VIEW, ListItems, PaginationResponse, RelatedListItems } from "../../exploreState";
|
|
4
4
|
import { ListItem } from "../entities";
|
|
5
5
|
/**
|
|
@@ -48,6 +48,13 @@ export declare type ToggleEntityViewPayload = ENTITY_VIEW;
|
|
|
48
48
|
* Update column visibility payload.
|
|
49
49
|
*/
|
|
50
50
|
export declare type UpdateColumnVisibilityPayload = VisibilityState;
|
|
51
|
+
/**
|
|
52
|
+
* Update entity filters payload.
|
|
53
|
+
*/
|
|
54
|
+
export interface UpdateEntityFiltersPayload {
|
|
55
|
+
entityListType: string;
|
|
56
|
+
filters: SelectedFilter[];
|
|
57
|
+
}
|
|
51
58
|
/**
|
|
52
59
|
* Update entity view access payload.
|
|
53
60
|
*/
|
|
@@ -70,9 +70,10 @@ export declare function resetPage(paginationState: PaginationState): PaginationS
|
|
|
70
70
|
/**
|
|
71
71
|
* Resets row selection for the current entity and entities that share the same category group config key.
|
|
72
72
|
* @param state - Explore state.
|
|
73
|
+
* @param categoryGroupConfigKey - Category group config key.
|
|
73
74
|
* @returns entity page state mapper with row selection reset.
|
|
74
75
|
*/
|
|
75
|
-
export declare function resetRowSelection(state: ExploreState): EntityPageStateMapper;
|
|
76
|
+
export declare function resetRowSelection(state: ExploreState, categoryGroupConfigKey?: string): EntityPageStateMapper;
|
|
76
77
|
/**
|
|
77
78
|
* Updates entity page state for the given entity path.
|
|
78
79
|
* @param entityPath - Entity path.
|
|
@@ -93,9 +94,10 @@ export declare function updateEntityPageStateSorting(state: ExploreState, sortin
|
|
|
93
94
|
* Updates entity state by category group config key.
|
|
94
95
|
* @param state - Explore state.
|
|
95
96
|
* @param nextEntityState - Partial next entity state.
|
|
97
|
+
* @param categoryGroupConfigKey - Category group config key.
|
|
96
98
|
* @returns updated entity state by category group config key.
|
|
97
99
|
*/
|
|
98
|
-
export declare function updateEntityStateByCategoryGroupConfigKey(state: ExploreState, nextEntityState: Partial<EntityState
|
|
100
|
+
export declare function updateEntityStateByCategoryGroupConfigKey(state: ExploreState, nextEntityState: Partial<EntityState>, categoryGroupConfigKey?: string): void;
|
|
99
101
|
/**
|
|
100
102
|
* Updates the entity page state for each entity with row selection enabled,
|
|
101
103
|
* by updating the visibility of the "select" column based on user access and resetting row selection state.
|
|
@@ -118,10 +118,10 @@ exports.resetPage = resetPage;
|
|
|
118
118
|
/**
|
|
119
119
|
* Resets row selection for the current entity and entities that share the same category group config key.
|
|
120
120
|
* @param state - Explore state.
|
|
121
|
+
* @param categoryGroupConfigKey - Category group config key.
|
|
121
122
|
* @returns entity page state mapper with row selection reset.
|
|
122
123
|
*/
|
|
123
|
-
function resetRowSelection(state) {
|
|
124
|
-
const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(state.tabValue, state.entityPageState);
|
|
124
|
+
function resetRowSelection(state, categoryGroupConfigKey = getEntityCategoryGroupConfigKey(state.tabValue, state.entityPageState)) {
|
|
125
125
|
return Object.entries(state.entityPageState).reduce((acc, [entityPath, entityPageState]) => {
|
|
126
126
|
if (entityPageState.categoryGroupConfigKey === categoryGroupConfigKey) {
|
|
127
127
|
return Object.assign(Object.assign({}, acc), { [entityPath]: Object.assign(Object.assign({}, entityPageState), { rowSelection: {} }) });
|
|
@@ -173,10 +173,10 @@ exports.updateEntityPageStateSorting = updateEntityPageStateSorting;
|
|
|
173
173
|
* Updates entity state by category group config key.
|
|
174
174
|
* @param state - Explore state.
|
|
175
175
|
* @param nextEntityState - Partial next entity state.
|
|
176
|
+
* @param categoryGroupConfigKey - Category group config key.
|
|
176
177
|
* @returns updated entity state by category group config key.
|
|
177
178
|
*/
|
|
178
|
-
function updateEntityStateByCategoryGroupConfigKey(state, nextEntityState) {
|
|
179
|
-
const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(state.tabValue, state.entityPageState);
|
|
179
|
+
function updateEntityStateByCategoryGroupConfigKey(state, nextEntityState, categoryGroupConfigKey = getEntityCategoryGroupConfigKey(state.tabValue, state.entityPageState)) {
|
|
180
180
|
const entityState = getEntityState(state, categoryGroupConfigKey);
|
|
181
181
|
if (entityState) {
|
|
182
182
|
setEntityStateByCategoryGroupConfigKey(categoryGroupConfigKey, state, Object.assign(Object.assign({}, entityState), nextEntityState));
|