@reltio/components 1.4.1736 → 1.4.1738
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/MultipleInput/MultipleInput.d.ts +13 -27
- package/cjs/components/MultipleInput/MultipleInput.js +15 -30
- package/cjs/components/MultipleInput/styles.d.ts +1 -1
- package/cjs/components/editors/TypeaheadEditor/TypeaheadEditor.d.ts +2 -2
- package/cjs/components/editors/TypeaheadEditor/TypeaheadEditor.js +4 -2
- package/esm/components/MultipleInput/MultipleInput.d.ts +13 -27
- package/esm/components/MultipleInput/MultipleInput.js +15 -30
- package/esm/components/MultipleInput/styles.d.ts +1 -1
- package/esm/components/editors/TypeaheadEditor/TypeaheadEditor.d.ts +2 -2
- package/esm/components/editors/TypeaheadEditor/TypeaheadEditor.js +6 -4
- package/package.json +2 -2
|
@@ -1,28 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
type MultipleInputProps = Omit<TextFieldProps, 'classes' | 'value' | 'onChange' | 'onKeyPress' | 'onKeyDown' | 'onFocus' | 'onBlur'> & {
|
|
4
|
+
values?: string | string[];
|
|
5
|
+
InputProps?: Omit<TextFieldProps['InputProps'], 'startAdornment' | 'inputComponent'>;
|
|
6
|
+
classes?: {
|
|
7
|
+
root?: string;
|
|
8
|
+
};
|
|
9
|
+
isCrossedOut?: boolean;
|
|
10
|
+
onChange?: (values: string[]) => void;
|
|
11
|
+
getValueLabel?: (value: string) => string;
|
|
12
|
+
};
|
|
13
|
+
declare const MultipleInput: ({ values: valuesProp, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: MultipleInputProps) => JSX.Element;
|
|
1
14
|
export default MultipleInput;
|
|
2
|
-
declare function MultipleInput({ values, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
values?: any[];
|
|
5
|
-
InputProps?: {};
|
|
6
|
-
inputProps?: {};
|
|
7
|
-
classes?: {};
|
|
8
|
-
isCrossedOut: any;
|
|
9
|
-
onChange?: () => void;
|
|
10
|
-
getValueLabel?: any;
|
|
11
|
-
}): JSX.Element;
|
|
12
|
-
declare namespace MultipleInput {
|
|
13
|
-
namespace propTypes {
|
|
14
|
-
const values: PropTypes.Requireable<string[]>;
|
|
15
|
-
const InputProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
-
classes: PropTypes.Requireable<PropTypes.InferProps<{
|
|
17
|
-
root: PropTypes.Requireable<string>;
|
|
18
|
-
}>>;
|
|
19
|
-
inputComponent: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
20
|
-
}>>;
|
|
21
|
-
const inputProps: PropTypes.Requireable<object>;
|
|
22
|
-
const onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
const classes: PropTypes.Requireable<object>;
|
|
24
|
-
const getValueLabel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
const isCrossedOut: PropTypes.Requireable<boolean>;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
import PropTypes from 'prop-types';
|
|
@@ -57,38 +57,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
57
57
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
var react_1 = __importStar(require("react"));
|
|
61
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
62
|
+
var ramda_1 = require("ramda");
|
|
60
63
|
var react_input_autosize_1 = __importDefault(require("react-input-autosize"));
|
|
61
64
|
var classnames_1 = __importDefault(require("classnames"));
|
|
65
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
62
66
|
var TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
63
|
-
var
|
|
64
|
-
var react_1 = __importStar(require("react"));
|
|
65
|
-
var ramda_1 = require("ramda");
|
|
67
|
+
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
66
68
|
var utils_1 = require("../../core/utils");
|
|
67
|
-
var styles_1 = require("./styles");
|
|
68
69
|
var ValueChip_1 = __importDefault(require("../ValueChip/ValueChip"));
|
|
69
|
-
var
|
|
70
|
-
var
|
|
70
|
+
var styles_1 = require("./styles");
|
|
71
|
+
var EMPTY_VALUES_EDIT_HINT = ui_i18n_1.default.text('Press Enter to add. You may enter multiple values');
|
|
72
|
+
var isEmptyValue = (0, ramda_1.pipe)(ramda_1.trim, ramda_1.isEmpty);
|
|
71
73
|
var AutosizeInputWrapper = (0, react_1.forwardRef)(function (props, ref) {
|
|
72
74
|
var CustomInputComponent = props.CustomInputComponent, other = __rest(props, ["CustomInputComponent"]);
|
|
73
75
|
return CustomInputComponent ? (react_1.default.createElement(CustomInputComponent, __assign({}, other, { ref: ref, customInput: react_input_autosize_1.default }))) : (react_1.default.createElement(react_input_autosize_1.default, __assign({}, other, { ref: ref })));
|
|
74
76
|
});
|
|
75
|
-
AutosizeInputWrapper.propTypes = {
|
|
76
|
-
CustomInputComponent: prop_types_1.default.elementType
|
|
77
|
-
};
|
|
78
77
|
AutosizeInputWrapper.displayName = 'AutosizeInputWrapper';
|
|
79
|
-
var BACKSPACE_KEY_CODE = 8;
|
|
80
|
-
var EMPTY_VALUES_EDIT_HINT = ui_i18n_1.default.text('Press Enter to add. You may enter multiple values');
|
|
81
|
-
var isEmptyValue = (0, ramda_1.pipe)(ramda_1.trim, ramda_1.isEmpty);
|
|
82
78
|
var MultipleInput = function (_a) {
|
|
83
79
|
var _b;
|
|
84
|
-
var _c = _a.values,
|
|
80
|
+
var _c = _a.values, valuesProp = _c === void 0 ? [] : _c, _d = _a.InputProps, InputProps = _d === void 0 ? {} : _d, _e = _a.inputProps, inputProps = _e === void 0 ? {} : _e, _f = _a.classes, classes = _f === void 0 ? {} : _f, isCrossedOut = _a.isCrossedOut, _g = _a.onChange, onChange = _g === void 0 ? utils_1.noop : _g, _h = _a.getValueLabel, getValueLabel = _h === void 0 ? ramda_1.identity : _h, otherProps = __rest(_a, ["values", "InputProps", "inputProps", "classes", "isCrossedOut", "onChange", "getValueLabel"]);
|
|
85
81
|
var styles = (0, styles_1.useStyles)();
|
|
86
82
|
var _j = InputProps.classes || {}, root = _j.root, InputClasses = __rest(_j, ["root"]);
|
|
87
83
|
var _k = (0, react_1.useState)(''), inputValue = _k[0], setInputValue = _k[1];
|
|
84
|
+
var _l = (0, react_1.useState)(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
85
|
+
var values = (0, mdm_sdk_1.wrapInArrayIfNeeded)(valuesProp);
|
|
86
|
+
var hasValues = values.length > 0;
|
|
88
87
|
var clearInputValue = function () { return setInputValue(''); };
|
|
88
|
+
var setFocused = function () { return setIsFocused(true); };
|
|
89
|
+
var setUnfocused = function () { return setIsFocused(false); };
|
|
89
90
|
var removeValueAt = function (index) { return onChange((0, ramda_1.remove)(index, 1, values)); };
|
|
90
91
|
var appendValue = function (value) { return onChange((0, ramda_1.uniq)(__spreadArray(__spreadArray([], values, true), [value], false))); };
|
|
91
|
-
var hasValues = values.length > 0;
|
|
92
92
|
var appendInputValueIfNotEmpty = function () {
|
|
93
93
|
if (!isEmptyValue(inputValue)) {
|
|
94
94
|
appendValue(inputValue);
|
|
@@ -100,25 +100,10 @@ var MultipleInput = function (_a) {
|
|
|
100
100
|
removeValueAt(-1);
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
var _l = (0, react_1.useState)(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
104
|
-
var setFocused = function () { return setIsFocused(true); };
|
|
105
|
-
var setUnfocused = function () { return setIsFocused(false); };
|
|
106
103
|
var hintText = !hasValues && isFocused ? EMPTY_VALUES_EDIT_HINT : '';
|
|
107
104
|
return (react_1.default.createElement(Tooltip_1.default, { title: hintText },
|
|
108
105
|
react_1.default.createElement(TextField_1.default, __assign({ variant: "standard" }, otherProps, { classes: {
|
|
109
106
|
root: classes.root
|
|
110
|
-
}, value: inputValue, onChange: (0, ramda_1.pipe)(utils_1.getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (react_1.default.createElement(ValueChip_1.default, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: (0, classnames_1.default)(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: (0, classnames_1.default)(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: (0, ramda_1.when)((0, ramda_1.propEq)('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: (0, ramda_1.when)((0, ramda_1.propEq)('
|
|
111
|
-
};
|
|
112
|
-
MultipleInput.propTypes = {
|
|
113
|
-
values: prop_types_1.default.arrayOf(prop_types_1.default.string),
|
|
114
|
-
InputProps: prop_types_1.default.shape({
|
|
115
|
-
classes: prop_types_1.default.shape({ root: prop_types_1.default.string }),
|
|
116
|
-
inputComponent: prop_types_1.default.elementType
|
|
117
|
-
}),
|
|
118
|
-
inputProps: prop_types_1.default.object,
|
|
119
|
-
onChange: prop_types_1.default.func,
|
|
120
|
-
classes: prop_types_1.default.object,
|
|
121
|
-
getValueLabel: prop_types_1.default.func,
|
|
122
|
-
isCrossedOut: prop_types_1.default.bool
|
|
107
|
+
}, value: inputValue, onChange: (0, ramda_1.pipe)(utils_1.getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (react_1.default.createElement(ValueChip_1.default, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: (0, classnames_1.default)(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: (0, classnames_1.default)(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: (0, ramda_1.when)((0, ramda_1.propEq)('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: (0, ramda_1.when)((0, ramda_1.propEq)('key', 'Backspace'), popLastValueIfInputIsEmpty), onFocus: setFocused, onBlur: (0, ramda_1.pipe)(appendInputValueIfNotEmpty, setUnfocused) }))));
|
|
123
108
|
};
|
|
124
109
|
exports.default = MultipleInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
@@ -8,7 +8,7 @@ type CommonProps = Omit<TextFieldProps, 'onChange' | 'value'> & {
|
|
|
8
8
|
isCrossedOut?: boolean;
|
|
9
9
|
};
|
|
10
10
|
type MultipleProps = CommonProps & {
|
|
11
|
-
value?: string[];
|
|
11
|
+
value?: string | string[];
|
|
12
12
|
onChange: (values: string[]) => void;
|
|
13
13
|
multiple: true;
|
|
14
14
|
};
|
|
@@ -18,5 +18,5 @@ type SingleProps = CommonProps & {
|
|
|
18
18
|
multiple?: false;
|
|
19
19
|
};
|
|
20
20
|
export type Props = MultipleProps | SingleProps;
|
|
21
|
-
declare const TypeaheadEditor: ({ value, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
21
|
+
declare const TypeaheadEditor: ({ value: valueProp, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
22
22
|
export default TypeaheadEditor;
|
|
@@ -119,7 +119,7 @@ var ChangeMethod;
|
|
|
119
119
|
ChangeMethod["Enter"] = "enter";
|
|
120
120
|
})(ChangeMethod || (ChangeMethod = {}));
|
|
121
121
|
var TypeaheadEditor = function (_a) {
|
|
122
|
-
var
|
|
122
|
+
var valueProp = _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, _d = _a.isCrossedOut, isCrossedOut = _d === void 0 ? false : _d, inputProps = __rest(_a, ["value", "max", "getSuggestions", "onChange", "multiple", "fullWidth", "InputProps", "isCrossedOut"]);
|
|
123
123
|
var styles = (0, styles_1.useStyles)();
|
|
124
124
|
var inputRef = (0, react_1.useRef)(null);
|
|
125
125
|
var safePromise = (0, hooks_1.useSafePromise)();
|
|
@@ -132,6 +132,7 @@ var TypeaheadEditor = function (_a) {
|
|
|
132
132
|
var pageSizeForRequest = max + 1;
|
|
133
133
|
var displayedSuggestions = (0, react_1.useMemo)(function () { return suggestions.slice(0, pageNumber * max); }, [suggestions, pageNumber, max]);
|
|
134
134
|
var showMoreButton = suggestions.length > displayedSuggestions.length;
|
|
135
|
+
var value = multiple === true && !(0, ramda_1.isNil)(valueProp) ? (0, mdm_sdk_1.wrapInArrayIfNeeded)(valueProp) : valueProp;
|
|
135
136
|
var isFocused = function () { var _a; return ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === document.activeElement; };
|
|
136
137
|
var fetchSuggestions = (0, react_1.useCallback)(function (_a) {
|
|
137
138
|
var value = _a.value;
|
|
@@ -226,8 +227,9 @@ var TypeaheadEditor = function (_a) {
|
|
|
226
227
|
onChange(inputValue);
|
|
227
228
|
}, [inputValue, onChange, multiple]);
|
|
228
229
|
(0, react_1.useEffect)(function () {
|
|
230
|
+
var _a;
|
|
229
231
|
if (multiple !== true)
|
|
230
|
-
setInputValue(value !== null &&
|
|
232
|
+
setInputValue((_a = value) !== null && _a !== void 0 ? _a : '');
|
|
231
233
|
}, [value, multiple]);
|
|
232
234
|
(0, hooks_1.useDidUpdateEffect)(function () {
|
|
233
235
|
setPageNumber(1);
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
type MultipleInputProps = Omit<TextFieldProps, 'classes' | 'value' | 'onChange' | 'onKeyPress' | 'onKeyDown' | 'onFocus' | 'onBlur'> & {
|
|
4
|
+
values?: string | string[];
|
|
5
|
+
InputProps?: Omit<TextFieldProps['InputProps'], 'startAdornment' | 'inputComponent'>;
|
|
6
|
+
classes?: {
|
|
7
|
+
root?: string;
|
|
8
|
+
};
|
|
9
|
+
isCrossedOut?: boolean;
|
|
10
|
+
onChange?: (values: string[]) => void;
|
|
11
|
+
getValueLabel?: (value: string) => string;
|
|
12
|
+
};
|
|
13
|
+
declare const MultipleInput: ({ values: valuesProp, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: MultipleInputProps) => JSX.Element;
|
|
1
14
|
export default MultipleInput;
|
|
2
|
-
declare function MultipleInput({ values, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
values?: any[];
|
|
5
|
-
InputProps?: {};
|
|
6
|
-
inputProps?: {};
|
|
7
|
-
classes?: {};
|
|
8
|
-
isCrossedOut: any;
|
|
9
|
-
onChange?: () => void;
|
|
10
|
-
getValueLabel?: any;
|
|
11
|
-
}): JSX.Element;
|
|
12
|
-
declare namespace MultipleInput {
|
|
13
|
-
namespace propTypes {
|
|
14
|
-
const values: PropTypes.Requireable<string[]>;
|
|
15
|
-
const InputProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
-
classes: PropTypes.Requireable<PropTypes.InferProps<{
|
|
17
|
-
root: PropTypes.Requireable<string>;
|
|
18
|
-
}>>;
|
|
19
|
-
inputComponent: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
20
|
-
}>>;
|
|
21
|
-
const inputProps: PropTypes.Requireable<object>;
|
|
22
|
-
const onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
const classes: PropTypes.Requireable<object>;
|
|
24
|
-
const getValueLabel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
const isCrossedOut: PropTypes.Requireable<boolean>;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
import PropTypes from 'prop-types';
|
|
@@ -29,38 +29,38 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
29
29
|
}
|
|
30
30
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
31
|
};
|
|
32
|
+
import React, { forwardRef, useState } from 'react';
|
|
33
|
+
import i18n from 'ui-i18n';
|
|
34
|
+
import { identity, pipe, propEq, remove, uniq, when, trim, isEmpty } from 'ramda';
|
|
32
35
|
import AutosizeInput from 'react-input-autosize';
|
|
33
36
|
import classnames from 'classnames';
|
|
37
|
+
import { wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
|
|
34
38
|
import TextField from '@mui/material/TextField';
|
|
35
|
-
import
|
|
36
|
-
import React, { forwardRef, useState } from 'react';
|
|
37
|
-
import { identity, pipe, propEq, remove, uniq, when, trim, isEmpty } from 'ramda';
|
|
39
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
38
40
|
import { getValue, noop } from '../../core/utils';
|
|
39
|
-
import { useStyles } from './styles';
|
|
40
41
|
import ValueChip from '../ValueChip/ValueChip';
|
|
41
|
-
import
|
|
42
|
-
|
|
42
|
+
import { useStyles } from './styles';
|
|
43
|
+
var EMPTY_VALUES_EDIT_HINT = i18n.text('Press Enter to add. You may enter multiple values');
|
|
44
|
+
var isEmptyValue = pipe(trim, isEmpty);
|
|
43
45
|
var AutosizeInputWrapper = forwardRef(function (props, ref) {
|
|
44
46
|
var CustomInputComponent = props.CustomInputComponent, other = __rest(props, ["CustomInputComponent"]);
|
|
45
47
|
return CustomInputComponent ? (React.createElement(CustomInputComponent, __assign({}, other, { ref: ref, customInput: AutosizeInput }))) : (React.createElement(AutosizeInput, __assign({}, other, { ref: ref })));
|
|
46
48
|
});
|
|
47
|
-
AutosizeInputWrapper.propTypes = {
|
|
48
|
-
CustomInputComponent: PropTypes.elementType
|
|
49
|
-
};
|
|
50
49
|
AutosizeInputWrapper.displayName = 'AutosizeInputWrapper';
|
|
51
|
-
var BACKSPACE_KEY_CODE = 8;
|
|
52
|
-
var EMPTY_VALUES_EDIT_HINT = i18n.text('Press Enter to add. You may enter multiple values');
|
|
53
|
-
var isEmptyValue = pipe(trim, isEmpty);
|
|
54
50
|
var MultipleInput = function (_a) {
|
|
55
51
|
var _b;
|
|
56
|
-
var _c = _a.values,
|
|
52
|
+
var _c = _a.values, valuesProp = _c === void 0 ? [] : _c, _d = _a.InputProps, InputProps = _d === void 0 ? {} : _d, _e = _a.inputProps, inputProps = _e === void 0 ? {} : _e, _f = _a.classes, classes = _f === void 0 ? {} : _f, isCrossedOut = _a.isCrossedOut, _g = _a.onChange, onChange = _g === void 0 ? noop : _g, _h = _a.getValueLabel, getValueLabel = _h === void 0 ? identity : _h, otherProps = __rest(_a, ["values", "InputProps", "inputProps", "classes", "isCrossedOut", "onChange", "getValueLabel"]);
|
|
57
53
|
var styles = useStyles();
|
|
58
54
|
var _j = InputProps.classes || {}, root = _j.root, InputClasses = __rest(_j, ["root"]);
|
|
59
55
|
var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
|
|
56
|
+
var _l = useState(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
57
|
+
var values = wrapInArrayIfNeeded(valuesProp);
|
|
58
|
+
var hasValues = values.length > 0;
|
|
60
59
|
var clearInputValue = function () { return setInputValue(''); };
|
|
60
|
+
var setFocused = function () { return setIsFocused(true); };
|
|
61
|
+
var setUnfocused = function () { return setIsFocused(false); };
|
|
61
62
|
var removeValueAt = function (index) { return onChange(remove(index, 1, values)); };
|
|
62
63
|
var appendValue = function (value) { return onChange(uniq(__spreadArray(__spreadArray([], values, true), [value], false))); };
|
|
63
|
-
var hasValues = values.length > 0;
|
|
64
64
|
var appendInputValueIfNotEmpty = function () {
|
|
65
65
|
if (!isEmptyValue(inputValue)) {
|
|
66
66
|
appendValue(inputValue);
|
|
@@ -72,25 +72,10 @@ var MultipleInput = function (_a) {
|
|
|
72
72
|
removeValueAt(-1);
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
var _l = useState(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
76
|
-
var setFocused = function () { return setIsFocused(true); };
|
|
77
|
-
var setUnfocused = function () { return setIsFocused(false); };
|
|
78
75
|
var hintText = !hasValues && isFocused ? EMPTY_VALUES_EDIT_HINT : '';
|
|
79
76
|
return (React.createElement(Tooltip, { title: hintText },
|
|
80
77
|
React.createElement(TextField, __assign({ variant: "standard" }, otherProps, { classes: {
|
|
81
78
|
root: classes.root
|
|
82
|
-
}, value: inputValue, onChange: pipe(getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (React.createElement(ValueChip, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: classnames(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: classnames(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: when(propEq('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: when(propEq('
|
|
83
|
-
};
|
|
84
|
-
MultipleInput.propTypes = {
|
|
85
|
-
values: PropTypes.arrayOf(PropTypes.string),
|
|
86
|
-
InputProps: PropTypes.shape({
|
|
87
|
-
classes: PropTypes.shape({ root: PropTypes.string }),
|
|
88
|
-
inputComponent: PropTypes.elementType
|
|
89
|
-
}),
|
|
90
|
-
inputProps: PropTypes.object,
|
|
91
|
-
onChange: PropTypes.func,
|
|
92
|
-
classes: PropTypes.object,
|
|
93
|
-
getValueLabel: PropTypes.func,
|
|
94
|
-
isCrossedOut: PropTypes.bool
|
|
79
|
+
}, value: inputValue, onChange: pipe(getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (React.createElement(ValueChip, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: classnames(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: classnames(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: when(propEq('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: when(propEq('key', 'Backspace'), popLastValueIfInputIsEmpty), onFocus: setFocused, onBlur: pipe(appendInputValueIfNotEmpty, setUnfocused) }))));
|
|
95
80
|
};
|
|
96
81
|
export default MultipleInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
@@ -8,7 +8,7 @@ type CommonProps = Omit<TextFieldProps, 'onChange' | 'value'> & {
|
|
|
8
8
|
isCrossedOut?: boolean;
|
|
9
9
|
};
|
|
10
10
|
type MultipleProps = CommonProps & {
|
|
11
|
-
value?: string[];
|
|
11
|
+
value?: string | string[];
|
|
12
12
|
onChange: (values: string[]) => void;
|
|
13
13
|
multiple: true;
|
|
14
14
|
};
|
|
@@ -18,5 +18,5 @@ type SingleProps = CommonProps & {
|
|
|
18
18
|
multiple?: false;
|
|
19
19
|
};
|
|
20
20
|
export type Props = MultipleProps | SingleProps;
|
|
21
|
-
declare const TypeaheadEditor: ({ value, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
21
|
+
declare const TypeaheadEditor: ({ value: valueProp, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
22
22
|
export default TypeaheadEditor;
|
|
@@ -66,9 +66,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
66
66
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
67
|
};
|
|
68
68
|
import React, { useCallback, useRef, useMemo, useState, useEffect } from 'react';
|
|
69
|
-
import { identity, isEmpty, nthArg, path, pipe, prop, remove, T, uniq } from 'ramda';
|
|
69
|
+
import { identity, isEmpty, nthArg, path, pipe, prop, remove, T, uniq, isNil } from 'ramda';
|
|
70
70
|
import classnames from 'classnames';
|
|
71
|
-
import { debounce, isEmptyValue } from '@reltio/mdm-sdk';
|
|
71
|
+
import { debounce, isEmptyValue, wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
|
|
72
72
|
import Autosuggest from 'react-autosuggest';
|
|
73
73
|
import AutosizeInput from 'react-input-autosize';
|
|
74
74
|
import TextField from '@mui/material/TextField';
|
|
@@ -91,7 +91,7 @@ var ChangeMethod;
|
|
|
91
91
|
ChangeMethod["Enter"] = "enter";
|
|
92
92
|
})(ChangeMethod || (ChangeMethod = {}));
|
|
93
93
|
var TypeaheadEditor = function (_a) {
|
|
94
|
-
var
|
|
94
|
+
var valueProp = _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, _d = _a.isCrossedOut, isCrossedOut = _d === void 0 ? false : _d, inputProps = __rest(_a, ["value", "max", "getSuggestions", "onChange", "multiple", "fullWidth", "InputProps", "isCrossedOut"]);
|
|
95
95
|
var styles = useStyles();
|
|
96
96
|
var inputRef = useRef(null);
|
|
97
97
|
var safePromise = useSafePromise();
|
|
@@ -104,6 +104,7 @@ var TypeaheadEditor = function (_a) {
|
|
|
104
104
|
var pageSizeForRequest = max + 1;
|
|
105
105
|
var displayedSuggestions = useMemo(function () { return suggestions.slice(0, pageNumber * max); }, [suggestions, pageNumber, max]);
|
|
106
106
|
var showMoreButton = suggestions.length > displayedSuggestions.length;
|
|
107
|
+
var value = multiple === true && !isNil(valueProp) ? wrapInArrayIfNeeded(valueProp) : valueProp;
|
|
107
108
|
var isFocused = function () { var _a; return ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === document.activeElement; };
|
|
108
109
|
var fetchSuggestions = useCallback(function (_a) {
|
|
109
110
|
var value = _a.value;
|
|
@@ -198,8 +199,9 @@ var TypeaheadEditor = function (_a) {
|
|
|
198
199
|
onChange(inputValue);
|
|
199
200
|
}, [inputValue, onChange, multiple]);
|
|
200
201
|
useEffect(function () {
|
|
202
|
+
var _a;
|
|
201
203
|
if (multiple !== true)
|
|
202
|
-
setInputValue(value !== null &&
|
|
204
|
+
setInputValue((_a = value) !== null && _a !== void 0 ? _a : '');
|
|
203
205
|
}, [value, multiple]);
|
|
204
206
|
useDidUpdateEffect(function () {
|
|
205
207
|
setPageNumber(1);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1738",
|
|
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
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-sdk": "^1.4.1721",
|
|
11
11
|
"classnames": "^2.2.5",
|
|
12
12
|
"d3-cloud": "^1.2.5",
|
|
13
13
|
"d3-geo": "^2.0.1",
|