rez-table-listing-mui 1.0.32 → 1.0.34
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/index.d.ts +11 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +31 -29
- package/src/components/filter/components/attributes-filter.tsx +186 -13
- package/src/components/filter/components/forms/components/Date.tsx +94 -16
- package/src/components/filter/components/forms/components/Dropdown.tsx +12 -7
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +47 -40
- package/src/components/filter/components/forms/components/Multi-Select.tsx +6 -1
- package/src/components/filter/components/forms/components/Select.tsx +9 -0
- package/src/components/filter/components/forms/components/Textfield.tsx +6 -0
- package/src/components/filter/components/forms/index.tsx +135 -211
- package/src/components/filter/components/main-filter.tsx +2 -7
- package/src/components/filter/components/saved-edit-filter.tsx +15 -17
- package/src/components/filter/components/saved-filter.tsx +2 -1
- package/src/components/filter/components/search/index.tsx +0 -1
- package/src/components/filter/components/tabs/custom-tab-panel.tsx +7 -3
- package/src/components/filter/components/tabs/index.tsx +8 -8
- package/src/components/filter/index.tsx +187 -172
- package/src/components/filter/style.ts +106 -0
- package/src/components/index-table.tsx +87 -63
- package/src/components/index.scss +33 -0
- package/src/components/topbar/index.tsx +7 -33
- package/src/index.ts +2 -0
- package/src/libs/utils/common.ts +1 -1
- package/src/types/filter.ts +1 -0
- package/src/types/table.ts +7 -2
- package/src/components/filter/components/forms/components/Attributes-select.tsx +0 -192
|
@@ -34,6 +34,7 @@ function TableWrapper<T>({
|
|
|
34
34
|
// styleOptions,
|
|
35
35
|
shouldHideColumn,
|
|
36
36
|
emptyListComponent,
|
|
37
|
+
filterOptions,
|
|
37
38
|
}: CraftTableProps<T>) {
|
|
38
39
|
if (!Array.isArray(data)) {
|
|
39
40
|
throw new Error("data must be an array of objects.");
|
|
@@ -242,80 +243,103 @@ function TableWrapper<T>({
|
|
|
242
243
|
// className: "ts__table__wrapper",
|
|
243
244
|
// };
|
|
244
245
|
|
|
246
|
+
const showFilterCondition = filterOptions?.show;
|
|
247
|
+
|
|
245
248
|
return (
|
|
246
|
-
<div className="ts__table__container"
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
isFullscreen={isFullscreen}
|
|
254
|
-
fullscreenToggle={handleFullscreenToggle}
|
|
255
|
-
paginationComponent={
|
|
256
|
-
craftPaginationOptions?.showPagination === true &&
|
|
257
|
-
craftPaginationOptions?.paginationPosition === "top" ? (
|
|
258
|
-
<DefaultPagination
|
|
259
|
-
table={table}
|
|
260
|
-
rowsPerPageArray={rowsPerPageArray}
|
|
261
|
-
paginationOptions={craftPaginationOptions}
|
|
262
|
-
/>
|
|
263
|
-
) : null
|
|
264
|
-
}
|
|
265
|
-
// searchValue={searchValue} // 👈 new
|
|
266
|
-
// onSearchChange={onSearchChange}
|
|
267
|
-
tableStates={tableStates}
|
|
268
|
-
/>
|
|
269
|
-
)}
|
|
270
|
-
|
|
271
|
-
{isLoading ? (
|
|
272
|
-
loadingComponent ?? (
|
|
273
|
-
<div className="ts__loader">
|
|
274
|
-
<LoaderAnimation />
|
|
275
|
-
{loaderText && <p>{loaderText}</p>}
|
|
276
|
-
</div>
|
|
277
|
-
)
|
|
278
|
-
) : !isLoading && data.length === 0 && emptyListComponent ? (
|
|
279
|
-
emptyListComponent
|
|
280
|
-
) : (
|
|
249
|
+
<div className="ts__table__container">
|
|
250
|
+
<div
|
|
251
|
+
className={`ts__table__layout ${
|
|
252
|
+
showFilterCondition ? "has-filter" : ""
|
|
253
|
+
}`}
|
|
254
|
+
>
|
|
255
|
+
{/* Main Table Area */}
|
|
281
256
|
<div
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
isFullscreen ? "is-fullscreen" : ""
|
|
285
|
-
}`}
|
|
257
|
+
className={`ts__table__main ${isFullscreen ? "is-fullscreen" : ""}`}
|
|
258
|
+
ref={tableRef}
|
|
286
259
|
>
|
|
287
|
-
{
|
|
288
|
-
<
|
|
260
|
+
{enableTopbar && (
|
|
261
|
+
<Topbar
|
|
289
262
|
table={table}
|
|
290
|
-
|
|
291
|
-
featureOptions={craftFeatureOptions}
|
|
292
|
-
NestedComponent={nestedComponent}
|
|
293
|
-
setColumnOrder={setColumnOrder}
|
|
263
|
+
topbarOptions={craftTopbarOptions}
|
|
294
264
|
isCompactTable={isCompactTable}
|
|
265
|
+
setIsCompactTable={setIsCompactTable}
|
|
266
|
+
isFullscreen={isFullscreen}
|
|
267
|
+
fullscreenToggle={handleFullscreenToggle}
|
|
268
|
+
paginationComponent={
|
|
269
|
+
craftPaginationOptions?.showPagination === true &&
|
|
270
|
+
craftPaginationOptions?.paginationPosition === "top" ? (
|
|
271
|
+
<DefaultPagination
|
|
272
|
+
table={table}
|
|
273
|
+
rowsPerPageArray={rowsPerPageArray}
|
|
274
|
+
paginationOptions={craftPaginationOptions}
|
|
275
|
+
/>
|
|
276
|
+
) : null
|
|
277
|
+
}
|
|
278
|
+
// searchValue={searchValue} // 👈 new
|
|
279
|
+
// onSearchChange={onSearchChange}
|
|
295
280
|
tableStates={tableStates}
|
|
281
|
+
onFilterButtonClick={topbarOptions?.onFilterButtonClick}
|
|
296
282
|
/>
|
|
283
|
+
)}
|
|
284
|
+
|
|
285
|
+
{isLoading ? (
|
|
286
|
+
loadingComponent ?? (
|
|
287
|
+
<div className="ts__loader">
|
|
288
|
+
<LoaderAnimation />
|
|
289
|
+
{loaderText && <p>{loaderText}</p>}
|
|
290
|
+
</div>
|
|
291
|
+
)
|
|
292
|
+
) : !isLoading && data.length === 0 && emptyListComponent ? (
|
|
293
|
+
emptyListComponent
|
|
297
294
|
) : (
|
|
298
|
-
<
|
|
295
|
+
<div
|
|
296
|
+
// {...tableWrapperProps}
|
|
297
|
+
className={`ts__table__wrapper ${
|
|
298
|
+
isFullscreen ? "is-fullscreen" : ""
|
|
299
|
+
}`}
|
|
300
|
+
>
|
|
301
|
+
{enableColumnReordering ? (
|
|
302
|
+
<TableDND
|
|
303
|
+
table={table}
|
|
304
|
+
columnOrder={columnOrder}
|
|
305
|
+
featureOptions={craftFeatureOptions}
|
|
306
|
+
NestedComponent={nestedComponent}
|
|
307
|
+
setColumnOrder={setColumnOrder}
|
|
308
|
+
isCompactTable={isCompactTable}
|
|
309
|
+
tableStates={tableStates}
|
|
310
|
+
/>
|
|
311
|
+
) : (
|
|
312
|
+
<Table
|
|
313
|
+
table={table}
|
|
314
|
+
featureOptions={craftFeatureOptions}
|
|
315
|
+
NestedComponent={nestedComponent}
|
|
316
|
+
columnOrder={columnOrder}
|
|
317
|
+
setColumnOrder={setColumnOrder}
|
|
318
|
+
isCompactTable={isCompactTable}
|
|
319
|
+
tableStates={tableStates}
|
|
320
|
+
/>
|
|
321
|
+
)}
|
|
322
|
+
</div>
|
|
323
|
+
)}
|
|
324
|
+
|
|
325
|
+
{craftPaginationOptions?.showPagination === true &&
|
|
326
|
+
craftPaginationOptions?.paginationPosition === "bottom" ? (
|
|
327
|
+
<DefaultPagination
|
|
299
328
|
table={table}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
columnOrder={columnOrder}
|
|
303
|
-
setColumnOrder={setColumnOrder}
|
|
304
|
-
isCompactTable={isCompactTable}
|
|
305
|
-
tableStates={tableStates}
|
|
329
|
+
rowsPerPageArray={rowsPerPageArray}
|
|
330
|
+
paginationOptions={craftPaginationOptions}
|
|
306
331
|
/>
|
|
307
|
-
)}
|
|
332
|
+
) : null}
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<div
|
|
336
|
+
className={`ts__table__filter ${
|
|
337
|
+
showFilterCondition ? "show" : ""
|
|
338
|
+
}`.trim()}
|
|
339
|
+
>
|
|
340
|
+
{filterOptions?.component && filterOptions?.component}
|
|
308
341
|
</div>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
{craftPaginationOptions?.showPagination === true &&
|
|
312
|
-
craftPaginationOptions?.paginationPosition === "bottom" ? (
|
|
313
|
-
<DefaultPagination
|
|
314
|
-
table={table}
|
|
315
|
-
rowsPerPageArray={rowsPerPageArray}
|
|
316
|
-
paginationOptions={craftPaginationOptions}
|
|
317
|
-
/>
|
|
318
|
-
) : null}
|
|
342
|
+
</div>
|
|
319
343
|
</div>
|
|
320
344
|
);
|
|
321
345
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
--grey-600: #bbbbbd;
|
|
9
9
|
--grey-700: #77787b;
|
|
10
10
|
--grey-900: #414042;
|
|
11
|
+
--filter-width: 24rem;
|
|
11
12
|
|
|
12
13
|
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
13
14
|
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
|
@@ -17,6 +18,38 @@
|
|
|
17
18
|
box-sizing: border-box;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
.ts__table__layout {
|
|
22
|
+
display: flex;
|
|
23
|
+
width: calc(100% - var(--filter-width));
|
|
24
|
+
transition: all 0.4s ease-in-out;
|
|
25
|
+
|
|
26
|
+
.ts__table__filter {
|
|
27
|
+
width: 0rem;
|
|
28
|
+
opacity: 0;
|
|
29
|
+
margin-right: calc(-1 * var(--filter-width));
|
|
30
|
+
transition: all 0.4s ease-in-out;
|
|
31
|
+
max-height: calc(100vh - 50px);
|
|
32
|
+
}
|
|
33
|
+
.ts__table__filter.show {
|
|
34
|
+
transition: all 0.4s ease-in-out;
|
|
35
|
+
opacity: 1;
|
|
36
|
+
width: var(--filter-width);
|
|
37
|
+
max-width: var(--filter-width);
|
|
38
|
+
margin-left: 1.25rem;
|
|
39
|
+
margin-right: 0rem;
|
|
40
|
+
min-height: calc(100vh - 50px);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ts__table__layout.has-filter {
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ts__table__main {
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
min-width: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
20
53
|
.ts__loader {
|
|
21
54
|
display: flex;
|
|
22
55
|
flex-direction: column;
|
|
@@ -17,7 +17,6 @@ import SortPopover from "../sorting-modal.tsx";
|
|
|
17
17
|
import ColumnToggle from "../column-visibility-modal/index.tsx";
|
|
18
18
|
import { CraftTableOptionsProps } from "../../types/table-options.ts";
|
|
19
19
|
import TableSearch from "../search/index.tsx";
|
|
20
|
-
import FilterDrawer from "../filter/index.tsx";
|
|
21
20
|
|
|
22
21
|
interface TopbarProps<T> {
|
|
23
22
|
table: Table<T>;
|
|
@@ -32,6 +31,7 @@ interface TopbarProps<T> {
|
|
|
32
31
|
tableStates: CraftTableOptionsProps;
|
|
33
32
|
searchValue?: string;
|
|
34
33
|
onSearchChange?: (val: string) => void;
|
|
34
|
+
onFilterButtonClick?: () => void;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function Topbar<T>({
|
|
@@ -43,6 +43,7 @@ function Topbar<T>({
|
|
|
43
43
|
paginationComponent,
|
|
44
44
|
topbarOptions,
|
|
45
45
|
tableStates,
|
|
46
|
+
onFilterButtonClick,
|
|
46
47
|
}: TopbarProps<T>) {
|
|
47
48
|
const [isFullscreenState, setIsFullscreenState] = useState(isFullscreen);
|
|
48
49
|
const [sortAnchorEl, setSortAnchorEl] = useState<HTMLElement | null>(null);
|
|
@@ -61,7 +62,7 @@ function Topbar<T>({
|
|
|
61
62
|
);
|
|
62
63
|
|
|
63
64
|
//Filter
|
|
64
|
-
const [showFilterInput, setShowFilterInput] = useState(false);
|
|
65
|
+
// const [showFilterInput, setShowFilterInput] = useState(false);
|
|
65
66
|
|
|
66
67
|
// search
|
|
67
68
|
const [showSearchInput, setShowSearchInput] = useState(false);
|
|
@@ -83,17 +84,6 @@ function Topbar<T>({
|
|
|
83
84
|
showSearch,
|
|
84
85
|
searchValue,
|
|
85
86
|
onSearchChange,
|
|
86
|
-
filterOptions = {
|
|
87
|
-
columnsData: {
|
|
88
|
-
column_list: [],
|
|
89
|
-
operation_list: {},
|
|
90
|
-
saved_filter: [],
|
|
91
|
-
},
|
|
92
|
-
onDeleteFilter: () => {},
|
|
93
|
-
onSaveFilter: () => {},
|
|
94
|
-
dropdownData: [],
|
|
95
|
-
onUpdateFilter: () => {},
|
|
96
|
-
},
|
|
97
87
|
} = topbarOptions ?? {};
|
|
98
88
|
|
|
99
89
|
const { container: fullscreenContainer } = useFullscreenPopoverContainer();
|
|
@@ -118,9 +108,9 @@ function Topbar<T>({
|
|
|
118
108
|
handler: () => setShowSearchInput(false),
|
|
119
109
|
});
|
|
120
110
|
|
|
121
|
-
const handleFilterDrawer = () => {
|
|
122
|
-
|
|
123
|
-
};
|
|
111
|
+
// const handleFilterDrawer = () => {
|
|
112
|
+
// setShowFilterInput((prev) => !prev);
|
|
113
|
+
// };
|
|
124
114
|
|
|
125
115
|
return (
|
|
126
116
|
<div className="ts-topbar">
|
|
@@ -152,12 +142,6 @@ function Topbar<T>({
|
|
|
152
142
|
onClose={() => setLayoutAnchorEl(null)}
|
|
153
143
|
anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
|
|
154
144
|
container={fullscreenContainer}
|
|
155
|
-
// transformOrigin={{ vertical: "top", horizontal: "left" }}
|
|
156
|
-
// PaperProps={{
|
|
157
|
-
// sx: {
|
|
158
|
-
// mt: 2,
|
|
159
|
-
// },
|
|
160
|
-
// }}
|
|
161
145
|
sx={{
|
|
162
146
|
mt: 2.2,
|
|
163
147
|
}}
|
|
@@ -214,19 +198,9 @@ function Topbar<T>({
|
|
|
214
198
|
<div
|
|
215
199
|
className="filter ts--button"
|
|
216
200
|
title="Filter"
|
|
217
|
-
onClick={
|
|
201
|
+
onClick={onFilterButtonClick && onFilterButtonClick}
|
|
218
202
|
>
|
|
219
203
|
<FilterationIcon />
|
|
220
|
-
<FilterDrawer
|
|
221
|
-
tableStates={tableStates}
|
|
222
|
-
open={showFilterInput}
|
|
223
|
-
onClose={handleFilterDrawer}
|
|
224
|
-
onDeleteFilter={filterOptions?.onDeleteFilter}
|
|
225
|
-
columnsData={filterOptions.columnsData} // @ts-ignore
|
|
226
|
-
onSaveFilter={filterOptions?.onSaveFilter}
|
|
227
|
-
dropdownData={filterOptions.dropdownData}
|
|
228
|
-
onUpdateFilter={filterOptions?.onUpdateFilter}
|
|
229
|
-
/>
|
|
230
204
|
</div>
|
|
231
205
|
)}
|
|
232
206
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { default as TableWrapper } from "./components/index-table";
|
|
2
2
|
export { useCraftTable } from "./libs/hooks/useCraftTable";
|
|
3
3
|
export { TableTabs as CraftTableTabs } from "./components/tabs";
|
|
4
|
+
export { TableFilter as CraftTableFilter } from "./components/filter";
|
|
5
|
+
|
|
4
6
|
export * from "./types/table";
|
|
5
7
|
export * from "./types/table-options";
|
package/src/libs/utils/common.ts
CHANGED
package/src/types/filter.ts
CHANGED
package/src/types/table.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
CraftTableOptionsProps,
|
|
11
11
|
} from "./table-options";
|
|
12
12
|
import React from "react";
|
|
13
|
-
import { FilterDrawerProps } from "./filter";
|
|
14
13
|
|
|
15
14
|
export interface CraftTablePaginationProps {
|
|
16
15
|
totalRows?: number;
|
|
@@ -39,7 +38,7 @@ export interface TopbarOptionsProps {
|
|
|
39
38
|
showFilterToggle?: boolean;
|
|
40
39
|
searchValue?: string;
|
|
41
40
|
onSearchChange?: (val: string) => void;
|
|
42
|
-
|
|
41
|
+
onFilterButtonClick?: () => void;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
export interface CustomRenderContext<T> {
|
|
@@ -66,6 +65,11 @@ interface CraftTableStyleProps {
|
|
|
66
65
|
wrapperStyle?: React.CSSProperties;
|
|
67
66
|
}
|
|
68
67
|
|
|
68
|
+
interface FilterOptionsProps {
|
|
69
|
+
show?: boolean;
|
|
70
|
+
component: React.ReactNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
export interface CraftTableProps<T> {
|
|
70
74
|
data: T[];
|
|
71
75
|
columns: CustomColumnDef<T>[];
|
|
@@ -79,6 +83,7 @@ export interface CraftTableProps<T> {
|
|
|
79
83
|
shouldHideColumn?: (accessorKey?: string) => boolean;
|
|
80
84
|
styleOptions?: CraftTableStyleProps;
|
|
81
85
|
emptyListComponent?: React.ReactNode;
|
|
86
|
+
filterOptions?: FilterOptionsProps;
|
|
82
87
|
}
|
|
83
88
|
export interface CraftTableComponentProps<T> {
|
|
84
89
|
table: Table<T>;
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
FormControl,
|
|
4
|
-
MenuItem,
|
|
5
|
-
Select,
|
|
6
|
-
SelectChangeEvent,
|
|
7
|
-
Radio,
|
|
8
|
-
RadioGroup,
|
|
9
|
-
FormControlLabel,
|
|
10
|
-
} from "@mui/material";
|
|
11
|
-
import {
|
|
12
|
-
AttributesFilterSelectProps,
|
|
13
|
-
FilterMasterStateProps,
|
|
14
|
-
} from "../../../../../types/filter";
|
|
15
|
-
import { useMemo } from "react";
|
|
16
|
-
import CustomSearch from "../../search";
|
|
17
|
-
|
|
18
|
-
const SelectAttribute = ({
|
|
19
|
-
columnsData,
|
|
20
|
-
tableStates,
|
|
21
|
-
dropdownData,
|
|
22
|
-
searchTerm = "",
|
|
23
|
-
setSearchTerm,
|
|
24
|
-
tabValue,
|
|
25
|
-
}: AttributesFilterSelectProps) => {
|
|
26
|
-
const { filterMaster, setFilterMaster, filters, setFilters } = tableStates;
|
|
27
|
-
|
|
28
|
-
const selectedAttribute = filterMaster?.attributes?.selected;
|
|
29
|
-
|
|
30
|
-
// Get the current filter value to set radio button state
|
|
31
|
-
const currentFilterValue = useMemo(() => {
|
|
32
|
-
if (!selectedAttribute) return "";
|
|
33
|
-
|
|
34
|
-
const matchingColumn = columnsData.column_list.find(
|
|
35
|
-
(column) => column.datasource_list === selectedAttribute
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
if (!matchingColumn) return "";
|
|
39
|
-
|
|
40
|
-
const existingFilter = filters.find(
|
|
41
|
-
(filter) => filter.filter_attribute === matchingColumn.attribute_key
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return existingFilter?.filter_value || "";
|
|
45
|
-
}, [selectedAttribute, filters, columnsData]);
|
|
46
|
-
|
|
47
|
-
const handleSelectChange = (event: SelectChangeEvent) => {
|
|
48
|
-
const attributeKey = event.target.value as string;
|
|
49
|
-
|
|
50
|
-
setFilterMaster(
|
|
51
|
-
(prev) =>
|
|
52
|
-
({
|
|
53
|
-
...prev,
|
|
54
|
-
attributes: {
|
|
55
|
-
...prev?.attributes,
|
|
56
|
-
selected: attributeKey,
|
|
57
|
-
radio: "", // Reset radio selection when changing attribute
|
|
58
|
-
},
|
|
59
|
-
} as FilterMasterStateProps)
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
64
|
-
event.preventDefault();
|
|
65
|
-
|
|
66
|
-
const selectedValue = event.target.value;
|
|
67
|
-
|
|
68
|
-
setFilterMaster(
|
|
69
|
-
(prev) =>
|
|
70
|
-
({
|
|
71
|
-
...prev,
|
|
72
|
-
attributes: {
|
|
73
|
-
...prev?.attributes,
|
|
74
|
-
radio: selectedValue,
|
|
75
|
-
},
|
|
76
|
-
activeFilterTabIndex: tabValue,
|
|
77
|
-
} as FilterMasterStateProps)
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const selectedAttribute = filterMaster?.attributes.selected;
|
|
81
|
-
if (selectedAttribute) {
|
|
82
|
-
const matchingColumn = columnsData.column_list.find(
|
|
83
|
-
(column) => column.datasource_list === selectedAttribute
|
|
84
|
-
);
|
|
85
|
-
if (matchingColumn) {
|
|
86
|
-
const defaultOperator =
|
|
87
|
-
columnsData.operation_list[matchingColumn.data_type]?.[0]?.value ||
|
|
88
|
-
"equals";
|
|
89
|
-
const newFilter = {
|
|
90
|
-
filter_attribute: matchingColumn.attribute_key,
|
|
91
|
-
filter_operator: defaultOperator,
|
|
92
|
-
filter_value: selectedValue,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
setFilters([newFilter]);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const selectedAttributeOptions = useMemo(() => {
|
|
101
|
-
const selected = columnsData.column_list.find(
|
|
102
|
-
(col) => col.datasource_list === selectedAttribute
|
|
103
|
-
)?.attribute_key;
|
|
104
|
-
|
|
105
|
-
return selected ? dropdownData[selected] : [];
|
|
106
|
-
}, [selectedAttribute, dropdownData]);
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<Box sx={{ mt: 2 }}>
|
|
110
|
-
<FormControl fullWidth size="small">
|
|
111
|
-
<Select
|
|
112
|
-
value={selectedAttribute || ""}
|
|
113
|
-
onChange={handleSelectChange}
|
|
114
|
-
displayEmpty
|
|
115
|
-
renderValue={(selected) => {
|
|
116
|
-
if (!selected) {
|
|
117
|
-
return <span>Select Attribute</span>;
|
|
118
|
-
}
|
|
119
|
-
return columnsData?.column_list?.find(
|
|
120
|
-
(col) => col.datasource_list === selected
|
|
121
|
-
)?.name;
|
|
122
|
-
}}
|
|
123
|
-
sx={{
|
|
124
|
-
"& .MuiOutlinedInput-root": {
|
|
125
|
-
borderRadius: "6px",
|
|
126
|
-
fontSize: "14px",
|
|
127
|
-
bgcolor: "#fafafa",
|
|
128
|
-
"& fieldset": {
|
|
129
|
-
borderColor: "#7a5af8 !important",
|
|
130
|
-
},
|
|
131
|
-
"&:hover fieldset": {
|
|
132
|
-
borderColor: "#7a5af8 !important",
|
|
133
|
-
},
|
|
134
|
-
"&.Mui-focused fieldset": {
|
|
135
|
-
borderColor: "#7a5af8 !important",
|
|
136
|
-
boxShadow: "none",
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
"& .MuiSelect-select": {
|
|
140
|
-
padding: "8px 14px",
|
|
141
|
-
},
|
|
142
|
-
}}
|
|
143
|
-
>
|
|
144
|
-
{columnsData?.column_list
|
|
145
|
-
?.filter((column) => column.data_type.includes("select"))
|
|
146
|
-
.map((column, index) => (
|
|
147
|
-
<MenuItem
|
|
148
|
-
key={index}
|
|
149
|
-
value={column.datasource_list}
|
|
150
|
-
disabled={column.datasource_list === selectedAttribute}
|
|
151
|
-
>
|
|
152
|
-
{column.name}
|
|
153
|
-
</MenuItem>
|
|
154
|
-
))}
|
|
155
|
-
</Select>
|
|
156
|
-
{selectedAttribute && (
|
|
157
|
-
<CustomSearch value={searchTerm} onChange={setSearchTerm} />
|
|
158
|
-
)}
|
|
159
|
-
</FormControl>
|
|
160
|
-
|
|
161
|
-
{dropdownData && (
|
|
162
|
-
<Box sx={{ mt: 2 }}>
|
|
163
|
-
<FormControl>
|
|
164
|
-
<RadioGroup
|
|
165
|
-
onChange={handleRadioChange}
|
|
166
|
-
value={currentFilterValue} // Set the value from current filter
|
|
167
|
-
>
|
|
168
|
-
{selectedAttributeOptions
|
|
169
|
-
?.filter((option) => {
|
|
170
|
-
if (!searchTerm) return true;
|
|
171
|
-
|
|
172
|
-
return option.label
|
|
173
|
-
.toLowerCase()
|
|
174
|
-
.includes(searchTerm.toLowerCase());
|
|
175
|
-
})
|
|
176
|
-
.map((option) => (
|
|
177
|
-
<FormControlLabel
|
|
178
|
-
key={option.value}
|
|
179
|
-
value={option.value}
|
|
180
|
-
control={<Radio />}
|
|
181
|
-
label={option.label}
|
|
182
|
-
/>
|
|
183
|
-
))}
|
|
184
|
-
</RadioGroup>
|
|
185
|
-
</FormControl>
|
|
186
|
-
</Box>
|
|
187
|
-
)}
|
|
188
|
-
</Box>
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export default SelectAttribute;
|