@reltio/components 1.4.1976 → 1.4.1977
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/cjs/AttributesFiltersBuilder/AttributesFiltersBuilder.js +5 -10
- package/cjs/AttributesFiltersBuilder/helpers.d.ts +2 -4
- package/cjs/AttributesFiltersBuilder/helpers.js +1 -77
- package/cjs/helpers/attributesSelector.d.ts +4 -0
- package/cjs/helpers/attributesSelector.js +79 -0
- package/cjs/hooks/useFilterAutoFocus/index.d.ts +1 -0
- package/cjs/hooks/useFilterAutoFocus/index.js +5 -0
- package/cjs/hooks/useFilterAutoFocus/useFilterAutoFocus.d.ts +6 -0
- package/cjs/hooks/useFilterAutoFocus/useFilterAutoFocus.js +18 -0
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +10 -4
- package/esm/AttributesFiltersBuilder/AttributesFiltersBuilder.js +5 -10
- package/esm/AttributesFiltersBuilder/helpers.d.ts +2 -4
- package/esm/AttributesFiltersBuilder/helpers.js +0 -74
- package/esm/helpers/attributesSelector.d.ts +4 -0
- package/esm/helpers/attributesSelector.js +74 -0
- package/esm/hooks/useFilterAutoFocus/index.d.ts +1 -0
- package/esm/hooks/useFilterAutoFocus/index.js +1 -0
- package/esm/hooks/useFilterAutoFocus/useFilterAutoFocus.d.ts +6 -0
- package/esm/hooks/useFilterAutoFocus/useFilterAutoFocus.js +14 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +3 -0
- package/package.json +1 -1
|
@@ -47,12 +47,14 @@ var react_1 = __importStar(require("react"));
|
|
|
47
47
|
var ramda_1 = require("ramda");
|
|
48
48
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
49
49
|
var EmptyStub_1 = require("../EmptyStub");
|
|
50
|
+
var attributesSelector_1 = require("../helpers/attributesSelector");
|
|
50
51
|
var helpers_1 = require("./helpers");
|
|
51
52
|
var AttributesFilterSelector_1 = require("../AttributesFilterSelector");
|
|
52
53
|
var RowActions_1 = require("./components/RowActions");
|
|
53
54
|
var QueryBuilderRowsGroup_1 = require("../QueryBuilderRowsGroup");
|
|
54
55
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
55
56
|
var AttributeSelector_1 = require("./components/AttributeSelector");
|
|
57
|
+
var useFilterAutoFocus_1 = require("../hooks/useFilterAutoFocus");
|
|
56
58
|
var AttributesValuesEditor_1 = require("../AttributesValuesEditor");
|
|
57
59
|
var styles_1 = require("./styles");
|
|
58
60
|
var EMPTY_FILTER = { fieldName: null, filter: null, operator: mdm_sdk_1.SearchOperator.and, values: [] };
|
|
@@ -61,8 +63,6 @@ var AttributesFiltersBuilder = function (_a) {
|
|
|
61
63
|
var _d = components, CustomValuesEditor = _d.ValuesEditor, CustomFilterSelector = _d.FilterSelector, _e = _d.LogicalOperator, LogicalOperator = _e === void 0 ? EmptyStub_1.EmptyStub : _e;
|
|
62
64
|
var styles = (0, styles_1.useStyles)();
|
|
63
65
|
var actualFilters = (0, react_1.useRef)(filters);
|
|
64
|
-
var attributeFilterRef = (0, react_1.useRef)(null);
|
|
65
|
-
var lastAttributesCountRef = (0, react_1.useRef)(null);
|
|
66
66
|
var attributesCountRef = (0, react_1.useRef)(null);
|
|
67
67
|
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
68
68
|
actualFilters.current = filters;
|
|
@@ -75,20 +75,15 @@ var AttributesFiltersBuilder = function (_a) {
|
|
|
75
75
|
var currentEntityType = (0, react_1.useMemo)(function () {
|
|
76
76
|
var entityTypesUris = attributesTypesGroups.map(function (_a) {
|
|
77
77
|
var attributeTypes = _a.attributeTypes;
|
|
78
|
-
return (0,
|
|
78
|
+
return (0, attributesSelector_1.getOperationalTypeUriFromAttrTypes)(attributeTypes);
|
|
79
79
|
});
|
|
80
80
|
var closestEntityTypeAncestorUri = (0, mdm_sdk_1.findClosestCommonAncestor)(metadata, entityTypesUris);
|
|
81
81
|
return (0, mdm_sdk_1.getEntityType)(metadata, closestEntityTypeAncestorUri);
|
|
82
82
|
}, [attributesTypesGroups, metadata]);
|
|
83
|
-
var attributeSelectorItemsGroups = (0, react_1.useMemo)(function () { return (0,
|
|
83
|
+
var attributeSelectorItemsGroups = (0, react_1.useMemo)(function () { return (0, attributesSelector_1.getAttributeSelectorItems)(metadata, attributesTypesGroups, attributesTypesGroupFilter); }, [attributesTypesGroups, metadata]);
|
|
84
84
|
var rowsData = (0, react_1.useMemo)(function () { return (filters.length ? (0, helpers_1.getRowsDataFromFilters)(filters, attributeSelectorItemsGroups) : []); }, [attributeSelectorItemsGroups, filters]);
|
|
85
|
+
var _f = (0, useFilterAutoFocus_1.useFilterAutoFocus)(rowsData), attributeFilterRef = _f.attributeFilterRef, lastAttributesCountRef = _f.lastAttributesCountRef;
|
|
85
86
|
attributesCountRef.current = rowsData.length;
|
|
86
|
-
(0, react_1.useEffect)(function () {
|
|
87
|
-
if (attributeFilterRef.current && lastAttributesCountRef.current !== attributesCountRef.current) {
|
|
88
|
-
attributeFilterRef.current.querySelector('input').focus();
|
|
89
|
-
lastAttributesCountRef.current = null;
|
|
90
|
-
}
|
|
91
|
-
}, [rowsData.length]);
|
|
92
87
|
var handleAttributeSelectorOnOpen = (0, react_1.useCallback)(function () {
|
|
93
88
|
lastAttributesCountRef.current = rowsData.length;
|
|
94
89
|
}, [rowsData.length]);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AttributeSelectorItem, AttributeSelectorItemsGroup
|
|
1
|
+
import { SearchFilter } from '@reltio/mdm-sdk';
|
|
2
|
+
import { AttributeSelectorItem, AttributeSelectorItemsGroup } from '../types';
|
|
3
3
|
import { FilterOption } from './types';
|
|
4
|
-
export declare const getAttributeSelectorItems: (metadata: Metadata, attributesTypesGroups: AttributesTypesGroup[], attributesTypesGroupFilter: (metadata: Metadata, attributeSelectorItemsGroup: AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[];
|
|
5
4
|
export declare const findValue: (options: FilterOption[], filter: string) => FilterOption;
|
|
6
5
|
export declare const getRowsDataFromFilters: (filters: SearchFilter[], attributesGroupArr: AttributeSelectorItemsGroup[]) => {
|
|
7
6
|
attribute: AttributeSelectorItem;
|
|
@@ -10,4 +9,3 @@ export declare const getRowsDataFromFilters: (filters: SearchFilter[], attribute
|
|
|
10
9
|
id: number;
|
|
11
10
|
values: import("@reltio/mdm-sdk").SearchValue[];
|
|
12
11
|
}[];
|
|
13
|
-
export declare const getOperationalTypeUriFromAttrTypes: (attributeTypes: AttributeType[]) => any;
|
|
@@ -1,77 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
-
if (ar || !(i in from)) {
|
|
16
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
-
ar[i] = from[i];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
-
};
|
|
22
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
24
|
-
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
25
|
-
var ramda_1 = require("ramda");
|
|
26
|
-
var createAttributeItem = function (metadata, attrType, operationalTypeUri, parents) {
|
|
27
|
-
var title = attrType.label || attrType.name;
|
|
28
|
-
if ((0, mdm_sdk_1.isSpecialAttribute)(attrType)) {
|
|
29
|
-
return { attrType: attrType, title: title, fieldName: attrType.name };
|
|
30
|
-
}
|
|
31
|
-
if ((0, mdm_sdk_1.isInteractionTypeUri)(operationalTypeUri)) {
|
|
32
|
-
return { attrType: attrType, title: title, fieldName: (0, mdm_sdk_1.attributeUriToSearchUri)(attrType.uri, parents) };
|
|
33
|
-
}
|
|
34
|
-
var entityTypeLabel = (0, mdm_sdk_1.getEntityTypeLabel)(metadata, { type: operationalTypeUri });
|
|
35
|
-
return {
|
|
36
|
-
attrType: attrType,
|
|
37
|
-
title: title,
|
|
38
|
-
entityTypeUri: operationalTypeUri,
|
|
39
|
-
pathToTitle: Array.isArray(parents)
|
|
40
|
-
? __spreadArray(__spreadArray([entityTypeLabel], (0, ramda_1.chain)((0, ramda_1.prop)('label'), parents), true), [title], false) : [entityTypeLabel, title],
|
|
41
|
-
fieldName: (0, mdm_sdk_1.attributeUriToSearchUri)(attrType.uri, parents)
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
var createAttributesConfig = function (metadata, attrNode, operationalTypeUri, parents) {
|
|
45
|
-
if (parents === void 0) { parents = []; }
|
|
46
|
-
var resConfig = __assign(__assign({}, createAttributeItem(metadata, attrNode, operationalTypeUri, parents)), { uri: attrNode.uri });
|
|
47
|
-
var children = attrNode.children
|
|
48
|
-
? attrNode.children.map(function (childNode) {
|
|
49
|
-
return createAttributesConfig(metadata, childNode, operationalTypeUri, parents.concat(attrNode));
|
|
50
|
-
})
|
|
51
|
-
: [];
|
|
52
|
-
if (children.length) {
|
|
53
|
-
resConfig.children = children;
|
|
54
|
-
}
|
|
55
|
-
return resConfig;
|
|
56
|
-
};
|
|
57
|
-
var getAttributeSelectorItems = function (metadata, attributesTypesGroups, attributesTypesGroupFilter) {
|
|
58
|
-
var attributeSelectorItemsGroup = attributesTypesGroups.map(function (_a) {
|
|
59
|
-
var id = _a.id, title = _a.title, attributeTypes = _a.attributeTypes;
|
|
60
|
-
var operationalTypeUri = (0, exports.getOperationalTypeUriFromAttrTypes)(attributeTypes);
|
|
61
|
-
return {
|
|
62
|
-
id: id,
|
|
63
|
-
title: title,
|
|
64
|
-
attributes: (0, mdm_sdk_1.getAttributesTreeFromAttributes)(attributeTypes, metadata).map(function (attrNode) {
|
|
65
|
-
var uri = (0, mdm_sdk_1.isSpecialAttribute)(attrNode) ? null : operationalTypeUri;
|
|
66
|
-
return createAttributesConfig(metadata, attrNode, uri);
|
|
67
|
-
})
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
return attributesTypesGroupFilter
|
|
71
|
-
? attributesTypesGroupFilter(metadata, attributeSelectorItemsGroup)
|
|
72
|
-
: attributeSelectorItemsGroup;
|
|
73
|
-
};
|
|
74
|
-
exports.getAttributeSelectorItems = getAttributeSelectorItems;
|
|
3
|
+
exports.getRowsDataFromFilters = exports.findValue = void 0;
|
|
75
4
|
var findAttributeSelectorItem = function (fieldName, attributesGroup) {
|
|
76
5
|
var attrGroup;
|
|
77
6
|
var _loop_1 = function (attributesGroupItem) {
|
|
@@ -111,8 +40,3 @@ var getRowsDataFromFilters = function (filters, attributesGroupArr) {
|
|
|
111
40
|
});
|
|
112
41
|
};
|
|
113
42
|
exports.getRowsDataFromFilters = getRowsDataFromFilters;
|
|
114
|
-
var getOperationalTypeUriFromAttrTypes = function (attributeTypes) {
|
|
115
|
-
var regularAttribute = (0, mdm_sdk_1.findRegularAttribute)(attributeTypes);
|
|
116
|
-
return regularAttribute ? (0, mdm_sdk_1.getBaseUri)(regularAttribute.uri) : null;
|
|
117
|
-
};
|
|
118
|
-
exports.getOperationalTypeUriFromAttrTypes = getOperationalTypeUriFromAttrTypes;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AttributeType, Metadata } from '@reltio/mdm-sdk';
|
|
2
|
+
import { AttributeSelectorItemsGroup, AttributesTypesGroup } from '../types';
|
|
3
|
+
export declare const getOperationalTypeUriFromAttrTypes: (attributeTypes: AttributeType[]) => any;
|
|
4
|
+
export declare const getAttributeSelectorItems: (metadata: Metadata, attributesTypesGroups: AttributesTypesGroup[], attributesTypesGroupFilter: (metadata: Metadata, attributeSelectorItemsGroup: AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.getAttributeSelectorItems = exports.getOperationalTypeUriFromAttrTypes = void 0;
|
|
24
|
+
var ramda_1 = require("ramda");
|
|
25
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
26
|
+
var createAttributeItem = function (metadata, attrType, operationalTypeUri, parents) {
|
|
27
|
+
var title = attrType.label || attrType.name;
|
|
28
|
+
if ((0, mdm_sdk_1.isSpecialAttribute)(attrType)) {
|
|
29
|
+
return { attrType: attrType, title: title, fieldName: attrType.name };
|
|
30
|
+
}
|
|
31
|
+
if ((0, mdm_sdk_1.isInteractionTypeUri)(operationalTypeUri)) {
|
|
32
|
+
return { attrType: attrType, title: title, fieldName: (0, mdm_sdk_1.attributeUriToSearchUri)(attrType.uri, parents) };
|
|
33
|
+
}
|
|
34
|
+
var entityTypeLabel = (0, mdm_sdk_1.getEntityTypeLabel)(metadata, { type: operationalTypeUri });
|
|
35
|
+
return {
|
|
36
|
+
attrType: attrType,
|
|
37
|
+
title: title,
|
|
38
|
+
entityTypeUri: operationalTypeUri,
|
|
39
|
+
pathToTitle: Array.isArray(parents)
|
|
40
|
+
? __spreadArray(__spreadArray([entityTypeLabel], (0, ramda_1.chain)((0, ramda_1.prop)('label'), parents), true), [title], false) : [entityTypeLabel, title],
|
|
41
|
+
fieldName: (0, mdm_sdk_1.attributeUriToSearchUri)(attrType.uri, parents)
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
var createAttributesConfig = function (metadata, attrNode, operationalTypeUri, parents) {
|
|
45
|
+
if (parents === void 0) { parents = []; }
|
|
46
|
+
var resConfig = __assign(__assign({}, createAttributeItem(metadata, attrNode, operationalTypeUri, parents)), { uri: attrNode.uri });
|
|
47
|
+
var children = attrNode.children
|
|
48
|
+
? attrNode.children.map(function (childNode) {
|
|
49
|
+
return createAttributesConfig(metadata, childNode, operationalTypeUri, parents.concat(attrNode));
|
|
50
|
+
})
|
|
51
|
+
: [];
|
|
52
|
+
if (children.length) {
|
|
53
|
+
resConfig.children = children;
|
|
54
|
+
}
|
|
55
|
+
return resConfig;
|
|
56
|
+
};
|
|
57
|
+
var getOperationalTypeUriFromAttrTypes = function (attributeTypes) {
|
|
58
|
+
var regularAttribute = (0, mdm_sdk_1.findRegularAttribute)(attributeTypes);
|
|
59
|
+
return regularAttribute ? (0, mdm_sdk_1.getBaseUri)(regularAttribute.uri) : null;
|
|
60
|
+
};
|
|
61
|
+
exports.getOperationalTypeUriFromAttrTypes = getOperationalTypeUriFromAttrTypes;
|
|
62
|
+
var getAttributeSelectorItems = function (metadata, attributesTypesGroups, attributesTypesGroupFilter) {
|
|
63
|
+
var attributeSelectorItemsGroup = attributesTypesGroups.map(function (_a) {
|
|
64
|
+
var id = _a.id, title = _a.title, attributeTypes = _a.attributeTypes;
|
|
65
|
+
var operationalTypeUri = (0, exports.getOperationalTypeUriFromAttrTypes)(attributeTypes);
|
|
66
|
+
return {
|
|
67
|
+
id: id,
|
|
68
|
+
title: title,
|
|
69
|
+
attributes: (0, mdm_sdk_1.getAttributesTreeFromAttributes)(attributeTypes, metadata).map(function (attrNode) {
|
|
70
|
+
var uri = (0, mdm_sdk_1.isSpecialAttribute)(attrNode) ? null : operationalTypeUri;
|
|
71
|
+
return createAttributesConfig(metadata, attrNode, uri);
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
return attributesTypesGroupFilter
|
|
76
|
+
? attributesTypesGroupFilter(metadata, attributeSelectorItemsGroup)
|
|
77
|
+
: attributeSelectorItemsGroup;
|
|
78
|
+
};
|
|
79
|
+
exports.getAttributeSelectorItems = getAttributeSelectorItems;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFilterAutoFocus } from './useFilterAutoFocus';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFilterAutoFocus = void 0;
|
|
4
|
+
var useFilterAutoFocus_1 = require("./useFilterAutoFocus");
|
|
5
|
+
Object.defineProperty(exports, "useFilterAutoFocus", { enumerable: true, get: function () { return useFilterAutoFocus_1.useFilterAutoFocus; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const useFilterAutoFocus: (rowsData: Record<string, unknown>[]) => {
|
|
3
|
+
attributeFilterRef: import("react").MutableRefObject<any>;
|
|
4
|
+
lastAttributesCountRef: import("react").MutableRefObject<any>;
|
|
5
|
+
attributesCountRef: import("react").MutableRefObject<any>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFilterAutoFocus = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var useFilterAutoFocus = function (rowsData) {
|
|
6
|
+
var attributeFilterRef = (0, react_1.useRef)(null);
|
|
7
|
+
var lastAttributesCountRef = (0, react_1.useRef)(null);
|
|
8
|
+
var attributesCountRef = (0, react_1.useRef)(null);
|
|
9
|
+
attributesCountRef.current = rowsData.length;
|
|
10
|
+
(0, react_1.useEffect)(function () {
|
|
11
|
+
if (attributeFilterRef.current && lastAttributesCountRef.current !== attributesCountRef.current) {
|
|
12
|
+
attributeFilterRef.current.querySelector('input').focus();
|
|
13
|
+
lastAttributesCountRef.current = null;
|
|
14
|
+
}
|
|
15
|
+
}, [rowsData.length]);
|
|
16
|
+
return { attributeFilterRef: attributeFilterRef, lastAttributesCountRef: lastAttributesCountRef, attributesCountRef: attributesCountRef };
|
|
17
|
+
};
|
|
18
|
+
exports.useFilterAutoFocus = useFilterAutoFocus;
|
package/cjs/index.d.ts
CHANGED
|
@@ -178,6 +178,7 @@ export { RelationEditor } from './RelationEditor';
|
|
|
178
178
|
export { GaugeChart } from './GaugeChart';
|
|
179
179
|
export { UpSetChart } from './UpSetChart';
|
|
180
180
|
export { DateRangeSelector } from './DateRangeSelector';
|
|
181
|
+
export { MetadataTypesSelector } from './MetadataTypesSelector';
|
|
181
182
|
export { withTooltip } from './HOCs/withTooltip';
|
|
182
183
|
export { withAsyncMount } from './HOCs/withAsyncMount';
|
|
183
184
|
export { withDragHandle } from './HOCs/withDragHandle';
|
|
@@ -267,11 +268,13 @@ export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
|
|
267
268
|
export { useMaskedAttribute } from './hooks/useMaskedAttribute';
|
|
268
269
|
export { useMarkers, resolveMarkers } from './hooks/useMarkers';
|
|
269
270
|
export { useSegmentationRequest } from './hooks/useSegmentationRequest';
|
|
271
|
+
export { useFilterAutoFocus } from './hooks/useFilterAutoFocus';
|
|
270
272
|
export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
271
273
|
export { enrichDataWithPercents } from './helpers/charts';
|
|
272
274
|
export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
|
|
273
275
|
export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
|
|
274
276
|
export { mergeClasses } from './helpers/classes';
|
|
277
|
+
export { getAttributeSelectorItems } from './helpers/attributesSelector';
|
|
275
278
|
export type { AttributeFiltersComponentProps } from './AttributesFiltersBuilder';
|
|
276
279
|
export type { ChartData } from './types/charts';
|
|
277
280
|
export type { AddInlineAttributeEvent, DeleteInlineAttributeEvent, EditInlineAttributeEvent, IgnoreInlineAttributeEvent, PinInlineAttributeEvent } from './types/inlineAttributes';
|
package/cjs/index.js
CHANGED
|
@@ -17,10 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.NestedAttributeEditor = exports.NestedAttribute = exports.MoreAttributesButton = exports.InlineReferenceAttribute = exports.InlineNestedAttribute = exports.InlineImageAttribute = exports.InlineAttributesPager = exports.InfoIcon = exports.EditableImageAttributesLine = exports.FilterButton = exports.FacetViewHeader = exports.ExpandedValueTooltip = exports.EntitySelector = exports.EntityCreator = exports.AttributesPager = exports.AttributesList = exports.EditableAttribute = exports.DropDownMenuButton = exports.DescriptionIcon = exports.DefaultCellValueRenderer = exports.ControlAttributeIcon = exports.ColumnsSettingsPopup = exports.ColumnsSettings = exports.ColorBar = exports.CollapseRowButton = exports.BasicChartsFactory = exports.ChartsFactory = exports.CardinalityMessage = exports.BranchDecorator = exports.BasicViewHeader = exports.BasicViewContent = exports.BasicView = exports.BasicTablePagination = exports.basicTableViewState = exports.BasicTable = exports.BasicAttributeSelector = exports.BarChart = exports.AvatarWithFallback = exports.AutoSizeList = exports.AttributesView = exports.AttributesValuesEditor = exports.AttributesFiltersButton = exports.AttributesFiltersBuilder = exports.AttributesFilterSelector = exports.AttributesErrorsPanel = exports.AttributeListItem = exports.AttributeGroupIcon = exports.ArrowExpandButton = exports.ActionsPanel = exports.ActionButton = void 0;
|
|
18
18
|
exports.ConnectionEditor = exports.DropDownSelector = exports.ReactSelectOptionWithCheckIcon = exports.ReactSelectMenuWithPopper = exports.ReactSelectMenuList = exports.ReactSelectLoadMoreButton = exports.ReactSelectDropdownIndicatorWithIconButton = exports.ReactSelectDropdownIndicator = exports.Highlighter = exports.HierarchyNodeTitle = exports.HierarchicalAttributeTooltip = exports.HideOnShrink = exports.ExpandableSearchInput = exports.ErrorPopup = exports.ErrorBoundary = exports.EntityUriLink = exports.EntityTypesSelector = exports.EntityTypeIcon = exports.EntityTypeBadge = exports.EntityAvatar = exports.EMPTY_STATE_VARIANTS = exports.EMPTY_STATE_ICONS = exports.EmptyState = exports.Drawer = exports.DataTypeValue = exports.DataTenantBadge = exports.ConnectionRelationTypeSelector = exports.CollaborationItem = exports.ConfirmationDialog = exports.CommentsContainer = exports.ColoredSourceIcon = exports.CollapseButton = exports.TreeChart = exports.TableWithBars = exports.SourceIcon = exports.SmallIconButtonWithTooltip = exports.SmallIconButton = exports.SimpleAttributeEditor = exports.SimpleAttribute = exports.RowCellAutoSizer = exports.RelationTypeSelector = exports.ReferenceAttributeEditor = exports.ReferenceAttribute = exports.ImageAttributesLine = exports.ReadOnlyAttributesPager = exports.ReadOnlyAttributesList = exports.ReadOnlyAttribute = exports.ReadOnlyAttributeValuesBlock = exports.PieChart = exports.OvIcon = void 0;
|
|
19
19
|
exports.MultipleInput = exports.ModeSwitcherSelect = exports.ModeSwitcher = exports.TransitiveMatchBlock = exports.SimpleMatchRulesBuilder = exports.SimpleMatchRulesBlock = exports.SimpleMatchRules = exports.MatchRulesBlock = exports.LoadingSpinner = exports.Link = exports.LinearLoadIndicator = exports.ImportButton = exports.ReadableSearchQueryBuilder = exports.ReadableSearchQuery = exports.LogicOperator = exports.TableSkeleton = exports.StepNavigation = exports.TenantLabel = exports.RelevanceScoreBadge = exports.RequiredMark = exports.SettingsMenu = exports.TenantsDropDownSelector = exports.TenantIcon = exports.SourceSystemsSelector = exports.MatchRulesSelector = exports.MultiValueSelector = exports.ProfilesList = exports.NotMatchButton = exports.MergeButton = exports.ProfileMatchCard = exports.ImageGalleryDialog = exports.RelationTypesSelector = exports.ScreenProfileBand = exports.ProfileBandNavigation = exports.EmptyStub = exports.SaveSegmentDialog = exports.MaskingSwitcher = exports.FileTypeEditor = exports.EmptySearchResult = exports.DropDownEditor = exports.FilterValueEditor = exports.MultiValueChip = exports.TextEditor = exports.DateRangeEditor = exports.NumberEditor = exports.DataTypeValueEditor = exports.DateEditor = exports.ErrorWrapper = exports.ErrorMessage = exports.ConfigureColumnsPopup = void 0;
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.FakeMouseEvent = exports.rerenderWrapper = exports.mockElementSizes = exports.fixClicksOnResizablePanes = exports.mockBasicTableSizing = exports.getMuiIconsByName = exports.getMuiIconByName = exports.delayPromise = exports.deepFreeze = exports.awaitMockPromises = exports.TestStylesProvider = exports.TestPerspectivesSettingsProvider = exports.mergeClasses = exports.isControlOrCommandPressed = exports.getValue = exports.getChecked = exports.showErrorMessage = exports.showDefaultErrorMessage = exports.enrichDataWithPercents = exports.defaultRenderRowCell = exports.defaultGetRowCellHeight = exports.columnFilterToMdmFilter = exports.buildColumnsSizeById = exports.buildColumnsFilter = exports.useSegmentationRequest = void 0;
|
|
20
|
+
exports.PopupBoundariesContext = exports.HistoryDiffContext = exports.AsyncMountContext = exports.MdmModuleProvider = exports.withTableContext = exports.withFilterAtBottom = exports.withPercents = exports.withContext = exports.withDateRangeSelector = exports.withDragHandle = exports.withAsyncMount = exports.withTooltip = exports.MetadataTypesSelector = exports.DateRangeSelector = exports.UpSetChart = exports.GaugeChart = exports.RelationEditor = exports.ReltioMap = exports.Marginator = exports.LightArrowTooltip = exports.ScrollableTabs = exports.VirtualGroupedList = exports.ViewMoreToggle = exports.VerticalHeadingsTable = exports.VerticalDivider = exports.AttributeTitle = exports.Spacer = exports.SimpleDropDownSelector = exports.SidePanelContentHeader = exports.SidePanel = exports.SidePanelEmptyState = exports.SideButtonsPanel = exports.SelectorWithOnlyOptionAutoSelect = exports.SelectionPopup = exports.WhiteSearchInput = exports.SearchInput = exports.ProfileResizablePanes = exports.ResizablePanes = exports.ReltioGridLayout = exports.RCTree = exports.reactSortableTreeHelpers = exports.ReactSortableTree = exports.MultiSelect = exports.QueryBuilderRowsGroup = exports.QueryBuilderRow = exports.ProfileCard = exports.ProfileBand = exports.PotentialMatchReviewCard = exports.PopupWithArrow = exports.Popper = void 0;
|
|
21
|
+
exports.useReloadData = exports.ReloadDataProvider = exports.useAttributeValueConfigPermissions = exports.ConfigPermissionsContextProvider = exports.ConfigPermissionsContext = exports.useActionsHook = exports.ActionsHookProvider = exports.PageRequestsAbortingContext = exports.DependentLookupAutopopulationContext = exports.FeaturesContext = exports.LabelsContext = exports.UrlGeneratorsContext = exports.isHighlightedAttributeType = exports.isHighlightedErrorType = exports.ScrollType = exports.ScrollToElementProvider = exports.ScrollToElementContext = exports.SearchValueContext = exports.InterceptHandlersContext = exports.HighlightedValuesContext = exports.SnackbarContext = exports.SearchFiltersContext = exports.useReloadFacet = exports.ReloadFacetProvider = exports.useReloadAllFacets = exports.SandboxAPIContext = exports.EntityContext = exports.RelatedObjectUrisContext = exports.WorkflowTasksContext = exports.useEntityLoadingIndication = exports.EntityLoadingIndicationProvider = exports.EntityMarkerContext = exports.useAttributeExpanded = exports.ExpandedAttributesProvider = exports.useHighlightedCrosswalks = exports.useCrosswalkHighlight = exports.useCrosswalkFocus = exports.useCrosswalkColor = exports.CrosswalksDisplayProvider = exports.EntitiesMapContext = exports.IdContext = exports.ProfilePerspectiveViewContext = exports.usePerspectivesSettings = exports.PerspectivesSettingsContext = exports.PivotingAttributeContext = exports.UsersContext = exports.InitialCollaborationContextValue = exports.CollaborationContextProvider = exports.CollaborationContext = exports.BlockImageGalleryDialogContext = void 0;
|
|
22
|
+
exports.useMarkers = exports.useMaskedAttribute = exports.useKeyboardNavigation = exports.useDynamicRowCellHeight = exports.useClickableStyle = exports.BasicTableCellRenderer = exports.useBasicTableCellRenderer = exports.useHiddenAttributes = exports.useSavedSearchesRequest = exports.useRequestDCRReview = exports.useAutoFocus = exports.useExpandInvalidRelations = exports.useLayoutResetter = exports.useIsMountedRef = exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = exports.usePagingSimulator = exports.useMatchesLoader = exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.useAPI = exports.useActions = exports.useMatchesColumnsData = exports.useScrollToAttributeError = exports.ProfileTablesContext = exports.HiddenAttributesContext = exports.BasicTableContext = exports.BasicTableRowCollapseContext = exports.useDeleteUnmaskedAttributeForRelation = exports.useUnmaskedAttributeValue = exports.useUnmaskAttributeValue = exports.useMaskAttributeValue = exports.MaskedAttributesProvider = exports.SegmentationContext = void 0;
|
|
23
|
+
exports.FakeMouseEvent = exports.rerenderWrapper = exports.mockElementSizes = exports.fixClicksOnResizablePanes = exports.mockBasicTableSizing = exports.getMuiIconsByName = exports.getMuiIconByName = exports.delayPromise = exports.deepFreeze = exports.awaitMockPromises = exports.TestStylesProvider = exports.TestPerspectivesSettingsProvider = exports.getAttributeSelectorItems = exports.mergeClasses = exports.isControlOrCommandPressed = exports.getValue = exports.getChecked = exports.showErrorMessage = exports.showDefaultErrorMessage = exports.enrichDataWithPercents = exports.defaultRenderRowCell = exports.defaultGetRowCellHeight = exports.columnFilterToMdmFilter = exports.buildColumnsSizeById = exports.buildColumnsFilter = exports.useFilterAutoFocus = exports.useSegmentationRequest = exports.resolveMarkers = void 0;
|
|
24
24
|
// components
|
|
25
25
|
var ActionButton_1 = require("./ActionButton");
|
|
26
26
|
Object.defineProperty(exports, "ActionButton", { enumerable: true, get: function () { return ActionButton_1.ActionButton; } });
|
|
@@ -389,6 +389,8 @@ var UpSetChart_1 = require("./UpSetChart");
|
|
|
389
389
|
Object.defineProperty(exports, "UpSetChart", { enumerable: true, get: function () { return UpSetChart_1.UpSetChart; } });
|
|
390
390
|
var DateRangeSelector_1 = require("./DateRangeSelector");
|
|
391
391
|
Object.defineProperty(exports, "DateRangeSelector", { enumerable: true, get: function () { return DateRangeSelector_1.DateRangeSelector; } });
|
|
392
|
+
var MetadataTypesSelector_1 = require("./MetadataTypesSelector");
|
|
393
|
+
Object.defineProperty(exports, "MetadataTypesSelector", { enumerable: true, get: function () { return MetadataTypesSelector_1.MetadataTypesSelector; } });
|
|
392
394
|
// HOCs
|
|
393
395
|
var withTooltip_1 = require("./HOCs/withTooltip");
|
|
394
396
|
Object.defineProperty(exports, "withTooltip", { enumerable: true, get: function () { return withTooltip_1.withTooltip; } });
|
|
@@ -595,6 +597,8 @@ Object.defineProperty(exports, "useMarkers", { enumerable: true, get: function (
|
|
|
595
597
|
Object.defineProperty(exports, "resolveMarkers", { enumerable: true, get: function () { return useMarkers_1.resolveMarkers; } });
|
|
596
598
|
var useSegmentationRequest_1 = require("./hooks/useSegmentationRequest");
|
|
597
599
|
Object.defineProperty(exports, "useSegmentationRequest", { enumerable: true, get: function () { return useSegmentationRequest_1.useSegmentationRequest; } });
|
|
600
|
+
var useFilterAutoFocus_1 = require("./hooks/useFilterAutoFocus");
|
|
601
|
+
Object.defineProperty(exports, "useFilterAutoFocus", { enumerable: true, get: function () { return useFilterAutoFocus_1.useFilterAutoFocus; } });
|
|
598
602
|
// helpers
|
|
599
603
|
var basicTable_1 = require("./helpers/basicTable");
|
|
600
604
|
Object.defineProperty(exports, "buildColumnsFilter", { enumerable: true, get: function () { return basicTable_1.buildColumnsFilter; } });
|
|
@@ -613,6 +617,8 @@ Object.defineProperty(exports, "getValue", { enumerable: true, get: function ()
|
|
|
613
617
|
Object.defineProperty(exports, "isControlOrCommandPressed", { enumerable: true, get: function () { return events_1.isControlOrCommandPressed; } });
|
|
614
618
|
var classes_1 = require("./helpers/classes");
|
|
615
619
|
Object.defineProperty(exports, "mergeClasses", { enumerable: true, get: function () { return classes_1.mergeClasses; } });
|
|
620
|
+
var attributesSelector_1 = require("./helpers/attributesSelector");
|
|
621
|
+
Object.defineProperty(exports, "getAttributeSelectorItems", { enumerable: true, get: function () { return attributesSelector_1.getAttributeSelectorItems; } });
|
|
616
622
|
__exportStar(require("./types/preferences"), exports);
|
|
617
623
|
__exportStar(require("./types"), exports);
|
|
618
624
|
// constants
|
|
@@ -18,16 +18,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
-
import React, { useCallback, useRef, useMemo,
|
|
21
|
+
import React, { useCallback, useRef, useMemo, memo } from 'react';
|
|
22
22
|
import { always, evolve } from 'ramda';
|
|
23
23
|
import { SearchOperator, findClosestCommonAncestor, getEntityType } from '@reltio/mdm-sdk';
|
|
24
24
|
import { EmptyStub } from '../EmptyStub';
|
|
25
|
-
import { getAttributeSelectorItems, getOperationalTypeUriFromAttrTypes
|
|
25
|
+
import { getAttributeSelectorItems, getOperationalTypeUriFromAttrTypes } from '../helpers/attributesSelector';
|
|
26
|
+
import { getRowsDataFromFilters } from './helpers';
|
|
26
27
|
import { AttributesFilterSelector } from '../AttributesFilterSelector';
|
|
27
28
|
import { RowActions } from './components/RowActions';
|
|
28
29
|
import { QueryBuilderRowsGroup } from '../QueryBuilderRowsGroup';
|
|
29
30
|
import { useMdmMetadata } from '../contexts/MdmModuleContext';
|
|
30
31
|
import { AttributeSelector } from './components/AttributeSelector';
|
|
32
|
+
import { useFilterAutoFocus } from '../hooks/useFilterAutoFocus';
|
|
31
33
|
import { AttributesValuesEditor } from '../AttributesValuesEditor';
|
|
32
34
|
import { useStyles } from './styles';
|
|
33
35
|
var EMPTY_FILTER = { fieldName: null, filter: null, operator: SearchOperator.and, values: [] };
|
|
@@ -36,8 +38,6 @@ var AttributesFiltersBuilder = function (_a) {
|
|
|
36
38
|
var _d = components, CustomValuesEditor = _d.ValuesEditor, CustomFilterSelector = _d.FilterSelector, _e = _d.LogicalOperator, LogicalOperator = _e === void 0 ? EmptyStub : _e;
|
|
37
39
|
var styles = useStyles();
|
|
38
40
|
var actualFilters = useRef(filters);
|
|
39
|
-
var attributeFilterRef = useRef(null);
|
|
40
|
-
var lastAttributesCountRef = useRef(null);
|
|
41
41
|
var attributesCountRef = useRef(null);
|
|
42
42
|
var metadata = useMdmMetadata();
|
|
43
43
|
actualFilters.current = filters;
|
|
@@ -57,13 +57,8 @@ var AttributesFiltersBuilder = function (_a) {
|
|
|
57
57
|
}, [attributesTypesGroups, metadata]);
|
|
58
58
|
var attributeSelectorItemsGroups = useMemo(function () { return getAttributeSelectorItems(metadata, attributesTypesGroups, attributesTypesGroupFilter); }, [attributesTypesGroups, metadata]);
|
|
59
59
|
var rowsData = useMemo(function () { return (filters.length ? getRowsDataFromFilters(filters, attributeSelectorItemsGroups) : []); }, [attributeSelectorItemsGroups, filters]);
|
|
60
|
+
var _f = useFilterAutoFocus(rowsData), attributeFilterRef = _f.attributeFilterRef, lastAttributesCountRef = _f.lastAttributesCountRef;
|
|
60
61
|
attributesCountRef.current = rowsData.length;
|
|
61
|
-
useEffect(function () {
|
|
62
|
-
if (attributeFilterRef.current && lastAttributesCountRef.current !== attributesCountRef.current) {
|
|
63
|
-
attributeFilterRef.current.querySelector('input').focus();
|
|
64
|
-
lastAttributesCountRef.current = null;
|
|
65
|
-
}
|
|
66
|
-
}, [rowsData.length]);
|
|
67
62
|
var handleAttributeSelectorOnOpen = useCallback(function () {
|
|
68
63
|
lastAttributesCountRef.current = rowsData.length;
|
|
69
64
|
}, [rowsData.length]);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AttributeSelectorItem, AttributeSelectorItemsGroup
|
|
1
|
+
import { SearchFilter } from '@reltio/mdm-sdk';
|
|
2
|
+
import { AttributeSelectorItem, AttributeSelectorItemsGroup } from '../types';
|
|
3
3
|
import { FilterOption } from './types';
|
|
4
|
-
export declare const getAttributeSelectorItems: (metadata: Metadata, attributesTypesGroups: AttributesTypesGroup[], attributesTypesGroupFilter: (metadata: Metadata, attributeSelectorItemsGroup: AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[];
|
|
5
4
|
export declare const findValue: (options: FilterOption[], filter: string) => FilterOption;
|
|
6
5
|
export declare const getRowsDataFromFilters: (filters: SearchFilter[], attributesGroupArr: AttributeSelectorItemsGroup[]) => {
|
|
7
6
|
attribute: AttributeSelectorItem;
|
|
@@ -10,4 +9,3 @@ export declare const getRowsDataFromFilters: (filters: SearchFilter[], attribute
|
|
|
10
9
|
id: number;
|
|
11
10
|
values: import("@reltio/mdm-sdk").SearchValue[];
|
|
12
11
|
}[];
|
|
13
|
-
export declare const getOperationalTypeUriFromAttrTypes: (attributeTypes: AttributeType[]) => any;
|
|
@@ -1,73 +1,3 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
|
-
import { getAttributesTreeFromAttributes, attributeUriToSearchUri, isSpecialAttribute, getBaseUri, getEntityTypeLabel, findRegularAttribute, isInteractionTypeUri } from '@reltio/mdm-sdk';
|
|
22
|
-
import { chain, prop } from 'ramda';
|
|
23
|
-
var createAttributeItem = function (metadata, attrType, operationalTypeUri, parents) {
|
|
24
|
-
var title = attrType.label || attrType.name;
|
|
25
|
-
if (isSpecialAttribute(attrType)) {
|
|
26
|
-
return { attrType: attrType, title: title, fieldName: attrType.name };
|
|
27
|
-
}
|
|
28
|
-
if (isInteractionTypeUri(operationalTypeUri)) {
|
|
29
|
-
return { attrType: attrType, title: title, fieldName: attributeUriToSearchUri(attrType.uri, parents) };
|
|
30
|
-
}
|
|
31
|
-
var entityTypeLabel = getEntityTypeLabel(metadata, { type: operationalTypeUri });
|
|
32
|
-
return {
|
|
33
|
-
attrType: attrType,
|
|
34
|
-
title: title,
|
|
35
|
-
entityTypeUri: operationalTypeUri,
|
|
36
|
-
pathToTitle: Array.isArray(parents)
|
|
37
|
-
? __spreadArray(__spreadArray([entityTypeLabel], chain(prop('label'), parents), true), [title], false) : [entityTypeLabel, title],
|
|
38
|
-
fieldName: attributeUriToSearchUri(attrType.uri, parents)
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
var createAttributesConfig = function (metadata, attrNode, operationalTypeUri, parents) {
|
|
42
|
-
if (parents === void 0) { parents = []; }
|
|
43
|
-
var resConfig = __assign(__assign({}, createAttributeItem(metadata, attrNode, operationalTypeUri, parents)), { uri: attrNode.uri });
|
|
44
|
-
var children = attrNode.children
|
|
45
|
-
? attrNode.children.map(function (childNode) {
|
|
46
|
-
return createAttributesConfig(metadata, childNode, operationalTypeUri, parents.concat(attrNode));
|
|
47
|
-
})
|
|
48
|
-
: [];
|
|
49
|
-
if (children.length) {
|
|
50
|
-
resConfig.children = children;
|
|
51
|
-
}
|
|
52
|
-
return resConfig;
|
|
53
|
-
};
|
|
54
|
-
export var getAttributeSelectorItems = function (metadata, attributesTypesGroups, attributesTypesGroupFilter) {
|
|
55
|
-
var attributeSelectorItemsGroup = attributesTypesGroups.map(function (_a) {
|
|
56
|
-
var id = _a.id, title = _a.title, attributeTypes = _a.attributeTypes;
|
|
57
|
-
var operationalTypeUri = getOperationalTypeUriFromAttrTypes(attributeTypes);
|
|
58
|
-
return {
|
|
59
|
-
id: id,
|
|
60
|
-
title: title,
|
|
61
|
-
attributes: getAttributesTreeFromAttributes(attributeTypes, metadata).map(function (attrNode) {
|
|
62
|
-
var uri = isSpecialAttribute(attrNode) ? null : operationalTypeUri;
|
|
63
|
-
return createAttributesConfig(metadata, attrNode, uri);
|
|
64
|
-
})
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
return attributesTypesGroupFilter
|
|
68
|
-
? attributesTypesGroupFilter(metadata, attributeSelectorItemsGroup)
|
|
69
|
-
: attributeSelectorItemsGroup;
|
|
70
|
-
};
|
|
71
1
|
var findAttributeSelectorItem = function (fieldName, attributesGroup) {
|
|
72
2
|
var attrGroup;
|
|
73
3
|
var _loop_1 = function (attributesGroupItem) {
|
|
@@ -105,7 +35,3 @@ export var getRowsDataFromFilters = function (filters, attributesGroupArr) {
|
|
|
105
35
|
};
|
|
106
36
|
});
|
|
107
37
|
};
|
|
108
|
-
export var getOperationalTypeUriFromAttrTypes = function (attributeTypes) {
|
|
109
|
-
var regularAttribute = findRegularAttribute(attributeTypes);
|
|
110
|
-
return regularAttribute ? getBaseUri(regularAttribute.uri) : null;
|
|
111
|
-
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AttributeType, Metadata } from '@reltio/mdm-sdk';
|
|
2
|
+
import { AttributeSelectorItemsGroup, AttributesTypesGroup } from '../types';
|
|
3
|
+
export declare const getOperationalTypeUriFromAttrTypes: (attributeTypes: AttributeType[]) => any;
|
|
4
|
+
export declare const getAttributeSelectorItems: (metadata: Metadata, attributesTypesGroups: AttributesTypesGroup[], attributesTypesGroupFilter: (metadata: Metadata, attributeSelectorItemsGroup: AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[]) => AttributeSelectorItemsGroup[];
|
|
@@ -0,0 +1,74 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { chain, prop } from 'ramda';
|
|
22
|
+
import { attributeUriToSearchUri, findRegularAttribute, getAttributesTreeFromAttributes, getBaseUri, getEntityTypeLabel, isInteractionTypeUri, isSpecialAttribute } from '@reltio/mdm-sdk';
|
|
23
|
+
var createAttributeItem = function (metadata, attrType, operationalTypeUri, parents) {
|
|
24
|
+
var title = attrType.label || attrType.name;
|
|
25
|
+
if (isSpecialAttribute(attrType)) {
|
|
26
|
+
return { attrType: attrType, title: title, fieldName: attrType.name };
|
|
27
|
+
}
|
|
28
|
+
if (isInteractionTypeUri(operationalTypeUri)) {
|
|
29
|
+
return { attrType: attrType, title: title, fieldName: attributeUriToSearchUri(attrType.uri, parents) };
|
|
30
|
+
}
|
|
31
|
+
var entityTypeLabel = getEntityTypeLabel(metadata, { type: operationalTypeUri });
|
|
32
|
+
return {
|
|
33
|
+
attrType: attrType,
|
|
34
|
+
title: title,
|
|
35
|
+
entityTypeUri: operationalTypeUri,
|
|
36
|
+
pathToTitle: Array.isArray(parents)
|
|
37
|
+
? __spreadArray(__spreadArray([entityTypeLabel], chain(prop('label'), parents), true), [title], false) : [entityTypeLabel, title],
|
|
38
|
+
fieldName: attributeUriToSearchUri(attrType.uri, parents)
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
var createAttributesConfig = function (metadata, attrNode, operationalTypeUri, parents) {
|
|
42
|
+
if (parents === void 0) { parents = []; }
|
|
43
|
+
var resConfig = __assign(__assign({}, createAttributeItem(metadata, attrNode, operationalTypeUri, parents)), { uri: attrNode.uri });
|
|
44
|
+
var children = attrNode.children
|
|
45
|
+
? attrNode.children.map(function (childNode) {
|
|
46
|
+
return createAttributesConfig(metadata, childNode, operationalTypeUri, parents.concat(attrNode));
|
|
47
|
+
})
|
|
48
|
+
: [];
|
|
49
|
+
if (children.length) {
|
|
50
|
+
resConfig.children = children;
|
|
51
|
+
}
|
|
52
|
+
return resConfig;
|
|
53
|
+
};
|
|
54
|
+
export var getOperationalTypeUriFromAttrTypes = function (attributeTypes) {
|
|
55
|
+
var regularAttribute = findRegularAttribute(attributeTypes);
|
|
56
|
+
return regularAttribute ? getBaseUri(regularAttribute.uri) : null;
|
|
57
|
+
};
|
|
58
|
+
export var getAttributeSelectorItems = function (metadata, attributesTypesGroups, attributesTypesGroupFilter) {
|
|
59
|
+
var attributeSelectorItemsGroup = attributesTypesGroups.map(function (_a) {
|
|
60
|
+
var id = _a.id, title = _a.title, attributeTypes = _a.attributeTypes;
|
|
61
|
+
var operationalTypeUri = getOperationalTypeUriFromAttrTypes(attributeTypes);
|
|
62
|
+
return {
|
|
63
|
+
id: id,
|
|
64
|
+
title: title,
|
|
65
|
+
attributes: getAttributesTreeFromAttributes(attributeTypes, metadata).map(function (attrNode) {
|
|
66
|
+
var uri = isSpecialAttribute(attrNode) ? null : operationalTypeUri;
|
|
67
|
+
return createAttributesConfig(metadata, attrNode, uri);
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
return attributesTypesGroupFilter
|
|
72
|
+
? attributesTypesGroupFilter(metadata, attributeSelectorItemsGroup)
|
|
73
|
+
: attributeSelectorItemsGroup;
|
|
74
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFilterAutoFocus } from './useFilterAutoFocus';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFilterAutoFocus } from './useFilterAutoFocus';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const useFilterAutoFocus: (rowsData: Record<string, unknown>[]) => {
|
|
3
|
+
attributeFilterRef: import("react").MutableRefObject<any>;
|
|
4
|
+
lastAttributesCountRef: import("react").MutableRefObject<any>;
|
|
5
|
+
attributesCountRef: import("react").MutableRefObject<any>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
export var useFilterAutoFocus = function (rowsData) {
|
|
3
|
+
var attributeFilterRef = useRef(null);
|
|
4
|
+
var lastAttributesCountRef = useRef(null);
|
|
5
|
+
var attributesCountRef = useRef(null);
|
|
6
|
+
attributesCountRef.current = rowsData.length;
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
if (attributeFilterRef.current && lastAttributesCountRef.current !== attributesCountRef.current) {
|
|
9
|
+
attributeFilterRef.current.querySelector('input').focus();
|
|
10
|
+
lastAttributesCountRef.current = null;
|
|
11
|
+
}
|
|
12
|
+
}, [rowsData.length]);
|
|
13
|
+
return { attributeFilterRef: attributeFilterRef, lastAttributesCountRef: lastAttributesCountRef, attributesCountRef: attributesCountRef };
|
|
14
|
+
};
|
package/esm/index.d.ts
CHANGED
|
@@ -178,6 +178,7 @@ export { RelationEditor } from './RelationEditor';
|
|
|
178
178
|
export { GaugeChart } from './GaugeChart';
|
|
179
179
|
export { UpSetChart } from './UpSetChart';
|
|
180
180
|
export { DateRangeSelector } from './DateRangeSelector';
|
|
181
|
+
export { MetadataTypesSelector } from './MetadataTypesSelector';
|
|
181
182
|
export { withTooltip } from './HOCs/withTooltip';
|
|
182
183
|
export { withAsyncMount } from './HOCs/withAsyncMount';
|
|
183
184
|
export { withDragHandle } from './HOCs/withDragHandle';
|
|
@@ -267,11 +268,13 @@ export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
|
|
267
268
|
export { useMaskedAttribute } from './hooks/useMaskedAttribute';
|
|
268
269
|
export { useMarkers, resolveMarkers } from './hooks/useMarkers';
|
|
269
270
|
export { useSegmentationRequest } from './hooks/useSegmentationRequest';
|
|
271
|
+
export { useFilterAutoFocus } from './hooks/useFilterAutoFocus';
|
|
270
272
|
export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
271
273
|
export { enrichDataWithPercents } from './helpers/charts';
|
|
272
274
|
export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
|
|
273
275
|
export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
|
|
274
276
|
export { mergeClasses } from './helpers/classes';
|
|
277
|
+
export { getAttributeSelectorItems } from './helpers/attributesSelector';
|
|
275
278
|
export type { AttributeFiltersComponentProps } from './AttributesFiltersBuilder';
|
|
276
279
|
export type { ChartData } from './types/charts';
|
|
277
280
|
export type { AddInlineAttributeEvent, DeleteInlineAttributeEvent, EditInlineAttributeEvent, IgnoreInlineAttributeEvent, PinInlineAttributeEvent } from './types/inlineAttributes';
|
package/esm/index.js
CHANGED
|
@@ -179,6 +179,7 @@ export { RelationEditor } from './RelationEditor';
|
|
|
179
179
|
export { GaugeChart } from './GaugeChart';
|
|
180
180
|
export { UpSetChart } from './UpSetChart';
|
|
181
181
|
export { DateRangeSelector } from './DateRangeSelector';
|
|
182
|
+
export { MetadataTypesSelector } from './MetadataTypesSelector';
|
|
182
183
|
// HOCs
|
|
183
184
|
export { withTooltip } from './HOCs/withTooltip';
|
|
184
185
|
export { withAsyncMount } from './HOCs/withAsyncMount';
|
|
@@ -271,12 +272,14 @@ export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
|
|
271
272
|
export { useMaskedAttribute } from './hooks/useMaskedAttribute';
|
|
272
273
|
export { useMarkers, resolveMarkers } from './hooks/useMarkers';
|
|
273
274
|
export { useSegmentationRequest } from './hooks/useSegmentationRequest';
|
|
275
|
+
export { useFilterAutoFocus } from './hooks/useFilterAutoFocus';
|
|
274
276
|
// helpers
|
|
275
277
|
export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
276
278
|
export { enrichDataWithPercents } from './helpers/charts';
|
|
277
279
|
export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
|
|
278
280
|
export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
|
|
279
281
|
export { mergeClasses } from './helpers/classes';
|
|
282
|
+
export { getAttributeSelectorItems } from './helpers/attributesSelector';
|
|
280
283
|
export * from './types/preferences';
|
|
281
284
|
export * from './types';
|
|
282
285
|
// constants
|