@scheels-softdev/kendoreact-generics 2.1.0 → 2.1.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.
package/GenericDropdown.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export declare function GenericDropdown<T>({ data, // array of data objects
|
2
2
|
selectedId, // id of the selected data object
|
3
|
-
|
3
|
+
selectedData, //if there is no identity key in the object and you need to compare the entire object, use this instead of selectedId
|
4
4
|
changeEvent, // function to call when the selected value changes
|
5
5
|
textFields, // array of field names to use for text values
|
6
6
|
separator, // optional separator to use for concatenating text values
|
@@ -8,7 +8,7 @@ disabled, // boolean to disable the dropdown
|
|
8
8
|
idField, title, }: {
|
9
9
|
data: T[];
|
10
10
|
selectedId?: number;
|
11
|
-
|
11
|
+
selectedData?: T;
|
12
12
|
changeEvent: Function;
|
13
13
|
textFields: (keyof T)[];
|
14
14
|
separator?: string;
|
package/GenericDropdown.js
CHANGED
@@ -6,19 +6,19 @@ import { getTextValue } from "./Utility";
|
|
6
6
|
// component that renders a dropdown with a search filter
|
7
7
|
export function GenericDropdown({ data, // array of data objects
|
8
8
|
selectedId, // id of the selected data object
|
9
|
-
|
9
|
+
selectedData, //if there is no identity key in the object and you need to compare the entire object, use this instead of selectedId
|
10
10
|
changeEvent, // function to call when the selected value changes
|
11
11
|
textFields, // array of field names to use for text values
|
12
12
|
separator, // optional separator to use for concatenating text values
|
13
13
|
disabled, // boolean to disable the dropdown
|
14
14
|
idField, title, }) {
|
15
|
-
if (selectedId !== undefined &&
|
16
|
-
throw new Error("You cannot provide both
|
15
|
+
if (selectedId !== undefined && selectedData !== undefined) {
|
16
|
+
throw new Error("You cannot provide both selectedData and selectedId to GenericDropdown.");
|
17
17
|
}
|
18
|
-
if (selectedId === undefined &&
|
18
|
+
if (selectedId === undefined && selectedData === undefined) {
|
19
19
|
throw new Error("You must provide either selectedId or selectedObject to GenericDropdown.");
|
20
20
|
}
|
21
|
-
if (idField !== undefined &&
|
21
|
+
if (idField !== undefined && selectedData !== undefined) {
|
22
22
|
console.warn("idField is not necessary if you are using selectedObject instead of selectedId. Doing so may result in something funky");
|
23
23
|
}
|
24
24
|
//local state
|
@@ -68,5 +68,5 @@ idField, title, }) {
|
|
68
68
|
skip: state.skip,
|
69
69
|
}, suggest: true, onPageChange: pageChange, filterable: true, onFilterChange: onFilterChange, popupSettings: {
|
70
70
|
height: "210px",
|
71
|
-
}, onChange: (e) => e.value && changeEvent(e), onBlur: (e) => e.nativeEvent.preventDefault(), value: selectedId ? dataList.find((item) => selectedId === item[idField || "id"]) : dataList.find((x) => x ===
|
71
|
+
}, onChange: (e) => e.value && changeEvent(e), onBlur: (e) => e.nativeEvent.preventDefault(), value: selectedId ? dataList.find((item) => selectedId === item[idField || "id"]) : dataList.find((x) => x === selectedData) }) })));
|
72
72
|
}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { ComboBoxChangeEvent } from "@progress/kendo-react-dropdowns";
|
2
|
-
|
3
|
-
export declare function CommandCellDDWithoutId<T extends CommonProps>(props: {
|
2
|
+
export declare function CommandCellDDWithoutId<T>(props: {
|
4
3
|
data: T[];
|
5
4
|
selectedData: T;
|
6
5
|
textFields: (keyof T)[];
|