ab-ui-library 1.37.7 → 1.38.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.
|
@@ -104,7 +104,7 @@ var Select = function Select(props) {
|
|
|
104
104
|
setFieldValue = props.setFieldValue,
|
|
105
105
|
setSelectedItem = props.setSelectedItem,
|
|
106
106
|
onInputChange = props.onInputChange,
|
|
107
|
-
|
|
107
|
+
onInputFormatting = props.onInputFormatting,
|
|
108
108
|
outerHelperText = props.outerHelperText,
|
|
109
109
|
innerHelperText = props.innerHelperText,
|
|
110
110
|
isRequiredField = props.isRequiredField,
|
|
@@ -124,8 +124,6 @@ var Select = function Select(props) {
|
|
|
124
124
|
labelAddons = props.labelAddons,
|
|
125
125
|
tooltipAddons = props.tooltipAddons,
|
|
126
126
|
renderOptions = props.renderOptions,
|
|
127
|
-
_props$inputType = props.inputType,
|
|
128
|
-
inputType = _props$inputType === void 0 ? 'text' : _props$inputType,
|
|
129
127
|
isAllowed = props.isAllowed;
|
|
130
128
|
var scrollRef = useRef(null);
|
|
131
129
|
var inputRef = useRef(null);
|
|
@@ -157,11 +155,19 @@ var Select = function Select(props) {
|
|
|
157
155
|
selectedOption = _useState8[0],
|
|
158
156
|
setSelectedOption = _useState8[1];
|
|
159
157
|
var isWithSearch = isSearchable || isDynamicSearchEnabled || isCreateOnOutsideClick;
|
|
158
|
+
var getFormatedValue = function getFormatedValue(value) {
|
|
159
|
+
if (onInputFormatting && value) {
|
|
160
|
+
return onInputFormatting(value);
|
|
161
|
+
}
|
|
162
|
+
return value;
|
|
163
|
+
};
|
|
160
164
|
var setCurrentSelectedLabel = useCallback(function () {
|
|
161
165
|
var selectedItem = options.find(function (item) {
|
|
162
166
|
return item.value === currentSelection;
|
|
163
167
|
});
|
|
164
|
-
setSelectedOption(selectedItem)
|
|
168
|
+
setSelectedOption(_objectSpread(_objectSpread({}, selectedItem), {}, {
|
|
169
|
+
label: getFormatedValue(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label)
|
|
170
|
+
}));
|
|
165
171
|
}, [currentSelection, options]);
|
|
166
172
|
var leftIconProps = selectedOption !== null && selectedOption !== void 0 && (_selectedOption$optio = selectedOption.optionLeftIcon) !== null && _selectedOption$optio !== void 0 && _selectedOption$optio.Component ? {
|
|
167
173
|
Component: selectedOption === null || selectedOption === void 0 || (_selectedOption$optio2 = selectedOption.optionLeftIcon) === null || _selectedOption$optio2 === void 0 ? void 0 : _selectedOption$optio2.Component
|
|
@@ -246,7 +252,7 @@ var Select = function Select(props) {
|
|
|
246
252
|
};
|
|
247
253
|
var onSearch = function onSearch(e) {
|
|
248
254
|
setSelectedOption(null);
|
|
249
|
-
setSearchValue(e.target.value);
|
|
255
|
+
setSearchValue(getFormatedValue(e.target.value));
|
|
250
256
|
};
|
|
251
257
|
var _useGetHasBottomSpace = useGetHasBottomSpace({
|
|
252
258
|
element: dropdownRef,
|
|
@@ -278,7 +284,6 @@ var Select = function Select(props) {
|
|
|
278
284
|
label: label,
|
|
279
285
|
onChange: onSearch,
|
|
280
286
|
onInput: onInputChange,
|
|
281
|
-
handleChange: handleInputChange,
|
|
282
287
|
required: isRequiredField,
|
|
283
288
|
leftIconProps: leftIconProps,
|
|
284
289
|
rightIconProps: isOpen ? selectRightIconOpenedProps : selectRightIconProps,
|
|
@@ -286,7 +291,6 @@ var Select = function Select(props) {
|
|
|
286
291
|
placeholder: placeHolder,
|
|
287
292
|
value: searchValue || (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || '',
|
|
288
293
|
isValid: isValid,
|
|
289
|
-
type: inputType,
|
|
290
294
|
disabled: disabled,
|
|
291
295
|
helperText: outerHelperText,
|
|
292
296
|
ref: inputRef,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as _toConsumableArray } from '../../../toConsumableArray-9b03ca05.js';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
3
|
import { Text } from '../../Text/Text.js';
|
|
4
4
|
import { Input } from '../../Input/Input.js';
|
|
5
5
|
import '../../Input/InputPassword.js';
|
|
@@ -85,7 +85,6 @@ var ContentTop = /*#__PURE__*/React.memo(function (props) {
|
|
|
85
85
|
_props$menuOptions = props.menuOptions,
|
|
86
86
|
menuOptions = _props$menuOptions === void 0 ? [] : _props$menuOptions,
|
|
87
87
|
dataIdPrefix = props.dataIdPrefix;
|
|
88
|
-
var inputRef = useRef(null);
|
|
89
88
|
var _ref = translations || {},
|
|
90
89
|
searchInputPlaceHolder = _ref.searchInputPlaceHolder,
|
|
91
90
|
innerLabel = _ref.innerLabel,
|
|
@@ -125,11 +124,6 @@ var ContentTop = /*#__PURE__*/React.memo(function (props) {
|
|
|
125
124
|
var removeFilter = function removeFilter() {
|
|
126
125
|
return setSearchValue && setSearchValue('');
|
|
127
126
|
};
|
|
128
|
-
useEffect(function () {
|
|
129
|
-
if (inputRef && inputRef.current) {
|
|
130
|
-
inputRef.current.focus();
|
|
131
|
-
}
|
|
132
|
-
}, [inputRef]);
|
|
133
127
|
return /*#__PURE__*/React.createElement("div", {
|
|
134
128
|
className: "content-top"
|
|
135
129
|
}, helperText ? /*#__PURE__*/React.createElement(Text, {
|
|
@@ -137,7 +131,6 @@ var ContentTop = /*#__PURE__*/React.memo(function (props) {
|
|
|
137
131
|
type: "secondary",
|
|
138
132
|
className: "content-top__label"
|
|
139
133
|
}, helperText) : null, isSearchAvailable && /*#__PURE__*/React.createElement(Input, {
|
|
140
|
-
ref: inputRef,
|
|
141
134
|
className: "content-top__search",
|
|
142
135
|
size: "small",
|
|
143
136
|
placeholder: searchInputPlaceHolder,
|
|
@@ -123,7 +123,7 @@ export interface TSingleSelectPropTypes extends IFormCompProps, TSelectBaseProps
|
|
|
123
123
|
selectedItem?: TItemValue;
|
|
124
124
|
setSelectedItem?: (items: TItemValue | undefined) => void;
|
|
125
125
|
onInputChange?: (event: FormEvent<HTMLInputElement>) => void;
|
|
126
|
-
|
|
126
|
+
onInputFormatting?: (value: string) => string;
|
|
127
127
|
isSearchable?: boolean;
|
|
128
128
|
isDynamicSearchable?: boolean;
|
|
129
129
|
outerHelperText?: string;
|
|
@@ -131,7 +131,6 @@ export interface TSingleSelectPropTypes extends IFormCompProps, TSelectBaseProps
|
|
|
131
131
|
labelAddons?: JSX.Element;
|
|
132
132
|
tooltipAddons?: TTooltipProps;
|
|
133
133
|
isCreateOnOutsideClick?: boolean;
|
|
134
|
-
inputType?: 'text' | 'number' | 'time' | 'password' | 'email' | 'file' | 'tel' | 'date' | 'numeric';
|
|
135
134
|
isAllowed?: (values: {
|
|
136
135
|
formattedValue: string;
|
|
137
136
|
value: string;
|