@reltio/components 1.4.2227 → 1.4.2229

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 (85) hide show
  1. package/AttributesFiltersBuilder/AttributesFiltersBuilder.js +5 -4
  2. package/AttributesFiltersBuilder/helpers.js +6 -1
  3. package/FacetsSelector/FacetsSelector.d.ts +1 -1
  4. package/FacetsSelector/FacetsSelector.js +1 -1
  5. package/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.d.ts +9 -1
  6. package/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.js +3 -3
  7. package/SimpleAttribute/SimpleAttribute.d.ts +5 -2
  8. package/SimpleAttribute/SimpleAttribute.js +15 -7
  9. package/SimpleAttribute/SimpleAttribute.module.css.js +9 -0
  10. package/cjs/AttributesFiltersBuilder/AttributesFiltersBuilder.js +3 -2
  11. package/cjs/AttributesFiltersBuilder/helpers.js +6 -1
  12. package/cjs/FacetsSelector/FacetsSelector.d.ts +1 -1
  13. package/cjs/FacetsSelector/FacetsSelector.js +1 -1
  14. package/cjs/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.d.ts +9 -1
  15. package/cjs/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.js +3 -3
  16. package/cjs/SimpleAttribute/SimpleAttribute.d.ts +5 -2
  17. package/cjs/SimpleAttribute/SimpleAttribute.js +19 -11
  18. package/cjs/SimpleAttribute/SimpleAttribute.module.css.js +9 -0
  19. package/cjs/features/crosswalks/AttributesTable/AttributesTable.js +3 -1
  20. package/cjs/features/crosswalks/AttributesTable/AttributesTable.test-data.d.ts +4 -1
  21. package/cjs/features/crosswalks/AttributesTable/AttributesTable.test-data.js +51 -21
  22. package/cjs/features/crosswalks/AttributesTable/AttributesTable.test.js +56 -0
  23. package/cjs/features/crosswalks/AttributesTable/components/FallbackIndicator/FallbackIndicator.d.ts +7 -0
  24. package/cjs/features/crosswalks/AttributesTable/components/FallbackIndicator/FallbackIndicator.js +31 -0
  25. package/cjs/features/crosswalks/AttributesTable/components/FallbackIndicator/FallbackIndicator.module.css.js +9 -0
  26. package/cjs/features/crosswalks/AttributesTable/components/FallbackIndicator/index.d.ts +1 -0
  27. package/cjs/features/crosswalks/AttributesTable/components/FallbackIndicator/index.js +5 -0
  28. package/cjs/features/crosswalks/AttributesTable/components/OvValuesRenderer/OvValuesRenderer.js +3 -1
  29. package/cjs/features/crosswalks/AttributesTable/components/RuleTypeInfoButton/RuleTypeInfoButton.js +1 -1
  30. package/cjs/features/crosswalks/AttributesTable/components/RuleTypeRenderer/RuleTypeRenderer.d.ts +1 -1
  31. package/cjs/features/crosswalks/AttributesTable/components/RuleTypeRenderer/RuleTypeRenderer.js +65 -11
  32. package/cjs/features/crosswalks/AttributesTable/components/RuleTypeRenderer/RuleTypeRenderer.module.css.js +9 -0
  33. package/cjs/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightConsumer.d.ts +7 -0
  34. package/cjs/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightConsumer.js +15 -0
  35. package/cjs/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightReporter.d.ts +7 -0
  36. package/cjs/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightReporter.js +53 -0
  37. package/cjs/features/crosswalks/AttributesTable/components/SyncedValueHeight/index.d.ts +2 -0
  38. package/cjs/features/crosswalks/AttributesTable/components/SyncedValueHeight/index.js +7 -0
  39. package/cjs/features/crosswalks/AttributesTable/helpers.d.ts +4 -2
  40. package/cjs/features/crosswalks/AttributesTable/helpers.js +96 -17
  41. package/cjs/features/crosswalks/AttributesTable/helpers.test.js +499 -50
  42. package/cjs/features/crosswalks/AttributesTable/types.d.ts +17 -3
  43. package/cjs/features/crosswalks/contexts/SyncedValueHeightsContext.d.ts +11 -0
  44. package/cjs/features/crosswalks/contexts/SyncedValueHeightsContext.js +66 -0
  45. package/cjs/helpers/attributesSelector.d.ts +2 -3
  46. package/cjs/helpers/attributesSelector.js +16 -18
  47. package/cjs/types/index.d.ts +1 -0
  48. package/features/crosswalks/AttributesTable/AttributesTable.js +3 -1
  49. package/features/crosswalks/AttributesTable/AttributesTable.test-data.d.ts +4 -1
  50. package/features/crosswalks/AttributesTable/AttributesTable.test-data.js +49 -20
  51. package/features/crosswalks/AttributesTable/AttributesTable.test.js +58 -2
  52. package/features/crosswalks/AttributesTable/components/FallbackIndicator/FallbackIndicator.d.ts +7 -0
  53. package/features/crosswalks/AttributesTable/components/FallbackIndicator/FallbackIndicator.js +24 -0
  54. package/features/crosswalks/AttributesTable/components/FallbackIndicator/FallbackIndicator.module.css.js +9 -0
  55. package/features/crosswalks/AttributesTable/components/FallbackIndicator/index.d.ts +1 -0
  56. package/features/crosswalks/AttributesTable/components/FallbackIndicator/index.js +1 -0
  57. package/features/crosswalks/AttributesTable/components/OvValuesRenderer/OvValuesRenderer.js +3 -1
  58. package/features/crosswalks/AttributesTable/components/RuleTypeInfoButton/RuleTypeInfoButton.js +1 -1
  59. package/features/crosswalks/AttributesTable/components/RuleTypeRenderer/RuleTypeRenderer.d.ts +1 -1
  60. package/features/crosswalks/AttributesTable/components/RuleTypeRenderer/RuleTypeRenderer.js +65 -11
  61. package/features/crosswalks/AttributesTable/components/RuleTypeRenderer/RuleTypeRenderer.module.css.js +9 -0
  62. package/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightConsumer.d.ts +7 -0
  63. package/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightConsumer.js +8 -0
  64. package/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightReporter.d.ts +7 -0
  65. package/features/crosswalks/AttributesTable/components/SyncedValueHeight/ValueHeightReporter.js +23 -0
  66. package/features/crosswalks/AttributesTable/components/SyncedValueHeight/index.d.ts +2 -0
  67. package/features/crosswalks/AttributesTable/components/SyncedValueHeight/index.js +2 -0
  68. package/features/crosswalks/AttributesTable/helpers.d.ts +4 -2
  69. package/features/crosswalks/AttributesTable/helpers.js +95 -18
  70. package/features/crosswalks/AttributesTable/helpers.test.js +501 -52
  71. package/features/crosswalks/AttributesTable/types.d.ts +17 -3
  72. package/features/crosswalks/contexts/SyncedValueHeightsContext.d.ts +11 -0
  73. package/features/crosswalks/contexts/SyncedValueHeightsContext.js +38 -0
  74. package/helpers/attributesSelector.d.ts +2 -3
  75. package/helpers/attributesSelector.js +16 -17
  76. package/package.json +2 -2
  77. package/types/index.d.ts +1 -0
  78. package/SimpleAttribute/styles.d.ts +0 -1
  79. package/SimpleAttribute/styles.js +0 -42
  80. package/cjs/SimpleAttribute/styles.d.ts +0 -1
  81. package/cjs/SimpleAttribute/styles.js +0 -45
  82. package/cjs/features/crosswalks/AttributesTable/components/RuleTypeRenderer/styles.d.ts +0 -1
  83. package/cjs/features/crosswalks/AttributesTable/components/RuleTypeRenderer/styles.js +0 -13
  84. package/features/crosswalks/AttributesTable/components/RuleTypeRenderer/styles.d.ts +0 -1
  85. package/features/crosswalks/AttributesTable/components/RuleTypeRenderer/styles.js +0 -10
@@ -0,0 +1,23 @@
1
+ import React, { useCallback, useLayoutEffect, useRef } from 'react';
2
+ import ReactResizeDetector from 'react-resize-detector';
3
+ import { useSyncedValueHeights } from '../../../contexts/SyncedValueHeightsContext';
4
+ export var ValueHeightReporter = function (_a) {
5
+ var uri = _a.uri, children = _a.children;
6
+ var reportHeight = useSyncedValueHeights().reportHeight;
7
+ var contentRef = useRef(null);
8
+ var lastHeightRef = useRef();
9
+ var report = useCallback(function () {
10
+ var _a;
11
+ var height = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight;
12
+ if (!height || height === lastHeightRef.current)
13
+ return;
14
+ lastHeightRef.current = height;
15
+ reportHeight(uri, height);
16
+ }, [reportHeight, uri, lastHeightRef]);
17
+ useLayoutEffect(function () {
18
+ report();
19
+ }, [report]);
20
+ return (React.createElement("div", { ref: contentRef },
21
+ React.createElement(ReactResizeDetector, { handleHeight: true, onResize: report }),
22
+ children));
23
+ };
@@ -0,0 +1,2 @@
1
+ export { ValueHeightConsumer } from './ValueHeightConsumer';
2
+ export { ValueHeightReporter } from './ValueHeightReporter';
@@ -0,0 +1,2 @@
1
+ export { ValueHeightConsumer } from './ValueHeightConsumer';
2
+ export { ValueHeightReporter } from './ValueHeightReporter';
@@ -1,4 +1,4 @@
1
- import { AttributeType, AttributeValue, Crosswalk, Metadata, RecordAttributesType } from '@reltio/mdm-sdk';
1
+ import { AppliedSurvivorshipRule, AttributeType, AttributeValue, Crosswalk, Metadata, OvDetails, RecordAttributesType } from '@reltio/mdm-sdk';
2
2
  import { CrosswalksMap } from '../../../types';
3
3
  import { CrosswalksByOwnerTypeMap } from '../types';
4
4
  import { AttributesTableRowValue, RuleTypeValues } from './types';
@@ -29,7 +29,9 @@ export declare const COLUMNS_DATA: ({
29
29
  })[];
30
30
  export declare const DEFAULT_VISIBLE_COLUMNS: string[];
31
31
  export declare const countAttributeValues: (type: string, values: AttributeValue[], crosswalksMap: CrosswalksMap) => number;
32
- export declare const getRuleTypeValues: (metadata: Metadata, attributeType: AttributeType, parentTypeUri: string, activeSurvivorshipGroupUri?: string) => RuleTypeValues;
32
+ export declare const collectRuleNames: (rule: AppliedSurvivorshipRule | undefined) => string[];
33
+ export declare const getFallbackLabels: (metadata: Metadata, ovDetails: OvDetails) => string[];
34
+ export declare const getRuleTypeValues: (metadata: Metadata, attributeType: AttributeType, parentTypeUri: string, attributeValues: AttributeValue[], activeSurvivorshipGroupUri?: string) => RuleTypeValues;
33
35
  export declare const getWinnerCrosswalks: (attributeValues: AttributeValue[], crosswalksMap: CrosswalksMap) => Crosswalk[];
34
36
  export declare const getBasicTableColumnsData: any;
35
37
  export declare const getBasicTableRowsData: (metadata: Metadata, parentTypeUri: string, attrTypes: AttributeType[], columns: string[], crosswalksMap: CrosswalksByOwnerTypeMap, attributes: RecordAttributesType, activeSurvivorshipGroupUri?: string) => AttributesTableRowValue[];
@@ -1,3 +1,14 @@
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
+ };
1
12
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
13
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
14
  if (ar || !(i in from)) {
@@ -8,8 +19,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8
19
  return to.concat(ar || Array.prototype.slice.call(from));
9
20
  };
10
21
  import i18n from 'ui-i18n';
11
- import { assoc, chain, curry, descend, filter, find, flatten, map, pickBy, pipe, prop, propEq, propOr, reduce, sortWith, uniq, uniqBy, values, pathOr } from 'ramda';
12
- import { areOneHierarchyUris, DataTypes, findValueInAttributesByUriSuffix, getBaseUri, getCrosswalksTypes, getDefaultSurvivorshipStrategy, getLastUriPart, getReferencedAttrTypeUrisFromAttrType, getSurvivorshipStrategy, isComplexAttribute, isOv, isReference, isTempUri } from '@reltio/mdm-sdk';
22
+ import { assoc, chain, curry, descend, filter, find, flatten, isNil, last, map, pathOr, pickBy, pipe, prop, propEq, propOr, reduce, reject, sortWith, uniq, uniqBy, values } from 'ramda';
23
+ import { areOneHierarchyUris, DataTypes, findValueInAttributesByUriSuffix, getBaseUri, getCrosswalksTypes, getDefaultSurvivorshipStrategy, getLastUriPart, getReferencedAttrTypeUrisFromAttrType, getSurvivorshipStrategy, isComplexAttribute, isOv, isReference, isTempUri, ParticipationStatus } from '@reltio/mdm-sdk';
13
24
  import { HeadCellRenderer } from './components/HeadCellRenderer';
14
25
  import { AttributesHeadCellRenderer } from './components/AttributesHeadCellRenderer';
15
26
  import { DefaultCellValueRenderer } from './components/DefaultCellValueRenderer';
@@ -107,27 +118,93 @@ var fixReferencedAttributeUri = curry(function (parentType, attrTypeUri) {
107
118
  return attrTypeUri;
108
119
  }
109
120
  });
110
- export var getRuleTypeValues = function (metadata, attributeType, parentTypeUri, activeSurvivorshipGroupUri) {
111
- var _a, _b;
121
+ export var collectRuleNames = function (rule) {
122
+ if (!rule) {
123
+ return [];
124
+ }
125
+ if (typeof rule === 'string') {
126
+ return [rule];
127
+ }
128
+ var entries = Object.entries(rule);
129
+ return entries.flatMap(function (_a) {
130
+ var key = _a[0], value = _a[1];
131
+ return __spreadArray([key], value.flatMap(collectRuleNames), true);
132
+ });
133
+ };
134
+ export var getFallbackLabels = function (metadata, ovDetails) {
135
+ if ((ovDetails === null || ovDetails === void 0 ? void 0 : ovDetails.participationStatus) && ovDetails.participationStatus !== ParticipationStatus.Strategy) {
136
+ return [];
137
+ }
138
+ var appliedRules = ovDetails === null || ovDetails === void 0 ? void 0 : ovDetails.appliedSurvivorshipRules;
139
+ var rules = collectRuleNames(appliedRules);
140
+ if (rules.length <= 1) {
141
+ return [];
142
+ }
143
+ return rules.map(function (uri) { var _a; return ((_a = getSurvivorshipStrategy(metadata, uri)) === null || _a === void 0 ? void 0 : _a.label) || uri; });
144
+ };
145
+ var getStrategyAdditionalFields = function (metadata, strategy, mapping, attributeType, currentSurvivorshipGroup) {
146
+ var fixUri = fixReferencedAttributeUri(attributeType);
147
+ var primaryAttributeUri = isOtherAttributeWinnerRule(strategy) ? fixUri(mapping === null || mapping === void 0 ? void 0 : mapping.primaryAttributeUri) : undefined;
148
+ var comparisonAttributeUri = isComplexAttribute(attributeType) && isMinMaxValueRule(strategy)
149
+ ? fixUri(mapping === null || mapping === void 0 ? void 0 : mapping.comparisonAttributeUri)
150
+ : undefined;
151
+ var sourcesUriOrder = isSourceSystemRule(strategy)
152
+ ? uniq(__spreadArray(__spreadArray(__spreadArray([], ((mapping === null || mapping === void 0 ? void 0 : mapping.sourcesUriOrder) || []), true), ((currentSurvivorshipGroup === null || currentSurvivorshipGroup === void 0 ? void 0 : currentSurvivorshipGroup.sourcesUriOrder) || []), true), getSourcesUriOrderFromMetadata(metadata), true))
153
+ : undefined;
154
+ return {
155
+ primaryAttributeUri: primaryAttributeUri,
156
+ comparisonAttributeUri: comparisonAttributeUri,
157
+ sourcesUriOrder: sourcesUriOrder
158
+ };
159
+ };
160
+ var getAppliedSurvivorshipRules = function (metadata, mapping, attributeType, attributeValues, currentSurvivorshipGroup) {
161
+ if (isComplexAttribute(attributeType) || !attributeValues) {
162
+ return [];
163
+ }
164
+ return pipe(filter(isOvValue), map(function (value) {
165
+ var ovDetails = value.ovDetails;
166
+ if (!ovDetails || !ovDetails.appliedSurvivorshipRules) {
167
+ return null;
168
+ }
169
+ if (ovDetails.participationStatus === ParticipationStatus.Strategy) {
170
+ return { type: 'rule', data: ovDetails.appliedSurvivorshipRules, valueUri: value.uri };
171
+ }
172
+ return { type: 'status', data: ovDetails.participationStatus, valueUri: value.uri };
173
+ }), reject(isNil), map(function (ruleOrStatus) {
174
+ if (ruleOrStatus.type === 'status') {
175
+ return ruleOrStatus;
176
+ }
177
+ var appliedRules = collectRuleNames(ruleOrStatus.data);
178
+ var lastRule = getSurvivorshipStrategy(metadata, last(appliedRules));
179
+ return lastRule
180
+ ? {
181
+ type: 'rule',
182
+ valueUri: ruleOrStatus.valueUri,
183
+ data: __assign({ strategy: lastRule }, getStrategyAdditionalFields(metadata, lastRule, mapping, attributeType, currentSurvivorshipGroup))
184
+ }
185
+ : null;
186
+ }), reject(isNil))(attributeValues);
187
+ };
188
+ export var getRuleTypeValues = function (metadata, attributeType, parentTypeUri, attributeValues, activeSurvivorshipGroupUri) {
189
+ var _a, _b, _c, _d;
112
190
  var parentType = __spreadArray(__spreadArray([], metadata.entityTypes, true), (metadata.relationTypes || []), true).find(propEq('uri', parentTypeUri));
113
191
  var survivorshipGroups = (_a = parentType === null || parentType === void 0 ? void 0 : parentType.survivorshipGroups) !== null && _a !== void 0 ? _a : [];
114
192
  var currentSurvivorshipGroup = (activeSurvivorshipGroupUri && survivorshipGroups.find(propEq('uri', activeSurvivorshipGroupUri))) ||
115
193
  survivorshipGroups.find(propEq('default', true));
116
194
  var mapping = (_b = currentSurvivorshipGroup === null || currentSurvivorshipGroup === void 0 ? void 0 : currentSurvivorshipGroup.mapping) === null || _b === void 0 ? void 0 : _b.find(propEq('attribute', attributeType.uri));
117
- var ruleType = getSurvivorshipStrategy(metadata, mapping === null || mapping === void 0 ? void 0 : mapping.survivorshipStrategy) || getDefaultSurvivorshipStrategy(metadata);
118
- var sourcesUriOrder = isSourceSystemRule(ruleType)
119
- ? uniq(__spreadArray(__spreadArray(__spreadArray([], ((mapping === null || mapping === void 0 ? void 0 : mapping.sourcesUriOrder) || []), true), ((currentSurvivorshipGroup === null || currentSurvivorshipGroup === void 0 ? void 0 : currentSurvivorshipGroup.sourcesUriOrder) || []), true), getSourcesUriOrderFromMetadata(metadata), true))
120
- : undefined;
121
- var fixUri = fixReferencedAttributeUri(attributeType);
122
- var primaryAttributeUri = isOtherAttributeWinnerRule(ruleType) ? fixUri(mapping === null || mapping === void 0 ? void 0 : mapping.primaryAttributeUri) : undefined;
123
- var comparisonAttributeUri = isComplexAttribute(attributeType) && isMinMaxValueRule(ruleType)
124
- ? fixUri(mapping === null || mapping === void 0 ? void 0 : mapping.comparisonAttributeUri)
125
- : undefined;
195
+ var defaultRuleType = getSurvivorshipStrategy(metadata, mapping === null || mapping === void 0 ? void 0 : mapping.survivorshipStrategy) || getDefaultSurvivorshipStrategy(metadata);
196
+ var appliedSurvivorshipRules = getAppliedSurvivorshipRules(metadata, mapping, attributeType, attributeValues, currentSurvivorshipGroup);
197
+ if (appliedSurvivorshipRules.length > 0) {
198
+ return { ruleTypes: appliedSurvivorshipRules };
199
+ }
126
200
  return {
127
- ruleType: ruleType,
128
- sourcesUriOrder: sourcesUriOrder,
129
- primaryAttributeUri: primaryAttributeUri,
130
- comparisonAttributeUri: comparisonAttributeUri
201
+ ruleTypes: [
202
+ {
203
+ type: 'rule',
204
+ valueUri: (_d = (_c = attributeValues === null || attributeValues === void 0 ? void 0 : attributeValues[0]) === null || _c === void 0 ? void 0 : _c.uri) !== null && _d !== void 0 ? _d : '',
205
+ data: __assign({ strategy: defaultRuleType }, getStrategyAdditionalFields(metadata, defaultRuleType, mapping, attributeType, currentSurvivorshipGroup))
206
+ }
207
+ ]
131
208
  };
132
209
  };
133
210
  export var getWinnerCrosswalks = function (attributeValues, crosswalksMap) {
@@ -172,7 +249,7 @@ var getRowValueForColumn = function (columnId, metadata, parentTypeUri, attribut
172
249
  case 'count':
173
250
  return countAttributeValues(attributeType.type, attributeValues, crosswalksMap);
174
251
  case 'ruleType':
175
- return getRuleTypeValues(metadata, attributeType, parentTypeUri, activeSurvivorshipGroupUri);
252
+ return getRuleTypeValues(metadata, attributeType, parentTypeUri, attributeValues, activeSurvivorshipGroupUri);
176
253
  case 'winnerSources':
177
254
  return { crosswalks: getWinnerCrosswalks(attributeValues, crosswalksMap) };
178
255
  default: