@reltio/components 1.4.1389 → 1.4.1391

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/cjs/components/BasicTableView/ColumnFilter/FilterChip/FilterChip.js +3 -1
  2. package/cjs/components/SelectionPopup/helpers.d.ts +1 -1
  3. package/cjs/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.d.ts +11 -19
  4. package/cjs/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.js +8 -17
  5. package/cjs/components/attributes/editMode/MoreAttributesButton/helpers.d.ts +3 -2
  6. package/cjs/components/attributes/editMode/MoreAttributesButton/helpers.js +2 -2
  7. package/cjs/components/attributes/editMode/MoreAttributesButton/index.d.ts +1 -1
  8. package/cjs/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
  9. package/cjs/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.js +17 -7
  10. package/cjs/hooks/useCustomScripts.js +1 -1
  11. package/esm/components/BasicTableView/ColumnFilter/FilterChip/FilterChip.js +3 -1
  12. package/esm/components/SelectionPopup/helpers.d.ts +1 -1
  13. package/esm/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.d.ts +11 -19
  14. package/esm/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.js +8 -17
  15. package/esm/components/attributes/editMode/MoreAttributesButton/helpers.d.ts +3 -2
  16. package/esm/components/attributes/editMode/MoreAttributesButton/helpers.js +4 -5
  17. package/esm/components/attributes/editMode/MoreAttributesButton/index.d.ts +1 -1
  18. package/esm/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
  19. package/esm/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.js +17 -7
  20. package/esm/hooks/useCustomScripts.js +1 -1
  21. package/package.json +3 -3
@@ -17,7 +17,9 @@ var FilterChip = function (_a) {
17
17
  var optionLabel = filterOption.label + (canFilterAcceptValues ? ': ' : '');
18
18
  var styles = (0, styles_1.useStyles)();
19
19
  var attributePresentations = (0, react_redux_1.useSelector)(mdm_module_1.default.selectors.getAttributePresentations);
20
- var formatValue = (0, mdm_sdk_1.formatDataTypeValue)({ attributePresentations: attributePresentations, dataTypeDefinition: dataTypeDefinition });
20
+ var dateMask = (0, react_redux_1.useSelector)(mdm_module_1.default.selectors.getDateMask);
21
+ var dateTimeMask = (0, react_redux_1.useSelector)(mdm_module_1.default.selectors.getDateTimeMask);
22
+ var formatValue = (0, mdm_sdk_1.formatDataTypeValue)({ attributePresentations: attributePresentations, dataTypeDefinition: dataTypeDefinition, dateMask: dateMask, dateTimeMask: dateTimeMask });
21
23
  var convertedValue = (0, mdm_sdk_1.mapFilterValue)(formatValue, filterValue);
22
24
  var filterLabel = canFilterAcceptValues ? (0, mdm_sdk_1.getFilterValueLabel)(filterOption.value, convertedValue) : '';
23
25
  return (react_1.default.createElement(Chip_1.default, { label: react_1.default.createElement(ExpandedValueTooltip_1.default, { value: optionLabel + filterLabel },
@@ -15,7 +15,7 @@ declare type Props = {
15
15
  groupData: Item['item'];
16
16
  }) => void;
17
17
  selectedItems: string[];
18
- onClose: (event: React.KeyboardEvent) => void;
18
+ onClose?: (event: React.KeyboardEvent) => void;
19
19
  };
20
20
  declare const useKeyboardNavigation: ({ items, open, onSelectFocusedItem, selectedItems, onClose }: Props) => {
21
21
  focusIndex: number;
@@ -1,20 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { AttributeType } from '@reltio/mdm-sdk';
3
+ declare type Props = {
4
+ label: string;
5
+ popupTitle?: string;
6
+ data: AttributeType[];
7
+ parent?: AttributeType;
8
+ dense?: boolean;
9
+ onApply: (attributeTypes: AttributeType[]) => void;
10
+ };
11
+ declare const MoreAttributesButton: ({ label, popupTitle, data, parent, dense, onApply }: Props) => JSX.Element;
1
12
  export default MoreAttributesButton;
2
- declare function MoreAttributesButton({ label, popupTitle, data, parent, dense, onApply }: {
3
- label: any;
4
- popupTitle?: any;
5
- data: any;
6
- parent: any;
7
- dense: any;
8
- onApply: any;
9
- }): JSX.Element;
10
- declare namespace MoreAttributesButton {
11
- namespace propTypes {
12
- const label: PropTypes.Requireable<string>;
13
- const popupTitle: PropTypes.Requireable<string>;
14
- const data: PropTypes.Requireable<any[]>;
15
- const parent: PropTypes.Requireable<object>;
16
- const dense: PropTypes.Requireable<boolean>;
17
- const onApply: PropTypes.Requireable<(...args: any[]) => any>;
18
- }
19
- }
20
- import PropTypes from "prop-types";
@@ -27,21 +27,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  var react_1 = __importStar(require("react"));
30
- var ui_i18n_1 = __importDefault(require("ui-i18n"));
31
- var classnames_1 = __importDefault(require("classnames"));
32
- var prop_types_1 = __importDefault(require("prop-types"));
33
- var ramda_1 = require("ramda");
34
30
  var Button_1 = __importDefault(require("@material-ui/core/Button"));
35
31
  var ListItem_1 = __importDefault(require("@material-ui/core/ListItem"));
36
32
  var Typography_1 = __importDefault(require("@material-ui/core/Typography"));
37
- var styles_1 = require("./styles");
38
- var SelectionPopup_1 = __importDefault(require("../../../SelectionPopup/SelectionPopup"));
33
+ var classnames_1 = __importDefault(require("classnames"));
34
+ var ramda_1 = require("ramda");
35
+ var ui_i18n_1 = __importDefault(require("ui-i18n"));
39
36
  var AttributeListItem_1 = __importDefault(require("../../../AttributeListItem/AttributeListItem"));
40
- var VirtualGroupedList_1 = __importDefault(require("../../../VirtualGroupedList/VirtualGroupedList"));
41
- var helpers_1 = require("../../../SelectionPopup/helpers");
37
+ var SelectionPopup_1 = __importDefault(require("../../../SelectionPopup/SelectionPopup"));
42
38
  var Add_1 = __importDefault(require("@material-ui/icons/Add"));
43
39
  var Highlighter_1 = __importDefault(require("../../../Highlighter/Highlighter"));
40
+ var helpers_1 = require("../../../SelectionPopup/helpers");
41
+ var VirtualGroupedList_1 = __importDefault(require("../../../VirtualGroupedList/VirtualGroupedList"));
44
42
  var useMoreAttributesItems_1 = require("./useMoreAttributesItems");
43
+ var styles_1 = require("./styles");
45
44
  var ITEM_HEIGHT = 28;
46
45
  var ITEM_GROUP_TITLE_HEIGHT = 40;
47
46
  var LIST_CONTAINER_WIDTH = 320;
@@ -99,16 +98,8 @@ var MoreAttributesButton = function (_a) {
99
98
  react_1.default.createElement(Add_1.default, { classes: { root: styles.icon } }),
100
99
  react_1.default.createElement("div", { className: styles.buttonLabel }, label)),
101
100
  react_1.default.createElement(SelectionPopup_1.default, { open: isOpen, className: (0, classnames_1.default)(styles.moreAttributesPopup, styles.popupContainer), anchorEl: inputRef.current, onClose: (0, ramda_1.pipe)(addSelectedAttributes, closePopup, clearFilter, clearSelectedItems), onSearch: setFilter, containerHeight: containerHeight, title: popupTitle, containerWidth: LIST_CONTAINER_WIDTH, searchInputOnKeyDown: handleKeyDown },
102
- react_1.default.createElement(VirtualGroupedList_1.default, { getItemSize: getItemSize, renderItem: listItemRenderer, renderGroupTitle: renderGroupTitle, items: items, height: listHeight, containerWidth: LIST_CONTAINER_WIDTH, focusIndex: focusIndex }),
101
+ react_1.default.createElement(VirtualGroupedList_1.default, { getItemSize: getItemSize, renderItem: listItemRenderer, renderGroupTitle: renderGroupTitle, items: items, height: listHeight, focusIndex: focusIndex }),
103
102
  items.length === 0 && (react_1.default.createElement("div", { className: styles.noResultsCaptionContainer },
104
103
  react_1.default.createElement(Typography_1.default, { variant: "caption", display: "block", gutterBottom: true }, ui_i18n_1.default.text('No results found')))))));
105
104
  };
106
- MoreAttributesButton.propTypes = {
107
- label: prop_types_1.default.string,
108
- popupTitle: prop_types_1.default.string,
109
- data: prop_types_1.default.array,
110
- parent: prop_types_1.default.object,
111
- dense: prop_types_1.default.bool,
112
- onApply: prop_types_1.default.func
113
- };
114
105
  exports.default = MoreAttributesButton;
@@ -3,6 +3,7 @@ import { GroupedItem } from './useMoreAttributesItems';
3
3
  declare type Props = {
4
4
  attrTypes: AttributeType[];
5
5
  filter?: string;
6
+ sortingFn: (item1: AttributeType, item2: AttributeType) => number;
6
7
  };
7
- declare const preparedGroupedItems: ({ attrTypes, filter }: Props) => GroupedItem[];
8
- export { preparedGroupedItems };
8
+ export declare const preparedGroupedItems: ({ attrTypes, filter, sortingFn }: Props) => GroupedItem[];
9
+ export {};
@@ -6,8 +6,8 @@ var filterItems = (0, ramda_1.curry)(function (filterText, items) {
6
6
  return (0, ramda_1.filter)(function (item) { return (item.label || item.name).toLowerCase().includes(filterText.toLowerCase()); })(items);
7
7
  });
8
8
  var preparedGroupedItems = function (_a) {
9
- var attrTypes = _a.attrTypes, _b = _a.filter, filter = _b === void 0 ? '' : _b;
10
- return (0, ramda_1.pipe)(filterItems(filter), (0, ramda_1.map)(function (attrType) { return ({
9
+ var attrTypes = _a.attrTypes, _b = _a.filter, filter = _b === void 0 ? '' : _b, sortingFn = _a.sortingFn;
10
+ return (0, ramda_1.pipe)(filterItems(filter), (0, ramda_1.sort)(sortingFn), (0, ramda_1.map)(function (attrType) { return ({
11
11
  item: {
12
12
  id: attrType.uri,
13
13
  label: attrType.label || attrType.name,
@@ -1 +1 @@
1
- export { default } from "./MoreAttributesButton";
1
+ export { default } from './MoreAttributesButton';
@@ -1 +1 @@
1
- export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dense" | "icon" | "moreButton" | "buttonLabel" | "moreAttributes" | "popupContainer" | "moreAttributesPopup" | "subHeader" | "noResultsCaptionContainer">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dense" | "icon" | "moreButton" | "buttonLabel" | "moreAttributes" | "popupContainer" | "moreAttributesPopup" | "subHeader" | "noResultsCaptionContainer">;
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useMoreAttributesItems = void 0;
7
7
  var react_1 = require("react");
8
8
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
9
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
9
10
  var helpers_1 = require("../../../VirtualGroupedList/helpers");
10
11
  var helpers_2 = require("./helpers");
12
+ var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
13
+ var react_redux_1 = require("react-redux");
11
14
  var GROUP_NAMES;
12
15
  (function (GROUP_NAMES) {
13
16
  GROUP_NAMES["parent"] = "parent";
@@ -16,7 +19,16 @@ var GROUP_NAMES;
16
19
  var useMoreAttributesItems = function (_a) {
17
20
  var data = _a.data, parent = _a.parent, filter = _a.filter;
18
21
  var hasGroups = Boolean(parent);
19
- var preparedParentGroupItem = (0, react_1.useMemo)(function () { return (hasGroups ? (0, helpers_2.preparedGroupedItems)({ attrTypes: [parent], filter: filter }) : []); }, [hasGroups, parent, filter]);
22
+ var strategy = (0, react_redux_1.useSelector)(mdm_module_1.default.selectors.getAttributesSortingStrategy);
23
+ var sortingFn = (0, react_1.useMemo)(function () {
24
+ switch (strategy) {
25
+ case mdm_sdk_1.SortingStrategy.ASC_BY_NAME:
26
+ return function (item1, item2) { var _a; return (_a = item1 === null || item1 === void 0 ? void 0 : item1.label) === null || _a === void 0 ? void 0 : _a.localeCompare(item2 === null || item2 === void 0 ? void 0 : item2.label); };
27
+ default:
28
+ return function (_item1, _item2) { return 0; };
29
+ }
30
+ }, [strategy]);
31
+ var preparedParentGroupItem = (0, react_1.useMemo)(function () { return (hasGroups ? (0, helpers_2.preparedGroupedItems)({ attrTypes: [parent], filter: filter, sortingFn: sortingFn }) : []); }, [hasGroups, parent, filter, sortingFn]);
20
32
  var parentGroup = (0, react_1.useMemo)(function () {
21
33
  return hasGroups && (preparedParentGroupItem === null || preparedParentGroupItem === void 0 ? void 0 : preparedParentGroupItem.length)
22
34
  ? [
@@ -33,9 +45,10 @@ var useMoreAttributesItems = function (_a) {
33
45
  var preparedAttributesGroupItems = (0, react_1.useMemo)(function () {
34
46
  return (0, helpers_2.preparedGroupedItems)({
35
47
  attrTypes: data,
36
- filter: filter
48
+ filter: filter,
49
+ sortingFn: sortingFn
37
50
  });
38
- }, [data, filter]);
51
+ }, [data, filter, sortingFn]);
39
52
  var attributesGroup = (0, react_1.useMemo)(function () {
40
53
  return hasGroups && (preparedAttributesGroupItems === null || preparedAttributesGroupItems === void 0 ? void 0 : preparedAttributesGroupItems.length)
41
54
  ? [
@@ -49,10 +62,7 @@ var useMoreAttributesItems = function (_a) {
49
62
  ]
50
63
  : preparedAttributesGroupItems;
51
64
  }, [hasGroups, preparedAttributesGroupItems]);
52
- var items = (0, react_1.useMemo)(function () { return (0, helpers_1.flattenGroupedItemsData)((parentGroup || []).concat(attributesGroup)); }, [
53
- parentGroup,
54
- attributesGroup
55
- ]);
65
+ var items = (0, react_1.useMemo)(function () { return (0, helpers_1.flattenGroupedItemsData)((parentGroup || []).concat(attributesGroup)); }, [parentGroup, attributesGroup]);
56
66
  var parentGroupLength = parentGroup.length;
57
67
  var attributesGroupLength = attributesGroup.length;
58
68
  return { items: items, hasGroups: hasGroups, parentGroupLength: parentGroupLength, attributesGroupLength: attributesGroupLength };
@@ -182,7 +182,7 @@ var useCustomScripts = function (config) {
182
182
  url: fakeURL,
183
183
  method: options.method,
184
184
  headers: __assign(__assign({}, options.headers), { origin: 'ui', requestId: requestId, actionId: actionId }),
185
- data: options.body
185
+ data: options.body || options.data
186
186
  });
187
187
  }
188
188
  else {
@@ -12,7 +12,9 @@ var FilterChip = function (_a) {
12
12
  var optionLabel = filterOption.label + (canFilterAcceptValues ? ': ' : '');
13
13
  var styles = useStyles();
14
14
  var attributePresentations = useSelector(mdm.selectors.getAttributePresentations);
15
- var formatValue = formatDataTypeValue({ attributePresentations: attributePresentations, dataTypeDefinition: dataTypeDefinition });
15
+ var dateMask = useSelector(mdm.selectors.getDateMask);
16
+ var dateTimeMask = useSelector(mdm.selectors.getDateTimeMask);
17
+ var formatValue = formatDataTypeValue({ attributePresentations: attributePresentations, dataTypeDefinition: dataTypeDefinition, dateMask: dateMask, dateTimeMask: dateTimeMask });
16
18
  var convertedValue = mapFilterValue(formatValue, filterValue);
17
19
  var filterLabel = canFilterAcceptValues ? getFilterValueLabel(filterOption.value, convertedValue) : '';
18
20
  return (React.createElement(Chip, { label: React.createElement(ExpandedValueTooltip, { value: optionLabel + filterLabel },
@@ -15,7 +15,7 @@ declare type Props = {
15
15
  groupData: Item['item'];
16
16
  }) => void;
17
17
  selectedItems: string[];
18
- onClose: (event: React.KeyboardEvent) => void;
18
+ onClose?: (event: React.KeyboardEvent) => void;
19
19
  };
20
20
  declare const useKeyboardNavigation: ({ items, open, onSelectFocusedItem, selectedItems, onClose }: Props) => {
21
21
  focusIndex: number;
@@ -1,20 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { AttributeType } from '@reltio/mdm-sdk';
3
+ declare type Props = {
4
+ label: string;
5
+ popupTitle?: string;
6
+ data: AttributeType[];
7
+ parent?: AttributeType;
8
+ dense?: boolean;
9
+ onApply: (attributeTypes: AttributeType[]) => void;
10
+ };
11
+ declare const MoreAttributesButton: ({ label, popupTitle, data, parent, dense, onApply }: Props) => JSX.Element;
1
12
  export default MoreAttributesButton;
2
- declare function MoreAttributesButton({ label, popupTitle, data, parent, dense, onApply }: {
3
- label: any;
4
- popupTitle?: any;
5
- data: any;
6
- parent: any;
7
- dense: any;
8
- onApply: any;
9
- }): JSX.Element;
10
- declare namespace MoreAttributesButton {
11
- namespace propTypes {
12
- const label: PropTypes.Requireable<string>;
13
- const popupTitle: PropTypes.Requireable<string>;
14
- const data: PropTypes.Requireable<any[]>;
15
- const parent: PropTypes.Requireable<object>;
16
- const dense: PropTypes.Requireable<boolean>;
17
- const onApply: PropTypes.Requireable<(...args: any[]) => any>;
18
- }
19
- }
20
- import PropTypes from "prop-types";
@@ -1,19 +1,18 @@
1
1
  import React, { useCallback, useRef, useState } from 'react';
2
- import i18n from 'ui-i18n';
3
- import classnames from 'classnames';
4
- import PropTypes from 'prop-types';
5
- import { always, any, append, ifElse, not, pipe, pluck, propEq, reject } from 'ramda';
6
2
  import Button from '@material-ui/core/Button';
7
3
  import ListItem from '@material-ui/core/ListItem';
8
4
  import Typography from '@material-ui/core/Typography';
9
- import { useStyles } from './styles';
10
- import SelectionPopup from '../../../SelectionPopup/SelectionPopup';
5
+ import classnames from 'classnames';
6
+ import { always, any, append, ifElse, not, pipe, pluck, propEq, reject } from 'ramda';
7
+ import i18n from 'ui-i18n';
11
8
  import AttributeListItem from '../../../AttributeListItem/AttributeListItem';
12
- import VirtualGroupedList from '../../../VirtualGroupedList/VirtualGroupedList';
13
- import { useKeyboardNavigation } from '../../../SelectionPopup/helpers';
9
+ import SelectionPopup from '../../../SelectionPopup/SelectionPopup';
14
10
  import AddIcon from '@material-ui/icons/Add';
15
11
  import Highlighter from '../../../Highlighter/Highlighter';
12
+ import { useKeyboardNavigation } from '../../../SelectionPopup/helpers';
13
+ import VirtualGroupedList from '../../../VirtualGroupedList/VirtualGroupedList';
16
14
  import { useMoreAttributesItems } from './useMoreAttributesItems';
15
+ import { useStyles } from './styles';
17
16
  var ITEM_HEIGHT = 28;
18
17
  var ITEM_GROUP_TITLE_HEIGHT = 40;
19
18
  var LIST_CONTAINER_WIDTH = 320;
@@ -71,16 +70,8 @@ var MoreAttributesButton = function (_a) {
71
70
  React.createElement(AddIcon, { classes: { root: styles.icon } }),
72
71
  React.createElement("div", { className: styles.buttonLabel }, label)),
73
72
  React.createElement(SelectionPopup, { open: isOpen, className: classnames(styles.moreAttributesPopup, styles.popupContainer), anchorEl: inputRef.current, onClose: pipe(addSelectedAttributes, closePopup, clearFilter, clearSelectedItems), onSearch: setFilter, containerHeight: containerHeight, title: popupTitle, containerWidth: LIST_CONTAINER_WIDTH, searchInputOnKeyDown: handleKeyDown },
74
- React.createElement(VirtualGroupedList, { getItemSize: getItemSize, renderItem: listItemRenderer, renderGroupTitle: renderGroupTitle, items: items, height: listHeight, containerWidth: LIST_CONTAINER_WIDTH, focusIndex: focusIndex }),
73
+ React.createElement(VirtualGroupedList, { getItemSize: getItemSize, renderItem: listItemRenderer, renderGroupTitle: renderGroupTitle, items: items, height: listHeight, focusIndex: focusIndex }),
75
74
  items.length === 0 && (React.createElement("div", { className: styles.noResultsCaptionContainer },
76
75
  React.createElement(Typography, { variant: "caption", display: "block", gutterBottom: true }, i18n.text('No results found')))))));
77
76
  };
78
- MoreAttributesButton.propTypes = {
79
- label: PropTypes.string,
80
- popupTitle: PropTypes.string,
81
- data: PropTypes.array,
82
- parent: PropTypes.object,
83
- dense: PropTypes.bool,
84
- onApply: PropTypes.func
85
- };
86
77
  export default MoreAttributesButton;
@@ -3,6 +3,7 @@ import { GroupedItem } from './useMoreAttributesItems';
3
3
  declare type Props = {
4
4
  attrTypes: AttributeType[];
5
5
  filter?: string;
6
+ sortingFn: (item1: AttributeType, item2: AttributeType) => number;
6
7
  };
7
- declare const preparedGroupedItems: ({ attrTypes, filter }: Props) => GroupedItem[];
8
- export { preparedGroupedItems };
8
+ export declare const preparedGroupedItems: ({ attrTypes, filter, sortingFn }: Props) => GroupedItem[];
9
+ export {};
@@ -1,10 +1,10 @@
1
- import { curry, filter, map, pipe } from 'ramda';
1
+ import { curry, filter, map, pipe, sort } from 'ramda';
2
2
  var filterItems = curry(function (filterText, items) {
3
3
  return filter(function (item) { return (item.label || item.name).toLowerCase().includes(filterText.toLowerCase()); })(items);
4
4
  });
5
- var preparedGroupedItems = function (_a) {
6
- var attrTypes = _a.attrTypes, _b = _a.filter, filter = _b === void 0 ? '' : _b;
7
- return pipe(filterItems(filter), map(function (attrType) { return ({
5
+ export var preparedGroupedItems = function (_a) {
6
+ var attrTypes = _a.attrTypes, _b = _a.filter, filter = _b === void 0 ? '' : _b, sortingFn = _a.sortingFn;
7
+ return pipe(filterItems(filter), sort(sortingFn), map(function (attrType) { return ({
8
8
  item: {
9
9
  id: attrType.uri,
10
10
  label: attrType.label || attrType.name,
@@ -12,4 +12,3 @@ var preparedGroupedItems = function (_a) {
12
12
  }
13
13
  }); }))(attrTypes);
14
14
  };
15
- export { preparedGroupedItems };
@@ -1 +1 @@
1
- export { default } from "./MoreAttributesButton";
1
+ export { default } from './MoreAttributesButton';
@@ -1 +1 @@
1
- export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dense" | "icon" | "moreButton" | "buttonLabel" | "moreAttributes" | "popupContainer" | "moreAttributesPopup" | "subHeader" | "noResultsCaptionContainer">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"dense" | "icon" | "moreButton" | "buttonLabel" | "moreAttributes" | "popupContainer" | "moreAttributesPopup" | "subHeader" | "noResultsCaptionContainer">;
@@ -1,7 +1,10 @@
1
1
  import { useMemo } from 'react';
2
2
  import i18n from 'ui-i18n';
3
+ import { SortingStrategy } from '@reltio/mdm-sdk';
3
4
  import { flattenGroupedItemsData } from '../../../VirtualGroupedList/helpers';
4
5
  import { preparedGroupedItems } from './helpers';
6
+ import mdmModule from '@reltio/mdm-module';
7
+ import { useSelector } from 'react-redux';
5
8
  var GROUP_NAMES;
6
9
  (function (GROUP_NAMES) {
7
10
  GROUP_NAMES["parent"] = "parent";
@@ -10,7 +13,16 @@ var GROUP_NAMES;
10
13
  export var useMoreAttributesItems = function (_a) {
11
14
  var data = _a.data, parent = _a.parent, filter = _a.filter;
12
15
  var hasGroups = Boolean(parent);
13
- var preparedParentGroupItem = useMemo(function () { return (hasGroups ? preparedGroupedItems({ attrTypes: [parent], filter: filter }) : []); }, [hasGroups, parent, filter]);
16
+ var strategy = useSelector(mdmModule.selectors.getAttributesSortingStrategy);
17
+ var sortingFn = useMemo(function () {
18
+ switch (strategy) {
19
+ case SortingStrategy.ASC_BY_NAME:
20
+ return function (item1, item2) { var _a; return (_a = item1 === null || item1 === void 0 ? void 0 : item1.label) === null || _a === void 0 ? void 0 : _a.localeCompare(item2 === null || item2 === void 0 ? void 0 : item2.label); };
21
+ default:
22
+ return function (_item1, _item2) { return 0; };
23
+ }
24
+ }, [strategy]);
25
+ var preparedParentGroupItem = useMemo(function () { return (hasGroups ? preparedGroupedItems({ attrTypes: [parent], filter: filter, sortingFn: sortingFn }) : []); }, [hasGroups, parent, filter, sortingFn]);
14
26
  var parentGroup = useMemo(function () {
15
27
  return hasGroups && (preparedParentGroupItem === null || preparedParentGroupItem === void 0 ? void 0 : preparedParentGroupItem.length)
16
28
  ? [
@@ -27,9 +39,10 @@ export var useMoreAttributesItems = function (_a) {
27
39
  var preparedAttributesGroupItems = useMemo(function () {
28
40
  return preparedGroupedItems({
29
41
  attrTypes: data,
30
- filter: filter
42
+ filter: filter,
43
+ sortingFn: sortingFn
31
44
  });
32
- }, [data, filter]);
45
+ }, [data, filter, sortingFn]);
33
46
  var attributesGroup = useMemo(function () {
34
47
  return hasGroups && (preparedAttributesGroupItems === null || preparedAttributesGroupItems === void 0 ? void 0 : preparedAttributesGroupItems.length)
35
48
  ? [
@@ -43,10 +56,7 @@ export var useMoreAttributesItems = function (_a) {
43
56
  ]
44
57
  : preparedAttributesGroupItems;
45
58
  }, [hasGroups, preparedAttributesGroupItems]);
46
- var items = useMemo(function () { return flattenGroupedItemsData((parentGroup || []).concat(attributesGroup)); }, [
47
- parentGroup,
48
- attributesGroup
49
- ]);
59
+ var items = useMemo(function () { return flattenGroupedItemsData((parentGroup || []).concat(attributesGroup)); }, [parentGroup, attributesGroup]);
50
60
  var parentGroupLength = parentGroup.length;
51
61
  var attributesGroupLength = attributesGroup.length;
52
62
  return { items: items, hasGroups: hasGroups, parentGroupLength: parentGroupLength, attributesGroupLength: attributesGroupLength };
@@ -153,7 +153,7 @@ export var useCustomScripts = function (config) {
153
153
  url: fakeURL,
154
154
  method: options.method,
155
155
  headers: __assign(__assign({}, options.headers), { origin: 'ui', requestId: requestId, actionId: actionId }),
156
- data: options.body
156
+ data: options.body || options.data
157
157
  });
158
158
  }
159
159
  else {
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1389",
3
+ "version": "1.4.1391",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1389",
11
- "@reltio/mdm-sdk": "^1.4.1389",
10
+ "@reltio/mdm-module": "^1.4.1391",
11
+ "@reltio/mdm-sdk": "^1.4.1391",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",