@reltio/components 1.4.2184 → 1.4.2186
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/FacetContainer/FacetContainer.d.ts +18 -0
- package/FacetContainer/FacetContainer.js +30 -0
- package/FacetContainer/FacetContainer.module.css.js +9 -0
- package/FacetContainer/components/ChipsCount/ChipCount.module.css.js +9 -0
- package/FacetContainer/components/ChipsCount/ChipsCount.d.ts +26 -0
- package/FacetContainer/components/ChipsCount/ChipsCount.js +39 -0
- package/FacetContainer/components/FacetTitle/FacetTitle.d.ts +10 -0
- package/FacetContainer/components/FacetTitle/FacetTitle.js +31 -0
- package/FacetContainer/components/FacetTitle/FacetTitle.module.css.js +9 -0
- package/FacetContainer/index.d.ts +1 -0
- package/FacetContainer/index.js +1 -0
- package/FacetsSelector/FacetsSelector.d.ts +2 -2
- package/FacetsSelector/FacetsSelector.js +2 -2
- package/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.d.ts +2 -2
- package/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.js +5 -5
- package/FacetsSelector/components/FacetsList/FacetsList.d.ts +3 -3
- package/FacetsSelector/components/FacetsList/FacetsList.js +6 -6
- package/FacetsSelector/components/FacetsList/FacetsList.module.css.js +2 -2
- package/FacetsSelector/helpers.d.ts +2 -2
- package/FacetsSelector/helpers.js +2 -2
- package/HierarchyNodeTitle/HierarchyNodeTitle.test.js +83 -1
- package/HierarchyNodeTitle/useEntityDetails.js +8 -4
- package/HierarchyNodeTitle/useEntityDetails.test.js +24 -9
- package/cjs/FacetContainer/FacetContainer.d.ts +18 -0
- package/cjs/FacetContainer/FacetContainer.js +60 -0
- package/cjs/FacetContainer/FacetContainer.module.css.js +9 -0
- package/cjs/FacetContainer/components/ChipsCount/ChipCount.module.css.js +9 -0
- package/cjs/FacetContainer/components/ChipsCount/ChipsCount.d.ts +26 -0
- package/cjs/FacetContainer/components/ChipsCount/ChipsCount.js +45 -0
- package/cjs/FacetContainer/components/FacetTitle/FacetTitle.d.ts +10 -0
- package/cjs/FacetContainer/components/FacetTitle/FacetTitle.js +36 -0
- package/cjs/FacetContainer/components/FacetTitle/FacetTitle.module.css.js +9 -0
- package/cjs/FacetContainer/index.d.ts +1 -0
- package/cjs/FacetContainer/index.js +5 -0
- package/cjs/FacetsSelector/FacetsSelector.d.ts +2 -2
- package/cjs/FacetsSelector/FacetsSelector.js +2 -2
- package/cjs/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.d.ts +2 -2
- package/cjs/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.js +5 -5
- package/cjs/FacetsSelector/components/FacetsList/FacetsList.d.ts +3 -3
- package/cjs/FacetsSelector/components/FacetsList/FacetsList.js +6 -6
- package/cjs/FacetsSelector/components/FacetsList/FacetsList.module.css.js +2 -2
- package/cjs/FacetsSelector/helpers.d.ts +2 -2
- package/cjs/FacetsSelector/helpers.js +2 -2
- package/cjs/HierarchyNodeTitle/HierarchyNodeTitle.test.js +83 -1
- package/cjs/HierarchyNodeTitle/useEntityDetails.js +6 -2
- package/cjs/HierarchyNodeTitle/useEntityDetails.test.js +27 -9
- package/cjs/features/history/hooks/useHistorySlice.js +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +6 -4
- package/features/history/hooks/useHistorySlice.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const RecommendedIconWithTooltip: React.ForwardRefExoticComponent<{
|
|
3
|
+
tooltipTitle?: import("@mui/material").TooltipProps["title"];
|
|
4
|
+
tooltipPlacement?: import("@mui/material").TooltipProps["placement"];
|
|
5
|
+
showForDisabled?: boolean;
|
|
6
|
+
} & React.SVGAttributes<SVGElement> & React.RefAttributes<HTMLElement>>;
|
|
7
|
+
export type Props = {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
title: string;
|
|
10
|
+
chipLabel?: number;
|
|
11
|
+
pathToTitle?: string[];
|
|
12
|
+
isOpenByDefault?: boolean;
|
|
13
|
+
isHighlighted?: boolean;
|
|
14
|
+
isRecommended?: boolean;
|
|
15
|
+
onDeleteChip?: () => void;
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
};
|
|
18
|
+
export declare const FacetContainer: ({ children, title, chipLabel, pathToTitle, isOpenByDefault, isHighlighted, isRecommended, onDeleteChip, onClose }: Props) => React.JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import i18n from 'ui-i18n';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
5
|
+
import { CollapseButton } from '../CollapseButton';
|
|
6
|
+
import { SmallIconButtonWithTooltip } from '../SmallIconButton';
|
|
7
|
+
import { withTooltip } from '../HOCs/withTooltip';
|
|
8
|
+
import FacetTitle from './components/FacetTitle/FacetTitle';
|
|
9
|
+
import RecommendedIcon from './Recommended.svg';
|
|
10
|
+
import styles from './FacetContainer.module.css';
|
|
11
|
+
export var RecommendedIconWithTooltip = withTooltip(RecommendedIcon);
|
|
12
|
+
export var FacetContainer = function (_a) {
|
|
13
|
+
var _b;
|
|
14
|
+
var children = _a.children, title = _a.title, chipLabel = _a.chipLabel, pathToTitle = _a.pathToTitle, _c = _a.isOpenByDefault, isOpenByDefault = _c === void 0 ? true : _c, _d = _a.isHighlighted, isHighlighted = _d === void 0 ? false : _d, _e = _a.isRecommended, isRecommended = _e === void 0 ? false : _e, onDeleteChip = _a.onDeleteChip, onClose = _a.onClose;
|
|
15
|
+
var _f = useState(isOpenByDefault), open = _f[0], setOpen = _f[1];
|
|
16
|
+
var toggleOpen = function () {
|
|
17
|
+
setOpen(!open);
|
|
18
|
+
};
|
|
19
|
+
return (React.createElement("div", { className: classnames(styles.facetContainer, (_b = {},
|
|
20
|
+
_b[styles.openedFacetContainer] = open,
|
|
21
|
+
_b[styles.closedFacetContainer] = !open,
|
|
22
|
+
_b[styles.highlighted] = isHighlighted,
|
|
23
|
+
_b)), "data-reltio-id": "search-facet-container-".concat(title) },
|
|
24
|
+
React.createElement("div", { className: styles.titleContainer },
|
|
25
|
+
React.createElement(SmallIconButtonWithTooltip, { tooltipTitle: i18n.text('Remove'), icon: CloseIcon, onClick: onClose, className: styles.iconButton, size: "XXS" }),
|
|
26
|
+
isRecommended && (React.createElement(RecommendedIconWithTooltip, { className: styles.recommendedIcon, tooltipTitle: i18n.text('Recommended'), showForDisabled: true })),
|
|
27
|
+
React.createElement(FacetTitle, { title: title, pathToTitle: pathToTitle, chipLabel: chipLabel, onDelete: onDeleteChip, onClick: toggleOpen }),
|
|
28
|
+
React.createElement(CollapseButton, { onClick: toggleOpen, isOpen: open, className: styles.iconButton, size: "S", tooltipTitle: open ? i18n.text('Collapse attribute') : i18n.text('Expand attribute'), tooltipPlacement: "bottom-end" })),
|
|
29
|
+
open ? children : null));
|
|
30
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {"facetContainer":"FacetContainer-facetContainer--PGQJm","openedFacetContainer":"FacetContainer-openedFacetContainer--T0y7f","closedFacetContainer":"FacetContainer-closedFacetContainer--s6-qP","iconButton":"FacetContainer-iconButton--FOXN9","recommendedIcon":"FacetContainer-recommendedIcon--v3mLt","titleContainer":"FacetContainer-titleContainer--mxRz2","expandIcon":"FacetContainer-expandIcon--eNUwN","expanded":"FacetContainer-expanded--XgtFv","highlighted":"FacetContainer-highlighted--Cf-qC","animate":"FacetContainer-animate--nGob0"};
|
|
2
|
+
if (typeof document !== 'undefined') {
|
|
3
|
+
const head = document.head || document.getElementsByTagName('head')[0]
|
|
4
|
+
const style = document.createElement('style');
|
|
5
|
+
style.type = 'text/css'
|
|
6
|
+
style.innerHTML = `.FacetContainer-facetContainer--PGQJm{border-bottom:1px solid rgba(0,0,0,.33);border-radius:1px;display:flex;flex-direction:column;flex-grow:1;flex-shrink:0;padding:0 16px;position:relative}.FacetContainer-facetContainer--PGQJm:last-child{border-bottom:1px solid #fff}.FacetContainer-openedFacetContainer--T0y7f{padding-bottom:15px}.FacetContainer-closedFacetContainer--s6-qP{padding-bottom:5px}.FacetContainer-iconButton--FOXN9{visibility:hidden}.FacetContainer-iconButton--FOXN9:first-child{height:24px;margin-left:-16px;width:24px}.FacetContainer-recommendedIcon--v3mLt{flex-shrink:0;height:18px;margin-right:6px;width:18px}.FacetContainer-titleContainer--mxRz2{align-items:center;border-radius:1px;display:flex;flex-direction:row;flex-shrink:0;height:42px;margin-left:-16px;padding-left:16px}.FacetContainer-titleContainer--mxRz2:hover .FacetContainer-iconButton--FOXN9{visibility:visible}.FacetContainer-expandIcon--eNUwN{color:rgba(0,0,0,.54);margin:0 2px;transition:transform .15s ease}.FacetContainer-expanded--XgtFv{transform:rotate(180deg)}@keyframes FacetContainer-animate--nGob0{0%{background:#fffbeb}66%{background:#fffbeb}to{background:transparent}}.FacetContainer-highlighted--Cf-qC{animation-duration:3s;animation-iteration-count:1;animation-name:FacetContainer-animate--nGob0}`;
|
|
7
|
+
head.appendChild(style);
|
|
8
|
+
}
|
|
9
|
+
export default styles;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {"root":"ChipsCount-root--nvCui","deleteIcon":"ChipsCount-deleteIcon--5PYeW","outlined":"ChipsCount-outlined--GUmLb","label":"ChipsCount-label--G-hwC"};
|
|
2
|
+
if (typeof document !== 'undefined') {
|
|
3
|
+
const head = document.head || document.getElementsByTagName('head')[0]
|
|
4
|
+
const style = document.createElement('style');
|
|
5
|
+
style.type = 'text/css'
|
|
6
|
+
style.innerHTML = `.ChipsCount-root--nvCui{background-color:transparent;border:1px solid rgba(0,0,0,.12);border-radius:16px;box-sizing:border-box;height:18px}.ChipsCount-root--nvCui .ChipsCount-deleteIcon--5PYeW{color:rgba(0,0,0,.38);height:12px;margin:0;width:12px}.ChipsCount-outlined--GUmLb .ChipsCount-deleteIcon--5PYeW{margin-right:2px}.ChipsCount-label--G-hwC{color:rgba(0,0,0,.38);font-size:12px;font-weight:500;line-height:16px;padding-left:4px;padding-right:4px}`;
|
|
7
|
+
head.appendChild(style);
|
|
8
|
+
}
|
|
9
|
+
export default styles;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChipProps } from '@mui/material/Chip';
|
|
3
|
+
export declare const ClearIconWithTooltip: React.ForwardRefExoticComponent<Omit<{
|
|
4
|
+
tooltipTitle?: import("@mui/material").TooltipProps["title"];
|
|
5
|
+
tooltipPlacement?: import("@mui/material").TooltipProps["placement"];
|
|
6
|
+
showForDisabled?: boolean;
|
|
7
|
+
} & {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
classes?: Partial<import("@mui/material").SvgIconClasses>;
|
|
10
|
+
color?: import("@mui/types").OverridableStringUnion<"inherit" | "action" | "disabled" | "primary" | "secondary" | "error" | "info" | "success" | "warning", import("@mui/material").SvgIconPropsColorOverrides>;
|
|
11
|
+
fontSize?: import("@mui/types").OverridableStringUnion<"inherit" | "large" | "medium" | "small", import("@mui/material").SvgIconPropsSizeOverrides>;
|
|
12
|
+
htmlColor?: string;
|
|
13
|
+
inheritViewBox?: boolean;
|
|
14
|
+
shapeRendering?: string;
|
|
15
|
+
sx?: import("@mui/system").SxProps<import("@mui/material").Theme>;
|
|
16
|
+
titleAccess?: string;
|
|
17
|
+
viewBox?: string;
|
|
18
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.SVGProps<SVGSVGElement>, "ref"> & {
|
|
19
|
+
ref?: React.Ref<SVGSVGElement>;
|
|
20
|
+
}, "color" | "fontSize" | "shapeRendering" | "children" | "sx" | keyof import("@mui/material/OverridableComponent").CommonProps | "viewBox" | "htmlColor" | "inheritViewBox" | "titleAccess">, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
21
|
+
type Props = Omit<ChipProps, 'onDelete' | 'label'> & {
|
|
22
|
+
label: number;
|
|
23
|
+
onDelete?: () => void;
|
|
24
|
+
};
|
|
25
|
+
declare const ChipsCount: ({ label, onDelete, ...extraProps }: Props) => React.JSX.Element;
|
|
26
|
+
export default ChipsCount;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import i18n from 'ui-i18n';
|
|
25
|
+
import Chip from '@mui/material/Chip';
|
|
26
|
+
import ClearIcon from '@mui/icons-material/Cancel';
|
|
27
|
+
import { withTooltip } from '../../../HOCs/withTooltip';
|
|
28
|
+
import styles from './ChipCount.module.css';
|
|
29
|
+
export var ClearIconWithTooltip = withTooltip(ClearIcon);
|
|
30
|
+
var ChipsCount = function (_a) {
|
|
31
|
+
var label = _a.label, onDelete = _a.onDelete, extraProps = __rest(_a, ["label", "onDelete"]);
|
|
32
|
+
return (React.createElement(Chip, __assign({ className: styles.root, label: i18n.number(label), onDelete: onDelete, variant: "outlined", classes: {
|
|
33
|
+
root: styles.root,
|
|
34
|
+
outlined: styles.outlined,
|
|
35
|
+
deleteIcon: styles.deleteIcon,
|
|
36
|
+
label: styles.label
|
|
37
|
+
}, deleteIcon: React.createElement(ClearIconWithTooltip, { tooltipTitle: i18n.text('Clear') }) }, extraProps)));
|
|
38
|
+
};
|
|
39
|
+
export default ChipsCount;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
title?: string;
|
|
4
|
+
chipLabel?: number;
|
|
5
|
+
onDelete?: () => void;
|
|
6
|
+
pathToTitle?: string[];
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const FacetTitle: ({ title, chipLabel, onDelete, pathToTitle, onClick }: Props) => React.JSX.Element;
|
|
10
|
+
export default FacetTitle;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { ExpandedValueTooltip } from '../../../ExpandedValueTooltip';
|
|
14
|
+
import { HierarchicalAttributeTooltip } from '../../../HierarchicalAttributeTooltip';
|
|
15
|
+
import ChipsCount from '../ChipsCount/ChipsCount';
|
|
16
|
+
import styles from './FacetTitle.module.css';
|
|
17
|
+
var FacetTitle = function (_a) {
|
|
18
|
+
var _b = _a.title, title = _b === void 0 ? '' : _b, _c = _a.chipLabel, chipLabel = _c === void 0 ? 0 : _c, onDelete = _a.onDelete, pathToTitle = _a.pathToTitle, onClick = _a.onClick;
|
|
19
|
+
var isNested = Boolean(pathToTitle && pathToTitle.length > 2);
|
|
20
|
+
var TooltipComponent = isNested ? HierarchicalAttributeTooltip : ExpandedValueTooltip;
|
|
21
|
+
var tooltipProps = isNested ? { pathToTitle: pathToTitle } : { value: title };
|
|
22
|
+
return (React.createElement("div", { className: styles.container, onClick: onClick },
|
|
23
|
+
isNested && (React.createElement(HierarchicalAttributeTooltip, __assign({ placement: "bottom-start" }, tooltipProps),
|
|
24
|
+
React.createElement("div", { className: styles.parent }, pathToTitle[pathToTitle.length - 2]))),
|
|
25
|
+
React.createElement("div", { className: styles.titleContainer },
|
|
26
|
+
React.createElement(TooltipComponent, __assign({ placement: "bottom-start" }, tooltipProps),
|
|
27
|
+
React.createElement("span", { className: styles.title }, title)),
|
|
28
|
+
chipLabel !== 0 && (React.createElement("div", { className: styles.chip },
|
|
29
|
+
React.createElement(ChipsCount, { label: chipLabel, onDelete: onDelete }))))));
|
|
30
|
+
};
|
|
31
|
+
export default FacetTitle;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {"container":"FacetTitle-container--fegMx","parent":"FacetTitle-parent--0sIc8","titleContainer":"FacetTitle-titleContainer--e8PWF","title":"FacetTitle-title--Four7","chip":"FacetTitle-chip--L9nDB"};
|
|
2
|
+
if (typeof document !== 'undefined') {
|
|
3
|
+
const head = document.head || document.getElementsByTagName('head')[0]
|
|
4
|
+
const style = document.createElement('style');
|
|
5
|
+
style.type = 'text/css'
|
|
6
|
+
style.innerHTML = `.FacetTitle-container--fegMx{cursor:pointer;display:flex;flex-direction:column;flex-grow:1;height:100%;justify-content:center;min-width:0}.FacetTitle-parent--0sIc8{color:var(--mui-palette-text-secondary);font-size:13px;letter-spacing:0;line-height:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.FacetTitle-titleContainer--e8PWF{align-items:flex-end;display:flex;flex-direction:row;height:18px;overflow:hidden;width:100%}.FacetTitle-title--Four7{color:var(--mui-palette-text-primary);font-size:14px;font-weight:500;letter-spacing:.24px;line-height:16px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.FacetTitle-chip--L9nDB{display:inline;margin-left:6px}`;
|
|
7
|
+
head.appendChild(style);
|
|
8
|
+
}
|
|
9
|
+
export default styles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FacetContainer } from './FacetContainer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FacetContainer } from './FacetContainer';
|
|
@@ -4,10 +4,10 @@ import { MoreFacetItem } from './types';
|
|
|
4
4
|
type Props = {
|
|
5
5
|
open?: boolean;
|
|
6
6
|
data?: MoreFacetItem[];
|
|
7
|
-
|
|
7
|
+
selectedFacetsFieldNames: string[];
|
|
8
8
|
onOpen: () => void;
|
|
9
9
|
onClose: () => void;
|
|
10
10
|
onFacetToggle: (item: FacetConfig, selected: boolean) => void;
|
|
11
11
|
};
|
|
12
|
-
export declare const FacetsSelector: ({ open, data,
|
|
12
|
+
export declare const FacetsSelector: ({ open, data, selectedFacetsFieldNames, onOpen, onClose, onFacetToggle }: Props) => React.JSX.Element;
|
|
13
13
|
export default FacetsSelector;
|
|
@@ -5,7 +5,7 @@ import { SearchInput } from '../SearchInput';
|
|
|
5
5
|
import { filterItemsInGroups } from './helpers';
|
|
6
6
|
import styles from './FacetsSelector.module.css';
|
|
7
7
|
export var FacetsSelector = function (_a) {
|
|
8
|
-
var open = _a.open, data = _a.data,
|
|
8
|
+
var open = _a.open, data = _a.data, selectedFacetsFieldNames = _a.selectedFacetsFieldNames, onOpen = _a.onOpen, onClose = _a.onClose, onFacetToggle = _a.onFacetToggle;
|
|
9
9
|
var _b = useState(''), filterText = _b[0], setFilterText = _b[1];
|
|
10
10
|
var _c = useState(null), lastFacetClicked = _c[0], setLastFacetClicked = _c[1];
|
|
11
11
|
var searchInputRootRef = useRef(null);
|
|
@@ -26,6 +26,6 @@ export var FacetsSelector = function (_a) {
|
|
|
26
26
|
}, [onOpen]);
|
|
27
27
|
return (React.createElement(React.Fragment, null,
|
|
28
28
|
React.createElement(SearchInput, { classes: { root: styles.inputContainer }, onSearch: setFilterText, onFocus: handleOpen, rootRef: searchInputRootRef, value: filterText, placeholder: i18n.text('Search & add attributes'), height: 40, "data-reltio-id": "reltio-search-more-facets-search-input" }),
|
|
29
|
-
React.createElement(AttributeSelectorPopup, { open: open,
|
|
29
|
+
React.createElement(AttributeSelectorPopup, { open: open, selectedFacetsFieldNames: selectedFacetsFieldNames, data: filteredList, lastFacetClicked: lastFacetClicked, anchorRef: searchInputRootRef, onListItemClick: handleListItemClick, onClose: handleClose, onSearch: setFilterText })));
|
|
30
30
|
};
|
|
31
31
|
export default FacetsSelector;
|
|
@@ -3,7 +3,7 @@ import { FacetConfig } from '@reltio/mdm-sdk';
|
|
|
3
3
|
import { MoreFacetItem, SelectedFacet } from '../../types';
|
|
4
4
|
type Props = {
|
|
5
5
|
open?: boolean;
|
|
6
|
-
|
|
6
|
+
selectedFacetsFieldNames: string[];
|
|
7
7
|
data?: MoreFacetItem[];
|
|
8
8
|
lastFacetClicked?: SelectedFacet;
|
|
9
9
|
anchorRef: React.RefObject<HTMLInputElement>;
|
|
@@ -11,5 +11,5 @@ type Props = {
|
|
|
11
11
|
onSearch?: (value?: string) => void;
|
|
12
12
|
onClose?: () => void;
|
|
13
13
|
};
|
|
14
|
-
export declare const AttributeSelectorPopup: ({ open,
|
|
14
|
+
export declare const AttributeSelectorPopup: ({ open, selectedFacetsFieldNames, data, lastFacetClicked, anchorRef, onListItemClick, onSearch, onClose }: Props) => React.JSX.Element;
|
|
15
15
|
export {};
|
|
@@ -13,7 +13,7 @@ import styles from './AttributeSelectorPopup.module.css';
|
|
|
13
13
|
var defaultLastFacetClicked = {};
|
|
14
14
|
export var AttributeSelectorPopup = function (_a) {
|
|
15
15
|
var _b, _c;
|
|
16
|
-
var open = _a.open,
|
|
16
|
+
var open = _a.open, selectedFacetsFieldNames = _a.selectedFacetsFieldNames, _d = _a.data, data = _d === void 0 ? [] : _d, _e = _a.lastFacetClicked, lastFacetClicked = _e === void 0 ? defaultLastFacetClicked : _e, anchorRef = _a.anchorRef, onListItemClick = _a.onListItemClick, onSearch = _a.onSearch, onClose = _a.onClose;
|
|
17
17
|
var _f = useState(DEFAULT_LIST_HEIGHT), listHeight = _f[0], setListHeight = _f[1];
|
|
18
18
|
var _g = adjustVerticalPopupLayout(anchorRef.current, DEFAULT_ATTRIBUTE_SELECTOR_POPUP_HEIGHT), verticalOrigin = _g.verticalOrigin, _h = _g.popupHeight, popupHeight = _h === void 0 ? DEFAULT_ATTRIBUTE_SELECTOR_POPUP_HEIGHT : _h;
|
|
19
19
|
var maxListHeight = popupHeight - POPUP_HEADER_HEIGHT;
|
|
@@ -61,17 +61,17 @@ export var AttributeSelectorPopup = function (_a) {
|
|
|
61
61
|
var popupWidth = (_c = (_b = anchorRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) !== null && _c !== void 0 ? _c : 0;
|
|
62
62
|
var handleSearchOnEnter = useCallback(function (_a) {
|
|
63
63
|
var item = _a.item, groupData = _a.groupData;
|
|
64
|
-
onListItemClick(item, !isSelectedFacet({ facet: item,
|
|
65
|
-
}, [onListItemClick,
|
|
64
|
+
onListItemClick(item, !isSelectedFacet({ facet: item, selectedFacetsFieldNames: selectedFacetsFieldNames }), groupData.groupId);
|
|
65
|
+
}, [onListItemClick, selectedFacetsFieldNames]);
|
|
66
66
|
var _j = useKeyboardNavigation({
|
|
67
67
|
items: items,
|
|
68
68
|
open: open,
|
|
69
69
|
onSelectFocusedItem: handleSearchOnEnter,
|
|
70
|
-
selectedItems:
|
|
70
|
+
selectedItems: selectedFacetsFieldNames
|
|
71
71
|
}), focusIndex = _j.focusIndex, handleKeyDown = _j.handleKeyDown;
|
|
72
72
|
var containerWidth = Math.max(popupWidth || getMaxItemWidth('title')(groupedItems), DEFAULT_MIN_CONTAINER_WIDTH);
|
|
73
73
|
return (React.createElement(SelectionPopup, { open: open, action: popupActionRef, title: i18n.text('Select attribute'), containerWidth: containerWidth, searchInputOnKeyDown: handleKeyDown, containerHeight: POPUP_HEADER_HEIGHT + listHeight, anchorOrigin: popupOrigin, transformOrigin: popupOrigin, headerPlacement: verticalOrigin === 'bottom' ? 'bottom' : 'top', anchorEl: anchorRef.current, disableRestoreFocus: true, onSearch: onSearch, onClose: onClose },
|
|
74
|
-
React.createElement(FacetsList, { focusIndex: focusIndex,
|
|
74
|
+
React.createElement(FacetsList, { focusIndex: focusIndex, selectedFacetsFieldNames: selectedFacetsFieldNames, onListItemClick: onListItemClick, items: items, height: listHeight, onInnerContainerResize: handleResizeList }),
|
|
75
75
|
items.length === 0 && (React.createElement("div", { className: styles.noResultsCaptionContainer },
|
|
76
76
|
React.createElement(Typography, { variant: "caption", display: "block", gutterBottom: true }, i18n.text('No results found'))))));
|
|
77
77
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ComponentProps } from 'react';
|
|
2
|
-
import { AttributeType
|
|
2
|
+
import { AttributeType } from '@reltio/mdm-sdk';
|
|
3
3
|
import { VirtualGroupedList } from '../../../VirtualGroupedList';
|
|
4
4
|
type Data = {
|
|
5
5
|
fieldName: string;
|
|
@@ -10,8 +10,8 @@ type Data = {
|
|
|
10
10
|
};
|
|
11
11
|
type Props = Omit<ComponentProps<typeof VirtualGroupedList>, 'renderItem' | 'getItemSize'> & {
|
|
12
12
|
focusIndex: number;
|
|
13
|
-
|
|
13
|
+
selectedFacetsFieldNames: string[];
|
|
14
14
|
onListItemClick: (data: Data, checked: boolean, groupId: string) => void;
|
|
15
15
|
};
|
|
16
|
-
export declare const FacetsList: ({ onListItemClick, focusIndex,
|
|
16
|
+
export declare const FacetsList: ({ onListItemClick, focusIndex, selectedFacetsFieldNames, ...otherProps }: Props) => React.JSX.Element;
|
|
17
17
|
export {};
|
|
@@ -29,24 +29,24 @@ import { Highlighter } from '../../../Highlighter';
|
|
|
29
29
|
import { AttributeGroupIcon } from '../../../AttributeGroupIcon';
|
|
30
30
|
import { FACET_LIST_ITEM_HEIGHT } from '../../constants';
|
|
31
31
|
import { useMdmMetadata } from '../../../contexts/MdmModuleContext';
|
|
32
|
+
import { ExpandedValueTooltip } from '../../../ExpandedValueTooltip';
|
|
32
33
|
import styles from './FacetsList.module.css';
|
|
33
34
|
var ITEM_GROUP_TITLE_HEIGHT = 40;
|
|
34
35
|
export var FacetsList = function (_a) {
|
|
35
|
-
var onListItemClick = _a.onListItemClick, focusIndex = _a.focusIndex,
|
|
36
|
-
var selectedFacetsRef = useRef(null);
|
|
37
|
-
selectedFacetsRef.current = selectedFacets;
|
|
36
|
+
var onListItemClick = _a.onListItemClick, focusIndex = _a.focusIndex, selectedFacetsFieldNames = _a.selectedFacetsFieldNames, otherProps = __rest(_a, ["onListItemClick", "focusIndex", "selectedFacetsFieldNames"]);
|
|
38
37
|
var focusIndexRef = useRef(null);
|
|
39
38
|
focusIndexRef.current = focusIndex;
|
|
40
39
|
var metadata = useMdmMetadata();
|
|
41
40
|
var renderItem = useCallback(function (style, _a, index) {
|
|
42
41
|
var item = _a.item, level = _a.level, groupId = _a.groupId;
|
|
43
|
-
var checked = isSelectedFacet({ facet: item,
|
|
42
|
+
var checked = isSelectedFacet({ facet: item, selectedFacetsFieldNames: selectedFacetsFieldNames });
|
|
44
43
|
var isFocused = focusIndexRef.current === index;
|
|
45
44
|
return (React.createElement(AttributeListItem, { key: "item-".concat(groupId, "-").concat(item.fieldName), onClick: onListItemClick, data: item, label: React.createElement(Highlighter, { text: item.title, highlight: item.filterText }), labelInText: item.title, level: level, style: style, checked: checked, isFocused: isFocused, groupId: groupId, LogoIcon: item.LogoIcon }));
|
|
46
|
-
}, [onListItemClick]);
|
|
45
|
+
}, [onListItemClick, selectedFacetsFieldNames]);
|
|
47
46
|
var renderGroupTitle = useCallback(function (style, item) { return (React.createElement(ListItem, { component: 'div', className: styles.subHeader, style: style, key: "group-".concat(item.item.id) },
|
|
48
47
|
item.item.needGroupIcon && React.createElement(AttributeGroupIcon, { metadata: metadata, group: item.item }),
|
|
49
|
-
item.item.title
|
|
48
|
+
React.createElement(ExpandedValueTooltip, { value: item.item.title },
|
|
49
|
+
React.createElement("div", { className: styles.subHeaderTitle }, item.item.title)))); }, [metadata]);
|
|
50
50
|
var getItemSize = useCallback(function (i, item) { return (item.items ? ITEM_GROUP_TITLE_HEIGHT : FACET_LIST_ITEM_HEIGHT); }, []);
|
|
51
51
|
return (React.createElement(VirtualGroupedList, __assign({ getItemSize: getItemSize, renderGroupTitle: renderGroupTitle, renderItem: renderItem, focusIndex: focusIndex }, otherProps, { disableHorizontalScrollbar: true })));
|
|
52
52
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const styles = {"subHeader":"FacetsList-subHeader--jcWLn","icon":"FacetsList-icon--HO3ZO","recommendedIcon":"FacetsList-recommendedIcon--ekXsX"};
|
|
1
|
+
const styles = {"subHeader":"FacetsList-subHeader--jcWLn","icon":"FacetsList-icon--HO3ZO","recommendedIcon":"FacetsList-recommendedIcon--ekXsX","subHeaderTitle":"FacetsList-subHeaderTitle--iOKhO"};
|
|
2
2
|
if (typeof document !== 'undefined') {
|
|
3
3
|
const head = document.head || document.getElementsByTagName('head')[0]
|
|
4
4
|
const style = document.createElement('style');
|
|
5
5
|
style.type = 'text/css'
|
|
6
|
-
style.innerHTML = `.FacetsList-subHeader--jcWLn{align-items:center;background-color:#f5f5f5;color:rgba(0,0,0,.84);display:flex;font-size:14px;font-weight:500;margin:0;padding:0 16px}.FacetsList-subHeader--jcWLn .FacetsList-icon--HO3ZO{margin-right:16px;max-height:25px;max-width:25px}.FacetsList-recommendedIcon--ekXsX:is(.FacetsList-subHeader--jcWLn .FacetsList-icon--HO3ZO){height:20px;width:20px}`;
|
|
6
|
+
style.innerHTML = `.FacetsList-subHeader--jcWLn{align-items:center;background-color:#f5f5f5;color:rgba(0,0,0,.84);display:flex;font-size:14px;font-weight:500;margin:0;padding:0 16px}.FacetsList-subHeader--jcWLn .FacetsList-icon--HO3ZO{margin-right:16px;max-height:25px;max-width:25px}.FacetsList-recommendedIcon--ekXsX:is(.FacetsList-subHeader--jcWLn .FacetsList-icon--HO3ZO){height:20px;width:20px}.FacetsList-subHeaderTitle--iOKhO{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}`;
|
|
7
7
|
head.appendChild(style);
|
|
8
8
|
}
|
|
9
9
|
export default styles;
|
|
@@ -5,9 +5,9 @@ declare const adjustVerticalPopupLayout: (anchorEl: HTMLElement, popupHeight: nu
|
|
|
5
5
|
popupHeight: number;
|
|
6
6
|
};
|
|
7
7
|
declare const filterItemsInGroups: (groups: MoreFacetItem[], filterText: string) => MoreFacetItem[];
|
|
8
|
-
declare const isSelectedFacet: ({ facet,
|
|
8
|
+
declare const isSelectedFacet: ({ facet, selectedFacetsFieldNames }: {
|
|
9
9
|
facet: any;
|
|
10
|
-
|
|
10
|
+
selectedFacetsFieldNames: any;
|
|
11
11
|
}) => boolean;
|
|
12
12
|
declare const constructPopoverOrigin: (verticalOrigin: PopoverOrigin["vertical"], horizontalOrigin?: PopoverOrigin["horizontal"]) => {
|
|
13
13
|
vertical: number | "bottom" | "top" | "center";
|
|
@@ -49,8 +49,8 @@ var filterItemsInGroups = function (groups, filterText) {
|
|
|
49
49
|
return groups.map(function (group) { return (__assign(__assign({}, group), { facets: getFilteredFacets(group.facets, filterText) })); });
|
|
50
50
|
};
|
|
51
51
|
var isSelectedFacet = function (_a) {
|
|
52
|
-
var facet = _a.facet,
|
|
53
|
-
return !!
|
|
52
|
+
var facet = _a.facet, selectedFacetsFieldNames = _a.selectedFacetsFieldNames;
|
|
53
|
+
return !!selectedFacetsFieldNames.find(function (fieldName) { return fieldName === facet.fieldName || fieldName.includes("".concat(facet.fieldName, ".")); });
|
|
54
54
|
};
|
|
55
55
|
var constructPopoverOrigin = function (verticalOrigin, horizontalOrigin) {
|
|
56
56
|
if (horizontalOrigin === void 0) { horizontalOrigin = 'right'; }
|
|
@@ -63,7 +63,21 @@ var defaultProps = {
|
|
|
63
63
|
entityUri: 'entities/123',
|
|
64
64
|
anchorEl: document.createElement('div')
|
|
65
65
|
};
|
|
66
|
-
var
|
|
66
|
+
var getDefaultMetadata = function (masking) {
|
|
67
|
+
if (masking === void 0) { masking = false; }
|
|
68
|
+
return ({
|
|
69
|
+
entityTypes: [
|
|
70
|
+
{
|
|
71
|
+
uri: 'configuration/entityTypes/HCP',
|
|
72
|
+
attributes: [
|
|
73
|
+
__assign({ uri: 'configuration/entityTypes/HCP/attributes/FirstName', type: 'String', name: 'FirstName', label: 'First Name' }, (masking && { masking: { regexPattern: '.*' } }))
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
relationTypes: []
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
var defaultMdmValues = { uiPath: 'http://localhost:3000/ui/sokol/', metadata: getDefaultMetadata(), showMasking: true };
|
|
67
81
|
var defaultMdmActions = { openEntity: jest.fn() };
|
|
68
82
|
var setUp = function (_a) {
|
|
69
83
|
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d, _e = _b.mdmActions, mdmActions = _e === void 0 ? defaultMdmActions : _e;
|
|
@@ -136,6 +150,9 @@ describe('Hierarchy node title tests', function () {
|
|
|
136
150
|
}); })];
|
|
137
151
|
case 2:
|
|
138
152
|
_a.sent();
|
|
153
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', {
|
|
154
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
155
|
+
});
|
|
139
156
|
within(tooltip).getByAltText('fallback entity avatar');
|
|
140
157
|
within(tooltip).getByText('perfect entity');
|
|
141
158
|
within(tooltip).getByText('ID:');
|
|
@@ -148,4 +165,69 @@ describe('Hierarchy node title tests', function () {
|
|
|
148
165
|
}
|
|
149
166
|
});
|
|
150
167
|
}); });
|
|
168
|
+
it('should pass sendMasked option to getEntity if metadata has masking', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
+
var user, entityWithMasking;
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
switch (_a.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
user = setUp({ mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true) }) }).user;
|
|
174
|
+
return [4 /*yield*/, user.hover(screen.getByText('Title'))];
|
|
175
|
+
case 1:
|
|
176
|
+
_a.sent();
|
|
177
|
+
expect(screen.getByRole('tooltip')).toBeInTheDocument();
|
|
178
|
+
entityWithMasking = {
|
|
179
|
+
uri: 'entities/123',
|
|
180
|
+
label: '***t entity',
|
|
181
|
+
type: 'configuration/entityTypes/HCP'
|
|
182
|
+
};
|
|
183
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
184
|
+
return __generator(this, function (_a) {
|
|
185
|
+
switch (_a.label) {
|
|
186
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entityWithMasking)];
|
|
187
|
+
case 1:
|
|
188
|
+
_a.sent();
|
|
189
|
+
return [2 /*return*/];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); })];
|
|
193
|
+
case 2:
|
|
194
|
+
_a.sent();
|
|
195
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', {
|
|
196
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk,sendMasked'
|
|
197
|
+
});
|
|
198
|
+
return [2 /*return*/];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}); });
|
|
202
|
+
it('should not pass sendMasked option to getEntity if metadata has masking but showMasking is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
203
|
+
var user;
|
|
204
|
+
return __generator(this, function (_a) {
|
|
205
|
+
switch (_a.label) {
|
|
206
|
+
case 0:
|
|
207
|
+
user = setUp({
|
|
208
|
+
mdmValues: __assign(__assign({}, defaultMdmValues), { metadata: getDefaultMetadata(true), showMasking: false })
|
|
209
|
+
}).user;
|
|
210
|
+
return [4 /*yield*/, user.hover(screen.getByText('Title'))];
|
|
211
|
+
case 1:
|
|
212
|
+
_a.sent();
|
|
213
|
+
expect(screen.getByRole('tooltip')).toBeInTheDocument();
|
|
214
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
switch (_a.label) {
|
|
217
|
+
case 0: return [4 /*yield*/, resolveGetEntity(entity)];
|
|
218
|
+
case 1:
|
|
219
|
+
_a.sent();
|
|
220
|
+
return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}); })];
|
|
224
|
+
case 2:
|
|
225
|
+
_a.sent();
|
|
226
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', {
|
|
227
|
+
options: 'sendHidden,addRefAttrUriToCrosswalk'
|
|
228
|
+
});
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}); });
|
|
151
233
|
});
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { getEntity, debounce } from '@reltio/mdm-sdk';
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { getEntity, debounce, addGetEntityMaskingOptions } from '@reltio/mdm-sdk';
|
|
3
3
|
import { useSafePromise } from '../hooks/useSafePromise';
|
|
4
|
+
import { useMdmMetadata, useMdmShowMasking } from '../contexts/MdmModuleContext';
|
|
4
5
|
export var useEntityDetails = function (entityUri) {
|
|
5
6
|
var _a = useState(null), entityDetails = _a[0], setEntityDetails = _a[1];
|
|
6
7
|
var _b = useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
7
8
|
var safePromise = useSafePromise();
|
|
8
9
|
var cancelRequest = useCallback(function () { return safePromise(Promise.resolve()); }, [safePromise]);
|
|
10
|
+
var metadata = useMdmMetadata();
|
|
11
|
+
var showMasking = useMdmShowMasking();
|
|
12
|
+
var entityOptions = useMemo(function () { return addGetEntityMaskingOptions(metadata, { showMasking: showMasking, showAccess: false }); }, [metadata, showMasking]);
|
|
9
13
|
var showEntityDetails = useCallback(debounce(function () {
|
|
10
14
|
setIsLoading(true);
|
|
11
|
-
safePromise(getEntity(entityUri))
|
|
15
|
+
safePromise(getEntity(entityUri, entityOptions))
|
|
12
16
|
.then(setEntityDetails)
|
|
13
17
|
.catch(function (error) {
|
|
14
18
|
console.warn('Failed to load entity', error);
|
|
15
19
|
})
|
|
16
20
|
.finally(function () { return setIsLoading(false); });
|
|
17
|
-
}, 1000), [entityUri, safePromise]);
|
|
21
|
+
}, 1000), [entityUri, safePromise, entityOptions]);
|
|
18
22
|
var hideEntityDetails = useCallback(function () {
|
|
19
23
|
cancelRequest();
|
|
20
24
|
showEntityDetails.cancel();
|
|
@@ -45,12 +45,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
import React from 'react';
|
|
48
49
|
import { renderHook, act } from '@testing-library/react-hooks';
|
|
49
50
|
import { getEntity, debounce } from '@reltio/mdm-sdk';
|
|
51
|
+
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
50
52
|
import { useEntityDetails } from './useEntityDetails';
|
|
51
53
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getEntity: jest.fn(), debounce: jest.fn() })); });
|
|
54
|
+
var entity = { uri: 'entities/123', type: 'configuration/entityTypes/HCP' };
|
|
55
|
+
var defaultMdmValues = {
|
|
56
|
+
metadata: {
|
|
57
|
+
entityTypes: []
|
|
58
|
+
}
|
|
59
|
+
};
|
|
52
60
|
describe('useEntityDetails', function () {
|
|
53
|
-
var
|
|
61
|
+
var setUp = function (_a) {
|
|
62
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? entity.uri : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
|
|
63
|
+
var Providers = function (_a) {
|
|
64
|
+
var children = _a.children;
|
|
65
|
+
return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
|
|
66
|
+
};
|
|
67
|
+
return renderHook(useEntityDetails, { initialProps: props, wrapper: Providers });
|
|
68
|
+
};
|
|
54
69
|
beforeEach(function () {
|
|
55
70
|
getEntity.mockResolvedValue(entity);
|
|
56
71
|
debounce.mockImplementation(function (fn) { return jest.requireActual('@reltio/mdm-sdk').debounce(fn, 10); });
|
|
@@ -66,7 +81,7 @@ describe('useEntityDetails', function () {
|
|
|
66
81
|
return __generator(this, function (_a) {
|
|
67
82
|
switch (_a.label) {
|
|
68
83
|
case 0:
|
|
69
|
-
result =
|
|
84
|
+
result = setUp().result;
|
|
70
85
|
expect(result.current.isLoading).toBe(false);
|
|
71
86
|
act(function () {
|
|
72
87
|
result.current.showEntityDetails();
|
|
@@ -78,7 +93,7 @@ describe('useEntityDetails', function () {
|
|
|
78
93
|
});
|
|
79
94
|
expect(result.current.isLoading).toBe(true);
|
|
80
95
|
expect(result.current.entityDetails).toBe(null);
|
|
81
|
-
expect(getEntity).toHaveBeenCalledWith(entity.uri);
|
|
96
|
+
expect(getEntity).toHaveBeenCalledWith(entity.uri, { options: 'sendHidden,addRefAttrUriToCrosswalk' });
|
|
82
97
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
98
|
return __generator(this, function (_a) {
|
|
84
99
|
return [2 /*return*/, Promise.resolve()];
|
|
@@ -97,7 +112,7 @@ describe('useEntityDetails', function () {
|
|
|
97
112
|
return __generator(this, function (_a) {
|
|
98
113
|
switch (_a.label) {
|
|
99
114
|
case 0:
|
|
100
|
-
result =
|
|
115
|
+
result = setUp().result;
|
|
101
116
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
117
|
return __generator(this, function (_a) {
|
|
103
118
|
result.current.showEntityDetails();
|
|
@@ -121,7 +136,7 @@ describe('useEntityDetails', function () {
|
|
|
121
136
|
return __generator(this, function (_a) {
|
|
122
137
|
switch (_a.label) {
|
|
123
138
|
case 0:
|
|
124
|
-
result =
|
|
139
|
+
result = setUp().result;
|
|
125
140
|
act(function () {
|
|
126
141
|
result.current.showEntityDetails();
|
|
127
142
|
jest.runAllTimers();
|
|
@@ -144,7 +159,7 @@ describe('useEntityDetails', function () {
|
|
|
144
159
|
});
|
|
145
160
|
}); });
|
|
146
161
|
it('should clear timeout if hideEntityDetails has been called before request started', function () {
|
|
147
|
-
var result =
|
|
162
|
+
var result = setUp().result;
|
|
148
163
|
act(function () {
|
|
149
164
|
result.current.showEntityDetails();
|
|
150
165
|
});
|
|
@@ -167,12 +182,12 @@ describe('useEntityDetails', function () {
|
|
|
167
182
|
return __generator(this, function (_a) {
|
|
168
183
|
switch (_a.label) {
|
|
169
184
|
case 0:
|
|
170
|
-
result =
|
|
185
|
+
result = setUp().result;
|
|
171
186
|
act(function () {
|
|
172
187
|
result.current.showEntityDetails();
|
|
173
188
|
jest.runAllTimers();
|
|
174
189
|
});
|
|
175
|
-
expect(getEntity).toHaveBeenCalledWith('entities/123');
|
|
190
|
+
expect(getEntity).toHaveBeenCalledWith('entities/123', { options: 'sendHidden,addRefAttrUriToCrosswalk' });
|
|
176
191
|
expect(result.current.isLoading).toBe(true);
|
|
177
192
|
expect(result.current.entityDetails).toBe(null);
|
|
178
193
|
act(function () {
|
|
@@ -201,7 +216,7 @@ describe('useEntityDetails', function () {
|
|
|
201
216
|
case 0:
|
|
202
217
|
warnSpy = jest.spyOn(global.console, 'warn');
|
|
203
218
|
getEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
|
|
204
|
-
result =
|
|
219
|
+
result = setUp().result;
|
|
205
220
|
act(function () {
|
|
206
221
|
result.current.showEntityDetails();
|
|
207
222
|
jest.runAllTimers();
|