@scheels-softdev/kendoreact-generics 1.7.3 → 2.0.0
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/FilterCellDropdown.d.ts +1 -2
- package/FilterCellDropdown.js +2 -2
- package/GenericDropdown.js +1 -1
- package/MultiSelectDropdown.d.ts +1 -1
- package/MultiSelectDropdown.js +0 -1
- package/README.md +169 -0
- package/package.json +1 -1
package/FilterCellDropdown.d.ts
CHANGED
@@ -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
|
-
|
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;
|
package/FilterCellDropdown.js
CHANGED
@@ -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
|
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.
|
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
|
}
|
package/GenericDropdown.js
CHANGED
@@ -56,7 +56,7 @@ idField, title, }) {
|
|
56
56
|
total: state.total,
|
57
57
|
pageSize: pageSize,
|
58
58
|
skip: state.skip,
|
59
|
-
}, onPageChange: pageChange, filterable: true, onFilterChange: onFilterChange, popupSettings: {
|
59
|
+
}, suggest: true, onPageChange: pageChange, filterable: true, onFilterChange: onFilterChange, popupSettings: {
|
60
60
|
height: "210px",
|
61
61
|
}, onChange: (e) => e.value && changeEvent(e), onBlur: (e) => e.nativeEvent.preventDefault(), value: dataList.find((item) => selectedId === item[idField || "id"]) }) })));
|
62
62
|
}
|
package/MultiSelectDropdown.d.ts
CHANGED
@@ -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
|
6
|
+
title?: string;
|
7
7
|
separator?: string;
|
8
8
|
limit?: number;
|
9
9
|
}): import("react/jsx-runtime").JSX.Element;
|
package/MultiSelectDropdown.js
CHANGED
@@ -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,169 @@
|
|
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={myDataArray}
|
137
|
+
selectedData={mySelectedDataArray}
|
138
|
+
textFields={["firstName", "lastName"]}
|
139
|
+
separator=" - "
|
140
|
+
selectEvent={setSelectedVend}
|
141
|
+
title="Vendor(s)"
|
142
|
+
limit={10}
|
143
|
+
/>
|
144
|
+
|
145
|
+
### Required props
|
146
|
+
|
147
|
+
#### {...FilterCellProps}
|
148
|
+
|
149
|
+
- all of the default props that are passed from kendo grid when trying to override the filter cell
|
150
|
+
|
151
|
+
#### data
|
152
|
+
|
153
|
+
- Array of T. What you want to display in the dropdown. the Definition of what T is matters for the "textFields" prop
|
154
|
+
|
155
|
+
#### textFields
|
156
|
+
|
157
|
+
- This is defined as (keyof T)[].
|
158
|
+
- 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"
|
159
|
+
|
160
|
+
### Optional props
|
161
|
+
|
162
|
+
#### separator
|
163
|
+
|
164
|
+
- 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
|
165
|
+
- For example, if we want our employee's names separated by a comma, we would pass ", " here
|
166
|
+
|
167
|
+
---
|
168
|
+
|
169
|
+
## More Updates to the README Coming Soon!
|