@expressms/smartapp-ui 3.0.0-alpha.47 → 3.0.0-alpha.49
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/build/main/constants/constants.d.ts +0 -3
- package/build/main/constants/constants.js +0 -3
- package/build/main/constants/constants.js.map +1 -1
- package/build/main/constants/types.d.ts +0 -6
- package/build/main/helpers/index.d.ts +0 -1
- package/build/main/helpers/index.js +0 -3
- package/build/main/helpers/index.js.map +1 -1
- package/build/main/hooks/useLongTap.d.ts +12 -0
- package/build/main/hooks/useLongTap.js +29 -0
- package/build/main/hooks/useLongTap.js.map +1 -0
- package/build/main/hooks/useModal.d.ts +8 -6
- package/build/main/hooks/useModal.js +78 -12
- package/build/main/hooks/useModal.js.map +1 -1
- package/build/main/index.d.ts +0 -1
- package/build/main/index.js +0 -1
- package/build/main/index.js.map +1 -1
- package/build/main/styles/styles.scss +2 -2
- package/build/main//321/201omponents/Avatar/Avatar.d.ts +2 -3
- package/build/main//321/201omponents/Avatar/Avatar.js +2 -2
- package/build/main//321/201omponents/Avatar/Avatar.js.map +1 -1
- package/build/main//321/201omponents/Chip/Chip.d.ts +2 -3
- package/build/main//321/201omponents/Chip/Chip.js +12 -144
- package/build/main//321/201omponents/Chip/Chip.js.map +1 -1
- package/build/main//321/201omponents/Chip/types.d.ts +4 -9
- package/build/main//321/201omponents/ConfirmationModal/ConfirmationModal.d.ts +1 -1
- package/build/main//321/201omponents/ConfirmationModal/ConfirmationModal.js +3 -2
- package/build/main//321/201omponents/ConfirmationModal/ConfirmationModal.js.map +1 -1
- package/build/main//321/201omponents/ConfirmationModal/types.d.ts +5 -2
- package/build/main//321/201omponents/ContextMenu/ContextMenu.d.ts +1 -1
- package/build/main//321/201omponents/ContextMenu/ContextMenu.js +10 -53
- package/build/main//321/201omponents/ContextMenu/ContextMenu.js.map +1 -1
- package/build/main//321/201omponents/ContextMenu/types.d.ts +6 -5
- package/build/main//321/201omponents/ContextMenuItem/ContextMenuItem.d.ts +1 -1
- package/build/main//321/201omponents/ContextMenuItem/ContextMenuItem.js +2 -2
- package/build/main//321/201omponents/ContextMenuItem/ContextMenuItem.js.map +1 -1
- package/build/main//321/201omponents/ContextMenuItem/types.d.ts +2 -3
- package/build/main//321/201omponents/DraggablePopup/DraggablePopup.js.map +1 -1
- package/build/main//321/201omponents/DraggablePopup/types.d.ts +8 -4
- package/build/main//321/201omponents/Modal/Modal.d.ts +1 -1
- package/build/main//321/201omponents/Modal/Modal.js +17 -5
- package/build/main//321/201omponents/Modal/Modal.js.map +1 -1
- package/build/main//321/201omponents/Modal/types.d.ts +16 -2
- package/build/main//321/201omponents/Stories/Stories.js +4 -72
- package/build/main//321/201omponents/Stories/Stories.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/MultiValueLabel/MultiValueLabel.d.ts +2 -3
- package/build/main//321/201omponents/UserDropdown/MultiValueLabel/MultiValueLabel.js +23 -32
- package/build/main//321/201omponents/UserDropdown/MultiValueLabel/MultiValueLabel.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/UserDropdown.d.ts +3 -3
- package/build/main//321/201omponents/UserDropdown/UserDropdown.js +42 -107
- package/build/main//321/201omponents/UserDropdown/UserDropdown.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/selectStyles.d.ts +1 -1
- package/build/main//321/201omponents/UserDropdown/selectStyles.js +4 -6
- package/build/main//321/201omponents/UserDropdown/selectStyles.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/types.d.ts +0 -13
- package/build/main//321/201omponents/UserDropdown/types.js.map +1 -1
- package/package.json +5 -6
- package/build/main/hooks/useMobileLongTap.d.ts +0 -16
- package/build/main/hooks/useMobileLongTap.js +0 -55
- package/build/main/hooks/useMobileLongTap.js.map +0 -1
- package/build/main//321/201omponents/ChipDndContext/ChipDndContext.d.ts +0 -13
- package/build/main//321/201omponents/ChipDndContext/ChipDndContext.js +0 -76
- package/build/main//321/201omponents/ChipDndContext/ChipDndContext.js.map +0 -1
- package/build/main//321/201omponents/ChipDndContext/index.d.ts +0 -1
- package/build/main//321/201omponents/ChipDndContext/index.js +0 -2
- package/build/main//321/201omponents/ChipDndContext/index.js.map +0 -1
|
@@ -10,14 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
14
|
import { components } from 'react-select';
|
|
15
15
|
import Popup from 'reactjs-popup';
|
|
16
16
|
import classNames from 'classnames';
|
|
17
17
|
import { isEqual } from 'lodash';
|
|
18
18
|
import Avatar from '../../Avatar';
|
|
19
19
|
import Chip from '../../Chip';
|
|
20
|
-
import {
|
|
20
|
+
import { generateAvatarIcon, generateFontFamilyStyle, isValueEqualToZero, renderUserIcon } from '../../../helpers';
|
|
21
21
|
import { COLORS } from '../../../constants';
|
|
22
22
|
import { AVATAR_SIZES } from '../../Avatar/types';
|
|
23
23
|
import '../../../styles/styles.scss';
|
|
@@ -25,30 +25,26 @@ var POPUP_APPEARANCE_DELAY = 1500;
|
|
|
25
25
|
var POPUP_HIDDEN_CLASSNAME = 'multi-value-info-hidden';
|
|
26
26
|
var POPUP_PADDINGS = 16;
|
|
27
27
|
var POPUP_MARGINS = 32;
|
|
28
|
-
var POPUP_MARGIN_TOP =
|
|
29
|
-
var TOUCH = 'touch';
|
|
28
|
+
var POPUP_MARGIN_TOP = 1;
|
|
30
29
|
var MultiValueLabel = function (props) {
|
|
31
|
-
var
|
|
32
|
-
var value = data.value, label = data.label, name = data.name, email = data.email, uid = data.uid, selectRef = data.selectRef, isResetChipsToInputValue = data.isResetChipsToInputValue, avatar = data.avatar, platform = data.platform, contextMenuItems = data.contextMenuItems, language = data.language, userType = data.userType, organizerName = data.organizerName, fontFamily = data.fontFamily, isOrganizerShort = data.isOrganizerShort, isMyContacts = data.isMyContacts, isPrivateSchedule = data.isPrivateSchedule, isNotRemovable = data.isNotRemovable, isChipsCollapsable = data.isChipsCollapsable, isSelectedChipHasTooltip = data.isSelectedChipHasTooltip, isBusyAtSelectedTime = data.isBusyAtSelectedTime, isLoading = data.isLoading, isWarning = data.isWarning, isInputFocused = data.isInputFocused.current, collapsableChipsCount = data.collapsableChipsCount.current, lastVisibleChipIndex = data.lastVisibleChipIndex.current;
|
|
30
|
+
var _a = props.data, value = _a.value, label = _a.label, name = _a.name, organizerName = _a.organizerName, email = _a.email, uid = _a.uid, isResetChipsToInputValue = _a.isResetChipsToInputValue, avatar = _a.avatar, platform = _a.platform, fontFamily = _a.fontFamily, contextMenuItems = _a.contextMenuItems, language = _a.language, userType = _a.userType, isMyContacts = _a.isMyContacts, isOrganizerShort = _a.isOrganizerShort, isPrivateSchedule = _a.isPrivateSchedule, isNotRemovable = _a.isNotRemovable, isChipsCollapsable = _a.isChipsCollapsable, isSelectedChipHasTooltip = _a.isSelectedChipHasTooltip, isBusyAtSelectedTime = _a.isBusyAtSelectedTime, isLoading = _a.isLoading, isWarning = _a.isWarning, isInputFocused = _a.isInputFocused.current, collapsableChipsCount = _a.collapsableChipsCount.current, lastVisibleChipIndex = _a.lastVisibleChipIndex.current, transformCurrentChipToInputValue = props.transformCurrentChipToInputValue, _b = props.selectProps, isDisabled = _b.isDisabled, selectedUsers = _b.value, onChange = _b.onChange, isChipsOutline = props.isChipsOutline;
|
|
33
31
|
var multiValueLabelRef = useRef(null);
|
|
34
32
|
var popupRef = useRef(null);
|
|
35
33
|
var popupContentRef = useRef(null);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
34
|
+
var _c = useState(-1), left = _c[0], setLeft = _c[1];
|
|
35
|
+
var _d = useState(-1), top = _d[0], setTop = _d[1];
|
|
36
|
+
var _e = useState(null), timeoutId = _e[0], setTimeoutId = _e[1];
|
|
37
|
+
var _f = useState(POPUP_HIDDEN_CLASSNAME), hiddenClassName = _f[0], setHiddenClassName = _f[1];
|
|
38
|
+
var _g = useState(false), isOpenContextMenu = _g[0], setIsOpenContextMenu = _g[1];
|
|
39
|
+
var _h = useState(false), isChipHovered = _h[0], setIsChipHovered = _h[1];
|
|
40
|
+
var _j = useState(false), isShowPopup = _j[0], setIsShowPopup = _j[1];
|
|
43
41
|
var isPopupVisible = isChipHovered && !isOpenContextMenu && name && email && isSelectedChipHasTooltip;
|
|
44
42
|
useEffect(function () {
|
|
45
|
-
label && isResetChipsToInputValue && transformCurrentChipToInputValue(label,
|
|
43
|
+
label && isResetChipsToInputValue && transformCurrentChipToInputValue(label, email);
|
|
46
44
|
// eslint-disable-next-line
|
|
47
45
|
}, [isResetChipsToInputValue]);
|
|
48
46
|
useEffect(function () {
|
|
49
47
|
var _a;
|
|
50
|
-
if (isMobilePlatform(platform))
|
|
51
|
-
return;
|
|
52
48
|
if (isPopupVisible) {
|
|
53
49
|
var timer_1 = setTimeout(function () {
|
|
54
50
|
if (isChipHovered && !isOpenContextMenu) {
|
|
@@ -63,7 +59,7 @@ var MultiValueLabel = function (props) {
|
|
|
63
59
|
(_a = popupRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
64
60
|
}
|
|
65
61
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
-
}, [isPopupVisible, isChipHovered, isOpenContextMenu
|
|
62
|
+
}, [isPopupVisible, isChipHovered, isOpenContextMenu]);
|
|
67
63
|
var windowInnerWidth = window.innerWidth;
|
|
68
64
|
var popupContentMaxWidth = windowInnerWidth - POPUP_MARGINS - POPUP_PADDINGS;
|
|
69
65
|
var noChipsCount = isValueEqualToZero(collapsableChipsCount);
|
|
@@ -72,23 +68,18 @@ var MultiValueLabel = function (props) {
|
|
|
72
68
|
return selectedUserValue === value && selectedUserLabel === label;
|
|
73
69
|
});
|
|
74
70
|
var handleDelete = function () { return onChange(selectedUsers.filter(function (user) { return !isEqual(user, props.data); })); };
|
|
71
|
+
var handleMouseDown = function (event) {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
event.stopPropagation();
|
|
74
|
+
};
|
|
75
|
+
var handleTouchEnd = function (event) { return event.stopPropagation(); };
|
|
75
76
|
var handleMouseEnter = function () { return !isOpenContextMenu && setIsChipHovered(true); };
|
|
76
77
|
var handleMouseLeave = function () { return setIsChipHovered(false); };
|
|
77
|
-
var handleContextMenu = function (
|
|
78
|
+
var handleContextMenu = function () {
|
|
78
79
|
var _a;
|
|
79
|
-
if (isOpenContextMenu === isOpen)
|
|
80
|
-
return;
|
|
81
|
-
setIsOpenContextMenu(isOpen);
|
|
82
80
|
setIsChipHovered(false);
|
|
83
81
|
setIsShowPopup(false);
|
|
84
82
|
(_a = popupRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
85
|
-
if (shouldFocusDropdown)
|
|
86
|
-
handleRequestFocus === null || handleRequestFocus === void 0 ? void 0 : handleRequestFocus();
|
|
87
|
-
};
|
|
88
|
-
var handlePreventEvent = function (event) {
|
|
89
|
-
var type = event.type;
|
|
90
|
-
event.stopPropagation();
|
|
91
|
-
!type.includes(TOUCH) && event.preventDefault();
|
|
92
83
|
};
|
|
93
84
|
var renderPopupContent = function () { return (_jsxs("div", __assign({ ref: popupContentRef, className: "smartapp-multi-value-label" }, { children: [_jsx(Avatar, { fontFamily: fontFamily, icon: generateAvatarIcon(userType), username: label, avatar: avatar, size: AVATAR_SIZES.size_32, isEye: isPrivateSchedule, outlineDefaultBackground: COLORS.chip }), _jsxs("div", __assign({ className: "smartapp-multi-value-label__content" }, { children: [_jsxs("div", __assign({ className: "smartapp-multi-value-label__content--name" }, { children: [_jsx("div", __assign({ className: "smartapp-multi-value-label__content--name__icon" }, { children: renderUserIcon({ userType: userType, isMyContacts: isMyContacts }) })), _jsx("span", { children: name })] })), _jsx("div", __assign({ className: "smartapp-multi-value-label__content--email" }, { children: email }))] }))] }))); };
|
|
94
85
|
var handleOpenPopup = function () {
|
|
@@ -111,7 +102,7 @@ var MultiValueLabel = function (props) {
|
|
|
111
102
|
if (left !== nextLeftValue) {
|
|
112
103
|
popupRefCurrent.close();
|
|
113
104
|
setLeft(nextLeftValue);
|
|
114
|
-
setTop(top_1 + height
|
|
105
|
+
setTop(top_1 + height - POPUP_MARGIN_TOP);
|
|
115
106
|
var nextTimeoutId = setTimeout(function () { var _a; return (_a = popupRef.current) === null || _a === void 0 ? void 0 : _a.open(); }, 0);
|
|
116
107
|
setTimeoutId(nextTimeoutId);
|
|
117
108
|
}
|
|
@@ -120,14 +111,14 @@ var MultiValueLabel = function (props) {
|
|
|
120
111
|
};
|
|
121
112
|
var handleClosePopup = function () { return timeoutId && clearTimeout(timeoutId); };
|
|
122
113
|
if (!isChipsCollapsable || isInputFocused || (!isInputFocused && userIndex < lastVisibleChipIndex) || noChipsCount) {
|
|
123
|
-
return (_jsx(components.MultiValueLabel, __assign({}, props, { innerProps: { ref: multiValueLabelRef } }, { children: _jsx(Popup, __assign({ ref: popupRef, onOpen: handleOpenPopup, onClose: handleClosePopup, arrow: false, open: isShowPopup,
|
|
114
|
+
return (_jsx(components.MultiValueLabel, __assign({}, props, { innerProps: { ref: multiValueLabelRef } }, { children: _jsx(Popup, __assign({ ref: popupRef, onOpen: handleOpenPopup, onClose: handleClosePopup, arrow: false, open: isShowPopup, className: classNames('multi-value-info', hiddenClassName), contentStyle: __assign({ '--multi-value-label-content-left': "".concat(left, "px"), '--multi-value-label-content-top': "".concat(top, "px"), '--multi-value-label-content-max-width': "".concat(popupContentMaxWidth, "px") }, generateFontFamilyStyle(fontFamily)), trigger: function () { return (_jsx("div", __assign({ onMouseDown: handleMouseDown, onTouchEnd: handleTouchEnd, onContextMenu: handleContextMenu, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, { children: _jsx(Chip, { fontFamily: fontFamily, language: language, name: label, email: email, uid: uid, isOpenContextMenu: isOpenContextMenu, setIsOpenContextMenu: setIsOpenContextMenu, isMyContacts: isMyContacts, organizerName: organizerName, isOrganizerShort: isOrganizerShort, isWarning: isWarning, userType: userType, avatar: avatar, isLoading: isLoading, isError: isBusyAtSelectedTime, isDisabled: isDisabled || isNotRemovable, isEye: isPrivateSchedule, isOutline: isChipsOutline, onDelete: handleDelete, contextMenuItems: contextMenuItems, platform: platform }) }))); } }, { children: renderPopupContent() })) })));
|
|
124
115
|
}
|
|
125
116
|
if (isChipsCollapsable && !isInputFocused && userIndex === lastVisibleChipIndex && !noChipsCount) {
|
|
126
117
|
return (_jsxs("div", __assign({ className: classNames('multi-value-label-counter', "multi-value-label-counter__".concat(platform), {
|
|
127
118
|
'multi-value-label-counter__outline': isChipsOutline,
|
|
128
|
-
}), onTouchEnd:
|
|
119
|
+
}), onTouchEnd: handleTouchEnd }, { children: ["+", collapsableChipsCount] })));
|
|
129
120
|
}
|
|
130
121
|
return null;
|
|
131
122
|
};
|
|
132
|
-
export default
|
|
123
|
+
export default MultiValueLabel;
|
|
133
124
|
//# sourceMappingURL=MultiValueLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiValueLabel.js","sourceRoot":"","sources":["../../../../../src/сomponents/UserDropdown/MultiValueLabel/MultiValueLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"MultiValueLabel.js","sourceRoot":"","sources":["../../../../../src/сomponents/UserDropdown/MultiValueLabel/MultiValueLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,MAAM,eAAe,CAAA;AAEjC,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,I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I,kBAAkB,IAAI,CAAC,cAAc,IAAI,SAAS,KAAK,oBAAoB,IAAI,CAAC,YAAY,EAAE;QAChG,OAAO,CACL,wBACE,SAAS,EAAE,UAAU,CAAC,2BAA2B,EAAE,qCAA8B,QAAQ,CAAE,EAAE;gBAC3F,oCAAoC,EAAE,cAAc;aACrD,CAAC,EACF,UAAU,EAAE,cAAc,sBAExB,qBAAqB,KACnB,CACP,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { IUserDropdownProps } from './types';
|
|
3
2
|
import '../../styles/styles.scss';
|
|
4
|
-
declare const
|
|
5
|
-
|
|
3
|
+
export declare const EMAIL_FIELD = "email";
|
|
4
|
+
declare const UserDropdown: ({ platform, fontFamily, isDisabled, isLoading, isChipsOutline, isChipsVisible, isChipsCollapsable, isSelectedChipHasTooltip, isMenuCloseOnSelect, isFilteringDisabled, hasNextPage, isNextPageLoading, isInputHidden, isBackspaceChipToInput, isShowCatalogSearchButton, isDisabledMenuOffsetAtFullscreen, isDisabledCheckUniqueEmails, isMenuShadowless, language, layoutType, externalInputValue, title, mask, suffix, placeholder, hint, onShowCatalogSearchButtonClick, noOptionsMessage, maxMembersCount, menuPosition, menuLocation, menuPortalTarget, autoFocus, containerClassName, containerPadding, containerStyles, selectedEntries, corporateEntries, myContactsEntries, emailsToExclude, onInputChange, onChange, onMenuOpen, onMenuClose, onLoadNextPage, }: IUserDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export default UserDropdown;
|
|
@@ -20,13 +20,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
20
20
|
};
|
|
21
21
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
22
|
/* eslint-disable max-lines */
|
|
23
|
-
import {
|
|
23
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
24
24
|
import Select, { components } from 'react-select';
|
|
25
25
|
import classNames from 'classnames';
|
|
26
26
|
import { ru } from 'convert-layout';
|
|
27
27
|
import { debounce, includes, isEmpty, isNil, isNull, isString, omit, uniq, uniqBy } from 'lodash';
|
|
28
28
|
import { transliterate as tr } from 'transliteration';
|
|
29
|
-
import { useDroppable } from '@dnd-kit/core';
|
|
30
29
|
import { useCharHintDisplay } from '../../hooks/useCharHintDisplay';
|
|
31
30
|
import Modal from '../Modal';
|
|
32
31
|
import ContactBottomSheet from './ContactBottomSheet/ContactBottomSheet';
|
|
@@ -36,9 +35,9 @@ import MultiValueLabel from './MultiValueLabel/MultiValueLabel';
|
|
|
36
35
|
import Option from './Option/Option';
|
|
37
36
|
import SearchInCatalogButton from './SearchInCatalogButton/SearchInCatalogButton';
|
|
38
37
|
import selectStyles from './selectStyles';
|
|
39
|
-
import {
|
|
38
|
+
import { generateFontFamilyStyle, generateId, isIosPlatform, isMobilePlatform } from '../../helpers';
|
|
40
39
|
import { DropdownIndicator, IndicatorSeparator, LoadingIndicator, MultiValueRemove, generateContactsOption, generateContactsOptionsToSelect, generateCorporateOption, generateCorporateOptionsToSelect, generateEnteredByUserOption, sortContacts, } from './helpers';
|
|
41
|
-
import { BACKSPACE_KEY, DEFAULT_INPUT_PADDING,
|
|
40
|
+
import { BACKSPACE_KEY, DEFAULT_INPUT_PADDING, ENTER_KEY, EVENT_LISTENER_TYPES, LANGUAGES, LAYOUT_TYPE, MASK_INPUT_PL, MENU_POSITIONS, MIN_INPUT_SYMBOLS, PLATFORM, SPACE, SPACE_KEY, SUFFIX_INPUT_PR, } from '../../constants';
|
|
42
41
|
import '../../styles/styles.scss';
|
|
43
42
|
var THREE_DIGIT_NUMBER_WIDTH = 48;
|
|
44
43
|
var TWO_DIGIT_NUMBER_WIDTH = 40;
|
|
@@ -46,20 +45,7 @@ var SINGLE_DIGIT_NUMBER_WIDTH = 32;
|
|
|
46
45
|
var INPUT_SPACE_WIDTH = 46;
|
|
47
46
|
var GAP = 8;
|
|
48
47
|
var USER_TYPING_TIMEOUT = 1000;
|
|
49
|
-
var
|
|
50
|
-
var EMPTY_STRING = '';
|
|
51
|
-
var BUBBLES = { bubbles: true };
|
|
52
|
-
var dispatchInputEvent = function (input) { return input.dispatchEvent(new Event(INPUT, BUBBLES)); };
|
|
53
|
-
var setCaretPosition = function (input, position) { return input.setSelectionRange(position, position); };
|
|
54
|
-
var setCaretInEmptyInput = function (input) {
|
|
55
|
-
input.value = SPACE;
|
|
56
|
-
dispatchInputEvent(input);
|
|
57
|
-
setTimeout(function () {
|
|
58
|
-
input.value = EMPTY_STRING;
|
|
59
|
-
dispatchInputEvent(input);
|
|
60
|
-
setCaretPosition(input, 0);
|
|
61
|
-
}, 0);
|
|
62
|
-
};
|
|
48
|
+
export var EMAIL_FIELD = 'email';
|
|
63
49
|
var MENU_ACTIONS;
|
|
64
50
|
(function (MENU_ACTIONS) {
|
|
65
51
|
MENU_ACTIONS["close"] = "menu-close";
|
|
@@ -99,44 +85,35 @@ var Input = function (props) {
|
|
|
99
85
|
return (_jsxs(_Fragment, { children: [_jsx(components.Input, __assign({}, props, { enterKeyHint: "done" })), suffix && (_jsx("div", __assign({ ref: suffixRef, className: "smartapp-user-dropdown__suffix" }, { children: suffix })))] }));
|
|
100
86
|
};
|
|
101
87
|
var UserDropdown = function (_a) {
|
|
102
|
-
var _b = _a.platform, platform = _b === void 0 ? PLATFORM.web : _b, fontFamily = _a.fontFamily, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isLoading, isLoading = _d === void 0 ? false : _d, _e = _a.isChipsOutline, isChipsOutline = _e === void 0 ? false : _e, _f = _a.isChipsVisible, isChipsVisible = _f === void 0 ? true : _f, _g = _a.isChipsCollapsable, isChipsCollapsable = _g === void 0 ? false : _g, _h = _a.isSelectedChipHasTooltip, isSelectedChipHasTooltip = _h === void 0 ? false : _h, _j = _a.isMenuCloseOnSelect, isMenuCloseOnSelect = _j === void 0 ? true : _j, _k = _a.isFilteringDisabled, isFilteringDisabled = _k === void 0 ? false : _k, _l = _a.hasNextPage, hasNextPage = _l === void 0 ? false : _l, _m = _a.isNextPageLoading, isNextPageLoading = _m === void 0 ? false : _m, _o = _a.isInputHidden, isInputHidden = _o === void 0 ? false : _o, _p = _a.isBackspaceChipToInput, isBackspaceChipToInput = _p === void 0 ? false : _p, _q = _a.isShowCatalogSearchButton, isShowCatalogSearchButton = _q === void 0 ? false : _q, _r = _a.isDisabledMenuOffsetAtFullscreen, isDisabledMenuOffsetAtFullscreen = _r === void 0 ? false : _r, _s = _a.isDisabledCheckUniqueEmails, isDisabledCheckUniqueEmails = _s === void 0 ? false : _s, _t = _a.isMenuShadowless, isMenuShadowless = _t === void 0 ? false : _t, _u = _a.language, language = _u === void 0 ? LANGUAGES.ru : _u, _v = _a.layoutType, layoutType = _v === void 0 ? LAYOUT_TYPE.minimal : _v, externalInputValue = _a.externalInputValue, title = _a.title, mask = _a.mask, suffix = _a.suffix, placeholder = _a.placeholder, hint = _a.hint, onShowCatalogSearchButtonClick = _a.onShowCatalogSearchButtonClick, noOptionsMessage = _a.noOptionsMessage, maxMembersCount = _a.maxMembersCount, _w = _a.menuPosition, menuPosition = _w === void 0 ? MENU_POSITIONS.top : _w, menuLocation = _a.menuLocation, menuPortalTarget = _a.menuPortalTarget, _x = _a.autoFocus, autoFocus = _x === void 0 ? false : _x, containerClassName = _a.containerClassName, containerPadding = _a.containerPadding, containerStyles = _a.containerStyles, _y = _a.selectedEntries, selectedEntries = _y === void 0 ? [] : _y, corporateEntries = _a.corporateEntries, myContactsEntries = _a.myContactsEntries, _z = _a.emailsToExclude, emailsToExclude = _z === void 0 ? [] : _z,
|
|
103
|
-
var
|
|
104
|
-
var
|
|
105
|
-
var
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
var
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
var
|
|
88
|
+
var _b = _a.platform, platform = _b === void 0 ? PLATFORM.web : _b, fontFamily = _a.fontFamily, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isLoading, isLoading = _d === void 0 ? false : _d, _e = _a.isChipsOutline, isChipsOutline = _e === void 0 ? false : _e, _f = _a.isChipsVisible, isChipsVisible = _f === void 0 ? true : _f, _g = _a.isChipsCollapsable, isChipsCollapsable = _g === void 0 ? false : _g, _h = _a.isSelectedChipHasTooltip, isSelectedChipHasTooltip = _h === void 0 ? false : _h, _j = _a.isMenuCloseOnSelect, isMenuCloseOnSelect = _j === void 0 ? true : _j, _k = _a.isFilteringDisabled, isFilteringDisabled = _k === void 0 ? false : _k, _l = _a.hasNextPage, hasNextPage = _l === void 0 ? false : _l, _m = _a.isNextPageLoading, isNextPageLoading = _m === void 0 ? false : _m, _o = _a.isInputHidden, isInputHidden = _o === void 0 ? false : _o, _p = _a.isBackspaceChipToInput, isBackspaceChipToInput = _p === void 0 ? false : _p, _q = _a.isShowCatalogSearchButton, isShowCatalogSearchButton = _q === void 0 ? false : _q, _r = _a.isDisabledMenuOffsetAtFullscreen, isDisabledMenuOffsetAtFullscreen = _r === void 0 ? false : _r, _s = _a.isDisabledCheckUniqueEmails, isDisabledCheckUniqueEmails = _s === void 0 ? false : _s, _t = _a.isMenuShadowless, isMenuShadowless = _t === void 0 ? false : _t, _u = _a.language, language = _u === void 0 ? LANGUAGES.ru : _u, _v = _a.layoutType, layoutType = _v === void 0 ? LAYOUT_TYPE.minimal : _v, externalInputValue = _a.externalInputValue, title = _a.title, mask = _a.mask, suffix = _a.suffix, placeholder = _a.placeholder, hint = _a.hint, onShowCatalogSearchButtonClick = _a.onShowCatalogSearchButtonClick, noOptionsMessage = _a.noOptionsMessage, maxMembersCount = _a.maxMembersCount, _w = _a.menuPosition, menuPosition = _w === void 0 ? MENU_POSITIONS.top : _w, menuLocation = _a.menuLocation, menuPortalTarget = _a.menuPortalTarget, _x = _a.autoFocus, autoFocus = _x === void 0 ? false : _x, containerClassName = _a.containerClassName, containerPadding = _a.containerPadding, containerStyles = _a.containerStyles, _y = _a.selectedEntries, selectedEntries = _y === void 0 ? [] : _y, corporateEntries = _a.corporateEntries, myContactsEntries = _a.myContactsEntries, _z = _a.emailsToExclude, emailsToExclude = _z === void 0 ? [] : _z, onInputChange = _a.onInputChange, onChange = _a.onChange, onMenuOpen = _a.onMenuOpen, onMenuClose = _a.onMenuClose, onLoadNextPage = _a.onLoadNextPage;
|
|
89
|
+
var _0 = useState(''), userDropdownId = _0[0], setUserDropdownId = _0[1];
|
|
90
|
+
var _1 = useState([]), selectedUsers = _1[0], setSelectedUsers = _1[1];
|
|
91
|
+
var _2 = useState(''), paddingLeft = _2[0], setPaddingLeft = _2[1];
|
|
92
|
+
var _3 = useState(''), paddingRight = _3[0], setPaddingRight = _3[1];
|
|
93
|
+
var _4 = useState(0), maskWidth = _4[0], setMaskWidth = _4[1];
|
|
94
|
+
var _5 = useState(0), suffixWidth = _5[0], setSuffixWidth = _5[1];
|
|
95
|
+
var _6 = useState(false), isError = _6[0], setIsError = _6[1];
|
|
96
|
+
var _7 = useState(true), isSearchable = _7[0], setIsSearchable = _7[1];
|
|
97
|
+
var _8 = useState(false), isUserTyping = _8[0], setIsUserTyping = _8[1];
|
|
98
|
+
var _9 = useState(null), modalData = _9[0], setModalData = _9[1];
|
|
99
|
+
var _10 = useState(''), chipLabelWithMaxWidth = _10[0], setChipLabelWithMaxWidth = _10[1];
|
|
100
|
+
var _11 = useState(''), inputValue = _11[0], setInputValue = _11[1];
|
|
115
101
|
var isInputFocused = useRef(false);
|
|
116
102
|
var selectRef = useRef(null);
|
|
117
103
|
var maskRef = useRef(null);
|
|
118
104
|
var suffixRef = useRef(null);
|
|
119
105
|
var menuScrollFromTop = useRef(0);
|
|
120
106
|
var collapsableChipsCount = useRef(0);
|
|
121
|
-
var visibleChipsCount = useRef(0);
|
|
122
|
-
var isNeedCheckChipCollapsableCount = useRef(false);
|
|
123
107
|
var lastVisibleChipIndex = useRef(-1);
|
|
124
108
|
var skipAddUserToChipsOnNextBlurRef = useRef(false);
|
|
125
109
|
var selectedUsersLength = selectedUsers.length;
|
|
126
|
-
var _13 = useDroppable({ id: userDropdownId }), setNodeRef = _13.setNodeRef, over = _13.over;
|
|
127
|
-
var overId = (over || {}).id;
|
|
128
|
-
var isDraggable = overId === userDropdownId;
|
|
129
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
130
|
-
useImperativeHandle(focusRef, function () { return ({ focus: handleFocus, blur: function () { return handleDragBlur(true); } }); }, []);
|
|
131
110
|
var fontFamilyStyle = generateFontFamilyStyle(fontFamily);
|
|
132
111
|
var isCharHintVisible = useCharHintDisplay({ inputValue: inputValue }).isCharHintVisible;
|
|
133
112
|
var checkIsValueIsEmail = function (inputValue) {
|
|
134
113
|
var regex = new RegExp(/^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/);
|
|
135
114
|
return regex.test(inputValue);
|
|
136
115
|
};
|
|
137
|
-
|
|
138
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
139
|
-
var checkIsEmailToExclude = useCallback(function (email) { return includes(emailsToExclude, email); }, []);
|
|
116
|
+
var checkIsEmailToExclude = function (email) { return includes(emailsToExclude, email); };
|
|
140
117
|
var calculatePaddingLeft = function () {
|
|
141
118
|
var _a, _b;
|
|
142
119
|
var maskWidth = ((_b = (_a = maskRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.width) || null;
|
|
@@ -168,8 +145,6 @@ var UserDropdown = function (_a) {
|
|
|
168
145
|
isMenuShadowless: isMenuShadowless,
|
|
169
146
|
fontFamilyStyle: fontFamilyStyle,
|
|
170
147
|
containerPadding: containerPadding,
|
|
171
|
-
isDraggable: isDraggable,
|
|
172
|
-
isChipsCollapsed: isChipsCollapsable && !isInputFocused.current,
|
|
173
148
|
});
|
|
174
149
|
};
|
|
175
150
|
var generateNoOptionsMessage = function (_a) {
|
|
@@ -221,13 +196,13 @@ var UserDropdown = function (_a) {
|
|
|
221
196
|
}, USER_TYPING_TIMEOUT);
|
|
222
197
|
}, [onInputChange]);
|
|
223
198
|
var resetIsUserTypingDebounce = useMemo(function () { return debounce(function () { return setIsUserTyping(false); }, USER_TYPING_TIMEOUT); }, []);
|
|
224
|
-
var handleResetError =
|
|
199
|
+
var handleResetError = function () { return isError && setIsError(false); };
|
|
225
200
|
var handleMenuClose = function () {
|
|
226
201
|
menuScrollFromTop.current = 0;
|
|
227
202
|
handleResetError();
|
|
228
203
|
onMenuClose === null || onMenuClose === void 0 ? void 0 : onMenuClose();
|
|
229
204
|
};
|
|
230
|
-
var handleInputChange =
|
|
205
|
+
var handleInputChange = function (inputValue, additionalInfo) {
|
|
231
206
|
if (additionalInfo) {
|
|
232
207
|
var action = additionalInfo.action, prevInputValue = additionalInfo.prevInputValue;
|
|
233
208
|
var trimPrevInputValue_1 = prevInputValue.trim();
|
|
@@ -246,7 +221,7 @@ var UserDropdown = function (_a) {
|
|
|
246
221
|
setIsUserTyping(!isEmpty(inputValue));
|
|
247
222
|
handleResetError();
|
|
248
223
|
inputValue.length >= MIN_INPUT_SYMBOLS ? requestInputChangeDebounce(inputValue) : resetIsUserTypingDebounce();
|
|
249
|
-
}
|
|
224
|
+
};
|
|
250
225
|
var extractInputEmails = function (inputValue) {
|
|
251
226
|
return inputValue
|
|
252
227
|
.split(/[,;]+/)
|
|
@@ -333,27 +308,24 @@ var UserDropdown = function (_a) {
|
|
|
333
308
|
(_c = (_b = selectRef.current) === null || _b === void 0 ? void 0 : _b.onMenuOpen) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
334
309
|
}
|
|
335
310
|
};
|
|
336
|
-
var transformCurrentChipToInputValue =
|
|
311
|
+
var transformCurrentChipToInputValue = function (label, email) {
|
|
337
312
|
var _a, _b;
|
|
338
313
|
skipAddUserToChipsOnNextBlurRef.current = true;
|
|
339
314
|
setSelectedUsers(function (prevSelectedUsers) {
|
|
340
315
|
var nextSelectedUsers = prevSelectedUsers.filter(function (_a) {
|
|
341
|
-
var userEmail = _a.email
|
|
342
|
-
return
|
|
316
|
+
var userEmail = _a.email;
|
|
317
|
+
return userEmail !== email;
|
|
343
318
|
});
|
|
344
319
|
onChange === null || onChange === void 0 ? void 0 : onChange(nextSelectedUsers.map(function (userData) { return omit(userData, COMMON_FIELDS_TO_OMIT); }));
|
|
345
320
|
return nextSelectedUsers;
|
|
346
321
|
});
|
|
347
|
-
handleFocus();
|
|
348
322
|
setInputValue(label);
|
|
349
323
|
onInputChange(label);
|
|
350
324
|
handleInputChange(label);
|
|
351
325
|
onMenuOpen === null || onMenuOpen === void 0 ? void 0 : onMenuOpen();
|
|
352
326
|
(_b = (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.onMenuOpen) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
353
327
|
setIsUserTyping(false);
|
|
354
|
-
}
|
|
355
|
-
// eslint-disable-next-line
|
|
356
|
-
[onInputChange, handleInputChange, onMenuOpen, onChange]);
|
|
328
|
+
};
|
|
357
329
|
var handleChange = function (newSelectedUsers) {
|
|
358
330
|
var uniqNewSelectedUsers = isDisabledCheckUniqueEmails ? newSelectedUsers : uniqBy(newSelectedUsers, EMAIL_FIELD);
|
|
359
331
|
var users = [];
|
|
@@ -446,14 +418,11 @@ var UserDropdown = function (_a) {
|
|
|
446
418
|
}
|
|
447
419
|
}
|
|
448
420
|
});
|
|
449
|
-
var visibleChipsCurrentCount = chips.length - collapsableChips;
|
|
450
|
-
isNeedCheckChipCollapsableCount.current = true;
|
|
451
|
-
visibleChipsCount.current = visibleChipsCurrentCount;
|
|
452
421
|
collapsableChipsCount.current = collapsableChips;
|
|
453
|
-
lastVisibleChipIndex.current =
|
|
422
|
+
lastVisibleChipIndex.current = chips.length - collapsableChips;
|
|
454
423
|
setChipLabelWithMaxWidth(chipLabelWithMaxWidth || generateId());
|
|
455
424
|
};
|
|
456
|
-
var handleUnCollapseChips =
|
|
425
|
+
var handleUnCollapseChips = function () {
|
|
457
426
|
var _a;
|
|
458
427
|
if (!userDropdownId)
|
|
459
428
|
return;
|
|
@@ -464,26 +433,13 @@ var UserDropdown = function (_a) {
|
|
|
464
433
|
var chipLabel = ((_a = chip.querySelector('.smartapp-chip__info--name')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '';
|
|
465
434
|
chipLabel === chipLabelWithMaxWidth && (chip.style.maxWidth = '100%');
|
|
466
435
|
});
|
|
467
|
-
isNeedCheckChipCollapsableCount.current = false;
|
|
468
|
-
visibleChipsCount.current = chips.length;
|
|
469
436
|
collapsableChipsCount.current = 0;
|
|
470
437
|
lastVisibleChipIndex.current = -1;
|
|
471
438
|
setChipLabelWithMaxWidth('');
|
|
472
|
-
}, [chipLabelWithMaxWidth, userDropdownId]);
|
|
473
|
-
var handleDragBlur = function (isDisableCheckFocused) {
|
|
474
|
-
var _a;
|
|
475
|
-
if (!isInputFocused.current && !isDisableCheckFocused)
|
|
476
|
-
return;
|
|
477
|
-
if (selectRef.current)
|
|
478
|
-
selectRef.current._preventBlur = false;
|
|
479
|
-
(_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
480
439
|
};
|
|
481
440
|
var handleBlur = function () {
|
|
482
441
|
var _a;
|
|
483
442
|
var shouldSkipAddUserToChipsOnNextBlur = skipAddUserToChipsOnNextBlurRef.current;
|
|
484
|
-
var _b = selectRef.current || {}, _preventBlur = _b._preventBlur, _contextMenuOpen = _b._contextMenuOpen, _isDragging = _b._isDragging;
|
|
485
|
-
if (_preventBlur || _contextMenuOpen || _isDragging || skipAddUserToChipsOnNextBlurRef.current)
|
|
486
|
-
return;
|
|
487
443
|
var onBlurComplete = function () {
|
|
488
444
|
isChipsCollapsable && handleCollapseChips();
|
|
489
445
|
isInputFocused.current = false;
|
|
@@ -496,27 +452,16 @@ var UserDropdown = function (_a) {
|
|
|
496
452
|
(_a = handleAddUser(false)) === null || _a === void 0 ? void 0 : _a.then(onBlurComplete);
|
|
497
453
|
skipAddUserToChipsOnNextBlurRef.current = false;
|
|
498
454
|
};
|
|
499
|
-
var
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
}, []);
|
|
507
|
-
var handleFocus = useCallback(function (isDisableCheckFocused) {
|
|
508
|
-
if (isInputFocused.current && !isDisableCheckFocused)
|
|
509
|
-
return;
|
|
455
|
+
var handleFocus = function () {
|
|
456
|
+
if (isIosPlatform(platform)) {
|
|
457
|
+
new Promise(function (resolve) { return resolve(); }).then(function () { var _a; return (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
setTimeout(function () { var _a; return (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, 100);
|
|
461
|
+
}
|
|
510
462
|
isInputFocused.current = true;
|
|
511
|
-
var selectRefCurrent = selectRef.current;
|
|
512
|
-
var _a = selectRefCurrent || {}, _preventBlur = _a._preventBlur, inputRef = _a.inputRef;
|
|
513
|
-
setTimeout(function () {
|
|
514
|
-
if (selectRefCurrent && !_preventBlur)
|
|
515
|
-
isIosPlatform(platform) && inputRef ? focusInputIOS(inputRef) : selectRefCurrent.focus();
|
|
516
|
-
}, RENDER_DELAY);
|
|
517
463
|
isChipsCollapsable && handleUnCollapseChips();
|
|
518
|
-
}
|
|
519
|
-
var handleForceFocus = useCallback(function () { return setTimeout(function () { return handleFocus(true); }, RENDER_DELAY); }, [handleFocus]);
|
|
464
|
+
};
|
|
520
465
|
var handleCloseModal = function () {
|
|
521
466
|
setModalData(null);
|
|
522
467
|
setIsSearchable(true);
|
|
@@ -545,8 +490,9 @@ var UserDropdown = function (_a) {
|
|
|
545
490
|
!userDropdownId && setUserDropdownId("user_dropdown_".concat(generateId().replace(/-/g, '_')));
|
|
546
491
|
}, [userDropdownId]);
|
|
547
492
|
useLayoutEffect(function () {
|
|
548
|
-
if (userDropdownId)
|
|
549
|
-
|
|
493
|
+
if (userDropdownId) {
|
|
494
|
+
isChipsCollapsable ? handleCollapseChips() : handleUnCollapseChips();
|
|
495
|
+
}
|
|
550
496
|
// eslint-disable-next-line
|
|
551
497
|
}, [isChipsCollapsable, userDropdownId]);
|
|
552
498
|
useEffect(function () {
|
|
@@ -563,12 +509,7 @@ var UserDropdown = function (_a) {
|
|
|
563
509
|
useEffect(function () {
|
|
564
510
|
if (!isEmpty(selectedEntries)) {
|
|
565
511
|
setSelectedUsers(selectedEntries.map(function (entity) {
|
|
566
|
-
var isWarning = entity.isWarning, isLoading = entity.isLoading, isOrganizerShort = entity.isOrganizerShort, isResetChipsToInputValue = entity.isResetChipsToInputValue, userType = entity.userType,
|
|
567
|
-
var contextMenuItems = currentContextItems === null || currentContextItems === void 0 ? void 0 : currentContextItems.map(function (item) { return (__assign(__assign({}, item), { action: function (data) {
|
|
568
|
-
var _a;
|
|
569
|
-
(_a = item.action) === null || _a === void 0 ? void 0 : _a.call(item, data);
|
|
570
|
-
isMobilePlatform(platform) && handleFocus(true);
|
|
571
|
-
} })); });
|
|
512
|
+
var isWarning = entity.isWarning, isLoading = entity.isLoading, isOrganizerShort = entity.isOrganizerShort, isResetChipsToInputValue = entity.isResetChipsToInputValue, userType = entity.userType, uid = entity.uid, organizerName = entity.organizerName, contextMenuItems = entity.contextMenuItems;
|
|
572
513
|
var commonFields = {
|
|
573
514
|
platform: platform,
|
|
574
515
|
layoutType: layoutType,
|
|
@@ -595,8 +536,6 @@ var UserDropdown = function (_a) {
|
|
|
595
536
|
return 'contacts' in entity ? generateCorporateOption(__assign({ option: entity }, commonFields)) : generatedNotCorporateEntity;
|
|
596
537
|
}));
|
|
597
538
|
}
|
|
598
|
-
else
|
|
599
|
-
setSelectedUsers([]);
|
|
600
539
|
// eslint-disable-next-line
|
|
601
540
|
}, [selectedEntries]);
|
|
602
541
|
useEffect(function () {
|
|
@@ -612,10 +551,6 @@ var UserDropdown = function (_a) {
|
|
|
612
551
|
resetIsUserTypingDebounce.cancel();
|
|
613
552
|
};
|
|
614
553
|
}, [requestInputChangeDebounce, resetIsUserTypingDebounce]);
|
|
615
|
-
useEffect(function () {
|
|
616
|
-
if (isChipsCollapsable && !isInputFocused.current && isNeedCheckChipCollapsableCount.current)
|
|
617
|
-
collapsableChipsCount.current = selectedEntries.length - visibleChipsCount.current;
|
|
618
|
-
}, [isChipsCollapsable, selectedEntries]);
|
|
619
554
|
var OptionComponent = useCallback(function (props) { return _jsx(Option, __assign({}, props, { isMenuShadowless: isMenuShadowless, children: props.children })); }, [isMenuShadowless]);
|
|
620
555
|
var MenuListComponent = useCallback(function (props) { return (_jsx(MenuList, __assign({}, props, { children: props.children, selectRef: selectRef, scrollFromTop: menuScrollFromTop, language: language, hasNextPage: hasNextPage, isLoading: isLoading, isShowCatalogSearchButton: isShowCatalogSearchButton, onShowCatalogSearchButtonClick: onShowCatalogSearchButtonClick, isUserTyping: isUserTyping, isCharHintVisible: isCharHintVisible, isMenuShadowless: isMenuShadowless, isNextPageLoading: isNextPageLoading, onLoadNextPage: function (inputValue) { return onLoadNextPage === null || onLoadNextPage === void 0 ? void 0 : onLoadNextPage(inputValue); } }))); }, [
|
|
621
556
|
hasNextPage,
|
|
@@ -630,9 +565,9 @@ var UserDropdown = function (_a) {
|
|
|
630
565
|
onShowCatalogSearchButtonClick,
|
|
631
566
|
]);
|
|
632
567
|
var NoOptionsButton = function (props) { return (_jsx(components.NoOptionsMessage, __assign({}, props, { children: _jsx(SearchInCatalogButton, { language: language, isOnlyButtonInList: true, onShowCatalogSearchButtonClick: onShowCatalogSearchButtonClick, noOptionText: isShowCatalogSearchButton ? undefined : generateNoOptionsMessage({ inputValue: inputValue }) }) }))); };
|
|
568
|
+
var MultiValueLabelComponent = function (props) { return (_jsx(MultiValueLabel, __assign({}, props, { isChipsOutline: isChipsOutline, transformCurrentChipToInputValue: transformCurrentChipToInputValue }))); };
|
|
633
569
|
var InputComponent = useCallback(function (props) { return _jsx(Input, __assign({}, props, { suffixref: suffixRef, suffix: suffix })); }, [suffix]);
|
|
634
|
-
|
|
635
|
-
return (_jsxs("div", __assign({ id: userDropdownId, className: classNames('smartapp-user-dropdown', containerClassName), style: __assign(__assign({}, fontFamilyStyle), containerStyles) }, { children: [renderTitle(), _jsxs("div", __assign({ className: "smartapp-user-dropdown__container", ref: setNodeRef }, { children: [renderMask(), _jsx(Select, { ref: selectRef, menuIsOpen: isInputHidden ? !!externalInputValue : undefined, menuPortalTarget: menuPortalTarget === null || menuPortalTarget === void 0 ? void 0 : menuPortalTarget.current, isMulti: true, openMenuOnFocus: true, blurInputOnSelect: false, captureMenuScroll: false, isSearchable: isSearchable, menuPlacement: menuPosition, menuPosition: menuLocation, controlShouldRenderValue: isChipsVisible, backspaceRemovesValue: isChipsVisible, isDisabled: isDisabled, closeMenuOnSelect: isMenuCloseOnSelect, isLoading: isLoading || isUserTyping, isClearable: false, styles: generateStyles(), placeholder: placeholder || '', noOptionsMessage: generateNoOptionsMessage, loadingMessage: function () { return _jsx(LoadingMessage, {}); }, value: selectedUsers, inputValue: inputValue, options: !isNull(corporateEntries) || !isNull(myContactsEntries) ? generateOptions() : undefined, filterOption: handleFilterOption, onInputChange: handleInputChange, onChange: handleChange, onMenuClose: handleMenuClose, onMenuOpen: onMenuOpen, onKeyDown: handleKeyDown, onBlur: handleSelectBlur, autoFocus: autoFocus, onFocus: function () { return handleFocus(); }, instanceId: userDropdownId, components: {
|
|
570
|
+
return (_jsxs("div", __assign({ id: userDropdownId, className: classNames('smartapp-user-dropdown', containerClassName), style: __assign(__assign({}, fontFamilyStyle), containerStyles) }, { children: [renderTitle(), _jsxs("div", __assign({ className: "smartapp-user-dropdown__container" }, { children: [renderMask(), _jsx(Select, { ref: selectRef, menuIsOpen: isInputHidden ? !!externalInputValue : undefined, menuPortalTarget: menuPortalTarget === null || menuPortalTarget === void 0 ? void 0 : menuPortalTarget.current, isMulti: true, openMenuOnFocus: true, blurInputOnSelect: false, captureMenuScroll: false, isSearchable: isSearchable, menuPlacement: menuPosition, menuPosition: menuLocation, controlShouldRenderValue: isChipsVisible, backspaceRemovesValue: isChipsVisible, isDisabled: isDisabled, closeMenuOnSelect: isMenuCloseOnSelect, isLoading: isLoading || isUserTyping, isClearable: false, styles: generateStyles(), placeholder: placeholder || '', noOptionsMessage: generateNoOptionsMessage, loadingMessage: function () { return _jsx(LoadingMessage, {}); }, value: selectedUsers, inputValue: inputValue, options: !isNull(corporateEntries) || !isNull(myContactsEntries) ? generateOptions() : undefined, filterOption: handleFilterOption, onInputChange: handleInputChange, onChange: handleChange, onMenuClose: handleMenuClose, onMenuOpen: onMenuOpen, onKeyDown: handleKeyDown, onBlur: handleBlur, autoFocus: autoFocus, onFocus: handleFocus, components: {
|
|
636
571
|
Input: InputComponent,
|
|
637
572
|
MultiValueLabel: MultiValueLabelComponent,
|
|
638
573
|
MultiValueRemove: MultiValueRemove,
|
|
@@ -644,5 +579,5 @@ var UserDropdown = function (_a) {
|
|
|
644
579
|
NoOptionsMessage: NoOptionsButton,
|
|
645
580
|
} })] })), renderHint(), _jsx(Modal, { isModalOpen: !isNull(modalData), platform: platform, fontFamily: fontFamily, content: modalContent, isBottomSheet: isMobilePlatform(platform), backgroundColor: "var(--color-bg-blackout-transparent)", handleCloseModal: handleCloseModal })] })));
|
|
646
581
|
};
|
|
647
|
-
export default
|
|
582
|
+
export default UserDropdown;
|
|
648
583
|
//# sourceMappingURL=UserDropdown.js.map
|