@reltio/components 1.4.1657 → 1.4.1659
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/ReactSelect/MultiSelect/MultiSelect.js +11 -1
- package/cjs/components/ReactSelect/hooks/useKeepInputVisible.d.ts +2 -0
- package/cjs/components/ReactSelect/hooks/useKeepInputVisible.js +39 -0
- package/cjs/components/history/HistoryFilterButton/HistoryFilterButton.js +1 -1
- package/esm/components/ReactSelect/MultiSelect/MultiSelect.js +13 -3
- package/esm/components/ReactSelect/hooks/useKeepInputVisible.d.ts +2 -0
- package/esm/components/ReactSelect/hooks/useKeepInputVisible.js +35 -0
- package/esm/components/history/HistoryFilterButton/HistoryFilterButton.js +1 -1
- package/package.json +2 -2
|
@@ -57,6 +57,14 @@ var AsyncSelect_1 = __importDefault(require("../AsyncSelect"));
|
|
|
57
57
|
var components_1 = __importDefault(require("./components"));
|
|
58
58
|
var styles_1 = require("@mui/styles");
|
|
59
59
|
var utils_1 = require("../../../core/utils");
|
|
60
|
+
var useKeepInputVisible_1 = require("../hooks/useKeepInputVisible");
|
|
61
|
+
var getControlRef = function (innerRef) {
|
|
62
|
+
var controlRef = {};
|
|
63
|
+
if (innerRef.current) {
|
|
64
|
+
controlRef.current = (0, ramda_1.either)((0, ramda_1.path)(['select', 'controlRef']), (0, ramda_1.path)(['select', 'select', 'controlRef']))(innerRef.current);
|
|
65
|
+
}
|
|
66
|
+
return controlRef;
|
|
67
|
+
};
|
|
60
68
|
var useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
61
69
|
label: {
|
|
62
70
|
top: 6,
|
|
@@ -85,6 +93,8 @@ function MultiSelect(props) {
|
|
|
85
93
|
var _b = (0, react_1.useState)(''), inputValue = _b[0], setInputValue = _b[1];
|
|
86
94
|
var multiSelectClasses = useStyles((0, ramda_1.omit)(['classes'], props));
|
|
87
95
|
var inputId = getInputId();
|
|
96
|
+
var innerRef = (0, react_1.useRef)();
|
|
97
|
+
(0, useKeepInputVisible_1.useKeepInputVisible)(props.value, getControlRef(innerRef));
|
|
88
98
|
var components = __assign(__assign({}, components_1.default), componentsProp);
|
|
89
99
|
var classes = (0, utils_1.mergeClasses)(multiSelectClasses, classesProp);
|
|
90
100
|
function handleInputChange(value, _a) {
|
|
@@ -112,7 +122,7 @@ function MultiSelect(props) {
|
|
|
112
122
|
} }, props.TextFieldProps)
|
|
113
123
|
}
|
|
114
124
|
: {};
|
|
115
|
-
return (react_1.default.createElement(SelectComponent, __assign({ isMulti: true, inputId: inputId, inputValue: inputValue, onChange: handleChange, onInputChange: handleInputChange, closeMenuOnSelect: false, hideSelectedOptions: false, classes: classes, components: components, styles: styles, menuPlacement: menuPlacement, loadOptions: getOptions }, labelProps, reactSelectProps)));
|
|
125
|
+
return (react_1.default.createElement(SelectComponent, __assign({ isMulti: true, inputId: inputId, inputValue: inputValue, onChange: handleChange, onInputChange: handleInputChange, closeMenuOnSelect: false, hideSelectedOptions: false, classes: classes, components: components, styles: styles, menuPlacement: menuPlacement, loadOptions: getOptions, innerRef: innerRef }, labelProps, reactSelectProps)));
|
|
116
126
|
}
|
|
117
127
|
MultiSelect.defaultProps = {
|
|
118
128
|
creatable: false,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useKeepInputVisible = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var hooks_1 = require("../../../hooks");
|
|
6
|
+
var findNearestScrollableElement = function (element) {
|
|
7
|
+
var currentElement = element === null || element === void 0 ? void 0 : element.parentElement;
|
|
8
|
+
while (currentElement) {
|
|
9
|
+
if (currentElement.scrollHeight > currentElement.clientHeight) {
|
|
10
|
+
return currentElement;
|
|
11
|
+
}
|
|
12
|
+
currentElement = currentElement.parentElement;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
var needToScroll = function (valueLength, prevValuesLength, parentElementWithScroll, currentElement) {
|
|
17
|
+
return valueLength &&
|
|
18
|
+
prevValuesLength < valueLength &&
|
|
19
|
+
currentElement.getBoundingClientRect().bottom > parentElementWithScroll.getBoundingClientRect().bottom;
|
|
20
|
+
};
|
|
21
|
+
var useKeepInputVisible = function (values, ref) {
|
|
22
|
+
if (values === void 0) { values = []; }
|
|
23
|
+
var prevValuesLength = (0, hooks_1.usePrevious)(values === null || values === void 0 ? void 0 : values.length);
|
|
24
|
+
(0, react_1.useEffect)(function () {
|
|
25
|
+
var timerId = setTimeout(function () {
|
|
26
|
+
var _a;
|
|
27
|
+
var parentElementWithScroll = findNearestScrollableElement(ref === null || ref === void 0 ? void 0 : ref.current);
|
|
28
|
+
if (parentElementWithScroll &&
|
|
29
|
+
needToScroll(values === null || values === void 0 ? void 0 : values.length, prevValuesLength, parentElementWithScroll, ref.current)) {
|
|
30
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView(false);
|
|
31
|
+
}
|
|
32
|
+
}, 0);
|
|
33
|
+
return function () {
|
|
34
|
+
clearTimeout(timerId);
|
|
35
|
+
};
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [values === null || values === void 0 ? void 0 : values.length]);
|
|
38
|
+
};
|
|
39
|
+
exports.useKeepInputVisible = useKeepInputVisible;
|
|
@@ -96,7 +96,7 @@ var HistoryFilterButton = function (_a) {
|
|
|
96
96
|
horizontal: 'right'
|
|
97
97
|
} },
|
|
98
98
|
react_1.default.createElement(DialogTitle_1.default, null, ui_i18n_1.default.text('Filter')),
|
|
99
|
-
react_1.default.createElement(DialogContent_1.default, { dividers: true, className: styles.filterContainer },
|
|
99
|
+
react_1.default.createElement(DialogContent_1.default, { dividers: true, className: styles.filterContainer, "data-reltio-id": "history-filter-container" },
|
|
100
100
|
react_1.default.createElement(DateRangeSelector_1.default, { value: dateRange, onChange: handlePropChange('dateRange'), className: styles.filterItem }),
|
|
101
101
|
react_1.default.createElement(Divider_1.default, { light: true, className: styles.divider }),
|
|
102
102
|
react_1.default.createElement(UserSelector_1.default, { selectedUsers: users, onChange: handlePropChange('users'), className: styles.filterItem, disableUnderline: true }),
|
|
@@ -20,15 +20,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React, { useState } from 'react';
|
|
23
|
+
import React, { useState, useRef } from 'react';
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
|
-
import { omit } from 'ramda';
|
|
25
|
+
import { omit, either, path } from 'ramda';
|
|
26
26
|
import CreatableSelect from '../CreatableSelect';
|
|
27
27
|
import Select from '../Select';
|
|
28
28
|
import AsyncSelect from '../AsyncSelect';
|
|
29
29
|
import multiSelectComponents from './components';
|
|
30
30
|
import { makeStyles } from '@mui/styles';
|
|
31
31
|
import { mergeClasses } from '../../../core/utils';
|
|
32
|
+
import { useKeepInputVisible } from '../hooks/useKeepInputVisible';
|
|
33
|
+
var getControlRef = function (innerRef) {
|
|
34
|
+
var controlRef = {};
|
|
35
|
+
if (innerRef.current) {
|
|
36
|
+
controlRef.current = either(path(['select', 'controlRef']), path(['select', 'select', 'controlRef']))(innerRef.current);
|
|
37
|
+
}
|
|
38
|
+
return controlRef;
|
|
39
|
+
};
|
|
32
40
|
var useStyles = makeStyles(function (theme) { return ({
|
|
33
41
|
label: {
|
|
34
42
|
top: 6,
|
|
@@ -57,6 +65,8 @@ function MultiSelect(props) {
|
|
|
57
65
|
var _b = useState(''), inputValue = _b[0], setInputValue = _b[1];
|
|
58
66
|
var multiSelectClasses = useStyles(omit(['classes'], props));
|
|
59
67
|
var inputId = getInputId();
|
|
68
|
+
var innerRef = useRef();
|
|
69
|
+
useKeepInputVisible(props.value, getControlRef(innerRef));
|
|
60
70
|
var components = __assign(__assign({}, multiSelectComponents), componentsProp);
|
|
61
71
|
var classes = mergeClasses(multiSelectClasses, classesProp);
|
|
62
72
|
function handleInputChange(value, _a) {
|
|
@@ -84,7 +94,7 @@ function MultiSelect(props) {
|
|
|
84
94
|
} }, props.TextFieldProps)
|
|
85
95
|
}
|
|
86
96
|
: {};
|
|
87
|
-
return (React.createElement(SelectComponent, __assign({ isMulti: true, inputId: inputId, inputValue: inputValue, onChange: handleChange, onInputChange: handleInputChange, closeMenuOnSelect: false, hideSelectedOptions: false, classes: classes, components: components, styles: styles, menuPlacement: menuPlacement, loadOptions: getOptions }, labelProps, reactSelectProps)));
|
|
97
|
+
return (React.createElement(SelectComponent, __assign({ isMulti: true, inputId: inputId, inputValue: inputValue, onChange: handleChange, onInputChange: handleInputChange, closeMenuOnSelect: false, hideSelectedOptions: false, classes: classes, components: components, styles: styles, menuPlacement: menuPlacement, loadOptions: getOptions, innerRef: innerRef }, labelProps, reactSelectProps)));
|
|
88
98
|
}
|
|
89
99
|
MultiSelect.defaultProps = {
|
|
90
100
|
creatable: false,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { usePrevious } from '../../../hooks';
|
|
3
|
+
var findNearestScrollableElement = function (element) {
|
|
4
|
+
var currentElement = element === null || element === void 0 ? void 0 : element.parentElement;
|
|
5
|
+
while (currentElement) {
|
|
6
|
+
if (currentElement.scrollHeight > currentElement.clientHeight) {
|
|
7
|
+
return currentElement;
|
|
8
|
+
}
|
|
9
|
+
currentElement = currentElement.parentElement;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
var needToScroll = function (valueLength, prevValuesLength, parentElementWithScroll, currentElement) {
|
|
14
|
+
return valueLength &&
|
|
15
|
+
prevValuesLength < valueLength &&
|
|
16
|
+
currentElement.getBoundingClientRect().bottom > parentElementWithScroll.getBoundingClientRect().bottom;
|
|
17
|
+
};
|
|
18
|
+
export var useKeepInputVisible = function (values, ref) {
|
|
19
|
+
if (values === void 0) { values = []; }
|
|
20
|
+
var prevValuesLength = usePrevious(values === null || values === void 0 ? void 0 : values.length);
|
|
21
|
+
useEffect(function () {
|
|
22
|
+
var timerId = setTimeout(function () {
|
|
23
|
+
var _a;
|
|
24
|
+
var parentElementWithScroll = findNearestScrollableElement(ref === null || ref === void 0 ? void 0 : ref.current);
|
|
25
|
+
if (parentElementWithScroll &&
|
|
26
|
+
needToScroll(values === null || values === void 0 ? void 0 : values.length, prevValuesLength, parentElementWithScroll, ref.current)) {
|
|
27
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView(false);
|
|
28
|
+
}
|
|
29
|
+
}, 0);
|
|
30
|
+
return function () {
|
|
31
|
+
clearTimeout(timerId);
|
|
32
|
+
};
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
}, [values === null || values === void 0 ? void 0 : values.length]);
|
|
35
|
+
};
|
|
@@ -68,7 +68,7 @@ var HistoryFilterButton = function (_a) {
|
|
|
68
68
|
horizontal: 'right'
|
|
69
69
|
} },
|
|
70
70
|
React.createElement(DialogTitle, null, i18n.text('Filter')),
|
|
71
|
-
React.createElement(DialogContent, { dividers: true, className: styles.filterContainer },
|
|
71
|
+
React.createElement(DialogContent, { dividers: true, className: styles.filterContainer, "data-reltio-id": "history-filter-container" },
|
|
72
72
|
React.createElement(DateRangeSelector, { value: dateRange, onChange: handlePropChange('dateRange'), className: styles.filterItem }),
|
|
73
73
|
React.createElement(Divider, { light: true, className: styles.divider }),
|
|
74
74
|
React.createElement(UserSelector, { selectedUsers: users, onChange: handlePropChange('users'), className: styles.filterItem, disableUnderline: true }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1659",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@date-io/moment": "^1.3.5",
|
|
9
9
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
10
10
|
"@react-google-maps/api": "2.7.0",
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1659",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|