@scheels-softdev/kendoreact-generics 3.0.1 → 3.0.4
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/GenericDropdown.d.ts +2 -1
- package/GenericDropdown.js +4 -6
- package/package.json +1 -1
package/GenericDropdown.d.ts
CHANGED
@@ -9,6 +9,7 @@ type GenericDDProps<T> = {
|
|
9
9
|
style?: React.CSSProperties;
|
10
10
|
isLoading?: boolean;
|
11
11
|
title?: string;
|
12
|
+
maxMenuHeight?: number;
|
12
13
|
};
|
13
|
-
export declare function GenericDropdown<T extends Record<string, any>>({ data, selectedId, selectedData, onChange, textField, idField, isLoading, title, }: GenericDDProps<T>): import("react/jsx-runtime").JSX.Element;
|
14
|
+
export declare function GenericDropdown<T extends Record<string, any>>({ data, selectedId, selectedData, onChange, textField, idField, style, isLoading, title, maxMenuHeight, }: GenericDDProps<T>): import("react/jsx-runtime").JSX.Element;
|
14
15
|
export {};
|
package/GenericDropdown.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import Select from "react-select";
|
3
|
-
export function GenericDropdown({ data, selectedId, selectedData, onChange, textField, idField, isLoading, title, }) {
|
3
|
+
export function GenericDropdown({ data, selectedId, selectedData, onChange, textField, idField, style, isLoading, title, maxMenuHeight, }) {
|
4
4
|
const options = data.map((item) => ({
|
5
5
|
value: item,
|
6
6
|
label: item[textField].toString(),
|
@@ -10,14 +10,12 @@ export function GenericDropdown({ data, selectedId, selectedData, onChange, text
|
|
10
10
|
: options.find((option) => option.value === selectedData);
|
11
11
|
const handleChange = (selectedOption) => {
|
12
12
|
if (selectedOption) {
|
13
|
-
const selectedItem = idField
|
14
|
-
|
15
|
-
: data.find((item) => item === selectedOption.value);
|
16
|
-
onChange(selectedItem || null);
|
13
|
+
const selectedItem = idField ? data.find((item) => item[idField].toString() === selectedOption.value.id) : selectedOption.value;
|
14
|
+
onChange(selectedItem !== null && selectedItem !== void 0 ? selectedItem : null);
|
17
15
|
}
|
18
16
|
else {
|
19
17
|
onChange(null);
|
20
18
|
}
|
21
19
|
};
|
22
|
-
return (_jsx(Select, { options: options, onChange: handleChange, value: selectedOption, isLoading: isLoading, isDisabled: isLoading, placeholder: title || "Select an option" }));
|
20
|
+
return (_jsx(Select, { options: options, onChange: handleChange, value: selectedOption, isLoading: isLoading, isDisabled: isLoading, maxMenuHeight: 300 || maxMenuHeight, styles: { control: (base) => (Object.assign(Object.assign(Object.assign({}, base), { zIndex: 100, minHeight: "45px", maxHeight: "45px" }), style)) }, placeholder: title || "Select an option" }));
|
23
21
|
}
|