@reltio/components 1.4.2175 → 1.4.2177
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/AdvancedSearchFabButton/AdvancedSearchFabButton.d.ts +1 -1
- package/AdvancedSearchFabButton/AdvancedSearchFabButton.js +5 -4
- package/FacetsSelector/FacetsSelector.d.ts +13 -0
- package/FacetsSelector/FacetsSelector.js +31 -0
- package/FacetsSelector/FacetsSelector.module.css.js +9 -0
- package/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.d.ts +15 -0
- package/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.js +77 -0
- package/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.module.css.js +9 -0
- package/FacetsSelector/components/AttributeSelectorPopup/index.d.ts +1 -0
- package/FacetsSelector/components/AttributeSelectorPopup/index.js +1 -0
- package/FacetsSelector/components/FacetsList/FacetsList.d.ts +17 -0
- package/FacetsSelector/components/FacetsList/FacetsList.js +52 -0
- package/FacetsSelector/components/FacetsList/FacetsList.module.css.js +9 -0
- package/FacetsSelector/components/FacetsList/index.d.ts +1 -0
- package/FacetsSelector/components/FacetsList/index.js +1 -0
- package/FacetsSelector/constants.d.ts +6 -0
- package/FacetsSelector/constants.js +6 -0
- package/FacetsSelector/helpers.d.ts +16 -0
- package/FacetsSelector/helpers.js +62 -0
- package/FacetsSelector/helpers.test.d.ts +1 -0
- package/FacetsSelector/helpers.test.js +26 -0
- package/FacetsSelector/index.d.ts +2 -0
- package/FacetsSelector/index.js +1 -0
- package/FacetsSelector/types.d.ts +11 -0
- package/FacetsSelector/types.js +1 -0
- package/QuickFiltersFacetPanel/QuickFiltersFacetPanel.d.ts +1 -1
- package/QuickFiltersFacetPanel/QuickFiltersFacetPanel.js +1 -1
- package/cjs/AdvancedSearchFabButton/AdvancedSearchFabButton.d.ts +1 -1
- package/cjs/AdvancedSearchFabButton/AdvancedSearchFabButton.js +28 -5
- package/cjs/FacetsSelector/FacetsSelector.d.ts +13 -0
- package/cjs/FacetsSelector/FacetsSelector.js +61 -0
- package/cjs/FacetsSelector/FacetsSelector.module.css.js +9 -0
- package/cjs/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.d.ts +15 -0
- package/cjs/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.js +107 -0
- package/cjs/FacetsSelector/components/AttributeSelectorPopup/AttributeSelectorPopup.module.css.js +9 -0
- package/cjs/FacetsSelector/components/AttributeSelectorPopup/index.d.ts +1 -0
- package/cjs/FacetsSelector/components/AttributeSelectorPopup/index.js +5 -0
- package/cjs/FacetsSelector/components/FacetsList/FacetsList.d.ts +17 -0
- package/cjs/FacetsSelector/components/FacetsList/FacetsList.js +82 -0
- package/cjs/FacetsSelector/components/FacetsList/FacetsList.module.css.js +9 -0
- package/cjs/FacetsSelector/components/FacetsList/index.d.ts +1 -0
- package/cjs/FacetsSelector/components/FacetsList/index.js +5 -0
- package/cjs/FacetsSelector/constants.d.ts +6 -0
- package/cjs/FacetsSelector/constants.js +9 -0
- package/cjs/FacetsSelector/helpers.d.ts +16 -0
- package/cjs/FacetsSelector/helpers.js +68 -0
- package/cjs/FacetsSelector/helpers.test.d.ts +1 -0
- package/cjs/FacetsSelector/helpers.test.js +28 -0
- package/cjs/FacetsSelector/index.d.ts +2 -0
- package/cjs/FacetsSelector/index.js +5 -0
- package/cjs/FacetsSelector/types.d.ts +11 -0
- package/cjs/FacetsSelector/types.js +2 -0
- package/cjs/QuickFiltersFacetPanel/QuickFiltersFacetPanel.d.ts +1 -1
- package/cjs/QuickFiltersFacetPanel/QuickFiltersFacetPanel.js +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +6 -4
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -2
|
@@ -3,5 +3,5 @@ type Props = {
|
|
|
3
3
|
tooltipTitle?: string;
|
|
4
4
|
onClick: () => void;
|
|
5
5
|
};
|
|
6
|
-
export declare const AdvancedSearchFabButton:
|
|
6
|
+
export declare const AdvancedSearchFabButton: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
7
7
|
export {};
|
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React from 'react';
|
|
23
|
+
import React, { forwardRef } from 'react';
|
|
24
24
|
import i18n from 'ui-i18n';
|
|
25
25
|
import Fab from '@mui/material/Fab';
|
|
26
26
|
import TuneIcon from '@mui/icons-material/Tune';
|
|
@@ -28,10 +28,11 @@ import RightArrowIcon from '@mui/icons-material/ChevronRight';
|
|
|
28
28
|
import { withTooltip } from '../HOCs/withTooltip';
|
|
29
29
|
import styles from './AdvancedSearchFabButton.module.css';
|
|
30
30
|
var FabButtonWithTooltip = withTooltip(Fab);
|
|
31
|
-
export var AdvancedSearchFabButton = function (_a) {
|
|
31
|
+
export var AdvancedSearchFabButton = forwardRef(function (_a, ref) {
|
|
32
32
|
var tooltipTitle = _a.tooltipTitle, onClick = _a.onClick, otherProps = __rest(_a, ["tooltipTitle", "onClick"]);
|
|
33
|
-
return (React.createElement(FabButtonWithTooltip, __assign({ tooltipTitle: tooltipTitle || i18n.text('Open advanced search'), tooltipPlacement: "bottom-end", variant: "extended", classes: { root: styles.buttonRoot, extended: styles.buttonExtended }, onClick: onClick, "data-reltio-id": "reltio-advanced-search-fab-button" }, otherProps),
|
|
33
|
+
return (React.createElement(FabButtonWithTooltip, __assign({ tooltipTitle: tooltipTitle || i18n.text('Open advanced search'), tooltipPlacement: "bottom-end", variant: "extended", classes: { root: styles.buttonRoot, extended: styles.buttonExtended }, onClick: onClick, "data-reltio-id": "reltio-advanced-search-fab-button", ref: ref }, otherProps),
|
|
34
34
|
React.createElement(TuneIcon, { color: "primary", className: styles.menuIcon }),
|
|
35
35
|
React.createElement("span", { className: styles.buttonLabel }, i18n.text('Advanced search')),
|
|
36
36
|
React.createElement(RightArrowIcon, { color: "action", className: styles.goToActionIcon })));
|
|
37
|
-
};
|
|
37
|
+
});
|
|
38
|
+
AdvancedSearchFabButton.displayName = 'AdvancedSearchFabButton';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FacetConfig } from '@reltio/mdm-sdk';
|
|
3
|
+
import { MoreFacetItem } from './types';
|
|
4
|
+
type Props = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
data?: MoreFacetItem[];
|
|
7
|
+
selectedFacets: FacetConfig[];
|
|
8
|
+
onOpen: () => void;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onFacetToggle: (item: FacetConfig, selected: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const FacetsSelector: ({ open, data, selectedFacets, onOpen, onClose, onFacetToggle }: Props) => React.JSX.Element;
|
|
13
|
+
export default FacetsSelector;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import i18n from 'ui-i18n';
|
|
3
|
+
import { AttributeSelectorPopup } from './components/AttributeSelectorPopup';
|
|
4
|
+
import { SearchInput } from '../SearchInput';
|
|
5
|
+
import { filterItemsInGroups } from './helpers';
|
|
6
|
+
import styles from './FacetsSelector.module.css';
|
|
7
|
+
export var FacetsSelector = function (_a) {
|
|
8
|
+
var open = _a.open, data = _a.data, selectedFacets = _a.selectedFacets, onOpen = _a.onOpen, onClose = _a.onClose, onFacetToggle = _a.onFacetToggle;
|
|
9
|
+
var _b = useState(''), filterText = _b[0], setFilterText = _b[1];
|
|
10
|
+
var _c = useState(null), lastFacetClicked = _c[0], setLastFacetClicked = _c[1];
|
|
11
|
+
var searchInputRootRef = useRef(null);
|
|
12
|
+
var filteredList = useMemo(function () { return (filterText ? filterItemsInGroups(data, filterText) : data); }, [data, filterText]);
|
|
13
|
+
var showSearchInput = function () { return searchInputRootRef.current.scrollIntoView(true); };
|
|
14
|
+
var handleClose = useCallback(function () {
|
|
15
|
+
onClose();
|
|
16
|
+
setFilterText('');
|
|
17
|
+
setLastFacetClicked(null);
|
|
18
|
+
}, [onClose]);
|
|
19
|
+
var handleListItemClick = useCallback(function (facetConfig, checked, groupId) {
|
|
20
|
+
setLastFacetClicked({ facetConfig: facetConfig, groupId: groupId });
|
|
21
|
+
onFacetToggle(facetConfig, checked);
|
|
22
|
+
}, [onFacetToggle]);
|
|
23
|
+
var handleOpen = useCallback(function () {
|
|
24
|
+
showSearchInput();
|
|
25
|
+
onOpen();
|
|
26
|
+
}, [onOpen]);
|
|
27
|
+
return (React.createElement(React.Fragment, null,
|
|
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, selectedFacets: selectedFacets, data: filteredList, lastFacetClicked: lastFacetClicked, anchorRef: searchInputRootRef, onListItemClick: handleListItemClick, onClose: handleClose, onSearch: setFilterText })));
|
|
30
|
+
};
|
|
31
|
+
export default FacetsSelector;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {"inputContainer":"FacetsSelector-inputContainer--e6n0w"};
|
|
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 = `.FacetsSelector-inputContainer--e6n0w{flex-shrink:0;margin:4px 16px 16px}`;
|
|
7
|
+
head.appendChild(style);
|
|
8
|
+
}
|
|
9
|
+
export default styles;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FacetConfig } from '@reltio/mdm-sdk';
|
|
3
|
+
import { MoreFacetItem, SelectedFacet } from '../../types';
|
|
4
|
+
type Props = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
selectedFacets: FacetConfig[];
|
|
7
|
+
data?: MoreFacetItem[];
|
|
8
|
+
lastFacetClicked?: SelectedFacet;
|
|
9
|
+
anchorRef: React.RefObject<HTMLInputElement>;
|
|
10
|
+
onListItemClick: (item: FacetConfig, selected: boolean, groupId: string) => void;
|
|
11
|
+
onSearch?: (value?: string) => void;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const AttributeSelectorPopup: ({ open, selectedFacets, data, lastFacetClicked, anchorRef, onListItemClick, onSearch, onClose }: Props) => React.JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
+
import { path, clamp, has } from 'ramda';
|
|
3
|
+
import i18n from 'ui-i18n';
|
|
4
|
+
import Typography from '@mui/material/Typography';
|
|
5
|
+
import { getMaxItemWidth } from '@reltio/mdm-sdk';
|
|
6
|
+
import { useKeyboardNavigation } from '../../../hooks/useKeyboardNavigation';
|
|
7
|
+
import { adjustVerticalPopupLayout, constructPopoverOrigin, isSelectedFacet } from '../../helpers';
|
|
8
|
+
import { flattenGroupedItemsData } from '../../../VirtualGroupedList';
|
|
9
|
+
import { FacetsList } from '../FacetsList';
|
|
10
|
+
import { SelectionPopup } from '../../../SelectionPopup';
|
|
11
|
+
import { DEFAULT_ATTRIBUTE_SELECTOR_POPUP_HEIGHT, POPUP_HEADER_HEIGHT, DEFAULT_LIST_HEIGHT, DEFAULT_MIN_CONTAINER_WIDTH, MIN_LIST_HEIGHT } from '../../constants';
|
|
12
|
+
import styles from './AttributeSelectorPopup.module.css';
|
|
13
|
+
var defaultLastFacetClicked = {};
|
|
14
|
+
export var AttributeSelectorPopup = function (_a) {
|
|
15
|
+
var _b, _c;
|
|
16
|
+
var open = _a.open, selectedFacets = _a.selectedFacets, _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
|
+
var _f = useState(DEFAULT_LIST_HEIGHT), listHeight = _f[0], setListHeight = _f[1];
|
|
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
|
+
var maxListHeight = popupHeight - POPUP_HEADER_HEIGHT;
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
setListHeight(maxListHeight);
|
|
22
|
+
}, [maxListHeight]);
|
|
23
|
+
var handleResizeList = useCallback(function (width, height) { return setListHeight(clamp(MIN_LIST_HEIGHT, maxListHeight, height)); }, [maxListHeight]);
|
|
24
|
+
var popupActionRef = useRef();
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
var updatePopupPosition = path(['current', 'updatePosition'], popupActionRef);
|
|
27
|
+
if (updatePopupPosition)
|
|
28
|
+
updatePopupPosition();
|
|
29
|
+
}, [listHeight]);
|
|
30
|
+
var getFacetGroupData = useCallback(function (item, groupId, level) {
|
|
31
|
+
if (level === void 0) { level = 0; }
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
type: 'item',
|
|
35
|
+
item: item,
|
|
36
|
+
moveTo: has('facetConfig')(lastFacetClicked) &&
|
|
37
|
+
lastFacetClicked.facetConfig.fieldName === item.fieldName &&
|
|
38
|
+
groupId === lastFacetClicked.groupId,
|
|
39
|
+
level: level,
|
|
40
|
+
groupId: groupId
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
.concat(item.children
|
|
44
|
+
? item.children.flatMap(function (subItem) { return getFacetGroupData(subItem, groupId, level + 1); })
|
|
45
|
+
: [])
|
|
46
|
+
.flat()
|
|
47
|
+
.filter(function (item) { return !item.item.hide; });
|
|
48
|
+
}, [lastFacetClicked]);
|
|
49
|
+
var getFacetsData = useCallback(function (data) {
|
|
50
|
+
return data
|
|
51
|
+
.map(function (group) { return ({
|
|
52
|
+
type: 'group',
|
|
53
|
+
item: group,
|
|
54
|
+
items: group.facets.filter(function (item) { return !item.hide; }).map(function (item) { return getFacetGroupData(item, group.id); })
|
|
55
|
+
}); })
|
|
56
|
+
.filter(function (group) { return group.items.length; });
|
|
57
|
+
}, [getFacetGroupData]);
|
|
58
|
+
var groupedItems = useMemo(function () { return getFacetsData(data); }, [data, getFacetsData]);
|
|
59
|
+
var items = useMemo(function () { return flattenGroupedItemsData(groupedItems); }, [groupedItems]);
|
|
60
|
+
var popupOrigin = constructPopoverOrigin(verticalOrigin);
|
|
61
|
+
var popupWidth = (_c = (_b = anchorRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) !== null && _c !== void 0 ? _c : 0;
|
|
62
|
+
var handleSearchOnEnter = useCallback(function (_a) {
|
|
63
|
+
var item = _a.item, groupData = _a.groupData;
|
|
64
|
+
onListItemClick(item, !isSelectedFacet({ facet: item, selectedFacets: selectedFacets }), groupData.groupId);
|
|
65
|
+
}, [onListItemClick, selectedFacets]);
|
|
66
|
+
var _j = useKeyboardNavigation({
|
|
67
|
+
items: items,
|
|
68
|
+
open: open,
|
|
69
|
+
onSelectFocusedItem: handleSearchOnEnter,
|
|
70
|
+
selectedItems: selectedFacets
|
|
71
|
+
}), focusIndex = _j.focusIndex, handleKeyDown = _j.handleKeyDown;
|
|
72
|
+
var containerWidth = Math.max(popupWidth || getMaxItemWidth('title')(groupedItems), DEFAULT_MIN_CONTAINER_WIDTH);
|
|
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, selectedFacets: selectedFacets, onListItemClick: onListItemClick, items: items, height: listHeight, onInnerContainerResize: handleResizeList }),
|
|
75
|
+
items.length === 0 && (React.createElement("div", { className: styles.noResultsCaptionContainer },
|
|
76
|
+
React.createElement(Typography, { variant: "caption", display: "block", gutterBottom: true }, i18n.text('No results found'))))));
|
|
77
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {"noResultsCaptionContainer":"AttributeSelectorPopup-noResultsCaptionContainer--EjZUT"};
|
|
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 = `.AttributeSelectorPopup-noResultsCaptionContainer--EjZUT{align-items:center;bottom:0;display:flex;justify-content:center;left:0;position:absolute;right:0;top:0}`;
|
|
7
|
+
head.appendChild(style);
|
|
8
|
+
}
|
|
9
|
+
export default styles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AttributeSelectorPopup } from './AttributeSelectorPopup';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AttributeSelectorPopup } from './AttributeSelectorPopup';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
|
2
|
+
import { AttributeType, FacetConfig } from '@reltio/mdm-sdk';
|
|
3
|
+
import { VirtualGroupedList } from '../../../VirtualGroupedList';
|
|
4
|
+
type Data = {
|
|
5
|
+
fieldName: string;
|
|
6
|
+
title: string;
|
|
7
|
+
filterText?: string;
|
|
8
|
+
attrType: AttributeType;
|
|
9
|
+
LogoIcon?: React.ElementType;
|
|
10
|
+
};
|
|
11
|
+
type Props = Omit<ComponentProps<typeof VirtualGroupedList>, 'renderItem' | 'getItemSize'> & {
|
|
12
|
+
focusIndex: number;
|
|
13
|
+
selectedFacets: FacetConfig[];
|
|
14
|
+
onListItemClick: (data: Data, checked: boolean, groupId: string) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const FacetsList: ({ onListItemClick, focusIndex, selectedFacets, ...otherProps }: Props) => React.JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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, { useCallback, useRef } from 'react';
|
|
24
|
+
import ListItem from '@mui/material/ListItem';
|
|
25
|
+
import { isSelectedFacet } from '../../helpers';
|
|
26
|
+
import { AttributeListItem } from '../../../AttributeListItem';
|
|
27
|
+
import { VirtualGroupedList } from '../../../VirtualGroupedList';
|
|
28
|
+
import { Highlighter } from '../../../Highlighter';
|
|
29
|
+
import { AttributeGroupIcon } from '../../../AttributeGroupIcon';
|
|
30
|
+
import { FACET_LIST_ITEM_HEIGHT } from '../../constants';
|
|
31
|
+
import { useMdmMetadata } from '../../../contexts/MdmModuleContext';
|
|
32
|
+
import styles from './FacetsList.module.css';
|
|
33
|
+
var ITEM_GROUP_TITLE_HEIGHT = 40;
|
|
34
|
+
export var FacetsList = function (_a) {
|
|
35
|
+
var onListItemClick = _a.onListItemClick, focusIndex = _a.focusIndex, selectedFacets = _a.selectedFacets, otherProps = __rest(_a, ["onListItemClick", "focusIndex", "selectedFacets"]);
|
|
36
|
+
var selectedFacetsRef = useRef(null);
|
|
37
|
+
selectedFacetsRef.current = selectedFacets;
|
|
38
|
+
var focusIndexRef = useRef(null);
|
|
39
|
+
focusIndexRef.current = focusIndex;
|
|
40
|
+
var metadata = useMdmMetadata();
|
|
41
|
+
var renderItem = useCallback(function (style, _a, index) {
|
|
42
|
+
var item = _a.item, level = _a.level, groupId = _a.groupId;
|
|
43
|
+
var checked = isSelectedFacet({ facet: item, selectedFacets: selectedFacetsRef.current });
|
|
44
|
+
var isFocused = focusIndexRef.current === index;
|
|
45
|
+
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]);
|
|
47
|
+
var renderGroupTitle = useCallback(function (style, item) { return (React.createElement(ListItem, { component: 'div', className: styles.subHeader, style: style, key: "group-".concat(item.item.id) },
|
|
48
|
+
item.item.needGroupIcon && React.createElement(AttributeGroupIcon, { metadata: metadata, group: item.item }),
|
|
49
|
+
item.item.title)); }, [metadata]);
|
|
50
|
+
var getItemSize = useCallback(function (i, item) { return (item.items ? ITEM_GROUP_TITLE_HEIGHT : FACET_LIST_ITEM_HEIGHT); }, []);
|
|
51
|
+
return (React.createElement(VirtualGroupedList, __assign({ getItemSize: getItemSize, renderGroupTitle: renderGroupTitle, renderItem: renderItem, focusIndex: focusIndex }, otherProps, { disableHorizontalScrollbar: true })));
|
|
52
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {"subHeader":"FacetsList-subHeader--jcWLn","icon":"FacetsList-icon--HO3ZO","recommendedIcon":"FacetsList-recommendedIcon--ekXsX"};
|
|
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 = `.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}`;
|
|
7
|
+
head.appendChild(style);
|
|
8
|
+
}
|
|
9
|
+
export default styles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FacetsList } from './FacetsList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FacetsList } from './FacetsList';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const FACET_LIST_ITEM_HEIGHT = 28;
|
|
2
|
+
export declare const DEFAULT_LIST_HEIGHT = 464;
|
|
3
|
+
export declare const DEFAULT_MIN_CONTAINER_WIDTH = 240;
|
|
4
|
+
export declare const MIN_LIST_HEIGHT: number;
|
|
5
|
+
export declare const POPUP_HEADER_HEIGHT = 110;
|
|
6
|
+
export declare const DEFAULT_ATTRIBUTE_SELECTOR_POPUP_HEIGHT: number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var FACET_LIST_ITEM_HEIGHT = 28;
|
|
2
|
+
export var DEFAULT_LIST_HEIGHT = 464;
|
|
3
|
+
export var DEFAULT_MIN_CONTAINER_WIDTH = 240;
|
|
4
|
+
export var MIN_LIST_HEIGHT = FACET_LIST_ITEM_HEIGHT * 2;
|
|
5
|
+
export var POPUP_HEADER_HEIGHT = 110;
|
|
6
|
+
export var DEFAULT_ATTRIBUTE_SELECTOR_POPUP_HEIGHT = POPUP_HEADER_HEIGHT + DEFAULT_LIST_HEIGHT;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PopoverOrigin } from '@mui/material/Popover';
|
|
2
|
+
import { MoreFacetItem } from './types';
|
|
3
|
+
declare const adjustVerticalPopupLayout: (anchorEl: HTMLElement, popupHeight: number) => {
|
|
4
|
+
verticalOrigin: "bottom" | "top";
|
|
5
|
+
popupHeight: number;
|
|
6
|
+
};
|
|
7
|
+
declare const filterItemsInGroups: (groups: MoreFacetItem[], filterText: string) => MoreFacetItem[];
|
|
8
|
+
declare const isSelectedFacet: ({ facet, selectedFacets }: {
|
|
9
|
+
facet: any;
|
|
10
|
+
selectedFacets: any;
|
|
11
|
+
}) => boolean;
|
|
12
|
+
declare const constructPopoverOrigin: (verticalOrigin: PopoverOrigin["vertical"], horizontalOrigin?: PopoverOrigin["horizontal"]) => {
|
|
13
|
+
vertical: number | "bottom" | "top" | "center";
|
|
14
|
+
horizontal: number | "left" | "right" | "center";
|
|
15
|
+
};
|
|
16
|
+
export { adjustVerticalPopupLayout, filterItemsInGroups, isSelectedFacet, constructPopoverOrigin };
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { isEmpty } from 'ramda';
|
|
13
|
+
var adjustVerticalPopupLayout = function (anchorEl, popupHeight) {
|
|
14
|
+
var verticalOrigin = 'top';
|
|
15
|
+
var marginThreshold = 16;
|
|
16
|
+
if (anchorEl) {
|
|
17
|
+
var anchorRect = anchorEl.getBoundingClientRect();
|
|
18
|
+
var highestPoint = marginThreshold;
|
|
19
|
+
var lowestPoint = window.innerHeight - marginThreshold;
|
|
20
|
+
if (anchorRect.top + popupHeight > lowestPoint) {
|
|
21
|
+
if (anchorRect.bottom - popupHeight < highestPoint) {
|
|
22
|
+
var maxHeightToBottom = anchorRect.bottom - highestPoint;
|
|
23
|
+
var maxHeightToTop = lowestPoint - anchorRect.top;
|
|
24
|
+
popupHeight = Math.max(maxHeightToBottom, maxHeightToTop);
|
|
25
|
+
verticalOrigin = maxHeightToBottom > maxHeightToTop ? 'bottom' : 'top';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
verticalOrigin = 'bottom';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return { verticalOrigin: verticalOrigin, popupHeight: popupHeight };
|
|
33
|
+
};
|
|
34
|
+
var filterItem = function (item, filterText) { var _a, _b; return (_b = (_a = item.title) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(filterText.toLowerCase())) !== null && _b !== void 0 ? _b : false; };
|
|
35
|
+
var filterItemsTree = function (item, filterText) {
|
|
36
|
+
return filterItem(item, filterText) || (item.children || []).some(function (child) { return filterItemsTree(child, filterText); });
|
|
37
|
+
};
|
|
38
|
+
var getFilteredFacets = function (facets, filterText) {
|
|
39
|
+
return (facets || [])
|
|
40
|
+
.map(function (facet) { return (__assign(__assign({}, facet), { hide: !filterItemsTree(facet, filterText), filterText: filterText })); })
|
|
41
|
+
.map(function (facet) {
|
|
42
|
+
var children = getFilteredFacets(facet.children, filterText);
|
|
43
|
+
return isEmpty(children)
|
|
44
|
+
? facet
|
|
45
|
+
: __assign(__assign({}, facet), { children: children });
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var filterItemsInGroups = function (groups, filterText) {
|
|
49
|
+
return groups.map(function (group) { return (__assign(__assign({}, group), { facets: getFilteredFacets(group.facets, filterText) })); });
|
|
50
|
+
};
|
|
51
|
+
var isSelectedFacet = function (_a) {
|
|
52
|
+
var facet = _a.facet, selectedFacets = _a.selectedFacets;
|
|
53
|
+
return !!selectedFacets.find(function (selFacet) { return selFacet.fieldName === facet.fieldName || selFacet.fieldName.includes("".concat(facet.fieldName, ".")); });
|
|
54
|
+
};
|
|
55
|
+
var constructPopoverOrigin = function (verticalOrigin, horizontalOrigin) {
|
|
56
|
+
if (horizontalOrigin === void 0) { horizontalOrigin = 'right'; }
|
|
57
|
+
return {
|
|
58
|
+
vertical: verticalOrigin,
|
|
59
|
+
horizontal: horizontalOrigin
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export { adjustVerticalPopupLayout, filterItemsInGroups, isSelectedFacet, constructPopoverOrigin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { adjustVerticalPopupLayout } from './helpers';
|
|
2
|
+
describe('helpers tests', function () {
|
|
3
|
+
describe('adjustVerticalPopupLayout tests', function () {
|
|
4
|
+
it('should return top vertical origin if popup fits to the bottom', function () {
|
|
5
|
+
var anchorEl = document.createElement('div');
|
|
6
|
+
anchorEl.getBoundingClientRect = jest.fn(function () {
|
|
7
|
+
return { top: 100, bottom: 200 };
|
|
8
|
+
});
|
|
9
|
+
var popupHeight = 50;
|
|
10
|
+
var result = adjustVerticalPopupLayout(anchorEl, popupHeight);
|
|
11
|
+
expect(result).toEqual({ verticalOrigin: 'top', popupHeight: popupHeight });
|
|
12
|
+
});
|
|
13
|
+
it('should return correct height', function () {
|
|
14
|
+
var originalInnerHeight = global.innerHeight;
|
|
15
|
+
global.innerHeight = 600;
|
|
16
|
+
var anchorEl = document.createElement('div');
|
|
17
|
+
anchorEl.getBoundingClientRect = jest.fn(function () {
|
|
18
|
+
return { top: 540, bottom: 580 };
|
|
19
|
+
});
|
|
20
|
+
var popupHeight = 574;
|
|
21
|
+
var result = adjustVerticalPopupLayout(anchorEl, popupHeight);
|
|
22
|
+
expect(result).toEqual({ verticalOrigin: 'bottom', popupHeight: 564 });
|
|
23
|
+
global.innerHeight = originalInnerHeight;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FacetsSelector } from './FacetsSelector';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
onScroll
|
|
4
|
+
onScroll?: (scrollTop: number, event: Event) => void;
|
|
5
5
|
};
|
|
6
6
|
export declare const QuickFiltersFacetPanel: ({ children, onScroll }: Props) => React.ReactElement;
|
|
7
7
|
export {};
|
|
@@ -5,7 +5,7 @@ export var QuickFiltersFacetPanel = function (_a) {
|
|
|
5
5
|
var children = _a.children, onScroll = _a.onScroll;
|
|
6
6
|
var containerRef = useRef(null);
|
|
7
7
|
var onContainerScroll = useCallback(function (e) {
|
|
8
|
-
onScroll(containerRef.current.scrollTop, e);
|
|
8
|
+
onScroll === null || onScroll === void 0 ? void 0 : onScroll(containerRef.current.scrollTop, e);
|
|
9
9
|
}, [onScroll]);
|
|
10
10
|
var boundariesElement = containerRef.current;
|
|
11
11
|
var popupBoundariesValue = useMemo(function () { return ({
|
|
@@ -3,5 +3,5 @@ type Props = {
|
|
|
3
3
|
tooltipTitle?: string;
|
|
4
4
|
onClick: () => void;
|
|
5
5
|
};
|
|
6
|
-
export declare const AdvancedSearchFabButton:
|
|
6
|
+
export declare const AdvancedSearchFabButton: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
7
7
|
export {};
|
|
@@ -10,6 +10,29 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
13
36
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
37
|
var t = {};
|
|
15
38
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -26,7 +49,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
49
|
};
|
|
27
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
51
|
exports.AdvancedSearchFabButton = void 0;
|
|
29
|
-
var react_1 =
|
|
52
|
+
var react_1 = __importStar(require("react"));
|
|
30
53
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
31
54
|
var Fab_1 = __importDefault(require("@mui/material/Fab"));
|
|
32
55
|
var Tune_1 = __importDefault(require("@mui/icons-material/Tune"));
|
|
@@ -34,11 +57,11 @@ var ChevronRight_1 = __importDefault(require("@mui/icons-material/ChevronRight")
|
|
|
34
57
|
var withTooltip_1 = require("../HOCs/withTooltip");
|
|
35
58
|
var AdvancedSearchFabButton_module_css_1 = __importDefault(require("./AdvancedSearchFabButton.module.css"));
|
|
36
59
|
var FabButtonWithTooltip = (0, withTooltip_1.withTooltip)(Fab_1.default);
|
|
37
|
-
|
|
60
|
+
exports.AdvancedSearchFabButton = (0, react_1.forwardRef)(function (_a, ref) {
|
|
38
61
|
var tooltipTitle = _a.tooltipTitle, onClick = _a.onClick, otherProps = __rest(_a, ["tooltipTitle", "onClick"]);
|
|
39
|
-
return (react_1.default.createElement(FabButtonWithTooltip, __assign({ tooltipTitle: tooltipTitle || ui_i18n_1.default.text('Open advanced search'), tooltipPlacement: "bottom-end", variant: "extended", classes: { root: AdvancedSearchFabButton_module_css_1.default.buttonRoot, extended: AdvancedSearchFabButton_module_css_1.default.buttonExtended }, onClick: onClick, "data-reltio-id": "reltio-advanced-search-fab-button" }, otherProps),
|
|
62
|
+
return (react_1.default.createElement(FabButtonWithTooltip, __assign({ tooltipTitle: tooltipTitle || ui_i18n_1.default.text('Open advanced search'), tooltipPlacement: "bottom-end", variant: "extended", classes: { root: AdvancedSearchFabButton_module_css_1.default.buttonRoot, extended: AdvancedSearchFabButton_module_css_1.default.buttonExtended }, onClick: onClick, "data-reltio-id": "reltio-advanced-search-fab-button", ref: ref }, otherProps),
|
|
40
63
|
react_1.default.createElement(Tune_1.default, { color: "primary", className: AdvancedSearchFabButton_module_css_1.default.menuIcon }),
|
|
41
64
|
react_1.default.createElement("span", { className: AdvancedSearchFabButton_module_css_1.default.buttonLabel }, ui_i18n_1.default.text('Advanced search')),
|
|
42
65
|
react_1.default.createElement(ChevronRight_1.default, { color: "action", className: AdvancedSearchFabButton_module_css_1.default.goToActionIcon })));
|
|
43
|
-
};
|
|
44
|
-
exports.AdvancedSearchFabButton = AdvancedSearchFabButton;
|
|
66
|
+
});
|
|
67
|
+
exports.AdvancedSearchFabButton.displayName = 'AdvancedSearchFabButton';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FacetConfig } from '@reltio/mdm-sdk';
|
|
3
|
+
import { MoreFacetItem } from './types';
|
|
4
|
+
type Props = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
data?: MoreFacetItem[];
|
|
7
|
+
selectedFacets: FacetConfig[];
|
|
8
|
+
onOpen: () => void;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onFacetToggle: (item: FacetConfig, selected: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
export declare const FacetsSelector: ({ open, data, selectedFacets, onOpen, onClose, onFacetToggle }: Props) => React.JSX.Element;
|
|
13
|
+
export default FacetsSelector;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.FacetsSelector = void 0;
|
|
30
|
+
var react_1 = __importStar(require("react"));
|
|
31
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
32
|
+
var AttributeSelectorPopup_1 = require("./components/AttributeSelectorPopup");
|
|
33
|
+
var SearchInput_1 = require("../SearchInput");
|
|
34
|
+
var helpers_1 = require("./helpers");
|
|
35
|
+
var FacetsSelector_module_css_1 = __importDefault(require("./FacetsSelector.module.css"));
|
|
36
|
+
var FacetsSelector = function (_a) {
|
|
37
|
+
var open = _a.open, data = _a.data, selectedFacets = _a.selectedFacets, onOpen = _a.onOpen, onClose = _a.onClose, onFacetToggle = _a.onFacetToggle;
|
|
38
|
+
var _b = (0, react_1.useState)(''), filterText = _b[0], setFilterText = _b[1];
|
|
39
|
+
var _c = (0, react_1.useState)(null), lastFacetClicked = _c[0], setLastFacetClicked = _c[1];
|
|
40
|
+
var searchInputRootRef = (0, react_1.useRef)(null);
|
|
41
|
+
var filteredList = (0, react_1.useMemo)(function () { return (filterText ? (0, helpers_1.filterItemsInGroups)(data, filterText) : data); }, [data, filterText]);
|
|
42
|
+
var showSearchInput = function () { return searchInputRootRef.current.scrollIntoView(true); };
|
|
43
|
+
var handleClose = (0, react_1.useCallback)(function () {
|
|
44
|
+
onClose();
|
|
45
|
+
setFilterText('');
|
|
46
|
+
setLastFacetClicked(null);
|
|
47
|
+
}, [onClose]);
|
|
48
|
+
var handleListItemClick = (0, react_1.useCallback)(function (facetConfig, checked, groupId) {
|
|
49
|
+
setLastFacetClicked({ facetConfig: facetConfig, groupId: groupId });
|
|
50
|
+
onFacetToggle(facetConfig, checked);
|
|
51
|
+
}, [onFacetToggle]);
|
|
52
|
+
var handleOpen = (0, react_1.useCallback)(function () {
|
|
53
|
+
showSearchInput();
|
|
54
|
+
onOpen();
|
|
55
|
+
}, [onOpen]);
|
|
56
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
57
|
+
react_1.default.createElement(SearchInput_1.SearchInput, { classes: { root: FacetsSelector_module_css_1.default.inputContainer }, onSearch: setFilterText, onFocus: handleOpen, rootRef: searchInputRootRef, value: filterText, placeholder: ui_i18n_1.default.text('Search & add attributes'), height: 40, "data-reltio-id": "reltio-search-more-facets-search-input" }),
|
|
58
|
+
react_1.default.createElement(AttributeSelectorPopup_1.AttributeSelectorPopup, { open: open, selectedFacets: selectedFacets, data: filteredList, lastFacetClicked: lastFacetClicked, anchorRef: searchInputRootRef, onListItemClick: handleListItemClick, onClose: handleClose, onSearch: setFilterText })));
|
|
59
|
+
};
|
|
60
|
+
exports.FacetsSelector = FacetsSelector;
|
|
61
|
+
exports.default = exports.FacetsSelector;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const styles = {"inputContainer":"FacetsSelector-inputContainer--e6n0w"};
|
|
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 = `.FacetsSelector-inputContainer--e6n0w{flex-shrink:0;margin:4px 16px 16px}`;
|
|
7
|
+
head.appendChild(style);
|
|
8
|
+
}
|
|
9
|
+
module.exports = styles;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FacetConfig } from '@reltio/mdm-sdk';
|
|
3
|
+
import { MoreFacetItem, SelectedFacet } from '../../types';
|
|
4
|
+
type Props = {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
selectedFacets: FacetConfig[];
|
|
7
|
+
data?: MoreFacetItem[];
|
|
8
|
+
lastFacetClicked?: SelectedFacet;
|
|
9
|
+
anchorRef: React.RefObject<HTMLInputElement>;
|
|
10
|
+
onListItemClick: (item: FacetConfig, selected: boolean, groupId: string) => void;
|
|
11
|
+
onSearch?: (value?: string) => void;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const AttributeSelectorPopup: ({ open, selectedFacets, data, lastFacetClicked, anchorRef, onListItemClick, onSearch, onClose }: Props) => React.JSX.Element;
|
|
15
|
+
export {};
|