@reltio/components 1.4.2159 → 1.4.2161

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 (47) hide show
  1. package/AddressAutocompleteEditor/AddressAutocompleteEditor.d.ts +10 -0
  2. package/AddressAutocompleteEditor/AddressAutocompleteEditor.js +223 -0
  3. package/AddressAutocompleteEditor/AddressAutocompleteEditor.module.css.js +9 -0
  4. package/AddressAutocompleteEditor/AddressAutocompleteEditor.test.d.ts +1 -0
  5. package/AddressAutocompleteEditor/AddressAutocompleteEditor.test.js +522 -0
  6. package/AddressAutocompleteEditor/helpers.d.ts +10 -0
  7. package/AddressAutocompleteEditor/helpers.js +18 -0
  8. package/AddressAutocompleteEditor/index.d.ts +1 -0
  9. package/AddressAutocompleteEditor/index.js +1 -0
  10. package/BasicTable/index.d.ts +1 -0
  11. package/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.js +1 -1
  12. package/EditorsFactory/EditorsFactory.js +4 -0
  13. package/ReferenceAttributeEditor/ReferenceAttributeEditor.js +5 -3
  14. package/RelationEditor/RelationEditor.js +6 -4
  15. package/SimpleAttributeEditor/SimpleAttributeEditor.d.ts +1 -0
  16. package/SimpleAttributeEditor/SimpleAttributeEditor.js +15 -4
  17. package/cjs/AddressAutocompleteEditor/AddressAutocompleteEditor.d.ts +10 -0
  18. package/cjs/AddressAutocompleteEditor/AddressAutocompleteEditor.js +253 -0
  19. package/cjs/AddressAutocompleteEditor/AddressAutocompleteEditor.module.css.js +9 -0
  20. package/cjs/AddressAutocompleteEditor/AddressAutocompleteEditor.test.d.ts +1 -0
  21. package/cjs/AddressAutocompleteEditor/AddressAutocompleteEditor.test.js +527 -0
  22. package/cjs/AddressAutocompleteEditor/helpers.d.ts +10 -0
  23. package/cjs/AddressAutocompleteEditor/helpers.js +24 -0
  24. package/cjs/AddressAutocompleteEditor/index.d.ts +1 -0
  25. package/cjs/AddressAutocompleteEditor/index.js +5 -0
  26. package/cjs/BasicTable/index.d.ts +1 -0
  27. package/cjs/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.js +1 -1
  28. package/cjs/EditorsFactory/EditorsFactory.js +4 -0
  29. package/cjs/ReferenceAttributeEditor/ReferenceAttributeEditor.js +5 -3
  30. package/cjs/RelationEditor/RelationEditor.js +6 -4
  31. package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.d.ts +1 -0
  32. package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.js +14 -3
  33. package/cjs/contexts/AttributeValueContext/index.d.ts +3 -0
  34. package/cjs/contexts/AttributeValueContext/index.js +9 -0
  35. package/cjs/contexts/AutoCompleteContext/helpers.d.ts +24 -0
  36. package/cjs/contexts/AutoCompleteContext/helpers.js +165 -0
  37. package/cjs/contexts/AutoCompleteContext/index.d.ts +12 -0
  38. package/cjs/contexts/AutoCompleteContext/index.js +83 -0
  39. package/cjs/contexts/ProfileTablesContext/index.js +1 -0
  40. package/contexts/AttributeValueContext/index.d.ts +3 -0
  41. package/contexts/AttributeValueContext/index.js +3 -0
  42. package/contexts/AutoCompleteContext/helpers.d.ts +24 -0
  43. package/contexts/AutoCompleteContext/helpers.js +159 -0
  44. package/contexts/AutoCompleteContext/index.d.ts +12 -0
  45. package/contexts/AutoCompleteContext/index.js +56 -0
  46. package/contexts/ProfileTablesContext/index.js +1 -0
  47. package/package.json +2 -2
@@ -0,0 +1,56 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { createContext } from '@fluentui/react-context-selector';
3
+ import { getEntityType } from '@reltio/mdm-sdk';
4
+ import { useMdmAction, useMdmEntityUri, useMdmMetadata, useMdmModifiedEntity } from '../MdmModuleContext';
5
+ import { getSettings, isTriggerAttribute, modifyAttributes } from './helpers';
6
+ export var AddressAutoCompleteContext = createContext(null);
7
+ export var AddressAutoCompleteProvider = function (_a) {
8
+ var children = _a.children, entityUri = _a.entityUri;
9
+ var metadata = useMdmMetadata();
10
+ var modifyAttribute = useMdmAction('modifyAttribute');
11
+ var mdmEntityUri = useMdmEntityUri();
12
+ var modifiedEntity = useMdmModifiedEntity(entityUri || mdmEntityUri) || {};
13
+ var addressAutoCompleteConfig = useMemo(function () {
14
+ var _a;
15
+ var entityType = (modifiedEntity === null || modifiedEntity === void 0 ? void 0 : modifiedEntity.type) && metadata && getEntityType(metadata, modifiedEntity.type);
16
+ return (((_a = entityType === null || entityType === void 0 ? void 0 : entityType.cleanseConfig) === null || _a === void 0 ? void 0 : _a.addressAutoCompleteConfig) ||
17
+ { outputMapping: [], inputMapping: [] });
18
+ }, [modifiedEntity === null || modifiedEntity === void 0 ? void 0 : modifiedEntity.type, metadata]);
19
+ var onPopulateAttributes = useCallback(function (triggerAttributeTypeUri, triggerAttributeValueUri, values) {
20
+ if (!(addressAutoCompleteConfig === null || addressAutoCompleteConfig === void 0 ? void 0 : addressAutoCompleteConfig.outputMapping) ||
21
+ !(modifiedEntity === null || modifiedEntity === void 0 ? void 0 : modifiedEntity.uri) ||
22
+ !triggerAttributeTypeUri ||
23
+ !values) {
24
+ return;
25
+ }
26
+ var outputMapping = addressAutoCompleteConfig.outputMapping;
27
+ modifyAttributes({
28
+ outputMapping: outputMapping,
29
+ modifiedEntity: modifiedEntity,
30
+ metadata: metadata,
31
+ triggerAttributeTypeUri: triggerAttributeTypeUri,
32
+ triggerAttributeValueUri: triggerAttributeValueUri,
33
+ values: values,
34
+ modifyAttribute: modifyAttribute
35
+ });
36
+ }, [addressAutoCompleteConfig, modifiedEntity, metadata, modifyAttribute]);
37
+ var isAutocompleteTriggerAttribute = useCallback(function (attributeType) {
38
+ var _a = addressAutoCompleteConfig.inputMapping, inputMapping = _a === void 0 ? [] : _a;
39
+ return isTriggerAttribute(attributeType, inputMapping);
40
+ }, [addressAutoCompleteConfig]);
41
+ var getAutocompleteSettings = useCallback(function (triggerAttributeTypeUri, triggerAttributeValueUri) {
42
+ return getSettings({
43
+ metadata: metadata,
44
+ modifiedEntity: modifiedEntity,
45
+ triggerAttributeValueUri: triggerAttributeValueUri,
46
+ triggerAttributeTypeUri: triggerAttributeTypeUri,
47
+ addressAutoCompleteConfig: addressAutoCompleteConfig
48
+ });
49
+ }, [addressAutoCompleteConfig, metadata, modifiedEntity]);
50
+ var contextValue = useMemo(function () { return ({
51
+ onPopulateAttributes: onPopulateAttributes,
52
+ isAutocompleteTriggerAttribute: isAutocompleteTriggerAttribute,
53
+ getAutocompleteSettings: getAutocompleteSettings
54
+ }); }, [onPopulateAttributes, isAutocompleteTriggerAttribute, getAutocompleteSettings]);
55
+ return React.createElement(AddressAutoCompleteContext.Provider, { value: contextValue }, children);
56
+ };
@@ -3,3 +3,4 @@ export var ProfileTablesContext = createContext({
3
3
  profileTablesPreferences: {},
4
4
  setProfileTablesPreferences: function () { }
5
5
  });
6
+ ProfileTablesContext.displayName = 'ProfileTablesContext';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.2159",
3
+ "version": "1.4.2161",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -11,7 +11,7 @@
11
11
  "@fluentui/react-context-selector": "^9.1.26",
12
12
  "@googlemaps/markerclusterer": "^2.5.3",
13
13
  "@react-sigma/core": "3.4.0",
14
- "@reltio/mdm-sdk": "^1.4.1977",
14
+ "@reltio/mdm-sdk": "^1.4.1978",
15
15
  "@vis.gl/react-google-maps": "^1.3.0",
16
16
  "d3-cloud": "^1.2.5",
17
17
  "d3-geo": "^2.0.1",