ab-ui-library 1.9.0 → 1.11.0
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/components/Select/MultiSelect/MultiSelect.js +11 -3
- package/components/Select/MultiSelect/MultiSelectTree/MultiSelectTree.d.ts +3 -0
- package/components/Select/MultiSelect/MultiSelectTree/MultiSelectTree.js +250 -0
- package/components/Select/MultiSelect/OptionsWrapper.d.ts +1 -0
- package/components/Select/MultiSelect/OptionsWrapper.js +6 -2
- package/components/Select/index.js +1 -0
- package/components/Select/types.d.ts +6 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -70,6 +70,7 @@ import '../../SVGIcons/IconAttach.js';
|
|
|
70
70
|
import '../../SVGIcons/IconCheckmark.js';
|
|
71
71
|
import '../../SVGIcons/IconCaretDownFilled.js';
|
|
72
72
|
import '../../SVGIcons/IconCaretUpFilled.js';
|
|
73
|
+
import './MultiSelectTree/MultiSelectTree.js';
|
|
73
74
|
import './MultiBase/MultiBase.js';
|
|
74
75
|
import '../../Collapse/CollapseItem/CollapseItem.js';
|
|
75
76
|
import '../../../helperComponents/AnimatePresenceWrapper/AnimatePresenceWrapper.js';
|
|
@@ -89,7 +90,7 @@ import '../../Tab/consts.js';
|
|
|
89
90
|
import '../../../hooks/useChangePositionsOnScroll.js';
|
|
90
91
|
import '../SharedComponents/ButtonSelectWrapper/Button/Button.js';
|
|
91
92
|
|
|
92
|
-
var _excluded = ["options", "footerButtonProps", "selectedItems", "setSelectedItems", "name", "setFieldValue", "value", "label", "placeHolder", "isRequiredField", "labelAddons", "className", "disabled", "dropdownWidth", "align", "size", "isButtonSelect", "checkboxInfo", "translations", "hasError"];
|
|
93
|
+
var _excluded = ["options", "footerButtonProps", "selectedItems", "setSelectedItems", "name", "setFieldValue", "value", "label", "placeHolder", "isRequiredField", "labelAddons", "className", "disabled", "dropdownWidth", "align", "size", "isButtonSelect", "checkboxInfo", "translations", "hasError", "autoApplyOnClose"];
|
|
93
94
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
94
95
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
95
96
|
var MultiSelect = function MultiSelect(props) {
|
|
@@ -123,6 +124,8 @@ var MultiSelect = function MultiSelect(props) {
|
|
|
123
124
|
checkboxInfo = props.checkboxInfo,
|
|
124
125
|
translations = props.translations,
|
|
125
126
|
hasError = props.hasError,
|
|
127
|
+
_props$autoApplyOnClo = props.autoApplyOnClose,
|
|
128
|
+
autoApplyOnClose = _props$autoApplyOnClo === void 0 ? false : _props$autoApplyOnClo,
|
|
126
129
|
rest = _objectWithoutProperties(props, _excluded);
|
|
127
130
|
var _useState = useState(null),
|
|
128
131
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -154,6 +157,11 @@ var MultiSelect = function MultiSelect(props) {
|
|
|
154
157
|
})) === -1;
|
|
155
158
|
})) !== -1;
|
|
156
159
|
}, [selectedValues, initialSelected]);
|
|
160
|
+
useEffect(function () {
|
|
161
|
+
if (!isOpen && autoApplyOnClose) {
|
|
162
|
+
submitSelectedValue(selectedValues, false);
|
|
163
|
+
}
|
|
164
|
+
}, [isOpen]);
|
|
157
165
|
useEffect(function () {
|
|
158
166
|
setSelectedValues(value || []);
|
|
159
167
|
}, [value]);
|
|
@@ -166,7 +174,7 @@ var MultiSelect = function MultiSelect(props) {
|
|
|
166
174
|
setSelectedValues(initialSelected);
|
|
167
175
|
closeDropdown();
|
|
168
176
|
};
|
|
169
|
-
useOnOutsideClick(containerRef.current, cancelSelectedItems, isOpen, useId());
|
|
177
|
+
useOnOutsideClick(containerRef.current, autoApplyOnClose ? closeDropdown : cancelSelectedItems, isOpen, useId());
|
|
170
178
|
var submitSelectedValue = function submitSelectedValue(selections, isChecked) {
|
|
171
179
|
if (setSelectedItems) {
|
|
172
180
|
setSelectedItems(selections, isChecked);
|
|
@@ -214,7 +222,7 @@ var MultiSelect = function MultiSelect(props) {
|
|
|
214
222
|
selectedValues: selectedValues,
|
|
215
223
|
setSelectedValues: setSelectedValues,
|
|
216
224
|
containerRef: containerRef === null || containerRef === void 0 ? void 0 : containerRef.current
|
|
217
|
-
}, rest)), options.length ? /*#__PURE__*/React.createElement(Footer, {
|
|
225
|
+
}, rest)), !autoApplyOnClose && options.length ? /*#__PURE__*/React.createElement(Footer, {
|
|
218
226
|
checkboxInfo: checkboxInfo,
|
|
219
227
|
hasChange: hasChange,
|
|
220
228
|
buttonProps: footerButtonProps,
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { _ as _extends } from '../../../../extends-bf54b05e.js';
|
|
2
|
+
import { _ as _defineProperty } from '../../../../defineProperty-dd1f6104.js';
|
|
3
|
+
import { _ as _toConsumableArray } from '../../../../toConsumableArray-5ef8a63e.js';
|
|
4
|
+
import { _ as _slicedToArray } from '../../../../slicedToArray-356787eb.js';
|
|
5
|
+
import React, { useState, useMemo } from 'react';
|
|
6
|
+
import { Text } from '../../../Text/Text.js';
|
|
7
|
+
import { Empty } from '../../../Empty/Empty.js';
|
|
8
|
+
import { OptionItem } from '../../../../helperComponents/OptionItem/OptionItem.js';
|
|
9
|
+
import 'react-syntax-highlighter';
|
|
10
|
+
import 'classnames';
|
|
11
|
+
import { Checkbox } from '../../../Checkbox/Checkbox.js';
|
|
12
|
+
import 'react-dom';
|
|
13
|
+
import 'dayjs';
|
|
14
|
+
import '../../../../hooks/useScreenSize.js';
|
|
15
|
+
import 'react-hook-form';
|
|
16
|
+
import 'framer-motion';
|
|
17
|
+
import '../../../Collapse/CollapseGroup/CollapseGroup.js';
|
|
18
|
+
import { ContentTop } from '../../SharedComponents/ContentTop.js';
|
|
19
|
+
import '../../../Input/Input.js';
|
|
20
|
+
import '../../../Input/InputPassword.js';
|
|
21
|
+
import { IconCaretDownFilled } from '../../../SVGIcons/IconCaretDownFilled.js';
|
|
22
|
+
import { IconCaretUpFilled } from '../../../SVGIcons/IconCaretUpFilled.js';
|
|
23
|
+
import '../../../../typeof-02239c5f.js';
|
|
24
|
+
import '../../../../utils/helpers.js';
|
|
25
|
+
import '../../../Image/Image.js';
|
|
26
|
+
import '../../../Button/Button.js';
|
|
27
|
+
import '../../../../objectWithoutProperties-1a9e6a07.js';
|
|
28
|
+
import '../../../../helperComponents/Loader/Loader.js';
|
|
29
|
+
import '../../../Button/consts.js';
|
|
30
|
+
import '../../../Popover/Popover.js';
|
|
31
|
+
import '../../../../hooks/useGetTooltipStyles.js';
|
|
32
|
+
import '../../../../hooks/useGetElemSizes.js';
|
|
33
|
+
import '../../../../hooks/useGetElemPositions.js';
|
|
34
|
+
import '../../../../hooks/useGetTooltipPosition.js';
|
|
35
|
+
import '../../../Tooltip/types.js';
|
|
36
|
+
import '../../../../hooks/useHideOnScroll.js';
|
|
37
|
+
import '../../../../consts/index.js';
|
|
38
|
+
import '../../../../hooks/useOnOutsideClick.js';
|
|
39
|
+
import '../../../Link/Link.js';
|
|
40
|
+
import '../../../SVGIcons/IconInfo.js';
|
|
41
|
+
import '../../../../helperComponents/IconDynamicComponent/IconDynamicComponent.js';
|
|
42
|
+
import '../../../../helperComponents/IconDynamicComponent/constants.js';
|
|
43
|
+
import '../../../Avatar/Avatar.js';
|
|
44
|
+
import '../../../FileUpload/FileUpload.js';
|
|
45
|
+
import '../../../FileUpload/types.js';
|
|
46
|
+
import '../../../../helperComponents/Label/Label.js';
|
|
47
|
+
import '../../../FileUpload/UploadItems.js';
|
|
48
|
+
import '../../../../hooks/useFormProps.js';
|
|
49
|
+
import '../../../../context/types.js';
|
|
50
|
+
import '../../../../helperComponents/ErrorMessage/ErrorMessage.js';
|
|
51
|
+
import '../../../SVGIcons/IconDelete.js';
|
|
52
|
+
import '../../../SVGIcons/IconEditFilled.js';
|
|
53
|
+
import '../../../SVGIcons/IconEdit.js';
|
|
54
|
+
import '../../../SVGIcons/IconAttach.js';
|
|
55
|
+
import '../../../Tooltip/Tooltip.js';
|
|
56
|
+
import '../../../SVGIcons/IconCheckmark.js';
|
|
57
|
+
import '../../../Collapse/CollapseItem/CollapseItem.js';
|
|
58
|
+
import '../../../../helperComponents/AnimatePresenceWrapper/AnimatePresenceWrapper.js';
|
|
59
|
+
import '../../../SVGIcons/IconChevronDown.js';
|
|
60
|
+
import '../../SharedComponents/Actions.js';
|
|
61
|
+
import '../../../Menu/Menu.js';
|
|
62
|
+
import '../../../SVGIcons/IconMore.js';
|
|
63
|
+
import '../../../SVGIcons/IconDismissFilled.js';
|
|
64
|
+
import '../../../SVGIcons/IconSearchFilled.js';
|
|
65
|
+
import '../../../SVGIcons/IconSelectAllOff.js';
|
|
66
|
+
import 'react-input-mask';
|
|
67
|
+
import 'react-number-format';
|
|
68
|
+
import '../../../SVGIcons/IconCheckmarkCircleFilled.js';
|
|
69
|
+
import '../../../SVGIcons/IconDismissCircle.js';
|
|
70
|
+
import '../../../SVGIcons/IconDismissCircleFilled.js';
|
|
71
|
+
import '../../../SVGIcons/IconEyeOff.js';
|
|
72
|
+
import '../../../SVGIcons/IconEyeOn.js';
|
|
73
|
+
import '../../../Divider/Divider.js';
|
|
74
|
+
|
|
75
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
76
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
77
|
+
var MultiSelectTree = function MultiSelectTree(props) {
|
|
78
|
+
var avatar = props.avatar,
|
|
79
|
+
options = props.options,
|
|
80
|
+
helperText = props.helperText,
|
|
81
|
+
translations = props.translations,
|
|
82
|
+
selectedValues = props.selectedValues,
|
|
83
|
+
onItemSelect = props.onItemSelect,
|
|
84
|
+
onItemDeselect = props.onItemDeselect,
|
|
85
|
+
setSelectedValues = props.setSelectedValues,
|
|
86
|
+
isSearchAvailable = props.isSearchAvailable,
|
|
87
|
+
labelLeftIconProps = props.labelLeftIconProps,
|
|
88
|
+
scrollableContentStyle = props.scrollableContentStyle,
|
|
89
|
+
optionRightIconComponent = props.optionRightIconComponent,
|
|
90
|
+
labelRightIconComponent = props.labelRightIconComponent,
|
|
91
|
+
maxSelectCount = props.maxSelectCount,
|
|
92
|
+
menuOptions = props.menuOptions,
|
|
93
|
+
dataIdPrefix = props.dataIdPrefix;
|
|
94
|
+
var emptyListMainMessage = translations.emptyListMainMessage,
|
|
95
|
+
emptyListSecondaryMessage = translations.emptyListSecondaryMessage;
|
|
96
|
+
var _useState = useState(''),
|
|
97
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
98
|
+
searchValue = _useState2[0],
|
|
99
|
+
setSearchValue = _useState2[1];
|
|
100
|
+
var _useState3 = useState({
|
|
101
|
+
0: true
|
|
102
|
+
}),
|
|
103
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
104
|
+
openGroups = _useState4[0],
|
|
105
|
+
setOpenGroups = _useState4[1];
|
|
106
|
+
var _useState5 = useState(false),
|
|
107
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
108
|
+
isAllSelected = _useState6[0],
|
|
109
|
+
setAllSelected = _useState6[1];
|
|
110
|
+
var filteredData = useMemo(function () {
|
|
111
|
+
if (!searchValue) {
|
|
112
|
+
return options;
|
|
113
|
+
}
|
|
114
|
+
return options.reduce(function (acc, group) {
|
|
115
|
+
var data = group.data,
|
|
116
|
+
title = group.title;
|
|
117
|
+
var groupData = data.filter(function (dataItem) {
|
|
118
|
+
return typeof dataItem.label === 'string' && dataItem.label.toLocaleLowerCase().includes(searchValue.toLocaleLowerCase());
|
|
119
|
+
});
|
|
120
|
+
if (groupData.length) {
|
|
121
|
+
return [].concat(_toConsumableArray(acc), [{
|
|
122
|
+
title: title,
|
|
123
|
+
data: groupData
|
|
124
|
+
}]);
|
|
125
|
+
}
|
|
126
|
+
return acc;
|
|
127
|
+
}, []);
|
|
128
|
+
}, [searchValue, options]);
|
|
129
|
+
var onDeselect = function onDeselect(item) {
|
|
130
|
+
setAllSelected(false);
|
|
131
|
+
onItemDeselect(item);
|
|
132
|
+
};
|
|
133
|
+
var onGroupClick = function onGroupClick(index) {
|
|
134
|
+
setOpenGroups(function (prev) {
|
|
135
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, index, !prev[index]));
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
var optionProps = useMemo(function () {
|
|
139
|
+
return {
|
|
140
|
+
isCheckbox: true,
|
|
141
|
+
avatar: avatar,
|
|
142
|
+
labelLeftIconProps: labelLeftIconProps,
|
|
143
|
+
optionRightIconComponent: optionRightIconComponent,
|
|
144
|
+
labelRightIconComponent: labelRightIconComponent,
|
|
145
|
+
className: 'group-item__option'
|
|
146
|
+
};
|
|
147
|
+
}, [avatar, labelLeftIconProps, optionRightIconComponent, labelRightIconComponent]);
|
|
148
|
+
var hasTopContent = isSearchAvailable || helperText;
|
|
149
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, hasTopContent ? /*#__PURE__*/React.createElement(ContentTop, {
|
|
150
|
+
dataIdPrefix: dataIdPrefix,
|
|
151
|
+
menuOptions: menuOptions,
|
|
152
|
+
isSearchAvailable: isSearchAvailable,
|
|
153
|
+
hasLimitation: !!maxSelectCount,
|
|
154
|
+
isAnySelected: selectedValues.length !== 0,
|
|
155
|
+
helperText: helperText,
|
|
156
|
+
isSelectAllDisabled: isAllSelected || filteredData.length === 0,
|
|
157
|
+
setSearchValue: setSearchValue,
|
|
158
|
+
searchValue: searchValue,
|
|
159
|
+
translations: translations
|
|
160
|
+
}) : null, /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
className: 'select__options__scroll scrollbar scrollbar--vertical',
|
|
162
|
+
style: scrollableContentStyle
|
|
163
|
+
}, /*#__PURE__*/React.createElement("div", null, filteredData.map(function (_ref, index) {
|
|
164
|
+
var _data$;
|
|
165
|
+
var title = _ref.title,
|
|
166
|
+
data = _ref.data;
|
|
167
|
+
var isActive = !!openGroups[index];
|
|
168
|
+
var groupHasSelected = data.some(function (item) {
|
|
169
|
+
return selectedValues.find(function (s) {
|
|
170
|
+
return s.value === item.value;
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
var handleGroupCheckboxChange = function handleGroupCheckboxChange(checked) {
|
|
174
|
+
var groupValues = data.filter(function (item) {
|
|
175
|
+
return !item.disabled;
|
|
176
|
+
}).map(function (item) {
|
|
177
|
+
return {
|
|
178
|
+
value: item.value,
|
|
179
|
+
label: item.label,
|
|
180
|
+
parentId: item.parentId
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
if (checked) {
|
|
184
|
+
var newSelected = _toConsumableArray(selectedValues);
|
|
185
|
+
groupValues.forEach(function (item) {
|
|
186
|
+
if (!newSelected.find(function (s) {
|
|
187
|
+
return s.value === item.value;
|
|
188
|
+
})) {
|
|
189
|
+
newSelected.push(item);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
setSelectedValues(newSelected);
|
|
193
|
+
} else {
|
|
194
|
+
var _newSelected = selectedValues.filter(function (s) {
|
|
195
|
+
return !data.find(function (item) {
|
|
196
|
+
return item.value === s.value;
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
setSelectedValues(_newSelected);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
203
|
+
className: "select__group group-item",
|
|
204
|
+
key: "".concat((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.value, "_").concat(index)
|
|
205
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
206
|
+
onClick: function onClick() {
|
|
207
|
+
return onGroupClick(index);
|
|
208
|
+
},
|
|
209
|
+
className: "group-item__top"
|
|
210
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
211
|
+
className: "mr-8",
|
|
212
|
+
onClick: function onClick(checked) {
|
|
213
|
+
handleGroupCheckboxChange(checked);
|
|
214
|
+
},
|
|
215
|
+
selectedValue: groupHasSelected
|
|
216
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
217
|
+
size: "xxsmall",
|
|
218
|
+
type: "tertiary",
|
|
219
|
+
className: "group-item__title pr-4"
|
|
220
|
+
}, title), isActive ? /*#__PURE__*/React.createElement(IconCaretUpFilled, {
|
|
221
|
+
size: "xxsmall",
|
|
222
|
+
className: "group-item__icon"
|
|
223
|
+
}) : /*#__PURE__*/React.createElement(IconCaretDownFilled, {
|
|
224
|
+
size: "xxsmall",
|
|
225
|
+
className: "group-item__icon"
|
|
226
|
+
})), isActive && data.map(function (item) {
|
|
227
|
+
var isSelected = selectedValues.findIndex(function (s) {
|
|
228
|
+
return s.value === item.value;
|
|
229
|
+
}) !== -1;
|
|
230
|
+
return /*#__PURE__*/React.createElement(OptionItem, _extends({
|
|
231
|
+
data: item,
|
|
232
|
+
dataId: item.dataId,
|
|
233
|
+
key: item.value,
|
|
234
|
+
isSelected: isSelected,
|
|
235
|
+
disabled: item.disabled || !isSelected && selectedValues.length === maxSelectCount,
|
|
236
|
+
onClick: isSelected ? function () {
|
|
237
|
+
return onDeselect(item);
|
|
238
|
+
} : function () {
|
|
239
|
+
return onItemSelect(item);
|
|
240
|
+
}
|
|
241
|
+
}, optionProps));
|
|
242
|
+
}));
|
|
243
|
+
}))), filteredData.length === 0 ? /*#__PURE__*/React.createElement(Empty, {
|
|
244
|
+
size: "small",
|
|
245
|
+
mainMessage: emptyListMainMessage,
|
|
246
|
+
paragraphMessage: emptyListSecondaryMessage
|
|
247
|
+
}) : null);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export { MultiSelectTree };
|
|
@@ -19,6 +19,7 @@ import { Loading } from '../SharedComponents/Loading.js';
|
|
|
19
19
|
import '../../Input/Input.js';
|
|
20
20
|
import '../../Input/InputPassword.js';
|
|
21
21
|
import { MultiSelectGrouped } from './MultiSelectGrouped/MultiSelectGrouped.js';
|
|
22
|
+
import { MultiSelectTree } from './MultiSelectTree/MultiSelectTree.js';
|
|
22
23
|
import { MultiBase } from './MultiBase/MultiBase.js';
|
|
23
24
|
import { MultiSelectWithTabs } from './MultiSelectWithTabs/MultiSelectWithTabs.js';
|
|
24
25
|
import { TRANSLATIONS_DEFAULT_VALUES, SELECTED_VISIBLE_MIN_COUNT } from '../constants.js';
|
|
@@ -83,13 +84,14 @@ import '../../Badge/Badge.js';
|
|
|
83
84
|
import '../../Badge/consts.js';
|
|
84
85
|
import '../../Tab/consts.js';
|
|
85
86
|
|
|
86
|
-
var _excluded = ["isLoading", "withTabs", "isGrouped", "isOpen", "translations", "containerRef", "options", "selectedValues", "setSelectedValues", "setIsOpen", "dropdownRef"];
|
|
87
|
+
var _excluded = ["isLoading", "withTabs", "isGrouped", "isMultiSelectTree", "isOpen", "translations", "containerRef", "options", "selectedValues", "setSelectedValues", "setIsOpen", "dropdownRef"];
|
|
87
88
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
88
89
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
89
90
|
var OptionsWrapper = function OptionsWrapper(props) {
|
|
90
91
|
var isLoading = props.isLoading,
|
|
91
92
|
withTabs = props.withTabs,
|
|
92
93
|
isGrouped = props.isGrouped,
|
|
94
|
+
isMultiSelectTree = props.isMultiSelectTree,
|
|
93
95
|
isOpen = props.isOpen,
|
|
94
96
|
translations = props.translations,
|
|
95
97
|
containerRef = props.containerRef,
|
|
@@ -103,7 +105,7 @@ var OptionsWrapper = function OptionsWrapper(props) {
|
|
|
103
105
|
width = _useGetElemSizes.width;
|
|
104
106
|
var localizations = _objectSpread(_objectSpread({}, TRANSLATIONS_DEFAULT_VALUES), translations);
|
|
105
107
|
var inputRef = useRef(null);
|
|
106
|
-
var SelectComp = withTabs ? MultiSelectWithTabs : isGrouped ? MultiSelectGrouped : MultiBase;
|
|
108
|
+
var SelectComp = isMultiSelectTree ? MultiSelectTree : withTabs ? MultiSelectWithTabs : isGrouped ? MultiSelectGrouped : MultiBase;
|
|
107
109
|
var checkIsValueOverflowed = useCallback(function (value) {
|
|
108
110
|
var elemWidth = getStringWidth(value, 14);
|
|
109
111
|
return elemWidth > width - 80; // padding and width of (+number)
|
|
@@ -169,6 +171,8 @@ var OptionsWrapper = function OptionsWrapper(props) {
|
|
|
169
171
|
scrollableContentStyle: _objectSpread({}, !hasBottomSpace && !hasTopSpace ? {
|
|
170
172
|
maxHeight: bottomSpace - 65 - 56
|
|
171
173
|
} : {}) // 65 - height of the top content, 56 - height of the footer
|
|
174
|
+
,
|
|
175
|
+
isMultiSelectTree: isMultiSelectTree
|
|
172
176
|
}, rest));
|
|
173
177
|
};
|
|
174
178
|
|
|
@@ -82,6 +82,7 @@ import './MultiSelect/MultiSelectGrouped/MultiSelectGrouped.js';
|
|
|
82
82
|
import '../Empty/Empty.js';
|
|
83
83
|
import '../Image/Image.js';
|
|
84
84
|
import './constants.js';
|
|
85
|
+
import './MultiSelect/MultiSelectTree/MultiSelectTree.js';
|
|
85
86
|
import './MultiSelect/MultiBase/MultiBase.js';
|
|
86
87
|
import './MultiSelect/MultiSelectWithTabs/MultiSelectWithTabs.js';
|
|
87
88
|
import '../Tab/Tab.js';
|
|
@@ -60,6 +60,7 @@ interface TMultiSelectCompProps extends IFormCompProps, TSelectBaseProps {
|
|
|
60
60
|
onItemSelect: (item: TSelectedValue) => void;
|
|
61
61
|
onItemDeselect: (item: TSelectedValue) => void;
|
|
62
62
|
menuOptions?: TMenuItem[];
|
|
63
|
+
isMultiSelectTree?: boolean;
|
|
63
64
|
}
|
|
64
65
|
export interface TMultySingleTabPropTypes extends TMultiSelectCompProps {
|
|
65
66
|
options: TSelectOptions;
|
|
@@ -67,6 +68,9 @@ export interface TMultySingleTabPropTypes extends TMultiSelectCompProps {
|
|
|
67
68
|
export interface TMultiSelectGroupedProps extends TMultiSelectCompProps {
|
|
68
69
|
options: TSelectGroupOptions;
|
|
69
70
|
}
|
|
71
|
+
export interface TMultiSelectTreeProps extends TMultiSelectCompProps {
|
|
72
|
+
options: TSelectTreeOptions;
|
|
73
|
+
}
|
|
70
74
|
export type TCheckboxInfo = {
|
|
71
75
|
label: string;
|
|
72
76
|
isChecked: boolean;
|
|
@@ -79,6 +83,7 @@ export interface TMultiSelectPropTypes extends IFormCompProps, TSelectBaseProps
|
|
|
79
83
|
isSearchAvailable?: boolean;
|
|
80
84
|
withTabs?: boolean;
|
|
81
85
|
isGrouped?: boolean;
|
|
86
|
+
isMultiSelectTree?: boolean;
|
|
82
87
|
checkboxInfo?: TCheckboxInfo;
|
|
83
88
|
selectedItems?: TSelectedValue[];
|
|
84
89
|
translations: TSelectTranslations;
|
|
@@ -88,6 +93,7 @@ export interface TMultiSelectPropTypes extends IFormCompProps, TSelectBaseProps
|
|
|
88
93
|
cancel: TButtonPropTypes;
|
|
89
94
|
confirm: TButtonPropTypes;
|
|
90
95
|
};
|
|
96
|
+
autoApplyOnClose?: boolean;
|
|
91
97
|
labelAddons?: JSX.Element;
|
|
92
98
|
className?: string;
|
|
93
99
|
isButtonSelect?: boolean;
|
package/index.js
CHANGED
|
@@ -502,6 +502,7 @@ import './components/ProgressStep/consts.js';
|
|
|
502
502
|
import './components/Select/MultiSelect/OptionsWrapper.js';
|
|
503
503
|
import './components/Select/MultiSelect/MultiSelectGrouped/MultiSelectGrouped.js';
|
|
504
504
|
import './components/Select/constants.js';
|
|
505
|
+
import './components/Select/MultiSelect/MultiSelectTree/MultiSelectTree.js';
|
|
505
506
|
import './components/Select/MultiSelect/MultiBase/MultiBase.js';
|
|
506
507
|
import './components/Select/MultiSelect/MultiSelectWithTabs/MultiSelectWithTabs.js';
|
|
507
508
|
import './components/Tab/TabItem.js';
|