@scheels-softdev/kendoreact-generics 1.7.4 → 2.0.1

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,8 +1,7 @@
1
1
  import { GridFilterCellProps } from "@progress/kendo-react-grid";
2
2
  interface DropdownFilterCellProps<T> extends GridFilterCellProps {
3
- defaultItem?: any;
4
3
  data: T[];
5
- descriptionKeys: (keyof T)[];
4
+ textFields: (keyof T)[];
6
5
  separator?: string;
7
6
  }
8
7
  export declare function FilterCellDropdown<T>(props: DropdownFilterCellProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { GenericDropdown } from "./GenericDropdown";
4
4
  // Define the DropdownFilterCell component with props of type DropdownFilterCellProps
5
5
  export function FilterCellDropdown(props) {
6
6
  // Define a function that returns true if a value is not undefined or null, and is different from the default item
7
- let hasValue = (value) => Boolean(value && value !== props.defaultItem);
7
+ let hasValue = (value) => Boolean(value);
8
8
  // Define an onChange function that will be called when the ComboBox value changes
9
9
  const onChange = (event) => {
10
10
  // Update the hasValue variable based on the new value of the ComboBox
@@ -27,5 +27,5 @@ export function FilterCellDropdown(props) {
27
27
  });
28
28
  };
29
29
  // Render a div containing a GenericDropdownWithSearch component and a Clear button
30
- return (_jsxs("div", Object.assign({ className: "k-filtercell", "data-testid": "dropdownFilter" }, { children: [_jsx(GenericDropdown, { data: props.data, changeEvent: onChange, selectedId: props.value, textFields: [...props.descriptionKeys], separator: props.separator }), _jsx(Button, { title: "Clear", disabled: !hasValue(props.value), onClick: onClearButtonClick, icon: "filter-clear" })] })));
30
+ return (_jsxs("div", Object.assign({ className: "k-filtercell", "data-testid": "dropdownFilter" }, { children: [_jsx(GenericDropdown, { data: props.data, changeEvent: onChange, selectedId: props.value, textFields: [...props.textFields], separator: props.separator }), _jsx(Button, { title: "Clear", disabled: !hasValue(props.value), onClick: onClearButtonClick, icon: "filter-clear" })] })));
31
31
  }
@@ -3,7 +3,7 @@ export declare function MultiSelectDropdown<T>({ data, selectedData, textFields,
3
3
  selectedData: T[];
4
4
  textFields: (keyof T)[];
5
5
  selectEvent: Function;
6
- title: string;
6
+ title?: string;
7
7
  separator?: string;
8
8
  limit?: number;
9
9
  }): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,6 @@ import { useEffect, useRef, useState } from "react";
3
3
  import { filterBy } from "@progress/kendo-data-query";
4
4
  import { MultiSelect } from "@progress/kendo-react-dropdowns";
5
5
  import { getTextValue } from "./Utility";
6
- const pageSize = 10;
7
6
  export function MultiSelectDropdown({ data, selectedData, textFields, selectEvent, title, separator, limit, }) {
8
7
  //local state
9
8
  const pageSize = 8;
package/README.md CHANGED
@@ -0,0 +1,164 @@
1
+ # KendoReact Generics
2
+
3
+ ## About This Package
4
+
5
+ ### What is this package?
6
+
7
+ This package is a collection of Wrappers for various kendo components that we've found ourselves modifying in the same ways over and over across projects in the same ways.
8
+ @progress/kendo-react-licensing along with a valid kendo license is recommended (or required depending on whether they change their 'no license' warning to an error in the future).
9
+
10
+ ### What modifications have you made specifically?
11
+
12
+ - Most of what we're doing has to do with virtualization. The setup for virtualization is a lengthy task, both in lines of code and dev hours. This package exists to help us streamline that process.
13
+ - The other modifications have to do with adding support for placing Comboboxes, Checkboxes, Datepickers, and Switches from Kendo into a Kendo Grid Cell or Filter Cell and handling those events appropriately
14
+
15
+ ## Components
16
+
17
+ Note: This package has only been tested with typescript. if you're using javascript, use at your own risk
18
+
19
+ - [Generic Dropdown](#generic-dropdown)
20
+ - [MultiSelect Dropdown](#multiselect-dropdown)
21
+ - [Filter Cell Dropdown](#filter-cell-dropdown)
22
+ - [Command Cell Dropdown](#command-cell-dropdown)
23
+
24
+ ---
25
+
26
+ ## Generic Dropdown
27
+
28
+ ### Usage
29
+
30
+ <GenericDropdown
31
+ data={MyDataArray}
32
+ changeEvent={(e: ComboBoxChangeEvent) => setPrinterIp(e.target.value.ipAddress)}
33
+ selectedId={MyDataArray.find((x) => x.id === selectedValue.id)?.id || 0}
34
+ textFields={["name"]}
35
+ />
36
+
37
+ ### Required props
38
+
39
+ #### data
40
+
41
+ - Array of T. the Definition of what T is matters for the "textFields" prop
42
+
43
+ #### changeEvent
44
+
45
+ - Event passed is a ComboBoxChangeEvent (from kendo-react-dropdowns)
46
+
47
+ #### selectedId
48
+
49
+ - The id of the item selected. By default the dropdown will assume your item has an "id" property. if it doesn't, see optional parameters
50
+
51
+ #### textFields
52
+
53
+ - This is defined as (keyof T)[].
54
+ - For example, if my dropdown is fed a list of employee objects with a firstName, lastName, and id key, I would pass ["firstName","lastName"] to see "John Williams", or ["firstName","lastName","id"] to see "John Doe 19382032141"
55
+
56
+ ### Optional props
57
+
58
+ #### separator
59
+
60
+ - This defines what your text fields are separated by. by default, it is assumed you only want a space between them. Use this prop if you want to change this
61
+ - For example, if we want our employee's names separated by a comma, we would pass ", " here
62
+
63
+ #### idField
64
+
65
+ - IdField is a keyof T, much like textFields. while textFields determines what's displayed in the dropdown, idField overrides what field of each object the dropdown looks at to compare against the selectedId prop
66
+ - For example, if our employee's id field is employeeId instead of just id, we would pass "employeeId" here
67
+
68
+ #### disabled
69
+
70
+ - If you want to conditionally disable the dropdown you can do that here
71
+
72
+ #### title
73
+
74
+ - The label that appears in your multiselect when there aren't any options selected, or just above the multiselect when there are
75
+ - For example, if we want to use it to send a letter to an employee, we would pass "Selected Employee" here
76
+
77
+ ---
78
+
79
+ ## MultiSelect Dropdown
80
+
81
+ ### Usage
82
+
83
+ <MultiSelectDropdown
84
+ data={myDataArray}
85
+ selectedData={mySelectedDataArray}
86
+ textFields={["firstName", "lastName"]}
87
+ separator=" - "
88
+ selectEvent={setSelectedVend}
89
+ title="Vendor(s)"
90
+ limit={10}
91
+ />
92
+
93
+ ### Required props
94
+
95
+ #### data
96
+
97
+ - Array of T. the Definition of what T is matters for the "textFields" prop
98
+
99
+ #### selectedData
100
+
101
+ - The id of the item selected. By default the dropdown will assume your item has an "id" property. if it doesn't, see optional parameters
102
+
103
+ #### textFields
104
+
105
+ - This is defined as (keyof T)[].
106
+ - For example, if my dropdown is fed a list of employee objects with a firstName, lastName, and id key, I would pass ["firstName","lastName"] to see "John Williams", or ["firstName","lastName","id"] to see "John Doe 19382032141"
107
+
108
+ #### selectEvent
109
+
110
+ - "Event" you're given should just be your new array of selected Items
111
+
112
+ ### Optional props
113
+
114
+ #### title
115
+
116
+ - The label that appears in your multiselect when there aren't any options selected, or just above the multiselect when there are
117
+ - For example, if we want to use it to send work anniversary letters to multiple employees, we would pass "Selected Employees" here
118
+
119
+ #### separator
120
+
121
+ - This defines what your text fields are separated by. by default, it is assumed you only want a space between them. Use this prop if you want to change this
122
+ - For example, if we want our employee's names separated by a comma, we would pass ", " here
123
+
124
+ #### limit
125
+
126
+ - The upper limit of how many items the user can select at once.
127
+ - For example, if our meeting room only has room for 8 people, we would pass an 8.
128
+
129
+ ---
130
+
131
+ ## Filter Cell Dropdown
132
+
133
+ ### Usage
134
+
135
+ <FilterCellDropdown
136
+ data={myStatusArray}
137
+ textFields={["StatusName"]}
138
+ />
139
+
140
+ ### Required props
141
+
142
+ #### {...FilterCellProps}
143
+
144
+ - all of the default props that are passed from kendo grid when trying to override the filter cell
145
+
146
+ #### data
147
+
148
+ - Array of T. What you want to display in the dropdown. the Definition of what T is matters for the "textFields" prop
149
+
150
+ #### textFields
151
+
152
+ - This is defined as (keyof T)[].
153
+ - For example, if my dropdown is fed a list of employee Statuses, I could feed it a "StatusName" field (assuming my Status objects have that key) and it could display something like "Active", "Terminated", or "On Leave"
154
+
155
+ ### Optional props
156
+
157
+ #### separator
158
+
159
+ - This defines what your text fields are separated by. by default, it is assumed you only want a space between them. Use this prop if you want to change this
160
+ - For example, if some of our associates only know the status IDs for Active, Terminated, or On Leave and we want to display them side by side, we might want to add a "dash" seporator. to do this we would pass " - " here
161
+
162
+ ---
163
+
164
+ ## More Updates to the README Coming Soon!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scheels-softdev/kendoreact-generics",
3
- "version": "1.7.4",
3
+ "version": "2.0.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",