@scheels-softdev/kendoreact-generics 2.8.11 → 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.
- package/GenericDropdown.d.ts +0 -10
- package/GenericDropdown.js +9 -18
- package/commandCell/CommandCellCheckbox.d.ts +2 -2
- package/commandCell/CommandCellDropdown.d.ts +1 -2
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +1 -1
- package/commandCell/CommandCellDDWithoutId.d.ts +0 -19
- package/commandCell/CommandCellDDWithoutId.js +0 -9
package/GenericDropdown.d.ts
CHANGED
@@ -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.
|
package/GenericDropdown.js
CHANGED
@@ -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(
|
13
|
+
const [selectedObject, setSelectedObject] = useState(undefined);
|
27
14
|
const [state, setState] = useState({
|
28
15
|
skip: 0,
|
29
16
|
total: data.length,
|
@@ -32,9 +19,13 @@ export function GenericDropdown({ data, selectedId, selectedData, onChange, text
|
|
32
19
|
//trigger functions
|
33
20
|
useEffect(() => {
|
34
21
|
var _a, _b;
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
+
}
|
38
29
|
}, [selectedId, selectedData, data]);
|
39
30
|
useEffect(() => {
|
40
31
|
setState({
|
@@ -74,5 +65,5 @@ export function GenericDropdown({ data, selectedId, selectedData, onChange, text
|
|
74
65
|
skip: state.skip,
|
75
66
|
}, suggest: suggest, onPageChange: pageChange, filterable: true, onFilterChange: onFilterChange, popupSettings: {
|
76
67
|
height: "210px",
|
77
|
-
}, onChange: (e) =>
|
68
|
+
}, onChange: (e) => onChange(e), onBlur: (e) => e.nativeEvent.preventDefault(), clearButton: !hideClearButton, value: selectedObject !== null && selectedObject !== void 0 ? selectedObject : undefined }) })));
|
78
69
|
}
|
@@ -2,9 +2,9 @@ export declare function CommandCellCheckBox({ checked, onCheck, onUncheck, disab
|
|
2
2
|
/** Boolean value indicating whether the checkbox is checked (`true`) or unchecked (`false`). */
|
3
3
|
checked: boolean;
|
4
4
|
/** Callback function to be called when the checkbox is checked. */
|
5
|
-
onCheck:
|
5
|
+
onCheck: () => void;
|
6
6
|
/** Callback function to be called when the checkbox is unchecked. */
|
7
|
-
onUncheck:
|
7
|
+
onUncheck: () => void;
|
8
8
|
/** Boolean value indicating whether the checkbox is disabled. */
|
9
9
|
disabled?: boolean;
|
10
10
|
}): import("react/jsx-runtime").JSX.Element;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { ComboBoxChangeEvent } from "@progress/kendo-react-dropdowns";
|
2
1
|
export declare function CommandCellDropdown<T>(props: {
|
3
2
|
/** The data array for the dropdown options. */
|
4
3
|
data: T[];
|
@@ -7,7 +6,7 @@ export declare function CommandCellDropdown<T>(props: {
|
|
7
6
|
/** The field names to use for text values in the dropdown. */
|
8
7
|
textField: keyof T;
|
9
8
|
/** Callback function to be called when the selected value changes. */
|
10
|
-
onChange: (
|
9
|
+
onChange: () => void;
|
11
10
|
/** Optional separator to use for concatenating text values. */
|
12
11
|
separator?: string;
|
13
12
|
/** Determines if the edit field should be checked. */
|
package/index.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
export { CommandCellCheckBox } from "./commandCell/CommandCellCheckbox";
|
2
2
|
export { CommandCellDate } from "./commandCell/CommandCellDate";
|
3
3
|
export { CommandCellDropdown } from "./commandCell/CommandCellDropdown";
|
4
|
-
export { CommandCellDDWithoutId } from "./commandCell/CommandCellDDWithoutId";
|
5
4
|
export { CommandCellPrice } from "./commandCell/CommandCellPrice";
|
6
5
|
export { CommandCellSwitch } from "./commandCell/CommandCellSwitch";
|
7
6
|
export { FilterCellDropdown } from "./FilterCellDropdown";
|
package/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
export { CommandCellCheckBox } from "./commandCell/CommandCellCheckbox";
|
2
2
|
export { CommandCellDate } from "./commandCell/CommandCellDate";
|
3
3
|
export { CommandCellDropdown } from "./commandCell/CommandCellDropdown";
|
4
|
-
export { CommandCellDDWithoutId } from "./commandCell/CommandCellDDWithoutId";
|
5
4
|
export { CommandCellPrice } from "./commandCell/CommandCellPrice";
|
6
5
|
export { CommandCellSwitch } from "./commandCell/CommandCellSwitch";
|
7
6
|
export { FilterCellDropdown } from "./FilterCellDropdown";
|
package/package.json
CHANGED
@@ -1,19 +0,0 @@
|
|
1
|
-
import { ComboBoxChangeEvent } from "@progress/kendo-react-dropdowns";
|
2
|
-
export declare function CommandCellDDWithoutId<T>(props: {
|
3
|
-
/** The data array for the dropdown options. */
|
4
|
-
data: T[];
|
5
|
-
/** The currently selected data item. */
|
6
|
-
selectedData: T;
|
7
|
-
/** The field names to use for text values in the dropdown. */
|
8
|
-
textField: keyof T;
|
9
|
-
/** Callback function to be called when the selected value changes. */
|
10
|
-
onChange: (e: ComboBoxChangeEvent) => void;
|
11
|
-
/** Optional separator to use for concatenating text values. */
|
12
|
-
separator?: string;
|
13
|
-
/** Determines if the edit field should be checked. */
|
14
|
-
checkEditField?: boolean;
|
15
|
-
/** Determines if the cell is in an editing state. */
|
16
|
-
isEditing?: boolean;
|
17
|
-
/** Determines if the clear button should be displayed in the dropdown. */
|
18
|
-
showClearButton?: boolean;
|
19
|
-
}): import("react/jsx-runtime").JSX.Element;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { GenericDropdown } from "../GenericDropdown";
|
3
|
-
export function CommandCellDDWithoutId(props) {
|
4
|
-
// Function implementation...
|
5
|
-
return (_jsx("td", { children: props.checkEditField && !props.isEditing ? (_jsx(_Fragment, {}) //TODO remove this from Marketing display
|
6
|
-
) : (
|
7
|
-
// If "props.checkEditField" is false or "props.isEditing" is true, render the GenericDropdownWithSearch component with the "props" passed to it
|
8
|
-
_jsx(GenericDropdown, Object.assign({}, props))) }));
|
9
|
-
}
|