intelicoreact 1.1.76 → 1.1.78
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.
|
@@ -23,6 +23,8 @@ var _useDebounce = require("../../../Functions/useDebounce");
|
|
|
23
23
|
|
|
24
24
|
var _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
|
|
25
25
|
|
|
26
|
+
var _utils = require("../../../Functions/utils");
|
|
27
|
+
|
|
26
28
|
var _Spinner = _interopRequireDefault(require("../../Layout/Spinner/Spinner"));
|
|
27
29
|
|
|
28
30
|
require("./DropdownLiveSearch.scss");
|
|
@@ -32,9 +34,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
32
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
35
|
|
|
34
36
|
var RC = 'dropdown-live-search';
|
|
35
|
-
var notReact = {
|
|
36
|
-
searchValue: ''
|
|
37
|
-
};
|
|
38
37
|
|
|
39
38
|
var DropdownLiveSearch = function DropdownLiveSearch(_ref) {
|
|
40
39
|
var value = _ref.value,
|
|
@@ -80,20 +79,26 @@ var DropdownLiveSearch = function DropdownLiveSearch(_ref) {
|
|
|
80
79
|
searchValue = _useState6[0],
|
|
81
80
|
setSV = _useState6[1];
|
|
82
81
|
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
var _useState7 = (0, _react.useState)(options),
|
|
83
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
84
|
+
previousOptions = _useState8[0],
|
|
85
|
+
setPreviousOptions = _useState8[1];
|
|
87
86
|
|
|
88
87
|
var dropdownLiveSearchRef = (0, _react.useRef)(null);
|
|
89
88
|
var dropdownListBoxRef = (0, _react.useRef)(null);
|
|
90
89
|
var dropdownListRef = (0, _react.useRef)(null);
|
|
91
90
|
var searchInputRef = (0, _react.useRef)(null);
|
|
91
|
+
var searchValueRef = (0, _react.useRef)(labelByValue);
|
|
92
92
|
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
var setSearchValue = function setSearchValue(val) {
|
|
94
|
+
setSV(val);
|
|
95
|
+
searchValueRef.current = val;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var _useState9 = (0, _react.useState)(false),
|
|
99
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
100
|
+
isFocusedByClick = _useState10[0],
|
|
101
|
+
setIsFocusedByClick = _useState10[1];
|
|
97
102
|
|
|
98
103
|
var debouncedSearchTerm = (0, _useDebounce.useDebounce)({
|
|
99
104
|
searchValue: searchValue,
|
|
@@ -245,8 +250,8 @@ var DropdownLiveSearch = function DropdownLiveSearch(_ref) {
|
|
|
245
250
|
}, [dropdownLiveSearchRef, isOpen]);
|
|
246
251
|
var doScrollCallback = (0, _react.useCallback)(function (e) {
|
|
247
252
|
if (doRequest && typeof doRequest === 'function') {
|
|
248
|
-
if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
|
|
249
|
-
doRequest(
|
|
253
|
+
if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight && (0, _utils.compare)(options, previousOptions)) {
|
|
254
|
+
doRequest(searchValueRef.current, true);
|
|
250
255
|
}
|
|
251
256
|
}
|
|
252
257
|
}, [options]);
|
|
@@ -261,6 +266,9 @@ var DropdownLiveSearch = function DropdownLiveSearch(_ref) {
|
|
|
261
266
|
removeEventListener('scroll', doScrollCallback);
|
|
262
267
|
};
|
|
263
268
|
}, [isOpen, dropdownListRef]);
|
|
269
|
+
(0, _react.useEffect)(function () {
|
|
270
|
+
setPreviousOptions(options);
|
|
271
|
+
}, [options]);
|
|
264
272
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
265
273
|
className: (0, _classnames.default)(RC, className, disabled),
|
|
266
274
|
ref: dropdownLiveSearchRef
|
|
@@ -50,6 +50,7 @@ var Modal = function Modal(_ref2) {
|
|
|
50
50
|
zIndex = _ref2$zIndex === void 0 ? 100 : _ref2$zIndex,
|
|
51
51
|
isOpen = _ref2.isOpen,
|
|
52
52
|
onConfirm = _ref2.onConfirm,
|
|
53
|
+
onDecline = _ref2.onDecline,
|
|
53
54
|
closeModal = _ref2.closeModal,
|
|
54
55
|
children = _ref2.children,
|
|
55
56
|
className = _ref2.className,
|
|
@@ -91,6 +92,11 @@ var Modal = function Modal(_ref2) {
|
|
|
91
92
|
confirm: function confirm() {
|
|
92
93
|
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
93
94
|
},
|
|
95
|
+
decline: function decline() {
|
|
96
|
+
//? closeModal используется для ESC и оверлея, давно хотелось иметь возможность разделить
|
|
97
|
+
//? Теперь можно не передавать closeModal, а для cancel-кнопки передать отдельный обработчик
|
|
98
|
+
if (typeof onDecline === 'function') onDecline();else closeModal === null || closeModal === void 0 ? void 0 : closeModal();
|
|
99
|
+
},
|
|
94
100
|
pressEnter: function pressEnter(event) {
|
|
95
101
|
if (event.keyCode === KEY_CODE.ENTER && !event.repeat) handle.confirm();
|
|
96
102
|
},
|
|
@@ -124,7 +130,7 @@ var Modal = function Modal(_ref2) {
|
|
|
124
130
|
}, !noHeader && /*#__PURE__*/_react.default.createElement(_ModalTitle.default, {
|
|
125
131
|
variant: variant,
|
|
126
132
|
isForced: forced,
|
|
127
|
-
onClose:
|
|
133
|
+
onClose: handle.decline,
|
|
128
134
|
noHeaderCloseBtn: noHeaderCloseBtn
|
|
129
135
|
}, /*#__PURE__*/_react.default.createElement("span", null, renderModalTitle({
|
|
130
136
|
mode: mode,
|
|
@@ -142,7 +148,9 @@ var Modal = function Modal(_ref2) {
|
|
|
142
148
|
testId: "modal",
|
|
143
149
|
className: (0, _classnames.default)(closeBtnClassName, btnClassNames),
|
|
144
150
|
variant: closeBtnVariant || 'dark-outline',
|
|
145
|
-
onClick:
|
|
151
|
+
onClick: function onClick() {
|
|
152
|
+
return handle.decline();
|
|
153
|
+
},
|
|
146
154
|
label: closeBtnText || 'Cancel',
|
|
147
155
|
disabled: closeBtnDisable,
|
|
148
156
|
icon: closeBtnIcon,
|