@nolwenture/formik-jsonschema-form 0.21.0 → 0.21.2
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.
|
@@ -32,7 +32,7 @@ export const SearchableSelectField = (props) => {
|
|
|
32
32
|
}, [isActive]);
|
|
33
33
|
return (_jsx(SearchListOption, Object.assign({ ref: ref }, rest, { children: children })));
|
|
34
34
|
};
|
|
35
|
-
const { name, uiSchema, onChange } = props;
|
|
35
|
+
const { name, uiSchema, onChange, onSelect } = props;
|
|
36
36
|
const { props: inputProps, placeholder, clearButtonText, expandText, notFoundMessage, hoverColors = {}, hideClearButton = false, showOptionsMenu = false, // makes CSS styling easier
|
|
37
37
|
} = useExtractUiSchema(uiSchema);
|
|
38
38
|
const [{ value }, __, { setValue }] = useField(name);
|
|
@@ -101,6 +101,7 @@ export const SearchableSelectField = (props) => {
|
|
|
101
101
|
setSearchTerm((_a = item.title) !== null && _a !== void 0 ? _a : "");
|
|
102
102
|
setValue(item.const);
|
|
103
103
|
setShowOptions(false);
|
|
104
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(item.const);
|
|
104
105
|
};
|
|
105
106
|
const handleFocus = () => {
|
|
106
107
|
setShowOptions(true);
|
|
@@ -118,7 +119,7 @@ export const SearchableSelectField = (props) => {
|
|
|
118
119
|
const filteredOptions = options.filter((option) => { var _a, _b; return ((_b = (_a = option.title) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "").includes(searchTerm.toLowerCase()); });
|
|
119
120
|
const showMoreOption = displayedItems.length < filteredOptions.length &&
|
|
120
121
|
displayedItems.length >= 10;
|
|
121
|
-
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsxs(SearchableSelectContainer, { ref: containerRef, onBlur: handleBlur, children: [_jsxs(SearchInputContainer, { children: [_jsx(SearchInput, Object.assign({}, inputProps, { name: name, type: "text", placeholder: placeholder, value: searchTerm, onChange: handleSearchChange, onFocus: handleFocus })), searchTerm && !hideClearButton && (_jsx(SearchClearButton, { onClick: handleClear, children: clearButtonText !== null && clearButtonText !== void 0 ? clearButtonText : "x" }))] }), showOptions && (_jsxs(SearchDropdownContainer, { role: "dropdown-list", ref: moreRef, children: [displayedItems.length > 0 ? (displayedItems.map((item, index) => (_jsx(ListOption, { isActive: index === selectedItem, style: index === selectedItem
|
|
122
|
+
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsxs(SearchableSelectContainer, { ref: containerRef, onBlur: handleBlur, children: [_jsxs(SearchInputContainer, { children: [_jsx(SearchInput, Object.assign({}, inputProps, { name: name, type: "text", placeholder: placeholder, value: searchTerm, onChange: handleSearchChange, onFocus: handleFocus })), searchTerm && !hideClearButton && (_jsx(SearchClearButton, { onClick: handleClear, children: clearButtonText !== null && clearButtonText !== void 0 ? clearButtonText : "x" }))] }), showOptions && (_jsxs(SearchDropdownContainer, { role: "dropdown-list", ref: moreRef, children: [displayedItems.length > 0 ? (displayedItems.map((item, index) => (_jsx(ListOption, { isActive: index === selectedItem, className: index === selectedItem ? "selected-item-active" : "", style: index === selectedItem
|
|
122
123
|
? {
|
|
123
124
|
backgroundColor: hoverColors.backgroundColor,
|
|
124
125
|
color: hoverColors.color,
|