@scheels-softdev/kendoreact-generics 2.8.12 → 2.8.13

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.
@@ -1,14 +1,4 @@
1
1
  import { CSSProperties } from "react";
2
- import { ComboBoxChangeEvent } from "@progress/kendo-react-dropdowns";
3
- /**
4
- * Handles the change event of a dropdown.
5
- *
6
- * @param {ComboBoxChangeEvent} e - The change event object.
7
- * @param {(value: T) => void} setFunction - The function to set the value.
8
- * @param {T} nullEventValue - The value to set when the event value is null.
9
- * @param {string} valueKey - The key to access the value in the event object.
10
- */
11
- export declare function handleDropdownChange<T>(e: ComboBoxChangeEvent, setFunction: (value: T) => void, nullEventValue: T, valueKey?: string): void;
12
2
  /**
13
3
  * JSX Component for displaying items in a virtualized combobox
14
4
  * @template T - The type of the data objects in the dropdown.
@@ -22,7 +12,7 @@ type GenericDDProps<T> = {
22
12
  /** The currently selected data object. (optional)*/
23
13
  selectedData?: T;
24
14
  /** Callback function triggered when the selected value changes*/
25
- onChange: (e: ComboBoxChangeEvent) => void;
15
+ onChange: Function;
26
16
  /** The field names used to extract text values for display */
27
17
  textField: keyof T;
28
18
  /** The separator to use when concatenating multiple text values. (optional)*/
@@ -3,19 +3,6 @@ import { ComboBox } from "@progress/kendo-react-dropdowns";
3
3
  import { filterBy } from "@progress/kendo-data-query";
4
4
  import { useEffect, useRef, useState } from "react";
5
5
  import { Guard } from "@scheels-softdev/frontend-utility-functions";
6
- /**
7
- * Handles the change event of a dropdown.
8
- *
9
- * @param {ComboBoxChangeEvent} e - The change event object.
10
- * @param {(value: T) => void} setFunction - The function to set the value.
11
- * @param {T} nullEventValue - The value to set when the event value is null.
12
- * @param {string} valueKey - The key to access the value in the event object.
13
- */
14
- export function handleDropdownChange(e, setFunction, nullEventValue, valueKey) {
15
- Guard.Catch.NullEmptyOrWhitespace(e.target.value)
16
- ? setFunction(nullEventValue)
17
- : setFunction(Guard.Catch.NullEmptyOrWhitespace(valueKey) ? e.target.value : e.target.value[valueKey !== null && valueKey !== void 0 ? valueKey : ""]);
18
- }
19
6
  export function GenericDropdown({ data, selectedId, selectedData, onChange, textField, disabled, idField, title, hideClearButton, style, isLoading, suggest, }) {
20
7
  //local state
21
8
  const pageSize = 8;
@@ -23,7 +10,7 @@ export function GenericDropdown({ data, selectedId, selectedData, onChange, text
23
10
  throw new Error("You cannot provide both selectedData and selectedId to GenericDropdown.");
24
11
  }
25
12
  //useState
26
- const [selectedObject, setSelectedObject] = useState(null);
13
+ const [selectedObject, setSelectedObject] = useState(undefined);
27
14
  const [state, setState] = useState({
28
15
  skip: 0,
29
16
  total: data.length,
@@ -32,10 +19,13 @@ export function GenericDropdown({ data, selectedId, selectedData, onChange, text
32
19
  //trigger functions
33
20
  useEffect(() => {
34
21
  var _a, _b;
35
- console.log(selectedData, selectedId);
36
- setSelectedObject(selectedId
37
- ? (_a = data.find((item) => selectedId === item[idField || "id"])) !== null && _a !== void 0 ? _a : null
38
- : (_b = data.find((x) => Guard.Ensure.EqualObjects(Object.assign(Object.assign({}, x), selectedData), Object.assign({}, (x !== null && x !== void 0 ? x : {}))))) !== null && _b !== void 0 ? _b : null);
22
+ if (!selectedId && !selectedData)
23
+ setSelectedObject(undefined);
24
+ else {
25
+ setSelectedObject(selectedId
26
+ ? (_a = data.find((item) => selectedId === item[idField || "id"])) !== null && _a !== void 0 ? _a : undefined
27
+ : (_b = data.find((x) => Guard.Ensure.EqualObjects(Object.assign(Object.assign({}, x), selectedData), Object.assign({}, (x !== null && x !== void 0 ? x : {}))))) !== null && _b !== void 0 ? _b : undefined);
28
+ }
39
29
  }, [selectedId, selectedData, data]);
40
30
  useEffect(() => {
41
31
  setState({
@@ -75,5 +65,5 @@ export function GenericDropdown({ data, selectedId, selectedData, onChange, text
75
65
  skip: state.skip,
76
66
  }, suggest: suggest, onPageChange: pageChange, filterable: true, onFilterChange: onFilterChange, popupSettings: {
77
67
  height: "210px",
78
- }, onChange: (e) => handleDropdownChange(e, () => onChange(e.value), {}, idField === null || idField === void 0 ? void 0 : idField.toString()), onBlur: (e) => e.nativeEvent.preventDefault(), clearButton: !hideClearButton, value: selectedObject }) })));
68
+ }, onChange: (e) => onChange(e), onBlur: (e) => e.nativeEvent.preventDefault(), clearButton: !hideClearButton, value: selectedObject !== null && selectedObject !== void 0 ? selectedObject : undefined }) })));
79
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scheels-softdev/kendoreact-generics",
3
- "version": "2.8.12",
3
+ "version": "2.8.13",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest",