@reltio/components 1.4.1207 → 1.4.1210
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/components/MatchRulesBlock/MatchRulesBlock.js +2 -3
- package/cjs/components/MatchRulesBlock/SimpleMatchRulesBuilder/SimpleMatchRulesBuilder.js +3 -3
- package/cjs/components/MatchRulesBlock/types/index.d.ts +0 -2
- package/cjs/components/MatchRulesBlock/types/index.js +0 -2
- package/cjs/components/editors/DependentLookupEditor/DependentLookupEditor.d.ts +3 -1
- package/cjs/components/editors/DependentLookupEditor/DependentLookupEditor.js +30 -32
- package/cjs/components/editors/TypeaheadEditor/TypeaheadEditor.d.ts +3 -1
- package/cjs/components/editors/TypeaheadEditor/TypeaheadEditor.js +11 -10
- package/esm/components/MatchRulesBlock/MatchRulesBlock.js +2 -3
- package/esm/components/MatchRulesBlock/SimpleMatchRulesBuilder/SimpleMatchRulesBuilder.js +3 -3
- package/esm/components/MatchRulesBlock/types/index.d.ts +0 -2
- package/esm/components/MatchRulesBlock/types/index.js +0 -2
- package/esm/components/editors/DependentLookupEditor/DependentLookupEditor.d.ts +3 -1
- package/esm/components/editors/DependentLookupEditor/DependentLookupEditor.js +30 -32
- package/esm/components/editors/TypeaheadEditor/TypeaheadEditor.d.ts +3 -1
- package/esm/components/editors/TypeaheadEditor/TypeaheadEditor.js +11 -10
- package/package.json +3 -3
|
@@ -22,11 +22,10 @@ var MatchRulesBlock = function (_a) {
|
|
|
22
22
|
return uri !== mdm_sdk_1.NOT_MATCH;
|
|
23
23
|
});
|
|
24
24
|
var hasNotMatch = rules.length !== matchRules.length;
|
|
25
|
-
var showTransitive = isTransitive && variant !== types_1.MatchRuleVariant.ml;
|
|
26
25
|
var showSimple = !isTransitive && !hasNotMatch;
|
|
27
|
-
var showNotMatch = hasNotMatch &&
|
|
26
|
+
var showNotMatch = hasNotMatch && variant !== types_1.MatchRuleVariant.excludeNotMatch;
|
|
28
27
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
29
|
-
|
|
28
|
+
isTransitive ? (react_1.default.createElement(TransitiveMatchBlock_1.default, { transitiveMatchRules: mdm_sdk_1.getTransitiveMatchRules(metadata, match, entitiesMap) })) : null,
|
|
30
29
|
showSimple ? (react_1.default.createElement(SimpleMatchRulesBuilder_1.default, { variant: variant, matchRules: matchRules, Component: SimpleMatchRulesBlock_1.default })) : null,
|
|
31
30
|
showNotMatch ? react_1.default.createElement(NotMatchRule_1.default, null) : null));
|
|
32
31
|
};
|
|
@@ -33,9 +33,9 @@ var types_1 = require("../types");
|
|
|
33
33
|
var SimpleMatchRulesBuilder = function (_a) {
|
|
34
34
|
var matchRules = _a.matchRules, Component = _a.Component, _b = _a.variant, variant = _b === void 0 ? types_1.MatchRuleVariant.all : _b, otherProps = __rest(_a, ["matchRules", "Component", "variant"]);
|
|
35
35
|
var _c = mdm_sdk_1.partitionByMlMatch(matchRules), MlMatchRules = _c[0], otherMatchRules = _c[1];
|
|
36
|
-
var all = types_1.MatchRuleVariant.all, simple = types_1.MatchRuleVariant.simple,
|
|
37
|
-
var showSimple = [all, simple,
|
|
38
|
-
var showML = [all,
|
|
36
|
+
var all = types_1.MatchRuleVariant.all, simple = types_1.MatchRuleVariant.simple, excludeNotMatch = types_1.MatchRuleVariant.excludeNotMatch;
|
|
37
|
+
var showSimple = [all, simple, excludeNotMatch].includes(variant) && !ramda_1.isEmpty(otherMatchRules);
|
|
38
|
+
var showML = [all, excludeNotMatch].includes(variant) && !ramda_1.isEmpty(MlMatchRules);
|
|
39
39
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
40
40
|
showSimple ? react_1.default.createElement(Component, __assign({ matchRules: otherMatchRules }, otherProps)) : null,
|
|
41
41
|
showML ? react_1.default.createElement(Component, __assign({ isMlMatch: true, matchRules: MlMatchRules }, otherProps)) : null));
|
|
@@ -5,9 +5,7 @@ declare type MatchRule = {
|
|
|
5
5
|
export declare type MatchRules = MatchRule[];
|
|
6
6
|
export declare enum MatchRuleVariant {
|
|
7
7
|
all = "all",
|
|
8
|
-
ml = "ml",
|
|
9
8
|
simple = "simple",
|
|
10
|
-
excludeML = "excludeML",
|
|
11
9
|
excludeNotMatch = "excludeNotMatch"
|
|
12
10
|
}
|
|
13
11
|
export declare type TransitiveMatchRules = Array<{
|
|
@@ -4,8 +4,6 @@ exports.MatchRuleVariant = void 0;
|
|
|
4
4
|
var MatchRuleVariant;
|
|
5
5
|
(function (MatchRuleVariant) {
|
|
6
6
|
MatchRuleVariant["all"] = "all";
|
|
7
|
-
MatchRuleVariant["ml"] = "ml";
|
|
8
7
|
MatchRuleVariant["simple"] = "simple";
|
|
9
|
-
MatchRuleVariant["excludeML"] = "excludeML";
|
|
10
8
|
MatchRuleVariant["excludeNotMatch"] = "excludeNotMatch";
|
|
11
9
|
})(MatchRuleVariant = exports.MatchRuleVariant || (exports.MatchRuleVariant = {}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const DEBOUNCE_INTERVAL: 400;
|
|
2
2
|
export default DependentLookupEditor;
|
|
3
|
-
declare function DependentLookupEditor({ multiple, value, lookupCode: lookupTypeCode, TextFieldProps, parents, onChange, getLookups, lookups, resolveLookups, fullWidth, disabled, placeholder, autopopulationId, ...otherProps }: {
|
|
3
|
+
declare function DependentLookupEditor({ multiple, value, lookupCode: lookupTypeCode, TextFieldProps, parents, onChange, getLookups, lookups, resolveLookups, fullWidth, disabled, placeholder, autopopulationId, max, ...otherProps }: {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
multiple: any;
|
|
6
6
|
value: any;
|
|
@@ -15,6 +15,7 @@ declare function DependentLookupEditor({ multiple, value, lookupCode: lookupType
|
|
|
15
15
|
disabled: any;
|
|
16
16
|
placeholder: any;
|
|
17
17
|
autopopulationId: any;
|
|
18
|
+
max?: number;
|
|
18
19
|
}): JSX.Element;
|
|
19
20
|
declare namespace DependentLookupEditor {
|
|
20
21
|
namespace propTypes {
|
|
@@ -41,6 +42,7 @@ declare namespace DependentLookupEditor {
|
|
|
41
42
|
const placeholder: PropTypes.Requireable<string>;
|
|
42
43
|
const disabled: PropTypes.Requireable<boolean>;
|
|
43
44
|
const autopopulationId: PropTypes.Requireable<string>;
|
|
45
|
+
const max: PropTypes.Requireable<number>;
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
import PropTypes from "prop-types";
|
|
@@ -64,6 +64,7 @@ var useDefaultOptions_1 = __importDefault(require("./useDefaultOptions"));
|
|
|
64
64
|
var useAutopopulation_1 = __importDefault(require("./useAutopopulation"));
|
|
65
65
|
var useSavingFocus_1 = __importDefault(require("./useSavingFocus"));
|
|
66
66
|
var LoadMoreButton_1 = __importDefault(require("../../commonReactSelectComponents/LoadMoreButton"));
|
|
67
|
+
var hooks_1 = require("../../../hooks");
|
|
67
68
|
var SelectComponents = {
|
|
68
69
|
IndicatorSeparator: utils_1.EmptyStub,
|
|
69
70
|
LoadingIndicator: utils_1.EmptyStub,
|
|
@@ -76,7 +77,7 @@ var SelectComponents = {
|
|
|
76
77
|
exports.DEBOUNCE_INTERVAL = 400;
|
|
77
78
|
var MAX_DEPENDENT_LOOKUP_VALUES = 50;
|
|
78
79
|
var DependentLookupEditor = function (_a) {
|
|
79
|
-
var multiple = _a.multiple, value = _a.value, lookupTypeCode = _a.lookupCode, TextFieldProps = _a.TextFieldProps, parents = _a.parents, onChange = _a.onChange, getLookups = _a.getLookups, _b = _a.lookups, lookups = _b === void 0 ? {} : _b, resolveLookups = _a.resolveLookups, fullWidth = _a.fullWidth, disabled = _a.disabled, placeholder = _a.placeholder, autopopulationId = _a.autopopulationId, otherProps = __rest(_a, ["multiple", "value", "lookupCode", "TextFieldProps", "parents", "onChange", "getLookups", "lookups", "resolveLookups", "fullWidth", "disabled", "placeholder", "autopopulationId"]);
|
|
80
|
+
var multiple = _a.multiple, value = _a.value, lookupTypeCode = _a.lookupCode, TextFieldProps = _a.TextFieldProps, parents = _a.parents, onChange = _a.onChange, getLookups = _a.getLookups, _b = _a.lookups, lookups = _b === void 0 ? {} : _b, resolveLookups = _a.resolveLookups, fullWidth = _a.fullWidth, disabled = _a.disabled, placeholder = _a.placeholder, autopopulationId = _a.autopopulationId, _c = _a.max, max = _c === void 0 ? MAX_DEPENDENT_LOOKUP_VALUES : _c, otherProps = __rest(_a, ["multiple", "value", "lookupCode", "TextFieldProps", "parents", "onChange", "getLookups", "lookups", "resolveLookups", "fullWidth", "disabled", "placeholder", "autopopulationId", "max"]);
|
|
80
81
|
var inputRef = react_1.useRef(null);
|
|
81
82
|
var selectRef = react_1.useRef(null);
|
|
82
83
|
var styles = styles_1.useStyles();
|
|
@@ -87,10 +88,10 @@ var DependentLookupEditor = function (_a) {
|
|
|
87
88
|
onLookupsResolve: function (lookups) { return onChange(multiple ? lookups : lookups[0]); }
|
|
88
89
|
});
|
|
89
90
|
useSavingFocus_1.default(selectRef, inputRef, disabled);
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
var
|
|
91
|
+
var _d = react_1.useState(''), inputValue = _d[0], setInputValue = _d[1];
|
|
92
|
+
var _e = react_1.useState([]), options = _e[0], setOptions = _e[1];
|
|
93
|
+
var _f = react_1.useState(1), pageNumber = _f[0], setPageNumber = _f[1];
|
|
94
|
+
var _g = react_1.useState(false), optionsAreLoading = _g[0], setOptionsAreLoading = _g[1];
|
|
94
95
|
var handleInputChange = function (value) {
|
|
95
96
|
if (value !== inputValue) {
|
|
96
97
|
setInputValue(value);
|
|
@@ -100,41 +101,35 @@ var DependentLookupEditor = function (_a) {
|
|
|
100
101
|
};
|
|
101
102
|
var loadOptions = react_1.useCallback(function (value, pageNumber) {
|
|
102
103
|
if (pageNumber === void 0) { pageNumber = 1; }
|
|
104
|
+
setOptionsAreLoading(true);
|
|
103
105
|
return getLookups({
|
|
104
106
|
type: lookupTypeCode,
|
|
105
107
|
parents: parents,
|
|
106
108
|
displayNamePrefix: value,
|
|
107
|
-
max:
|
|
108
|
-
offset: (pageNumber - 1) *
|
|
109
|
-
}).then(function (buildOptions) { return helpers_1.buildLookupOptions(buildOptions); });
|
|
110
|
-
}, [lookupTypeCode, parents]);
|
|
111
|
-
var loadMoreOptions = react_1.useCallback(function () {
|
|
112
|
-
setNextPageIsLoading(true);
|
|
113
|
-
loadOptions(inputValue, pageNumber + 1)
|
|
114
|
-
.then(function (buildOptions) {
|
|
115
|
-
setOptions(function (options) {
|
|
116
|
-
return ramda_1.concat(options.slice(0, pageNumber * MAX_DEPENDENT_LOOKUP_VALUES), buildOptions);
|
|
117
|
-
});
|
|
118
|
-
setPageNumber(function (page) { return page + 1; });
|
|
109
|
+
max: max + 1,
|
|
110
|
+
offset: (pageNumber - 1) * max
|
|
119
111
|
})
|
|
112
|
+
.then(function (buildOptions) { return helpers_1.buildLookupOptions(buildOptions); })
|
|
120
113
|
.catch(function () { return []; })
|
|
121
|
-
.finally(function () { return
|
|
122
|
-
}, [
|
|
114
|
+
.finally(function () { return setOptionsAreLoading(false); });
|
|
115
|
+
}, [max, lookupTypeCode, parents]);
|
|
116
|
+
var loadMoreOptions = react_1.useCallback(function () {
|
|
117
|
+
loadOptions(inputValue, pageNumber + 1).then(function (buildOptions) {
|
|
118
|
+
setOptions(function (options) { return ramda_1.concat(options.slice(0, pageNumber * max), buildOptions); });
|
|
119
|
+
setPageNumber(function (page) { return page + 1; });
|
|
120
|
+
});
|
|
121
|
+
}, [max, loadOptions, inputValue, pageNumber]);
|
|
123
122
|
var debouncedLoadOptions = react_1.useCallback(mdm_sdk_1.debounce(function (value, callback) {
|
|
124
|
-
|
|
125
|
-
loadOptions(value)
|
|
126
|
-
.then(function (options) { return callback(options); })
|
|
127
|
-
.catch(function () { return callback([]); })
|
|
128
|
-
.finally(function () { return setNextPageIsLoading(false); });
|
|
123
|
+
loadOptions(value).then(function (options) { return callback(options); });
|
|
129
124
|
}, exports.DEBOUNCE_INTERVAL), [loadOptions]);
|
|
130
|
-
var
|
|
125
|
+
var _h = useDefaultOptions_1.default(loadOptions), defaultOptions = _h.defaultOptions, initialDefaultOptions = _h.initialDefaultOptions, isLoadingDefaultOptions = _h.isLoading;
|
|
131
126
|
react_1.useEffect(function () {
|
|
132
127
|
setOptions(defaultOptions);
|
|
133
128
|
}, [defaultOptions]);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
]);
|
|
129
|
+
hooks_1.useDidUpdateEffect(function () {
|
|
130
|
+
setPageNumber(1);
|
|
131
|
+
}, [lookupTypeCode]);
|
|
132
|
+
var displayedOptions = react_1.useMemo(function () { return options.slice(0, pageNumber * max); }, [max, options, pageNumber]);
|
|
138
133
|
var showMoreButton = options.length > displayedOptions.length;
|
|
139
134
|
var isEmptyValue = multiple ? ramda_1.isEmpty(value) : !(value === null || value === void 0 ? void 0 : value.lookupCode) && !(value === null || value === void 0 ? void 0 : value.value);
|
|
140
135
|
var markAsTouched = useAutopopulation_1.default({
|
|
@@ -147,10 +142,12 @@ var DependentLookupEditor = function (_a) {
|
|
|
147
142
|
return (react_1.default.createElement(Select_1.default, __assign({}, otherProps, { isMulti: multiple, classes: styles, menuPortalTarget: document.body, menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { ref: inputRef, disabled: (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.disabled) || disabled }), inputRef: inputRef, innerRef: selectRef, styles: {
|
|
148
143
|
menuPortal: function (base) { return (__assign(__assign({}, base), { zIndex: 1300 })); },
|
|
149
144
|
container: function (base) { return (__assign(__assign({}, base), (fullWidth ? { width: '100%' } : {}))); }
|
|
150
|
-
},
|
|
145
|
+
}, noOptionsMessage: function () {
|
|
146
|
+
return optionsAreLoading && !showMoreButton ? ui_i18n_1.default.text('Loading...') : ui_i18n_1.default.text('No results found');
|
|
147
|
+
}, components: SelectComponents, isClearable: true, isSearchable: true, inputValue: inputValue, onInputChange: handleInputChange, loadingMessage: function () { return ui_i18n_1.default.text('Loading...'); }, isLoading: !inputValue && isLoadingDefaultOptions, hideSelectedOptions: false, placeholder: placeholder || '', isDisabled: disabled, options: displayedOptions, getOptionValue: ramda_1.either(ramda_1.prop('value'), ramda_1.prop('lookupCode')), getOptionLabel: helpers_1.getOptionLabel, onChange: function (value) {
|
|
151
148
|
markAsTouched();
|
|
152
149
|
onChange(value);
|
|
153
|
-
}, value: ramda_1.defaultTo(multiple ? [] : null, value), menuListFooter: showMoreButton && react_1.default.createElement(LoadMoreButton_1.default, { loading:
|
|
150
|
+
}, value: ramda_1.defaultTo(multiple ? [] : null, value), menuListFooter: showMoreButton && react_1.default.createElement(LoadMoreButton_1.default, { loading: optionsAreLoading, onClick: loadMoreOptions }) })));
|
|
154
151
|
};
|
|
155
152
|
DependentLookupEditor.propTypes = {
|
|
156
153
|
multiple: prop_types_1.default.bool,
|
|
@@ -169,6 +166,7 @@ DependentLookupEditor.propTypes = {
|
|
|
169
166
|
fullWidth: prop_types_1.default.bool,
|
|
170
167
|
placeholder: prop_types_1.default.string,
|
|
171
168
|
disabled: prop_types_1.default.bool,
|
|
172
|
-
autopopulationId: prop_types_1.default.string
|
|
169
|
+
autopopulationId: prop_types_1.default.string,
|
|
170
|
+
max: prop_types_1.default.number
|
|
173
171
|
};
|
|
174
172
|
exports.default = DependentLookupEditor;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default TypeaheadEditor;
|
|
2
|
-
declare function TypeaheadEditor({ value, getSuggestions, onChange, multiple, fullWidth, InputProps, ...inputProps }: {
|
|
2
|
+
declare function TypeaheadEditor({ value, max, getSuggestions, onChange, multiple, fullWidth, InputProps, ...inputProps }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
value: any;
|
|
5
|
+
max?: number;
|
|
5
6
|
getSuggestions: any;
|
|
6
7
|
onChange: any;
|
|
7
8
|
multiple: any;
|
|
@@ -17,6 +18,7 @@ declare namespace TypeaheadEditor {
|
|
|
17
18
|
const onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
18
19
|
const getSuggestions: PropTypes.Validator<(...args: any[]) => any>;
|
|
19
20
|
const InputProps: PropTypes.Requireable<object>;
|
|
21
|
+
const max: PropTypes.Requireable<number>;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
import PropTypes from "prop-types";
|
|
@@ -70,13 +70,13 @@ var hooks_1 = require("../../../hooks");
|
|
|
70
70
|
var FETCH_DEBOUNCE_INTERVAL = 300;
|
|
71
71
|
var PAGE_SIZE = 50;
|
|
72
72
|
var TypeaheadEditor = function (_a) {
|
|
73
|
-
var value = _a.value, getSuggestions = _a.getSuggestions, onChange = _a.onChange, multiple = _a.multiple, fullWidth = _a.fullWidth,
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
-
var pageSizeForRequest =
|
|
79
|
-
var
|
|
73
|
+
var value = _a.value, _b = _a.max, max = _b === void 0 ? PAGE_SIZE : _b, getSuggestions = _a.getSuggestions, onChange = _a.onChange, multiple = _a.multiple, fullWidth = _a.fullWidth, _c = _a.InputProps, InputProps = _c === void 0 ? {} : _c, inputProps = __rest(_a, ["value", "max", "getSuggestions", "onChange", "multiple", "fullWidth", "InputProps"]);
|
|
74
|
+
var _d = react_1.useState([]), suggestions = _d[0], setSuggestions = _d[1];
|
|
75
|
+
var _e = react_1.useState(false), isPlaceholderVisible = _e[0], setPlaceholderVisibility = _e[1];
|
|
76
|
+
var _f = react_1.useState(1), pageNumber = _f[0], setPageNumber = _f[1];
|
|
77
|
+
var _g = react_1.useState(false), nextPageIsLoading = _g[0], setNextPageIsLoading = _g[1];
|
|
78
|
+
var pageSizeForRequest = max + 1;
|
|
79
|
+
var _h = react_1.useState(''), currentValue = _h[0], setCurrentValue = _h[1];
|
|
80
80
|
value = ramda_1.defaultTo(multiple ? [] : '', value);
|
|
81
81
|
var inputValue = multiple ? currentValue : value;
|
|
82
82
|
hooks_1.useDidUpdateEffect(function () {
|
|
@@ -100,9 +100,9 @@ var TypeaheadEditor = function (_a) {
|
|
|
100
100
|
var debouncedFetchSuggestions = react_1.useCallback(mdm_sdk_1.debounce(fetchSuggestions, FETCH_DEBOUNCE_INTERVAL), [
|
|
101
101
|
getSuggestions
|
|
102
102
|
]);
|
|
103
|
-
var displayedSuggestions = react_1.useMemo(function () { return suggestions.slice(0, pageNumber *
|
|
103
|
+
var displayedSuggestions = react_1.useMemo(function () { return suggestions.slice(0, pageNumber * max); }, [suggestions, pageNumber, max]);
|
|
104
104
|
var showMoreButton = suggestions.length > displayedSuggestions.length;
|
|
105
|
-
var
|
|
105
|
+
var _j = react_1.useState(false), hasHighlightedItem = _j[0], setHasHighlightedItem = _j[1];
|
|
106
106
|
var onInputChange = function (_a) {
|
|
107
107
|
var newValue = _a.newValue, method = _a.method;
|
|
108
108
|
switch (method) {
|
|
@@ -172,6 +172,7 @@ TypeaheadEditor.propTypes = {
|
|
|
172
172
|
value: prop_types_1.default.oneOfType([prop_types_1.default.string, prop_types_1.default.arrayOf(prop_types_1.default.string)]),
|
|
173
173
|
onChange: prop_types_1.default.func.isRequired,
|
|
174
174
|
getSuggestions: prop_types_1.default.func.isRequired,
|
|
175
|
-
InputProps: prop_types_1.default.object
|
|
175
|
+
InputProps: prop_types_1.default.object,
|
|
176
|
+
max: prop_types_1.default.number
|
|
176
177
|
};
|
|
177
178
|
exports.default = TypeaheadEditor;
|
|
@@ -17,11 +17,10 @@ var MatchRulesBlock = function (_a) {
|
|
|
17
17
|
return uri !== NOT_MATCH;
|
|
18
18
|
});
|
|
19
19
|
var hasNotMatch = rules.length !== matchRules.length;
|
|
20
|
-
var showTransitive = isTransitive && variant !== MatchRuleVariant.ml;
|
|
21
20
|
var showSimple = !isTransitive && !hasNotMatch;
|
|
22
|
-
var showNotMatch = hasNotMatch &&
|
|
21
|
+
var showNotMatch = hasNotMatch && variant !== MatchRuleVariant.excludeNotMatch;
|
|
23
22
|
return (React.createElement(React.Fragment, null,
|
|
24
|
-
|
|
23
|
+
isTransitive ? (React.createElement(TransitiveMatchBlock, { transitiveMatchRules: getTransitiveMatchRules(metadata, match, entitiesMap) })) : null,
|
|
25
24
|
showSimple ? (React.createElement(SimpleMatchRulesBuilder, { variant: variant, matchRules: matchRules, Component: SimpleMatchRulesBlock })) : null,
|
|
26
25
|
showNotMatch ? React.createElement(NotMatchRule, null) : null));
|
|
27
26
|
};
|
|
@@ -28,9 +28,9 @@ import { MatchRuleVariant } from '../types';
|
|
|
28
28
|
var SimpleMatchRulesBuilder = function (_a) {
|
|
29
29
|
var matchRules = _a.matchRules, Component = _a.Component, _b = _a.variant, variant = _b === void 0 ? MatchRuleVariant.all : _b, otherProps = __rest(_a, ["matchRules", "Component", "variant"]);
|
|
30
30
|
var _c = partitionByMlMatch(matchRules), MlMatchRules = _c[0], otherMatchRules = _c[1];
|
|
31
|
-
var all = MatchRuleVariant.all, simple = MatchRuleVariant.simple,
|
|
32
|
-
var showSimple = [all, simple,
|
|
33
|
-
var showML = [all,
|
|
31
|
+
var all = MatchRuleVariant.all, simple = MatchRuleVariant.simple, excludeNotMatch = MatchRuleVariant.excludeNotMatch;
|
|
32
|
+
var showSimple = [all, simple, excludeNotMatch].includes(variant) && !isEmpty(otherMatchRules);
|
|
33
|
+
var showML = [all, excludeNotMatch].includes(variant) && !isEmpty(MlMatchRules);
|
|
34
34
|
return (React.createElement(React.Fragment, null,
|
|
35
35
|
showSimple ? React.createElement(Component, __assign({ matchRules: otherMatchRules }, otherProps)) : null,
|
|
36
36
|
showML ? React.createElement(Component, __assign({ isMlMatch: true, matchRules: MlMatchRules }, otherProps)) : null));
|
|
@@ -5,9 +5,7 @@ declare type MatchRule = {
|
|
|
5
5
|
export declare type MatchRules = MatchRule[];
|
|
6
6
|
export declare enum MatchRuleVariant {
|
|
7
7
|
all = "all",
|
|
8
|
-
ml = "ml",
|
|
9
8
|
simple = "simple",
|
|
10
|
-
excludeML = "excludeML",
|
|
11
9
|
excludeNotMatch = "excludeNotMatch"
|
|
12
10
|
}
|
|
13
11
|
export declare type TransitiveMatchRules = Array<{
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export var MatchRuleVariant;
|
|
2
2
|
(function (MatchRuleVariant) {
|
|
3
3
|
MatchRuleVariant["all"] = "all";
|
|
4
|
-
MatchRuleVariant["ml"] = "ml";
|
|
5
4
|
MatchRuleVariant["simple"] = "simple";
|
|
6
|
-
MatchRuleVariant["excludeML"] = "excludeML";
|
|
7
5
|
MatchRuleVariant["excludeNotMatch"] = "excludeNotMatch";
|
|
8
6
|
})(MatchRuleVariant || (MatchRuleVariant = {}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const DEBOUNCE_INTERVAL: 400;
|
|
2
2
|
export default DependentLookupEditor;
|
|
3
|
-
declare function DependentLookupEditor({ multiple, value, lookupCode: lookupTypeCode, TextFieldProps, parents, onChange, getLookups, lookups, resolveLookups, fullWidth, disabled, placeholder, autopopulationId, ...otherProps }: {
|
|
3
|
+
declare function DependentLookupEditor({ multiple, value, lookupCode: lookupTypeCode, TextFieldProps, parents, onChange, getLookups, lookups, resolveLookups, fullWidth, disabled, placeholder, autopopulationId, max, ...otherProps }: {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
multiple: any;
|
|
6
6
|
value: any;
|
|
@@ -15,6 +15,7 @@ declare function DependentLookupEditor({ multiple, value, lookupCode: lookupType
|
|
|
15
15
|
disabled: any;
|
|
16
16
|
placeholder: any;
|
|
17
17
|
autopopulationId: any;
|
|
18
|
+
max?: number;
|
|
18
19
|
}): JSX.Element;
|
|
19
20
|
declare namespace DependentLookupEditor {
|
|
20
21
|
namespace propTypes {
|
|
@@ -41,6 +42,7 @@ declare namespace DependentLookupEditor {
|
|
|
41
42
|
const placeholder: PropTypes.Requireable<string>;
|
|
42
43
|
const disabled: PropTypes.Requireable<boolean>;
|
|
43
44
|
const autopopulationId: PropTypes.Requireable<string>;
|
|
45
|
+
const max: PropTypes.Requireable<number>;
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
import PropTypes from "prop-types";
|
|
@@ -39,6 +39,7 @@ import useDefaultOptions from './useDefaultOptions';
|
|
|
39
39
|
import useAutopopulation from './useAutopopulation';
|
|
40
40
|
import useSavingFocus from './useSavingFocus';
|
|
41
41
|
import LoadMoreButton from '../../commonReactSelectComponents/LoadMoreButton';
|
|
42
|
+
import { useDidUpdateEffect } from '../../../hooks';
|
|
42
43
|
var SelectComponents = {
|
|
43
44
|
IndicatorSeparator: EmptyStub,
|
|
44
45
|
LoadingIndicator: EmptyStub,
|
|
@@ -51,7 +52,7 @@ var SelectComponents = {
|
|
|
51
52
|
export var DEBOUNCE_INTERVAL = 400;
|
|
52
53
|
var MAX_DEPENDENT_LOOKUP_VALUES = 50;
|
|
53
54
|
var DependentLookupEditor = function (_a) {
|
|
54
|
-
var multiple = _a.multiple, value = _a.value, lookupTypeCode = _a.lookupCode, TextFieldProps = _a.TextFieldProps, parents = _a.parents, onChange = _a.onChange, getLookups = _a.getLookups, _b = _a.lookups, lookups = _b === void 0 ? {} : _b, resolveLookups = _a.resolveLookups, fullWidth = _a.fullWidth, disabled = _a.disabled, placeholder = _a.placeholder, autopopulationId = _a.autopopulationId, otherProps = __rest(_a, ["multiple", "value", "lookupCode", "TextFieldProps", "parents", "onChange", "getLookups", "lookups", "resolveLookups", "fullWidth", "disabled", "placeholder", "autopopulationId"]);
|
|
55
|
+
var multiple = _a.multiple, value = _a.value, lookupTypeCode = _a.lookupCode, TextFieldProps = _a.TextFieldProps, parents = _a.parents, onChange = _a.onChange, getLookups = _a.getLookups, _b = _a.lookups, lookups = _b === void 0 ? {} : _b, resolveLookups = _a.resolveLookups, fullWidth = _a.fullWidth, disabled = _a.disabled, placeholder = _a.placeholder, autopopulationId = _a.autopopulationId, _c = _a.max, max = _c === void 0 ? MAX_DEPENDENT_LOOKUP_VALUES : _c, otherProps = __rest(_a, ["multiple", "value", "lookupCode", "TextFieldProps", "parents", "onChange", "getLookups", "lookups", "resolveLookups", "fullWidth", "disabled", "placeholder", "autopopulationId", "max"]);
|
|
55
56
|
var inputRef = useRef(null);
|
|
56
57
|
var selectRef = useRef(null);
|
|
57
58
|
var styles = useStyles();
|
|
@@ -62,10 +63,10 @@ var DependentLookupEditor = function (_a) {
|
|
|
62
63
|
onLookupsResolve: function (lookups) { return onChange(multiple ? lookups : lookups[0]); }
|
|
63
64
|
});
|
|
64
65
|
useSavingFocus(selectRef, inputRef, disabled);
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
66
|
+
var _d = useState(''), inputValue = _d[0], setInputValue = _d[1];
|
|
67
|
+
var _e = useState([]), options = _e[0], setOptions = _e[1];
|
|
68
|
+
var _f = useState(1), pageNumber = _f[0], setPageNumber = _f[1];
|
|
69
|
+
var _g = useState(false), optionsAreLoading = _g[0], setOptionsAreLoading = _g[1];
|
|
69
70
|
var handleInputChange = function (value) {
|
|
70
71
|
if (value !== inputValue) {
|
|
71
72
|
setInputValue(value);
|
|
@@ -75,41 +76,35 @@ var DependentLookupEditor = function (_a) {
|
|
|
75
76
|
};
|
|
76
77
|
var loadOptions = useCallback(function (value, pageNumber) {
|
|
77
78
|
if (pageNumber === void 0) { pageNumber = 1; }
|
|
79
|
+
setOptionsAreLoading(true);
|
|
78
80
|
return getLookups({
|
|
79
81
|
type: lookupTypeCode,
|
|
80
82
|
parents: parents,
|
|
81
83
|
displayNamePrefix: value,
|
|
82
|
-
max:
|
|
83
|
-
offset: (pageNumber - 1) *
|
|
84
|
-
}).then(function (buildOptions) { return buildLookupOptions(buildOptions); });
|
|
85
|
-
}, [lookupTypeCode, parents]);
|
|
86
|
-
var loadMoreOptions = useCallback(function () {
|
|
87
|
-
setNextPageIsLoading(true);
|
|
88
|
-
loadOptions(inputValue, pageNumber + 1)
|
|
89
|
-
.then(function (buildOptions) {
|
|
90
|
-
setOptions(function (options) {
|
|
91
|
-
return concat(options.slice(0, pageNumber * MAX_DEPENDENT_LOOKUP_VALUES), buildOptions);
|
|
92
|
-
});
|
|
93
|
-
setPageNumber(function (page) { return page + 1; });
|
|
84
|
+
max: max + 1,
|
|
85
|
+
offset: (pageNumber - 1) * max
|
|
94
86
|
})
|
|
87
|
+
.then(function (buildOptions) { return buildLookupOptions(buildOptions); })
|
|
95
88
|
.catch(function () { return []; })
|
|
96
|
-
.finally(function () { return
|
|
97
|
-
}, [
|
|
89
|
+
.finally(function () { return setOptionsAreLoading(false); });
|
|
90
|
+
}, [max, lookupTypeCode, parents]);
|
|
91
|
+
var loadMoreOptions = useCallback(function () {
|
|
92
|
+
loadOptions(inputValue, pageNumber + 1).then(function (buildOptions) {
|
|
93
|
+
setOptions(function (options) { return concat(options.slice(0, pageNumber * max), buildOptions); });
|
|
94
|
+
setPageNumber(function (page) { return page + 1; });
|
|
95
|
+
});
|
|
96
|
+
}, [max, loadOptions, inputValue, pageNumber]);
|
|
98
97
|
var debouncedLoadOptions = useCallback(debounce(function (value, callback) {
|
|
99
|
-
|
|
100
|
-
loadOptions(value)
|
|
101
|
-
.then(function (options) { return callback(options); })
|
|
102
|
-
.catch(function () { return callback([]); })
|
|
103
|
-
.finally(function () { return setNextPageIsLoading(false); });
|
|
98
|
+
loadOptions(value).then(function (options) { return callback(options); });
|
|
104
99
|
}, DEBOUNCE_INTERVAL), [loadOptions]);
|
|
105
|
-
var
|
|
100
|
+
var _h = useDefaultOptions(loadOptions), defaultOptions = _h.defaultOptions, initialDefaultOptions = _h.initialDefaultOptions, isLoadingDefaultOptions = _h.isLoading;
|
|
106
101
|
useEffect(function () {
|
|
107
102
|
setOptions(defaultOptions);
|
|
108
103
|
}, [defaultOptions]);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]);
|
|
104
|
+
useDidUpdateEffect(function () {
|
|
105
|
+
setPageNumber(1);
|
|
106
|
+
}, [lookupTypeCode]);
|
|
107
|
+
var displayedOptions = useMemo(function () { return options.slice(0, pageNumber * max); }, [max, options, pageNumber]);
|
|
113
108
|
var showMoreButton = options.length > displayedOptions.length;
|
|
114
109
|
var isEmptyValue = multiple ? isEmpty(value) : !(value === null || value === void 0 ? void 0 : value.lookupCode) && !(value === null || value === void 0 ? void 0 : value.value);
|
|
115
110
|
var markAsTouched = useAutopopulation({
|
|
@@ -122,10 +117,12 @@ var DependentLookupEditor = function (_a) {
|
|
|
122
117
|
return (React.createElement(Select, __assign({}, otherProps, { isMulti: multiple, classes: styles, menuPortalTarget: document.body, menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { ref: inputRef, disabled: (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.disabled) || disabled }), inputRef: inputRef, innerRef: selectRef, styles: {
|
|
123
118
|
menuPortal: function (base) { return (__assign(__assign({}, base), { zIndex: 1300 })); },
|
|
124
119
|
container: function (base) { return (__assign(__assign({}, base), (fullWidth ? { width: '100%' } : {}))); }
|
|
125
|
-
},
|
|
120
|
+
}, noOptionsMessage: function () {
|
|
121
|
+
return optionsAreLoading && !showMoreButton ? i18n.text('Loading...') : i18n.text('No results found');
|
|
122
|
+
}, components: SelectComponents, isClearable: true, isSearchable: true, inputValue: inputValue, onInputChange: handleInputChange, loadingMessage: function () { return i18n.text('Loading...'); }, isLoading: !inputValue && isLoadingDefaultOptions, hideSelectedOptions: false, placeholder: placeholder || '', isDisabled: disabled, options: displayedOptions, getOptionValue: either(prop('value'), prop('lookupCode')), getOptionLabel: getOptionLabel, onChange: function (value) {
|
|
126
123
|
markAsTouched();
|
|
127
124
|
onChange(value);
|
|
128
|
-
}, value: defaultTo(multiple ? [] : null, value), menuListFooter: showMoreButton && React.createElement(LoadMoreButton, { loading:
|
|
125
|
+
}, value: defaultTo(multiple ? [] : null, value), menuListFooter: showMoreButton && React.createElement(LoadMoreButton, { loading: optionsAreLoading, onClick: loadMoreOptions }) })));
|
|
129
126
|
};
|
|
130
127
|
DependentLookupEditor.propTypes = {
|
|
131
128
|
multiple: PropTypes.bool,
|
|
@@ -144,6 +141,7 @@ DependentLookupEditor.propTypes = {
|
|
|
144
141
|
fullWidth: PropTypes.bool,
|
|
145
142
|
placeholder: PropTypes.string,
|
|
146
143
|
disabled: PropTypes.bool,
|
|
147
|
-
autopopulationId: PropTypes.string
|
|
144
|
+
autopopulationId: PropTypes.string,
|
|
145
|
+
max: PropTypes.number
|
|
148
146
|
};
|
|
149
147
|
export default DependentLookupEditor;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default TypeaheadEditor;
|
|
2
|
-
declare function TypeaheadEditor({ value, getSuggestions, onChange, multiple, fullWidth, InputProps, ...inputProps }: {
|
|
2
|
+
declare function TypeaheadEditor({ value, max, getSuggestions, onChange, multiple, fullWidth, InputProps, ...inputProps }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
value: any;
|
|
5
|
+
max?: number;
|
|
5
6
|
getSuggestions: any;
|
|
6
7
|
onChange: any;
|
|
7
8
|
multiple: any;
|
|
@@ -17,6 +18,7 @@ declare namespace TypeaheadEditor {
|
|
|
17
18
|
const onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
18
19
|
const getSuggestions: PropTypes.Validator<(...args: any[]) => any>;
|
|
19
20
|
const InputProps: PropTypes.Requireable<object>;
|
|
21
|
+
const max: PropTypes.Requireable<number>;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
import PropTypes from "prop-types";
|
|
@@ -46,13 +46,13 @@ import { useDidUpdateEffect } from '../../../hooks';
|
|
|
46
46
|
var FETCH_DEBOUNCE_INTERVAL = 300;
|
|
47
47
|
var PAGE_SIZE = 50;
|
|
48
48
|
var TypeaheadEditor = function (_a) {
|
|
49
|
-
var value = _a.value, getSuggestions = _a.getSuggestions, onChange = _a.onChange, multiple = _a.multiple, fullWidth = _a.fullWidth,
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var pageSizeForRequest =
|
|
55
|
-
var
|
|
49
|
+
var value = _a.value, _b = _a.max, max = _b === void 0 ? PAGE_SIZE : _b, getSuggestions = _a.getSuggestions, onChange = _a.onChange, multiple = _a.multiple, fullWidth = _a.fullWidth, _c = _a.InputProps, InputProps = _c === void 0 ? {} : _c, inputProps = __rest(_a, ["value", "max", "getSuggestions", "onChange", "multiple", "fullWidth", "InputProps"]);
|
|
50
|
+
var _d = useState([]), suggestions = _d[0], setSuggestions = _d[1];
|
|
51
|
+
var _e = useState(false), isPlaceholderVisible = _e[0], setPlaceholderVisibility = _e[1];
|
|
52
|
+
var _f = useState(1), pageNumber = _f[0], setPageNumber = _f[1];
|
|
53
|
+
var _g = useState(false), nextPageIsLoading = _g[0], setNextPageIsLoading = _g[1];
|
|
54
|
+
var pageSizeForRequest = max + 1;
|
|
55
|
+
var _h = useState(''), currentValue = _h[0], setCurrentValue = _h[1];
|
|
56
56
|
value = defaultTo(multiple ? [] : '', value);
|
|
57
57
|
var inputValue = multiple ? currentValue : value;
|
|
58
58
|
useDidUpdateEffect(function () {
|
|
@@ -76,9 +76,9 @@ var TypeaheadEditor = function (_a) {
|
|
|
76
76
|
var debouncedFetchSuggestions = useCallback(debounce(fetchSuggestions, FETCH_DEBOUNCE_INTERVAL), [
|
|
77
77
|
getSuggestions
|
|
78
78
|
]);
|
|
79
|
-
var displayedSuggestions = useMemo(function () { return suggestions.slice(0, pageNumber *
|
|
79
|
+
var displayedSuggestions = useMemo(function () { return suggestions.slice(0, pageNumber * max); }, [suggestions, pageNumber, max]);
|
|
80
80
|
var showMoreButton = suggestions.length > displayedSuggestions.length;
|
|
81
|
-
var
|
|
81
|
+
var _j = useState(false), hasHighlightedItem = _j[0], setHasHighlightedItem = _j[1];
|
|
82
82
|
var onInputChange = function (_a) {
|
|
83
83
|
var newValue = _a.newValue, method = _a.method;
|
|
84
84
|
switch (method) {
|
|
@@ -148,6 +148,7 @@ TypeaheadEditor.propTypes = {
|
|
|
148
148
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
149
149
|
onChange: PropTypes.func.isRequired,
|
|
150
150
|
getSuggestions: PropTypes.func.isRequired,
|
|
151
|
-
InputProps: PropTypes.object
|
|
151
|
+
InputProps: PropTypes.object,
|
|
152
|
+
max: PropTypes.number
|
|
152
153
|
};
|
|
153
154
|
export default TypeaheadEditor;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1210",
|
|
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.
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-module": "^1.4.1210",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1210",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|