@expressms/smartapp-ui 3.0.0-alpha.21 → 3.0.0-alpha.210
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/assets/icons/accepted-invite-status.svg +4 -0
- package/build/main/assets/icons/chevron.svg +3 -0
- package/build/main/assets/icons/close-modal.svg +1 -1
- package/build/main/assets/icons/copy.svg +3 -0
- package/build/main/assets/icons/declined-invite-status.svg +4 -0
- package/build/main/assets/icons/department.svg +3 -0
- package/build/main/assets/icons/doc-small.svg +5 -5
- package/build/main/assets/icons/download.svg +3 -0
- package/build/main/assets/icons/file-small.svg +5 -5
- package/build/main/assets/icons/file.svg +1 -1
- package/build/main/assets/icons/image-no-preview-small.svg +11 -0
- package/build/main/assets/icons/image-no-preview.svg +11 -0
- package/build/main/assets/icons/job-position.svg +3 -0
- package/build/main/assets/icons/needs-action-invite-status.svg +4 -0
- package/build/main/assets/icons/notification-close.svg +1 -1
- package/build/main/assets/icons/notification-error.svg +5 -0
- package/build/main/assets/icons/notification-failure-filled.svg +3 -0
- package/build/main/assets/icons/notification-info-filled.svg +5 -0
- package/build/main/assets/icons/notification-success-filled.svg +4 -0
- package/build/main/assets/icons/office.svg +3 -0
- package/build/main/assets/icons/pdf-small.svg +5 -5
- package/build/main/assets/icons/ppt-small.svg +5 -5
- package/build/main/assets/icons/private.svg +4 -11
- package/build/main/assets/icons/search.svg +1 -1
- package/build/main/assets/icons/select-arrow-down.svg +3 -0
- package/build/main/assets/icons/select-arrow-up.svg +3 -0
- package/build/main/assets/icons/server.svg +3 -0
- package/build/main/assets/icons/txt-small.svg +5 -5
- package/build/main/assets/icons/video-no-preview-small.svg +11 -0
- package/build/main/assets/icons/video-no-preview.svg +11 -0
- package/build/main/assets/icons/xls-small.svg +5 -5
- package/build/main/assets/storybook/index.d.ts +3 -0
- package/build/main/assets/storybook/index.js +3 -0
- package/build/main/assets/storybook/index.js.map +1 -1
- package/build/main/constants/constants.d.ts +92 -47
- package/build/main/constants/constants.js +132 -49
- package/build/main/constants/constants.js.map +1 -1
- package/build/main/constants/types.d.ts +13 -2
- package/build/main/helpers/index.d.ts +7 -5
- package/build/main/helpers/index.js +28 -7
- package/build/main/helpers/index.js.map +1 -1
- package/build/main/hooks/useCharHintDisplay.d.ts +9 -0
- package/build/main/hooks/useCharHintDisplay.js +35 -0
- package/build/main/hooks/useCharHintDisplay.js.map +1 -0
- package/build/main/hooks/useMobileLongTap.d.ts +16 -0
- package/build/main/hooks/useMobileLongTap.js +65 -0
- package/build/main/hooks/useMobileLongTap.js.map +1 -0
- package/build/main/hooks/useModal.d.ts +18 -10
- package/build/main/hooks/useModal.js +226 -13
- package/build/main/hooks/useModal.js.map +1 -1
- package/build/main/index.d.ts +2 -0
- package/build/main/index.js +2 -0
- package/build/main/index.js.map +1 -1
- package/build/main/styles/main.js +0 -6
- package/build/main/styles/styles.scss +2 -2
- package/build/main//321/201omponents/ActionModal/ActionModal.js +1 -1
- package/build/main//321/201omponents/ActionModal/ActionModal.js.map +1 -1
- package/build/main//321/201omponents/AttachedFile/AttachedFile.d.ts +1 -1
- package/build/main//321/201omponents/AttachedFile/AttachedFile.js +81 -26
- package/build/main//321/201omponents/AttachedFile/AttachedFile.js.map +1 -1
- package/build/main//321/201omponents/AttachedFile/types.d.ts +1 -0
- package/build/main//321/201omponents/Avatar/Avatar.d.ts +3 -2
- package/build/main//321/201omponents/Avatar/Avatar.js +55 -27
- package/build/main//321/201omponents/Avatar/Avatar.js.map +1 -1
- package/build/main//321/201omponents/Avatar/types.d.ts +9 -5
- package/build/main//321/201omponents/Avatar/types.js +5 -2
- package/build/main//321/201omponents/Avatar/types.js.map +1 -1
- package/build/main//321/201omponents/Button/Button.d.ts +1 -1
- package/build/main//321/201omponents/Button/Button.js +16 -10
- package/build/main//321/201omponents/Button/Button.js.map +1 -1
- package/build/main//321/201omponents/Button/types.d.ts +9 -2
- package/build/main//321/201omponents/Button/types.js +3 -0
- package/build/main//321/201omponents/Button/types.js.map +1 -1
- package/build/main//321/201omponents/Calendar/Calendar.d.ts +14 -2
- package/build/main//321/201omponents/Calendar/Calendar.js +201 -52
- package/build/main//321/201omponents/Calendar/Calendar.js.map +1 -1
- package/build/main//321/201omponents/Calendar/types.d.ts +16 -3
- package/build/main//321/201omponents/Charts/ChartBar/ChartBar.js +1 -1
- package/build/main//321/201omponents/Charts/ChartLine/ChartLine.js +1 -1
- package/build/main//321/201omponents/Charts/ChartPie/ChartPie.js +1 -1
- package/build/main//321/201omponents/Chip/Chip.d.ts +3 -2
- package/build/main//321/201omponents/Chip/Chip.js +211 -47
- package/build/main//321/201omponents/Chip/Chip.js.map +1 -1
- package/build/main//321/201omponents/Chip/types.d.ts +15 -4
- package/build/main//321/201omponents/ChipDndContext/ChipDndContext.d.ts +13 -0
- package/build/main//321/201omponents/ChipDndContext/ChipDndContext.js +76 -0
- package/build/main//321/201omponents/ChipDndContext/ChipDndContext.js.map +1 -0
- package/build/main//321/201omponents/ChipDndContext/index.d.ts +1 -0
- package/build/main//321/201omponents/ChipDndContext/index.js +2 -0
- package/build/main//321/201omponents/ChipDndContext/index.js.map +1 -0
- 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 +68 -27
- package/build/main//321/201omponents/ContextMenu/ContextMenu.js.map +1 -1
- package/build/main//321/201omponents/ContextMenu/types.d.ts +14 -7
- package/build/main//321/201omponents/ContextMenuItem/ContextMenuItem.d.ts +4 -0
- package/build/main//321/201omponents/ContextMenuItem/ContextMenuItem.js +49 -0
- package/build/main//321/201omponents/ContextMenuItem/ContextMenuItem.js.map +1 -0
- package/build/main//321/201omponents/ContextMenuItem/index.d.ts +1 -0
- package/build/main//321/201omponents/ContextMenuItem/index.js +2 -0
- package/build/main//321/201omponents/ContextMenuItem/index.js.map +1 -0
- package/build/main//321/201omponents/ContextMenuItem/types.d.ts +28 -0
- package/build/main//321/201omponents/ContextMenuItem/types.js +6 -0
- package/build/main//321/201omponents/ContextMenuItem/types.js.map +1 -0
- package/build/main//321/201omponents/CustomSelect/CustomSelect.d.ts +1 -1
- package/build/main//321/201omponents/CustomSelect/CustomSelect.js +55 -22
- package/build/main//321/201omponents/CustomSelect/CustomSelect.js.map +1 -1
- package/build/main//321/201omponents/CustomSelect/selectStyles.d.ts +1 -1
- package/build/main//321/201omponents/CustomSelect/selectStyles.js +33 -26
- package/build/main//321/201omponents/CustomSelect/selectStyles.js.map +1 -1
- package/build/main//321/201omponents/CustomSelect/types.d.ts +21 -4
- package/build/main//321/201omponents/CustomSelectProfiles/CustomSelectProfiles.d.ts +1 -1
- package/build/main//321/201omponents/CustomSelectProfiles/CustomSelectProfiles.js +33 -24
- package/build/main//321/201omponents/CustomSelectProfiles/CustomSelectProfiles.js.map +1 -1
- package/build/main//321/201omponents/CustomSelectProfiles/selectStyles.d.ts +12 -0
- package/build/main//321/201omponents/CustomSelectProfiles/selectStyles.js +41 -0
- package/build/main//321/201omponents/CustomSelectProfiles/selectStyles.js.map +1 -0
- package/build/main//321/201omponents/CustomSelectProfiles/types.d.ts +6 -5
- package/build/main//321/201omponents/DragAndDrop/DragAndDrop.js +2 -2
- package/build/main//321/201omponents/DragAndDrop/DragAndDrop.js.map +1 -1
- package/build/main//321/201omponents/DraggablePopup/DraggablePopup.d.ts +1 -1
- package/build/main//321/201omponents/DraggablePopup/DraggablePopup.js +24 -18
- package/build/main//321/201omponents/DraggablePopup/DraggablePopup.js.map +1 -1
- package/build/main//321/201omponents/DraggablePopup/types.d.ts +8 -8
- package/build/main//321/201omponents/Flex/Flex.d.ts +1 -1
- package/build/main//321/201omponents/Flex/Flex.js +2 -2
- package/build/main//321/201omponents/Flex/Flex.js.map +1 -1
- package/build/main//321/201omponents/Flex/types.d.ts +2 -0
- package/build/main//321/201omponents/Input/Input.d.ts +1 -1
- package/build/main//321/201omponents/Input/Input.js +92 -31
- package/build/main//321/201omponents/Input/Input.js.map +1 -1
- package/build/main//321/201omponents/Input/types.d.ts +13 -3
- package/build/main//321/201omponents/ListItem/ListItem.js +21 -10
- package/build/main//321/201omponents/ListItem/ListItem.js.map +1 -1
- package/build/main//321/201omponents/ListItem/types.d.ts +8 -2
- package/build/main//321/201omponents/Modal/Modal.d.ts +3 -2
- package/build/main//321/201omponents/Modal/Modal.js +219 -81
- package/build/main//321/201omponents/Modal/Modal.js.map +1 -1
- package/build/main//321/201omponents/Modal/types.d.ts +38 -2
- package/build/main//321/201omponents/Notification/Notification.d.ts +4 -6
- package/build/main//321/201omponents/Notification/Notification.js +88 -30
- package/build/main//321/201omponents/Notification/Notification.js.map +1 -1
- package/build/main//321/201omponents/Notification/types.d.ts +23 -5
- package/build/main//321/201omponents/ScrollBar/ScrollBar.js +2 -2
- package/build/main//321/201omponents/ScrollBar/ScrollBar.js.map +1 -1
- package/build/main//321/201omponents/Skeleton/Skeleton.js +1 -1
- package/build/main//321/201omponents/Skeleton/Skeleton.js.map +1 -1
- package/build/main//321/201omponents/Stories/Stories.js +76 -8
- package/build/main//321/201omponents/Stories/Stories.js.map +1 -1
- package/build/main//321/201omponents/Textarea/Textarea.d.ts +1 -1
- package/build/main//321/201omponents/Textarea/Textarea.js +2 -2
- package/build/main//321/201omponents/Textarea/Textarea.js.map +1 -1
- package/build/main//321/201omponents/Textarea/types.d.ts +2 -2
- package/build/main//321/201omponents/UserDropdown/ContactBottomSheet/ContactBottomSheet.d.ts +1 -1
- package/build/main//321/201omponents/UserDropdown/ContactBottomSheet/ContactBottomSheet.js +12 -3
- package/build/main//321/201omponents/UserDropdown/ContactBottomSheet/ContactBottomSheet.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/ContactInfo/ContactInfo.js +23 -13
- package/build/main//321/201omponents/UserDropdown/ContactInfo/ContactInfo.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/LoadingMessage/LoadingMessage.d.ts +2 -1
- package/build/main//321/201omponents/UserDropdown/LoadingMessage/LoadingMessage.js +4 -3
- package/build/main//321/201omponents/UserDropdown/LoadingMessage/LoadingMessage.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/MenuList/MenuList.js +37 -60
- package/build/main//321/201omponents/UserDropdown/MenuList/MenuList.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/MultiValueLabel/MultiValueLabel.d.ts +3 -2
- package/build/main//321/201omponents/UserDropdown/MultiValueLabel/MultiValueLabel.js +34 -38
- package/build/main//321/201omponents/UserDropdown/MultiValueLabel/MultiValueLabel.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/Option/Option.js +18 -13
- package/build/main//321/201omponents/UserDropdown/Option/Option.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/SearchInCatalogButton/SearchInCatalogButton.d.ts +1 -1
- package/build/main//321/201omponents/UserDropdown/SearchInCatalogButton/SearchInCatalogButton.js +6 -9
- package/build/main//321/201omponents/UserDropdown/SearchInCatalogButton/SearchInCatalogButton.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/UserDropdown.d.ts +3 -3
- package/build/main//321/201omponents/UserDropdown/UserDropdown.js +245 -266
- package/build/main//321/201omponents/UserDropdown/UserDropdown.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/components/Delimiter.d.ts +8 -0
- package/build/main//321/201omponents/UserDropdown/components/Delimiter.js +10 -0
- package/build/main//321/201omponents/UserDropdown/components/Delimiter.js.map +1 -0
- package/build/main//321/201omponents/UserDropdown/components/Hint.d.ts +6 -0
- package/build/main//321/201omponents/UserDropdown/components/Hint.js +21 -0
- package/build/main//321/201omponents/UserDropdown/components/Hint.js.map +1 -0
- package/build/main//321/201omponents/UserDropdown/components/Input.d.ts +2 -0
- package/build/main//321/201omponents/UserDropdown/components/Input.js +24 -0
- package/build/main//321/201omponents/UserDropdown/components/Input.js.map +1 -0
- package/build/main//321/201omponents/UserDropdown/components/Mask.d.ts +8 -0
- package/build/main//321/201omponents/UserDropdown/components/Mask.js +19 -0
- package/build/main//321/201omponents/UserDropdown/components/Mask.js.map +1 -0
- package/build/main//321/201omponents/UserDropdown/components/Title.d.ts +5 -0
- package/build/main//321/201omponents/UserDropdown/components/Title.js +18 -0
- package/build/main//321/201omponents/UserDropdown/components/Title.js.map +1 -0
- package/build/main//321/201omponents/UserDropdown/constants.d.ts +57 -0
- package/build/main//321/201omponents/UserDropdown/constants.js +73 -0
- package/build/main//321/201omponents/UserDropdown/constants.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/helpers.d.ts +84 -41
- package/build/main//321/201omponents/UserDropdown/helpers.js +184 -14
- package/build/main//321/201omponents/UserDropdown/helpers.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/selectStyles.d.ts +1 -1
- package/build/main//321/201omponents/UserDropdown/selectStyles.js +58 -27
- package/build/main//321/201omponents/UserDropdown/selectStyles.js.map +1 -1
- package/build/main//321/201omponents/UserDropdown/types.d.ts +146 -62
- package/build/main//321/201omponents/UserDropdown/types.js +1 -8
- package/build/main//321/201omponents/UserDropdown/types.js.map +1 -1
- package/package.json +13 -8
- package/build/main/assets/icons/avatar-arrow-down.svg +0 -3
- package/build/main/assets/icons/avatar-arrow-up.svg +0 -3
- package/build/main/hooks/useLongTap.d.ts +0 -12
- package/build/main/hooks/useLongTap.js +0 -29
- package/build/main/hooks/useLongTap.js.map +0 -1
|
@@ -9,33 +9,58 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
12
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
24
|
import { useLayoutEffect, useRef, useState } from 'react';
|
|
14
25
|
import classNames from 'classnames';
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
26
|
+
import ContextMenuItem from '../ContextMenuItem';
|
|
27
|
+
import { checkIsWebPlatform, generateFontFamilyStyle } from '../../helpers';
|
|
17
28
|
import { CONTEXT_MENU_SAFE_SPACE, FIT_CONTENT, PLATFORM } from '../../constants';
|
|
18
29
|
import '../../styles/styles.scss';
|
|
30
|
+
var AUTO_OVERFLOW_VALUE = 'auto';
|
|
31
|
+
var MAX_CONTENT = 'max-content';
|
|
19
32
|
var ContextMenu = function (_a) {
|
|
20
|
-
var _b;
|
|
21
|
-
var fontFamily = _a.fontFamily, isMenuOpen = _a.isMenuOpen,
|
|
33
|
+
var _b, _c;
|
|
34
|
+
var fontFamily = _a.fontFamily, isMenuOpen = _a.isMenuOpen, _d = _a.isClickForbidden, isClickForbidden = _d === void 0 ? false : _d, _e = _a.isCloseOnItemClick, isCloseOnItemClick = _e === void 0 ? true : _e, _f = _a.position, x = _f.x, y = _f.y, menuWidth = _a.menuWidth, containerClassName = _a.containerClassName, menuClassName = _a.menuClassName, itemClassName = _a.itemClassName, containerStyles = _a.containerStyles, _g = _a.menuStyles, menuStyles = _g === void 0 ? {} : _g, _h = _a.itemStyles, itemStyles = _h === void 0 ? {} : _h, items = _a.items, closeMenu = _a.closeMenu, _j = _a.platform, platform = _j === void 0 ? PLATFORM.web : _j, actionData = _a.actionData, topSlot = _a.topSlot, isTopSlotFixed = _a.isTopSlotFixed, maxHeight = _a.maxHeight, _k = _a.isMenuOverflowAuto, isMenuOverflowAuto = _k === void 0 ? true : _k;
|
|
22
35
|
var elementRef = useRef(null);
|
|
23
|
-
var
|
|
24
|
-
var
|
|
36
|
+
var topSlotRef = useRef(null);
|
|
37
|
+
var _l = useState(((_b = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0), contextMenuWidth = _l[0], setContextMenuWidth = _l[1];
|
|
38
|
+
var _m = useState(((_c = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) || 0), contextMenuHeight = _m[0], setContextMenuHeight = _m[1];
|
|
25
39
|
var clientHeight = document.documentElement.clientHeight;
|
|
26
40
|
var clientWidth = document.documentElement.clientWidth;
|
|
27
41
|
var handleContextMenu = function (event) {
|
|
28
42
|
event.preventDefault();
|
|
29
|
-
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
if (!checkIsWebPlatform(platform))
|
|
45
|
+
return;
|
|
46
|
+
!isClickForbidden && closeMenu(true);
|
|
47
|
+
};
|
|
48
|
+
var handleMenuItemClick = function (_a) {
|
|
49
|
+
var isCloseMenuOnCurrentItemClick = _a.isCloseMenuOnCurrentItemClick, event = _a.event, action = _a.action;
|
|
50
|
+
event.stopPropagation();
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
!isClickForbidden && action(actionData);
|
|
53
|
+
handleMenuClose({ event: event, shouldCloseDropdown: false, isCloseMenuOnCurrentItemClick: isCloseMenuOnCurrentItemClick });
|
|
30
54
|
};
|
|
31
|
-
var handleMenuItemClick = function (action) { return !isClickForbidden && action(actionData); };
|
|
32
55
|
var handleMenuClose = function (_a) {
|
|
33
|
-
var event = _a.event, _b = _a.isItemClick, isItemClick = _b === void 0 ? true : _b;
|
|
56
|
+
var event = _a.event, _b = _a.isItemClick, isItemClick = _b === void 0 ? true : _b, _c = _a.isCloseMenuOnCurrentItemClick, isCloseMenuOnCurrentItemClick = _c === void 0 ? true : _c, _d = _a.shouldCloseDropdown, shouldCloseDropdown = _d === void 0 ? true : _d;
|
|
34
57
|
event.stopPropagation();
|
|
35
|
-
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
if (isItemClick && (!isCloseOnItemClick || !isCloseMenuOnCurrentItemClick))
|
|
36
60
|
return;
|
|
61
|
+
var closeDropdown = isItemClick ? false : shouldCloseDropdown;
|
|
37
62
|
if (!isClickForbidden)
|
|
38
|
-
closeMenu();
|
|
63
|
+
closeMenu(closeDropdown);
|
|
39
64
|
};
|
|
40
65
|
var handleSortItems = function (_a, _b) {
|
|
41
66
|
var isFixedA = _a.isFixedUnderLine;
|
|
@@ -51,31 +76,47 @@ var ContextMenu = function (_a) {
|
|
|
51
76
|
setContextMenuWidth(menuWidth || width);
|
|
52
77
|
}
|
|
53
78
|
}, [isMenuOpen, menuWidth]);
|
|
54
|
-
|
|
79
|
+
useLayoutEffect(function () {
|
|
80
|
+
var elementRefCurrent = elementRef.current;
|
|
81
|
+
if (!isMenuOpen || !elementRefCurrent)
|
|
82
|
+
return;
|
|
83
|
+
var previousElementWidth = elementRefCurrent.style.width;
|
|
84
|
+
if (!menuWidth)
|
|
85
|
+
elementRefCurrent.style.width = MAX_CONTENT;
|
|
86
|
+
var nextElementWidth = Math.ceil(elementRefCurrent.getBoundingClientRect().width);
|
|
87
|
+
elementRefCurrent.style.width = previousElementWidth;
|
|
88
|
+
setContextMenuWidth(function (prevContextMenuWidth) { return (Math.abs(prevContextMenuWidth - nextElementWidth) >= 1 ? nextElementWidth : prevContextMenuWidth); });
|
|
89
|
+
}, [isMenuOpen, menuWidth, items, topSlot, isTopSlotFixed]);
|
|
55
90
|
var sortedContextMenuItems = items.sort(handleSortItems);
|
|
56
91
|
var firstIndexUnderLine = sortedContextMenuItems.findIndex(function (_a) {
|
|
57
92
|
var isFixedUnderLine = _a.isFixedUnderLine;
|
|
58
93
|
return isFixedUnderLine;
|
|
59
94
|
});
|
|
60
95
|
var contextMenuItems = sortedContextMenuItems.map(function (_a, index) {
|
|
61
|
-
var _b = _a.
|
|
62
|
-
return (
|
|
63
|
-
'smartapp-context-menu__item--checkbox': isWithCheckbox,
|
|
64
|
-
'smartapp-context-menu__item--negative': isNegativeAction,
|
|
65
|
-
'smartapp-context-menu__item--selected': isSelected,
|
|
66
|
-
'smartapp-context-menu__item--disabled': isDisabled,
|
|
67
|
-
'smartapp-context-menu__item--fixed-under-line': isFixedUnderLine && index === firstIndexUnderLine,
|
|
68
|
-
'smartapp-context-menu__item--hover': isWebPlatform(platform) && !isWithCheckbox,
|
|
69
|
-
}, itemClassName, className), disabled: isDisabled, style: itemStyles, onClick: function () { return handleMenuItemClick(action); } }, { children: [_jsxs("div", __assign({ className: classNames('smartapp-context-menu__item--content', {
|
|
70
|
-
'smartapp-context-menu__item--content__fixed-under-line': isFixedUnderLine,
|
|
71
|
-
'smartapp-context-menu__item--checkbox__content': isWithCheckbox,
|
|
72
|
-
'smartapp-context-menu__item--disabled__content': isDisabled,
|
|
73
|
-
}) }, { children: [!isFixedUnderLine && renderMenuItemIcon(icon), _jsx("span", { children: title }), isFixedUnderLine && renderMenuItemIcon(icon)] })), isWithCheckbox && _jsx(Checkbox, { id: generateId(), isChecked: isChecked, isDisabled: isDisabled })] }), title));
|
|
96
|
+
var _b = _a.isCloseMenuOnClick, isCloseMenuOnClick = _b === void 0 ? true : _b, title = _a.title, className = _a.className, action = _a.action, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, contextMenuItem = __rest(_a, ["isCloseMenuOnClick", "title", "className", "action", "onMouseEnter", "onMouseLeave"]);
|
|
97
|
+
return (_jsx(ContextMenuItem, __assign({ index: index, platform: platform, fontFamily: fontFamily, title: title, firstIndexUnderLine: firstIndexUnderLine, className: classNames(itemClassName, className), styles: itemStyles, onClick: function (event) { return handleMenuItemClick({ isCloseMenuOnCurrentItemClick: isCloseMenuOnClick, event: event, action: action }); }, onTouchEnd: function (event) { return handleMenuItemClick({ isCloseMenuOnCurrentItemClick: isCloseMenuOnClick, event: event, action: action }); }, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, contextMenuItem), title));
|
|
74
98
|
});
|
|
75
|
-
var
|
|
99
|
+
var calculateContextMenuHeight = function () {
|
|
100
|
+
var elementRefCurrent = elementRef.current;
|
|
101
|
+
if (!elementRefCurrent)
|
|
102
|
+
return FIT_CONTENT;
|
|
103
|
+
var currentElementHeight = elementRefCurrent.scrollHeight;
|
|
104
|
+
return maxHeight ? Math.min(currentElementHeight, maxHeight) : currentElementHeight;
|
|
105
|
+
};
|
|
106
|
+
var contextMenuStyles = __assign(__assign(__assign(__assign({ top: y + contextMenuHeight > clientHeight ? clientHeight - contextMenuHeight - CONTEXT_MENU_SAFE_SPACE : y, left: x + contextMenuWidth > clientWidth ? clientWidth - contextMenuWidth - CONTEXT_MENU_SAFE_SPACE : x }, (menuWidth ? { width: menuWidth } : { width: contextMenuWidth })), { height: calculateContextMenuHeight() }), (isMenuOverflowAuto ? { overflow: AUTO_OVERFLOW_VALUE } : {})), menuStyles);
|
|
107
|
+
var generateContextMenuItemsClassname = function () {
|
|
108
|
+
return classNames('smartapp-context-menu__items', {
|
|
109
|
+
'smartapp-context-menu__items--with-fixed-top-slot': isTopSlotFixed && topSlot,
|
|
110
|
+
}, menuClassName);
|
|
111
|
+
};
|
|
112
|
+
var generateTopSlotClassname = function () {
|
|
113
|
+
return classNames('smartapp-context-menu__items--top-slot', {
|
|
114
|
+
'smartapp-context-menu__items--top-slot__fixed': isTopSlotFixed,
|
|
115
|
+
});
|
|
116
|
+
};
|
|
76
117
|
if (!isMenuOpen)
|
|
77
118
|
return null;
|
|
78
|
-
return (_jsx("div", __assign({ className: classNames('smartapp-context-menu', containerClassName), style: __assign(__assign({}, generateFontFamilyStyle(fontFamily)), containerStyles), onClick: function (event) { return handleMenuClose({ event: event, isItemClick: false }); }, onContextMenu: handleContextMenu }, { children: _jsxs("div", __assign({ ref: elementRef, className:
|
|
119
|
+
return (_jsx("div", __assign({ className: classNames('smartapp-context-menu', containerClassName), style: __assign(__assign({}, generateFontFamilyStyle(fontFamily)), containerStyles), onClick: function (event) { return handleMenuClose({ event: event, isItemClick: false }); }, onContextMenu: handleContextMenu, onTouchEnd: function (event) { return handleMenuClose({ event: event, isItemClick: false }); } }, { children: _jsxs("div", __assign({ ref: elementRef, className: generateContextMenuItemsClassname(), style: contextMenuStyles, onClick: function (event) { return handleMenuClose({ event: event }); } }, { children: [topSlot && (_jsx("div", __assign({ ref: topSlotRef, className: generateTopSlotClassname() }, { children: topSlot }))), _jsx("div", __assign({ className: "smartapp-context-menu__items--list" }, { children: contextMenuItems }))] })) })));
|
|
79
120
|
};
|
|
80
121
|
export default ContextMenu;
|
|
81
122
|
//# sourceMappingURL=ContextMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/сomponents/ContextMenu/ContextMenu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/сomponents/ContextMenu/ContextMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAkB,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChF,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,eAAe,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,QAAQ,EAAe,MAAM,iBAAiB,CAAA;AAE7F,OAAO,0BAA0B,CAAA;AAEjC,IAAM,mBAAmB,GAAG,MAAM,CAAA;AAClC,IAAM,WAAW,GAAG,aAAa,CAAA;AAWjC,IAAM,WAAW,GAAG,UAAK,EAqBF;;QApBrB,UAAU,gBAAA,EACV,UAAU,g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,EAAE,KAAK,OAAA,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAA9C,CAA8C,gBAErE,wBAAK,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,iCAAiC,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAC,KAAK,IAAK,OAAA,eAAe,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC,EAA1B,CAA0B,iBAC3I,OAAO,IAAI,CACV,uBAAK,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,wBAAwB,EAAE,gBACxD,OAAO,IACJ,CACP,EACD,uBAAK,SAAS,EAAC,oCAAoC,gBAAE,gBAAgB,IAAO,KACxE,IACF,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { IFontFamilyProps, IPlatformProps, TStyles } from '../../constants';
|
|
2
|
+
import { IFontFamilyProps, IPlatformProps, TCoords, TStyles } from '../../constants';
|
|
3
|
+
import { ICON_POSITION, TContextMenuItemMouseEventHandler } from '../ContextMenuItem/types';
|
|
3
4
|
export type MenuItem<T extends unknown = any> = {
|
|
4
5
|
isNegativeAction?: boolean;
|
|
5
6
|
isSelected?: boolean;
|
|
@@ -7,19 +8,23 @@ export type MenuItem<T extends unknown = any> = {
|
|
|
7
8
|
isWithCheckbox?: boolean;
|
|
8
9
|
isChecked?: boolean;
|
|
9
10
|
isFixedUnderLine?: boolean;
|
|
11
|
+
isShowArrow?: boolean;
|
|
12
|
+
isCloseMenuOnClick?: boolean;
|
|
10
13
|
className?: string;
|
|
11
14
|
title: string;
|
|
12
|
-
|
|
15
|
+
secondaryText?: string;
|
|
13
16
|
icon?: ReactElement;
|
|
17
|
+
iconPosition?: ICON_POSITION;
|
|
18
|
+
onMouseEnter?: TContextMenuItemMouseEventHandler;
|
|
19
|
+
onMouseLeave?: TContextMenuItemMouseEventHandler;
|
|
20
|
+
action: (actionData?: T) => void;
|
|
14
21
|
};
|
|
15
22
|
export interface IContextMenuProps<T extends unknown = any> extends IPlatformProps, IFontFamilyProps {
|
|
16
23
|
isMenuOpen: boolean;
|
|
17
24
|
isCloseOnItemClick?: boolean;
|
|
18
25
|
isClickForbidden?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
y: number;
|
|
22
|
-
};
|
|
26
|
+
isMenuOverflowAuto?: boolean;
|
|
27
|
+
position: TCoords;
|
|
23
28
|
menuWidth?: number;
|
|
24
29
|
containerClassName?: string;
|
|
25
30
|
menuClassName?: string;
|
|
@@ -30,5 +35,7 @@ export interface IContextMenuProps<T extends unknown = any> extends IPlatformPro
|
|
|
30
35
|
items: MenuItem[];
|
|
31
36
|
actionData?: T;
|
|
32
37
|
topSlot?: ReactNode;
|
|
33
|
-
|
|
38
|
+
isTopSlotFixed?: boolean;
|
|
39
|
+
maxHeight?: number;
|
|
40
|
+
closeMenu: (shouldCloseDropdown?: boolean) => void;
|
|
34
41
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IContextMenuItemProps } from './types';
|
|
2
|
+
import '../../styles/styles.scss';
|
|
3
|
+
declare const ContextMenuItem: ({ platform, fontFamily, isNegativeAction, isSelected, isDisabled, isWithCheckbox, isChecked, isFixedUnderLine, index, firstIndexUnderLine, title, icon, iconPosition, className, styles, onClick, onTouchEnd, secondaryText, isShowArrow, onMouseEnter, onMouseLeave, }: IContextMenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export default ContextMenuItem;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import { isNil } from 'lodash';
|
|
15
|
+
import Checkbox from '../Checkbox/Checkbox';
|
|
16
|
+
import { checkIsWebPlatform, generateFontFamilyStyle, generateId } from '../../helpers';
|
|
17
|
+
import { COLORS, PLATFORM } from '../../constants';
|
|
18
|
+
import { ICON_POSITION } from './types';
|
|
19
|
+
import { ReactComponent as ChevronIcon } from '../../assets/icons/chevron.svg';
|
|
20
|
+
import '../../styles/styles.scss';
|
|
21
|
+
var checkIconPosition = function (isFixedUnderLine, iconPosition) {
|
|
22
|
+
var isLeftIconPosition = iconPosition === ICON_POSITION.left;
|
|
23
|
+
var isLeftIconLocation = iconPosition ? isLeftIconPosition : !isFixedUnderLine;
|
|
24
|
+
var isRightIconLocation = iconPosition ? iconPosition === ICON_POSITION.right : isFixedUnderLine;
|
|
25
|
+
return { isLeftIconPosition: isLeftIconPosition, isLeftIconLocation: isLeftIconLocation, isRightIconLocation: isRightIconLocation };
|
|
26
|
+
};
|
|
27
|
+
var ContextMenuItem = function (_a) {
|
|
28
|
+
var _b = _a.platform, platform = _b === void 0 ? PLATFORM.web : _b, fontFamily = _a.fontFamily, _c = _a.isNegativeAction, isNegativeAction = _c === void 0 ? false : _c, _d = _a.isSelected, isSelected = _d === void 0 ? false : _d, _e = _a.isDisabled, isDisabled = _e === void 0 ? false : _e, _f = _a.isWithCheckbox, isWithCheckbox = _f === void 0 ? false : _f, _g = _a.isChecked, isChecked = _g === void 0 ? false : _g, _h = _a.isFixedUnderLine, isFixedUnderLine = _h === void 0 ? false : _h, index = _a.index, firstIndexUnderLine = _a.firstIndexUnderLine, title = _a.title, icon = _a.icon, iconPosition = _a.iconPosition, className = _a.className, styles = _a.styles, onClick = _a.onClick, onTouchEnd = _a.onTouchEnd, secondaryText = _a.secondaryText, _j = _a.isShowArrow, isShowArrow = _j === void 0 ? false : _j, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave;
|
|
29
|
+
var _k = checkIconPosition(isFixedUnderLine, iconPosition), isLeftIconPosition = _k.isLeftIconPosition, isLeftIconLocation = _k.isLeftIconLocation, isRightIconLocation = _k.isRightIconLocation;
|
|
30
|
+
var renderContextMenuItemIcon = function (icon) { return icon && _jsx("div", __assign({ className: "smartapp-context-menu-item__content--icon" }, { children: icon })); };
|
|
31
|
+
var renderContextMenuItemText = function (title, secondaryText) {
|
|
32
|
+
return secondaryText ? (_jsxs("div", __assign({ className: "smartapp-context-menu-item__content--text" }, { children: [_jsx("span", __assign({ className: "smartapp-context-menu-item__content--text__title" }, { children: title })), _jsx("span", __assign({ className: "smartapp-context-menu-item__content--text__secondary-text" }, { children: secondaryText }))] }))) : (_jsx("span", { children: title }));
|
|
33
|
+
};
|
|
34
|
+
return (_jsxs(_Fragment, { children: [isFixedUnderLine && index === firstIndexUnderLine && _jsx("div", { className: "smartapp-context-menu-item__fixed-under-line" }), _jsxs("button", __assign({ className: classNames('smartapp-context-menu-item', {
|
|
35
|
+
'smartapp-context-menu-item__checkbox': isWithCheckbox,
|
|
36
|
+
'smartapp-context-menu-item__checkbox-with-arrow': isWithCheckbox && isShowArrow,
|
|
37
|
+
'smartapp-context-menu-item__negative': isNegativeAction,
|
|
38
|
+
'smartapp-context-menu-item__selected': isSelected,
|
|
39
|
+
'smartapp-context-menu-item__disabled': isDisabled,
|
|
40
|
+
'smartapp-context-menu-item__hover': checkIsWebPlatform(platform) && !isWithCheckbox,
|
|
41
|
+
}, className), disabled: isDisabled, style: __assign(__assign({}, styles), generateFontFamilyStyle(fontFamily)), onClick: onClick, onTouchEnd: onTouchEnd, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, { children: [_jsxs("div", __assign({ className: classNames('smartapp-context-menu-item__content', {
|
|
42
|
+
'smartapp-context-menu-item__content--fixed-under-line': isFixedUnderLine,
|
|
43
|
+
'smartapp-context-menu-item__content--fixed-under-line__reduced-gap': isFixedUnderLine && isLeftIconPosition,
|
|
44
|
+
'smartapp-context-menu-item__checkbox--content': isWithCheckbox && !isNil(icon),
|
|
45
|
+
'smartapp-context-menu-item__disabled--content': isDisabled,
|
|
46
|
+
}) }, { children: [isLeftIconLocation && renderContextMenuItemIcon(icon), renderContextMenuItemText(title, secondaryText), isRightIconLocation && renderContextMenuItemIcon(icon)] })), isWithCheckbox && _jsx(Checkbox, { id: generateId(), isChecked: isChecked, isDisabled: isDisabled }), isShowArrow && (_jsx("div", __assign({ className: "smartapp-context-menu-item__arrow" }, { children: _jsx(ChevronIcon, { color: COLORS.iconPrimary }) })))] }))] }));
|
|
47
|
+
};
|
|
48
|
+
export default ContextMenuItem;
|
|
49
|
+
//# sourceMappingURL=ContextMenuItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuItem.js","sourceRoot":"","sources":["../../../../src/сomponents/ContextMenuItem/ContextMenuItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,QAAQ,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAyB,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,cAAc,IAAI,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC9E,OAAO,0BAA0B,CAAA;AAEjC,IAAM,iBAAiB,GAAG,UAAC,gBAAyB,EAAE,YAA4B;IAChF,IAAM,kBAAkB,GAAG,YAAY,KAAK,aAAa,CAAC,IAAI,CAAA;IAC9D,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AAmB,IAAI,yBAAyB,CAAC,IAAI,CAAC,KACnD,EACL,cAAc,IAAI,KAAC,QAAQ,IAAC,EAAE,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,GAAI,EAC9F,WAAW,IAAI,CACd,uBAAK,SAAS,EAAC,mCAAmC,gBAChD,KAAC,WAAW,IAAC,KAAK,EAAE,MAAM,CAAC,WAAW,GAAI,IACtC,CACP,KACM,IACR,CACJ,CAAA;AACH,CAAC,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ContextMenuItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/сomponents/ContextMenuItem/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactElement } from 'react';
|
|
2
|
+
import { IFontFamilyProps, IPlatformProps, TClickEvent, TStyles } from '../../constants';
|
|
3
|
+
export declare enum ICON_POSITION {
|
|
4
|
+
left = "left",
|
|
5
|
+
right = "right"
|
|
6
|
+
}
|
|
7
|
+
export type TContextMenuItemMouseEventHandler = MouseEventHandler<HTMLButtonElement>;
|
|
8
|
+
export interface IContextMenuItemProps extends IPlatformProps, IFontFamilyProps {
|
|
9
|
+
isNegativeAction?: boolean;
|
|
10
|
+
isSelected?: boolean;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
isWithCheckbox?: boolean;
|
|
13
|
+
isChecked?: boolean;
|
|
14
|
+
isFixedUnderLine?: boolean;
|
|
15
|
+
index?: number;
|
|
16
|
+
firstIndexUnderLine?: number;
|
|
17
|
+
title: string;
|
|
18
|
+
icon?: ReactElement;
|
|
19
|
+
iconPosition?: ICON_POSITION;
|
|
20
|
+
className?: string;
|
|
21
|
+
secondaryText?: string;
|
|
22
|
+
isShowArrow?: boolean;
|
|
23
|
+
styles?: TStyles;
|
|
24
|
+
onClick?: (event: TClickEvent) => void;
|
|
25
|
+
onTouchEnd?: (event: TClickEvent) => void;
|
|
26
|
+
onMouseEnter?: TContextMenuItemMouseEventHandler;
|
|
27
|
+
onMouseLeave?: TContextMenuItemMouseEventHandler;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/сomponents/ContextMenuItem/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
|
|
@@ -8,5 +8,5 @@ export declare const generateListItemTextRect: (menuListRef: React.RefObject<HTM
|
|
|
8
8
|
top: number;
|
|
9
9
|
maxWidth: number;
|
|
10
10
|
};
|
|
11
|
-
declare const CustomSelect: ({ fontFamily, isLoading, isSearchable, isCreatable, isDisabled, isOptionsWithTooltip, isMenuAutoWidth, width, menuListMaxHeight, containerClassName, containerPadding, containerStyles, title, placeholder, hint, noOptionsMessage, noOptionsMessageClassName, error, menuPosition, menuLocation, defaultValue, options, onChange, onDisabledOptionClick, onMenuOpen, }: ICustomSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const CustomSelect: ({ platform, fontFamily, isLoading, isSearchable, isCreatable, isDisabled, isOptionsWithTooltip, isOptionsTextTruncated, isMenuAutoWidth, isInteractionDisabled, width, menuListMaxHeight, containerClassName, containerPadding, containerStyles, title, placeholder, hint, noOptionsMessage, noOptionsMessageClassName, error, menuPosition, menuLocation, defaultValue, options, selectProps, creatableSelectProps, onChange, onDisabledOptionClick, onMenuOpen, }: ICustomSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export default CustomSelect;
|
|
@@ -12,13 +12,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
/* eslint-disable max-lines */
|
|
14
14
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
15
|
-
import Select, { components } from 'react-select';
|
|
15
|
+
import Select, { components, } from 'react-select';
|
|
16
16
|
import CreatableSelect from 'react-select/creatable';
|
|
17
17
|
import Popup from 'reactjs-popup';
|
|
18
18
|
import classNames from 'classnames';
|
|
19
|
-
import { isEmpty, max, omit } from 'lodash';
|
|
19
|
+
import { isArray, isEmpty, isNull, max, omit } from 'lodash';
|
|
20
20
|
import ListItem from '../ListItem';
|
|
21
21
|
import { DEFAULT_INDICATOR_COLOR, NOT_INTERACTIVE_ELEMENT } from '../ListItem/ListItem';
|
|
22
|
+
import ScrollBar from '../ScrollBar';
|
|
23
|
+
import { DEFAULT_SCROLL_BAR_SIZE } from '../ScrollBar/ScrollBar';
|
|
22
24
|
import { Skeleton } from '../Skeleton';
|
|
23
25
|
import selectStyles from './selectStyles';
|
|
24
26
|
import { generateFontFamilyStyle, isValueEqualToZero } from '../../helpers';
|
|
@@ -47,7 +49,7 @@ export var generateListItemTextRect = function (menuListRef, listItemTextRef) {
|
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
51
|
var Option = function (props) {
|
|
50
|
-
var label = props.label, isSelected = props.isSelected, isOptionsWithTooltip = props.isOptionsWithTooltip, _a = props.data, isCreatable = _a.isCreatable, isDisabled = _a.isDisabled, _b = _a.element, element = _b === void 0 ? NOT_INTERACTIVE_ELEMENT.noElement : _b, secondaryText = _a.secondaryText, secondaryTextColor = _a.secondaryTextColor, color = _a.color, styles = _a.styles, containerClassName = _a.containerClassName,
|
|
52
|
+
var label = props.label, isSelected = props.isSelected, isOptionsWithTooltip = props.isOptionsWithTooltip, isOptionsTextTruncated = props.isOptionsTextTruncated, _a = props.data, isCreatable = _a.isCreatable, isDisabled = _a.isDisabled, _b = _a.element, element = _b === void 0 ? NOT_INTERACTIVE_ELEMENT.noElement : _b, primaryTextStyles = _a.primaryTextStyles, primaryTextClassName = _a.primaryTextClassName, secondaryText = _a.secondaryText, secondaryTextColor = _a.secondaryTextColor, secondaryTextStyles = _a.secondaryTextStyles, secondaryTextClassName = _a.secondaryTextClassName, color = _a.color, styles = _a.styles, containerClassName = _a.containerClassName, avatar = _a.avatar, onDisabledSpecialOptionClick = _a.onDisabledSpecialOptionClick, menuListRef = props.menuListRef, platform = props.platform, fontFamily = props.fontFamily, onDisabledOptionClick = props.onDisabledOptionClick;
|
|
51
53
|
var optionComponentRef = useRef(null);
|
|
52
54
|
var listItemTextRef = useRef(null);
|
|
53
55
|
var popupRef = useRef(null);
|
|
@@ -59,7 +61,7 @@ var Option = function (props) {
|
|
|
59
61
|
var _g = useState(POPUP_HIDDEN_CLASSNAME), hiddenClassName = _g[0], setHiddenClassName = _g[1];
|
|
60
62
|
var _h = useState(null), timeoutId = _h[0], setTimeoutId = _h[1];
|
|
61
63
|
var _j = generateListItemTextRect(menuListRef, listItemTextRef), scrollWidth = _j.scrollWidth, clientWidth = _j.clientWidth, left = _j.left, top = _j.top, maxWidth = _j.maxWidth;
|
|
62
|
-
var isTooltipAvailable = scrollWidth > clientWidth;
|
|
64
|
+
var isTooltipAvailable = isOptionsWithTooltip && scrollWidth > clientWidth;
|
|
63
65
|
var generateListItemTextWidth = function () {
|
|
64
66
|
var _a;
|
|
65
67
|
var listItemTextElement = (_a = optionComponentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.smartapp-list-item__text');
|
|
@@ -76,7 +78,8 @@ var Option = function (props) {
|
|
|
76
78
|
useLayoutEffect(function () {
|
|
77
79
|
setListItemTextWidth(generateListItemTextWidth());
|
|
78
80
|
}, []);
|
|
79
|
-
var
|
|
81
|
+
var handleDisabledOptionClick = onDisabledSpecialOptionClick || onDisabledOptionClick;
|
|
82
|
+
var handleOptionClick = function () { return isDisabled && handleDisabledOptionClick(); };
|
|
80
83
|
var recalculatePopupMaxWidth = function () {
|
|
81
84
|
var popupRefCurrent = popupRef.current;
|
|
82
85
|
var popupSpanRefCurrent = popupSpanRef.current;
|
|
@@ -93,7 +96,7 @@ var Option = function (props) {
|
|
|
93
96
|
}
|
|
94
97
|
};
|
|
95
98
|
var handleClosePopup = function () { return timeoutId && clearTimeout(timeoutId); };
|
|
96
|
-
var renderListItem = function () { return (_jsx(ListItem, { fontFamily: fontFamily, textRef: listItemTextRef, type: "not-interactive", element: element, text: label, secondaryText: secondaryText, secondaryTextColor: secondaryTextColor, color: color, isSelected: isSelected && !isCreatable, isDisabled: isDisabled, textStyles: __assign(__assign({}, styles), { width: listItemTextWidth }) })); };
|
|
99
|
+
var renderListItem = function () { return (_jsx(ListItem, { platform: platform, fontFamily: fontFamily, textRef: listItemTextRef, type: "not-interactive", element: element, text: label, primaryTextClassName: primaryTextClassName, primaryTextStyles: primaryTextStyles, secondaryText: secondaryText, secondaryTextColor: secondaryTextColor, secondaryTextStyles: secondaryTextStyles, secondaryTextClassName: secondaryTextClassName, color: color, isSelected: isSelected && !isCreatable, isDisabled: isDisabled, isTextTruncated: isOptionsTextTruncated, textStyles: __assign(__assign({}, styles), { width: listItemTextWidth }), avatar: avatar })); };
|
|
97
100
|
return (_jsx("div", __assign({ className: containerClassName, onClick: handleOptionClick }, { children: _jsx(components.Option, __assign({}, props, { innerRef: optionComponentRef, className: classNames({ 'smartapp-option-with-tooltip': isOptionsWithTooltip }) }, { children: isTooltipAvailable ? (_jsx(Popup, __assign({ ref: popupRef, arrow: false, className: classNames('select-label', hiddenClassName), contentStyle: __assign({ '--select-label-content-left': "".concat(popupLeft, "px"), '--select-label-content-top': "".concat(popupTop, "px"), '--select-label-content-max-width': "".concat(popupMaxWidth, "px") }, generateFontFamilyStyle(fontFamily)), on: [POPUP_ON_EVENT_TYPE.hover], mouseEnterDelay: POPUP_APPEARANCE_DELAY, onOpen: recalculatePopupMaxWidth, onClose: handleClosePopup, trigger: function () { return _jsx("div", __assign({ className: "w-100" }, { children: renderListItem() })); } }, { children: _jsx("span", __assign({ ref: popupSpanRef }, { children: label })) }))) : (renderListItem()) })) })));
|
|
98
101
|
};
|
|
99
102
|
var SingleValueComponent = function (props) {
|
|
@@ -109,7 +112,16 @@ var SingleValueComponent = function (props) {
|
|
|
109
112
|
return (_jsxs(components.SingleValue, __assign({}, props, { children: [renderIndicatorElement(), _jsx("div", __assign({ className: "smartapp-custom-select__selected-value" }, { children: children }))] })));
|
|
110
113
|
};
|
|
111
114
|
var MenuList = function (props) {
|
|
112
|
-
var menuListRef = props.menuListRef, selectWidth = props.selectWidth, optionHeight = props.optionHeight, setOptionHeight = props.setOptionHeight, children = props.children;
|
|
115
|
+
var platform = props.platform, menuListRef = props.menuListRef, isMenuAutoWidth = props.isMenuAutoWidth, menuListWidth = props.menuListWidth, menuListMaxHeight = props.menuListMaxHeight, selectWidth = props.selectWidth, optionHeight = props.optionHeight, setOptionHeight = props.setOptionHeight, children = props.children;
|
|
116
|
+
// Определяем количество элементов: если это список доступных для выбора элементов, берем его длину.
|
|
117
|
+
// Если это не массив, значит в меню отображается "Loading" или "No Options" компонент.
|
|
118
|
+
var optionsLength = isArray(children) ? children.length : 1;
|
|
119
|
+
// Рассчитываем итоговую высоту контейнера меню:
|
|
120
|
+
// 1. Общая высота всех элементов (высота одного элемента * количество);
|
|
121
|
+
// 2. Суммарная высота промежутков между элементами (количество промежутков всегда на 1 меньше, чем элементов);
|
|
122
|
+
// 3. Внутренние отступы (padding) контейнера сверху и снизу.
|
|
123
|
+
var menuListHeight = optionHeight * optionsLength + OPTIONS_GAP * (optionsLength - 1) + PADDING;
|
|
124
|
+
var containerHeight = Math.min(menuListHeight, menuListMaxHeight);
|
|
113
125
|
useLayoutEffect(function () {
|
|
114
126
|
var _a;
|
|
115
127
|
if (menuListRef.current && isValueEqualToZero(optionHeight)) {
|
|
@@ -118,7 +130,7 @@ var MenuList = function (props) {
|
|
|
118
130
|
!isEmpty(optionsHeights) && setOptionHeight(max(optionsHeights) || 0);
|
|
119
131
|
}
|
|
120
132
|
}, [optionHeight, setOptionHeight, selectWidth, menuListRef]);
|
|
121
|
-
return (_jsx(components.MenuList, __assign({}, props, { innerRef: menuListRef }, { children: children })));
|
|
133
|
+
return (_jsx(components.MenuList, __assign({}, props, { innerRef: menuListRef }, { children: isArray(children) ? (_jsx(ScrollBar, { platform: platform, content: children, containerHeight: "".concat(containerHeight, "px"), containerWidth: isMenuAutoWidth ? "".concat(menuListWidth, "px") : DEFAULT_SCROLL_BAR_SIZE, trackYHeight: TRACK_Y_HEIGHT })) : (children) })));
|
|
122
134
|
};
|
|
123
135
|
var LoadingMessage = function (_a) {
|
|
124
136
|
var _b = _a.isCreatableSelect, isCreatableSelect = _b === void 0 ? false : _b;
|
|
@@ -129,7 +141,7 @@ var LoadingMessage = function (_a) {
|
|
|
129
141
|
};
|
|
130
142
|
var NoOptionsMessage = function (props) {
|
|
131
143
|
var noOptionsMessage = props.noOptionsMessage, children = props.children;
|
|
132
|
-
return noOptionsMessage ? _jsx(components.NoOptionsMessage, __assign({}, props, { children: children })) : null;
|
|
144
|
+
return noOptionsMessage ? (_jsx(components.NoOptionsMessage, __assign({}, props, { className: "smartapp-custom-select__no-options" }, { children: children }))) : null;
|
|
133
145
|
};
|
|
134
146
|
var Input = function (props) { return _jsx(components.Input, __assign({}, props, { isHidden: false })); };
|
|
135
147
|
var IndicatorSeparator = function () { return null; };
|
|
@@ -142,22 +154,42 @@ var POPUP_HIDDEN_CLASSNAME = 'select-label-hidden';
|
|
|
142
154
|
var LOADING_MESSAGE_ITEMS = 6;
|
|
143
155
|
var IS_CREATABLE_FIELD_NAME = 'isCreatable';
|
|
144
156
|
var EMPTY_SELECTED_VALUE = { value: '', label: '' };
|
|
157
|
+
var OPTIONS_GAP = 2;
|
|
158
|
+
var PADDING = 12;
|
|
159
|
+
var TRACK_Y_HEIGHT = 'calc(100% - 16px)';
|
|
145
160
|
var ACTIONS = {
|
|
146
161
|
clear: 'clear',
|
|
147
162
|
inputChange: 'input-change',
|
|
148
163
|
};
|
|
149
164
|
var CustomSelect = function (_a) {
|
|
150
|
-
var
|
|
165
|
+
var _b;
|
|
166
|
+
var platform = _a.platform, fontFamily = _a.fontFamily, _c = _a.isLoading, isLoading = _c === void 0 ? false : _c, _d = _a.isSearchable, isSearchable = _d === void 0 ? false : _d, _e = _a.isCreatable, isCreatable = _e === void 0 ? false : _e, _f = _a.isDisabled, isDisabled = _f === void 0 ? false : _f, _g = _a.isOptionsWithTooltip, isOptionsWithTooltip = _g === void 0 ? false : _g, _h = _a.isOptionsTextTruncated, isOptionsTextTruncated = _h === void 0 ? false : _h, _j = _a.isMenuAutoWidth, isMenuAutoWidth = _j === void 0 ? false : _j, _k = _a.isInteractionDisabled, isInteractionDisabled = _k === void 0 ? false : _k, _l = _a.width, width = _l === void 0 ? 100 : _l, menuListMaxHeight = _a.menuListMaxHeight, containerClassName = _a.containerClassName, containerPadding = _a.containerPadding, containerStyles = _a.containerStyles, title = _a.title, placeholder = _a.placeholder, hint = _a.hint, noOptionsMessage = _a.noOptionsMessage, noOptionsMessageClassName = _a.noOptionsMessageClassName, error = _a.error, _m = _a.menuPosition, menuPosition = _m === void 0 ? MENU_POSITIONS.bottom : _m, menuLocation = _a.menuLocation, defaultValue = _a.defaultValue, options = _a.options, selectProps = _a.selectProps, creatableSelectProps = _a.creatableSelectProps, onChange = _a.onChange, _o = _a.onDisabledOptionClick, onDisabledOptionClick = _o === void 0 ? function () { } : _o, _p = _a.onMenuOpen, onMenuOpen = _p === void 0 ? function () { } : _p;
|
|
151
167
|
var selectRef = useRef(null);
|
|
152
168
|
var menuListRef = useRef(null);
|
|
153
|
-
var
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
var
|
|
169
|
+
var _q = useState(), value = _q[0], setValue = _q[1];
|
|
170
|
+
var _r = useState(''), inputValue = _r[0], setInputValue = _r[1];
|
|
171
|
+
var _s = useState(false), isInputFocused = _s[0], setIsInputFocused = _s[1];
|
|
172
|
+
var _t = useState(0), optionHeight = _t[0], setOptionHeight = _t[1];
|
|
173
|
+
var _u = useState(0), menuListWidth = _u[0], setMenuListWidth = _u[1];
|
|
157
174
|
var selectRefCurrent = selectRef.current;
|
|
158
175
|
var isSelectClearable = isInputFocused && !isEmpty(inputValue);
|
|
159
176
|
var fontFamilyStyle = generateFontFamilyStyle(fontFamily);
|
|
160
|
-
|
|
177
|
+
var isActionless = isInteractionDisabled && options.length === 1;
|
|
178
|
+
var isMenuOpen = isActionless ? false : undefined;
|
|
179
|
+
var isSelectMenuOpen = (_b = selectRefCurrent === null || selectRefCurrent === void 0 ? void 0 : selectRefCurrent.props) === null || _b === void 0 ? void 0 : _b.menuIsOpen;
|
|
180
|
+
useLayoutEffect(function () {
|
|
181
|
+
setOptionHeight(0);
|
|
182
|
+
setMenuListWidth(0);
|
|
183
|
+
}, [width, fontFamily, isMenuAutoWidth]);
|
|
184
|
+
useLayoutEffect(function () {
|
|
185
|
+
var _a;
|
|
186
|
+
var menuListRefCurrent = menuListRef.current;
|
|
187
|
+
if (isSelectMenuOpen && !isNull(menuListRefCurrent)) {
|
|
188
|
+
var _b = menuListRefCurrent.getBoundingClientRect().width, menuListWidth_1 = _b === void 0 ? 0 : _b;
|
|
189
|
+
var _c = (((_a = menuListRefCurrent.querySelector('[role="option"]')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {}).width, optionWidth = _c === void 0 ? 0 : _c;
|
|
190
|
+
setMenuListWidth(Math.max(optionWidth, menuListWidth_1 - PADDING));
|
|
191
|
+
}
|
|
192
|
+
}, [isMenuAutoWidth, isSelectMenuOpen]);
|
|
161
193
|
useEffect(function () {
|
|
162
194
|
if (defaultValue) {
|
|
163
195
|
setValue(defaultValue);
|
|
@@ -174,8 +206,8 @@ var CustomSelect = function (_a) {
|
|
|
174
206
|
};
|
|
175
207
|
var renderHint = function () { return hint && _jsx("div", __assign({ className: "smartapp-custom-select__hint" }, { children: hint })); };
|
|
176
208
|
var renderError = function () { return error && _jsx("div", __assign({ className: "smartapp-custom-select__error" }, { children: error })); };
|
|
177
|
-
var OptionComponent = function (props) { return (_jsx(Option, __assign({}, props, { menuListRef: menuListRef, fontFamily: fontFamily, isOptionsWithTooltip: isOptionsWithTooltip, onDisabledOptionClick: onDisabledOptionClick }))); };
|
|
178
|
-
var MenuListComponent = function (props) { return (_jsx(MenuList, __assign({}, props, { children: props.children, menuListRef: menuListRef, selectWidth: width, optionHeight: optionHeight, setOptionHeight: setOptionHeight }))); };
|
|
209
|
+
var OptionComponent = function (props) { return (_jsx(Option, __assign({}, props, { menuListRef: menuListRef, platform: platform, fontFamily: fontFamily, isOptionsWithTooltip: isOptionsWithTooltip, isOptionsTextTruncated: isOptionsTextTruncated, onDisabledOptionClick: onDisabledOptionClick }))); };
|
|
210
|
+
var MenuListComponent = function (props) { return (_jsx(MenuList, __assign({}, props, { children: props.children, platform: platform, menuListRef: menuListRef, isMenuAutoWidth: isMenuAutoWidth, menuListWidth: menuListWidth, menuListMaxHeight: generateMenuListMaxHeight(), selectWidth: width, optionHeight: optionHeight, setOptionHeight: setOptionHeight }))); };
|
|
179
211
|
var generateStyles = function () {
|
|
180
212
|
return selectStyles({
|
|
181
213
|
isDisabled: isDisabled,
|
|
@@ -215,6 +247,7 @@ var CustomSelect = function (_a) {
|
|
|
215
247
|
setIsInputFocused(true);
|
|
216
248
|
};
|
|
217
249
|
var handleBlur = function () { return setIsInputFocused(false); };
|
|
250
|
+
var handleMenuOpen = function () { return !isActionless && (onMenuOpen === null || onMenuOpen === void 0 ? void 0 : onMenuOpen()); };
|
|
218
251
|
var handleCreatableKeyDown = function (event) {
|
|
219
252
|
var key = event.key, code = event.code;
|
|
220
253
|
if (code === ENTER_KEY || key === ENTER_KEY) {
|
|
@@ -222,27 +255,27 @@ var CustomSelect = function (_a) {
|
|
|
222
255
|
selectRefCurrent === null || selectRefCurrent === void 0 ? void 0 : selectRefCurrent.blur();
|
|
223
256
|
}
|
|
224
257
|
};
|
|
225
|
-
return (_jsxs("div", __assign({ className: classNames('smartapp-custom-select', containerClassName), style: __assign(__assign({ width: "".concat(width, "%") }, fontFamilyStyle), containerStyles) }, { children: [renderTitle(), isCreatable ? (_jsx(CreatableSelect, { ref: selectRef, menuPlacement: menuPosition, menuPosition: menuLocation, isLoading: isLoading, isDisabled: isDisabled, isClearable: isSelectClearable, controlShouldRenderValue: isDisabled, filterOption: creatableFilterOption, options: options, value: (value === null || value === void 0 ? void 0 : value.label) ? value : null, styles: generateStyles(), placeholder: placeholder, inputValue: isDisabled ? '' : inputValue, onInputChange: handleInputChange, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleCreatableKeyDown, onMenuOpen:
|
|
258
|
+
return (_jsxs("div", __assign({ className: classNames('smartapp-custom-select', containerClassName), style: __assign(__assign({ width: "".concat(width, "%") }, fontFamilyStyle), containerStyles) }, { children: [renderTitle(), isCreatable ? (_jsx(CreatableSelect, __assign({ ref: selectRef, menuIsOpen: isMenuOpen, menuPlacement: menuPosition, menuPosition: menuLocation, isLoading: isLoading, isDisabled: isDisabled, isClearable: isSelectClearable, controlShouldRenderValue: isDisabled, filterOption: creatableFilterOption, options: options, value: (value === null || value === void 0 ? void 0 : value.label) ? value : null, styles: generateStyles(), placeholder: placeholder, inputValue: isDisabled ? '' : inputValue, onInputChange: handleInputChange, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleCreatableKeyDown, onMenuOpen: handleMenuOpen, loadingMessage: function () { return _jsx(LoadingMessage, { isCreatableSelect: true }); }, components: {
|
|
226
259
|
Input: Input,
|
|
227
260
|
Option: OptionComponent,
|
|
228
261
|
IndicatorSeparator: IndicatorSeparator,
|
|
229
|
-
DropdownIndicator: function (props) { return _jsx(DropdownIndicator, __assign({}, props, { isHidden: isSelectClearable })); },
|
|
262
|
+
DropdownIndicator: function (props) { return _jsx(DropdownIndicator, __assign({}, props, { isHidden: isSelectClearable || isActionless })); },
|
|
230
263
|
MenuList: MenuListComponent,
|
|
231
264
|
LoadingIndicator: LoadingIndicator,
|
|
232
265
|
NoOptionsMessage: function () { return null; },
|
|
233
266
|
ClearIndicator: ClearIndicator,
|
|
234
267
|
SingleValue: SingleValueComponent,
|
|
235
|
-
} })) : (_jsx(Select, { ref: selectRef, menuPlacement: menuPosition, menuPosition: menuLocation, isLoading: isLoading, isDisabled: isDisabled, isSearchable: isSearchable, isClearable: isSearchable && isSelectClearable, controlShouldRenderValue: isDisabled || !isSearchable, options: options, value: (value === null || value === void 0 ? void 0 : value.label) ? value : null, styles: generateStyles(), placeholder: placeholder, inputValue: isDisabled || !isSearchable ? '' : inputValue, onInputChange: handleInputChange, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onMenuOpen:
|
|
268
|
+
} }, creatableSelectProps))) : (_jsx(Select, __assign({ ref: selectRef, menuIsOpen: isMenuOpen, menuPlacement: menuPosition, menuPosition: menuLocation, isLoading: isLoading, isDisabled: isDisabled, isSearchable: isSearchable, isClearable: isSearchable && isSelectClearable, controlShouldRenderValue: isDisabled || !isSearchable, options: options, value: (value === null || value === void 0 ? void 0 : value.label) ? value : null, styles: generateStyles(), placeholder: placeholder, inputValue: isDisabled || !isSearchable ? '' : inputValue, onInputChange: handleInputChange, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onMenuOpen: handleMenuOpen, noOptionsMessage: function () { return noOptionsMessage; }, loadingMessage: function () { return _jsx(LoadingMessage, {}); }, components: {
|
|
236
269
|
Input: Input,
|
|
237
270
|
Option: OptionComponent,
|
|
238
271
|
IndicatorSeparator: IndicatorSeparator,
|
|
239
|
-
DropdownIndicator: function (props) { return _jsx(DropdownIndicator, __assign({}, props, { isHidden: isSearchable && isSelectClearable })); },
|
|
272
|
+
DropdownIndicator: function (props) { return _jsx(DropdownIndicator, __assign({}, props, { isHidden: (isSearchable && isSelectClearable) || isActionless })); },
|
|
240
273
|
SingleValue: SingleValueComponent,
|
|
241
274
|
MenuList: MenuListComponent,
|
|
242
275
|
LoadingIndicator: LoadingIndicator,
|
|
243
276
|
ClearIndicator: ClearIndicator,
|
|
244
277
|
NoOptionsMessage: function (props) { return _jsx(NoOptionsMessage, __assign({}, props, { className: noOptionsMessageClassName, noOptionsMessage: noOptionsMessage })); },
|
|
245
|
-
} })), renderHint(), renderError()] })));
|
|
278
|
+
} }, selectProps))), renderHint(), renderError()] })));
|
|
246
279
|
};
|
|
247
280
|
export default CustomSelect;
|
|
248
281
|
//# sourceMappingURL=CustomSelect.js.map
|