@megha-ui/react 1.2.57 → 1.2.59
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/dist/components/grid/index.js +98 -92
- package/dist/components/grid/utils/gridFilterDropdown.js +1 -1
- package/dist/components/grid/utils/gridHeader.js +2 -2
- package/dist/components/grid/utils/textFilterDropdown.d.ts +1 -0
- package/dist/components/grid/utils/textFilterDropdown.js +8 -2
- package/package.json +1 -1
|
@@ -179,53 +179,56 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
179
179
|
const regex = (0, regexUtils_1.createRegexFromWildcard)(query);
|
|
180
180
|
return regex.test(value);
|
|
181
181
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
new Date(value).getTime()
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
parseFloat(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
182
|
+
if (query) {
|
|
183
|
+
switch ((_c = searchQueries[column.key]) === null || _c === void 0 ? void 0 : _c.type) {
|
|
184
|
+
case "contains":
|
|
185
|
+
return value.toLowerCase().includes(query.toLowerCase());
|
|
186
|
+
case "doesNotContain":
|
|
187
|
+
return !value.toLowerCase().includes(query.toLowerCase());
|
|
188
|
+
case "equals":
|
|
189
|
+
return value.toLowerCase() === query.toLowerCase();
|
|
190
|
+
case "gt":
|
|
191
|
+
return parseFloat(value) > parseFloat(query);
|
|
192
|
+
case "gte":
|
|
193
|
+
return parseFloat(value) >= parseFloat(query);
|
|
194
|
+
case "lt":
|
|
195
|
+
return parseFloat(value) < parseFloat(query);
|
|
196
|
+
case "lte":
|
|
197
|
+
return parseFloat(value) <= parseFloat(query);
|
|
198
|
+
case "after":
|
|
199
|
+
return new Date(value).getTime() > new Date(query).getTime();
|
|
200
|
+
case "before":
|
|
201
|
+
return new Date(value).getTime() < new Date(query).getTime();
|
|
202
|
+
case "between":
|
|
203
|
+
let [start, end] = column.dataType === "date"
|
|
204
|
+
? query.split("to")
|
|
205
|
+
: query.split("-");
|
|
206
|
+
if (column.dataType === "date" && start && end) {
|
|
207
|
+
start = new Date(start).getTime();
|
|
208
|
+
end = new Date(end).getTime();
|
|
209
|
+
return (start < new Date(value).getTime() &&
|
|
210
|
+
new Date(value).getTime() < end);
|
|
211
|
+
}
|
|
212
|
+
else if (start && end) {
|
|
213
|
+
return (parseFloat(start.trim()) < parseFloat(value) &&
|
|
214
|
+
parseFloat(value) < parseFloat(end.trim()));
|
|
215
|
+
}
|
|
216
|
+
return true;
|
|
217
|
+
case "doesNotEqual":
|
|
218
|
+
return value.toLowerCase() !== query.toLowerCase();
|
|
219
|
+
case "startsWith":
|
|
220
|
+
return value.toLowerCase().startsWith(query.toLowerCase());
|
|
221
|
+
case "endsWith":
|
|
222
|
+
return value.toLowerCase().endsWith(query.toLowerCase());
|
|
223
|
+
case "blank":
|
|
224
|
+
return value === "";
|
|
225
|
+
case "notBlank":
|
|
226
|
+
return value !== "";
|
|
227
|
+
default:
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
228
230
|
}
|
|
231
|
+
return true;
|
|
229
232
|
})
|
|
230
233
|
: filterColumns.some((column) => {
|
|
231
234
|
var _a, _b, _c;
|
|
@@ -237,53 +240,56 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
237
240
|
const regex = (0, regexUtils_1.createRegexFromWildcard)(query);
|
|
238
241
|
return regex.test(value);
|
|
239
242
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
new Date(value).getTime()
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
parseFloat(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
243
|
+
if (query) {
|
|
244
|
+
switch ((_c = searchQueries[column.key]) === null || _c === void 0 ? void 0 : _c.type) {
|
|
245
|
+
case "contains":
|
|
246
|
+
return value.toLowerCase().includes(query.toLowerCase());
|
|
247
|
+
case "doesNotContain":
|
|
248
|
+
return !value.toLowerCase().includes(query.toLowerCase());
|
|
249
|
+
case "equals":
|
|
250
|
+
return value.toLowerCase() === query.toLowerCase();
|
|
251
|
+
case "gt":
|
|
252
|
+
return parseFloat(value) > parseFloat(query);
|
|
253
|
+
case "gte":
|
|
254
|
+
return parseFloat(value) >= parseFloat(query);
|
|
255
|
+
case "lt":
|
|
256
|
+
return parseFloat(value) < parseFloat(query);
|
|
257
|
+
case "lte":
|
|
258
|
+
return parseFloat(value) <= parseFloat(query);
|
|
259
|
+
case "after":
|
|
260
|
+
return new Date(value).getTime() > new Date(query).getTime();
|
|
261
|
+
case "before":
|
|
262
|
+
return new Date(value).getTime() < new Date(query).getTime();
|
|
263
|
+
case "between":
|
|
264
|
+
let [start, end] = column.dataType === "date"
|
|
265
|
+
? query.split("to")
|
|
266
|
+
: query.split("-");
|
|
267
|
+
if (column.dataType === "date" && start && end) {
|
|
268
|
+
start = new Date(start).getTime();
|
|
269
|
+
end = new Date(end).getTime();
|
|
270
|
+
return (start < new Date(value).getTime() &&
|
|
271
|
+
new Date(value).getTime() < end);
|
|
272
|
+
}
|
|
273
|
+
else if (start && end) {
|
|
274
|
+
return (parseFloat(start.trim()) < parseFloat(value) &&
|
|
275
|
+
parseFloat(value) < parseFloat(end.trim()));
|
|
276
|
+
}
|
|
277
|
+
return true;
|
|
278
|
+
case "doesNotEqual":
|
|
279
|
+
return value.toLowerCase() !== query.toLowerCase();
|
|
280
|
+
case "startsWith":
|
|
281
|
+
return value.toLowerCase().startsWith(query.toLowerCase());
|
|
282
|
+
case "endsWith":
|
|
283
|
+
return value.toLowerCase().endsWith(query.toLowerCase());
|
|
284
|
+
case "blank":
|
|
285
|
+
return value === "";
|
|
286
|
+
case "notBlank":
|
|
287
|
+
return value !== "";
|
|
288
|
+
default:
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
286
291
|
}
|
|
292
|
+
return true;
|
|
287
293
|
}));
|
|
288
294
|
_filteredData = _filteredData.filter((item) => {
|
|
289
295
|
const query = (globalInputSearch || "").toLowerCase().split(",");
|
|
@@ -85,7 +85,7 @@ const GridFilterDropdown = ({ headerDropdownIndex, searchOptions, position, colu
|
|
|
85
85
|
}, onClick: () => handleSelect(item, columnKey), children: [(0, jsx_runtime_1.jsx)(checkbox_1.default, { selected: (uniqueSearch === null || uniqueSearch === void 0 ? void 0 : uniqueSearch[columnKey])
|
|
86
86
|
? (_a = uniqueSearch === null || uniqueSearch === void 0 ? void 0 : uniqueSearch[columnKey]) === null || _a === void 0 ? void 0 : _a.includes(item)
|
|
87
87
|
: true, onChange: () => { }, style: { pointerEvents: "none" }, noLabel: true, wrapperClass: checkboxWrapper }), (0, jsx_runtime_1.jsx)("span", { style: { marginLeft: "0.5rem" }, children: item })] }, item));
|
|
88
|
-
})] }))] })), isOpen && ((0, jsx_runtime_1.jsx)(textFilterDropdown_1.default, { columnIndex: columnIndex, headerDropdownIndex: headerDropdownIndex || 1001, searchOptions: searchOptions, position: position
|
|
88
|
+
})] }))] })), isOpen && ((0, jsx_runtime_1.jsx)(textFilterDropdown_1.default, { combined: true, columnIndex: columnIndex, headerDropdownIndex: headerDropdownIndex || 1001, searchOptions: searchOptions, position: position
|
|
89
89
|
? {
|
|
90
90
|
top: position.top,
|
|
91
91
|
left: ((_d = headerDropdown === null || headerDropdown === void 0 ? void 0 : headerDropdown.current) === null || _d === void 0 ? void 0 : _d.clientWidth)
|
|
@@ -411,7 +411,7 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
|
|
|
411
411
|
: "hidden",
|
|
412
412
|
}, height: 32, width: "100%", className: "w-full", backgroundColor: "#fff" })) }), onFilter: onFilter, setUniqueSearch: setUniqueSearch, uniqueSearch: uniqueSearch, textFilterLabel: textFilterLabel, activeSearchType: ((_20 = searchQueries[((_19 = headerColumns.find((column) => column.key === _groupBy)) === null || _19 === void 0 ? void 0 : _19.key) || ""]) === null || _20 === void 0 ? void 0 : _20.type) ||
|
|
413
413
|
defaultSearchOperation ||
|
|
414
|
-
"contains", checkboxWrapper: checkboxWrapper })) : ((0, jsx_runtime_1.jsx)(textFilterDropdown_1.default, { columnIndex: -1, headerDropdownIndex: headerDropdownIndex, sortingOps: (0, jsx_runtime_1.jsx)(gridHeaderDropdown_1.default, { options: menuOptions.filter((item) => item.label !== "Group by"), onClose: () => setDropdownVisible(null), column: headerColumns.find((column) => column.key === _groupBy) }), searchOptions: searchOptions.filter((item) => {
|
|
414
|
+
"contains", checkboxWrapper: checkboxWrapper })) : ((0, jsx_runtime_1.jsx)(textFilterDropdown_1.default, { columnIndex: -1, combined: false, headerDropdownIndex: headerDropdownIndex, sortingOps: (0, jsx_runtime_1.jsx)(gridHeaderDropdown_1.default, { options: menuOptions.filter((item) => item.label !== "Group by"), onClose: () => setDropdownVisible(null), column: headerColumns.find((column) => column.key === _groupBy) }), searchOptions: searchOptions.filter((item) => {
|
|
415
415
|
var _a, _b;
|
|
416
416
|
return ((_a = headerColumns.find((column) => column.key === _groupBy)) === null || _a === void 0 ? void 0 : _a.dataType) === "number"
|
|
417
417
|
? numberTypeSearch.includes(item.value)
|
|
@@ -679,7 +679,7 @@ const GridHeader = ({ columns, onSearch, searchQueries, sortable, search, resiza
|
|
|
679
679
|
? "var(--background)"
|
|
680
680
|
: "var(--disabled-bg)",
|
|
681
681
|
}, placeholder: "Search", value: ((_h = searchQueries[column.key]) === null || _h === void 0 ? void 0 : _h.text) ||
|
|
682
|
-
"", disabled: !column.search, height: 32, extraInputStyle: { minWidth: 10 }, className: "w-full", backgroundColor: "#fff" }) })) })) : ((0, jsx_runtime_1.jsx)(textFilterDropdown_1.default, { columnIndex: colIndex, searchable: (column === null || column === void 0 ? void 0 : column.search) || false, sortingOps: (0, jsx_runtime_1.jsx)(gridHeaderDropdown_1.default, { options: menuOptions, onClose: () => setDropdownVisible(null), column: column }), headerDropdownIndex: headerDropdownIndex, searchOptions: searchOptions.filter((item) => column.dataType === "number"
|
|
682
|
+
"", disabled: !column.search, height: 32, extraInputStyle: { minWidth: 10 }, className: "w-full", backgroundColor: "#fff" }) })) })) : ((0, jsx_runtime_1.jsx)(textFilterDropdown_1.default, { combined: false, columnIndex: colIndex, searchable: (column === null || column === void 0 ? void 0 : column.search) || false, sortingOps: (0, jsx_runtime_1.jsx)(gridHeaderDropdown_1.default, { options: menuOptions, onClose: () => setDropdownVisible(null), column: column }), headerDropdownIndex: headerDropdownIndex, searchOptions: searchOptions.filter((item) => column.dataType === "number"
|
|
683
683
|
? numberTypeSearch.includes(item.value)
|
|
684
684
|
: column.dataType === "date"
|
|
685
685
|
? dateTypeSearch.includes(item.value)
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const dropdown_1 = __importDefault(require("../../dropdown"));
|
|
9
|
-
const TextFilterDropdown = ({ headerDropdownIndex, searchOptions, position, columnKey, searchElement, activeSearchType, sortingOps, searchable, searchInput, columnIndex }) => {
|
|
9
|
+
const TextFilterDropdown = ({ headerDropdownIndex, searchOptions, combined, position, columnKey, searchElement, activeSearchType, sortingOps, searchable, searchInput, columnIndex, }) => {
|
|
10
10
|
(0, react_1.useEffect)(() => {
|
|
11
11
|
var _a;
|
|
12
12
|
if (searchElement) {
|
|
@@ -21,7 +21,13 @@ const TextFilterDropdown = ({ headerDropdownIndex, searchOptions, position, colu
|
|
|
21
21
|
const clickedOption = searchOptions.find((item) => selected === item.value);
|
|
22
22
|
clickedOption === null || clickedOption === void 0 ? void 0 : clickedOption.action(columnKey, selected);
|
|
23
23
|
};
|
|
24
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: Object.assign(Object.assign({ position: "absolute", top:
|
|
24
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: Object.assign(Object.assign({ position: "absolute", top: combined ? 0 : "calc(100% + 5px)" }, (combined
|
|
25
|
+
? {
|
|
26
|
+
left: "100%",
|
|
27
|
+
}
|
|
28
|
+
: columnIndex > 1
|
|
29
|
+
? { right: 0 }
|
|
30
|
+
: { left: 0 })), { zIndex: headerDropdownIndex ? headerDropdownIndex : 1000, backgroundColor: "white", boxShadow: "0px 0.5rem 1rem 0px rgba(0,0,0,0.2)", listStyleType: "none", padding: "0.25rem 0", width: 230, borderRadius: "0.5rem", margin: 0 }), id: "grid-dropdown", onClick: (e) => e.stopPropagation(), children: [searchInput && searchInput, sortingOps && sortingOps, (0, jsx_runtime_1.jsx)("div", { style: {
|
|
25
31
|
padding: "0.5rem 0.75rem",
|
|
26
32
|
}, children: (0, jsx_runtime_1.jsx)(dropdown_1.default, { options: searchOptions, selectedValues: [activeSearchType], onChange: (selected) => handleDropdownChange(selected[0].toString(), columnKey), searchEnabled: false, maxDropdownHeight: 350 }) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
27
33
|
padding: "0.5rem 0.75rem",
|
package/package.json
CHANGED