ab-ui-library 1.39.4 → 1.41.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.
|
@@ -92,7 +92,7 @@ import './RadioSelectGrouped/RadioSelectGrouped.js';
|
|
|
92
92
|
import '../../../hooks/useChangePositionsOnScroll.js';
|
|
93
93
|
import '../SharedComponents/ButtonSelectWrapper/Button/Button.js';
|
|
94
94
|
|
|
95
|
-
var _excluded = ["options", "footerButtonProps", "selectedItems", "setSelectedItems", "name", "setFieldValue", "value", "label", "placeHolder", "isRequiredField", "labelAddons", "className", "disabled", "dropdownWidth", "align", "size", "isButtonSelect", "checkboxInfo", "translations", "hasError", "autoApplyOnClose"];
|
|
95
|
+
var _excluded = ["options", "footerButtonProps", "selectedItems", "setSelectedItems", "name", "setFieldValue", "value", "label", "placeHolder", "isRequiredField", "labelAddons", "className", "disabled", "dropdownWidth", "align", "size", "isButtonSelect", "checkboxInfo", "translations", "hasError", "autoApplyOnClose", "autoApplyOnChooseItem"];
|
|
96
96
|
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; }
|
|
97
97
|
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; }
|
|
98
98
|
var MultiSelect = function MultiSelect(props) {
|
|
@@ -128,6 +128,8 @@ var MultiSelect = function MultiSelect(props) {
|
|
|
128
128
|
hasError = props.hasError,
|
|
129
129
|
_props$autoApplyOnClo = props.autoApplyOnClose,
|
|
130
130
|
autoApplyOnClose = _props$autoApplyOnClo === void 0 ? false : _props$autoApplyOnClo,
|
|
131
|
+
_props$autoApplyOnCho = props.autoApplyOnChooseItem,
|
|
132
|
+
autoApplyOnChooseItem = _props$autoApplyOnCho === void 0 ? false : _props$autoApplyOnCho,
|
|
131
133
|
rest = _objectWithoutProperties(props, _excluded);
|
|
132
134
|
var _useState = useState(null),
|
|
133
135
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -167,6 +169,11 @@ var MultiSelect = function MultiSelect(props) {
|
|
|
167
169
|
return val !== current[index];
|
|
168
170
|
});
|
|
169
171
|
}, [initialSelected, selectedValues]);
|
|
172
|
+
useEffect(function () {
|
|
173
|
+
if (autoApplyOnChooseItem) {
|
|
174
|
+
submitSelectedValue(selectedValues, false, false);
|
|
175
|
+
}
|
|
176
|
+
}, [selectedValues, autoApplyOnChooseItem]);
|
|
170
177
|
useEffect(function () {
|
|
171
178
|
if (isOpen) {
|
|
172
179
|
hasOpenedRef.current = true;
|
|
@@ -189,13 +196,16 @@ var MultiSelect = function MultiSelect(props) {
|
|
|
189
196
|
};
|
|
190
197
|
useOnOutsideClick(containerRef.current, autoApplyOnClose ? closeDropdown : cancelSelectedItems, isOpen, useId());
|
|
191
198
|
var submitSelectedValue = function submitSelectedValue(selections, isChecked) {
|
|
199
|
+
var closeDropdownOnApply = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
192
200
|
if (setSelectedItems) {
|
|
193
201
|
setSelectedItems(selections, isChecked);
|
|
194
202
|
}
|
|
195
203
|
if (name && setFieldValue) {
|
|
196
204
|
setFieldValue(name, selections);
|
|
197
205
|
}
|
|
198
|
-
|
|
206
|
+
if (closeDropdownOnApply) {
|
|
207
|
+
closeDropdown();
|
|
208
|
+
}
|
|
199
209
|
};
|
|
200
210
|
var applySelectedItems = function applySelectedItems(isChecked) {
|
|
201
211
|
submitSelectedValue(selectedValues, isChecked);
|
|
@@ -95,6 +95,7 @@ export interface TMultiSelectPropTypes extends IFormCompProps, TSelectBaseProps
|
|
|
95
95
|
confirm: TButtonPropTypes;
|
|
96
96
|
};
|
|
97
97
|
autoApplyOnClose?: boolean;
|
|
98
|
+
autoApplyOnChooseItem?: boolean;
|
|
98
99
|
labelAddons?: JSX.Element;
|
|
99
100
|
className?: string;
|
|
100
101
|
isButtonSelect?: boolean;
|