rez-table-listing-mui 0.0.24 → 0.0.26

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.
Files changed (50) hide show
  1. package/.env.uat +1 -0
  2. package/.eslintrc.cjs +11 -9
  3. package/dist/index.d.ts +104 -11
  4. package/dist/index.js +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/package.json +6 -10
  7. package/src/App.tsx +185 -142
  8. package/src/assets/svg.tsx +33 -2
  9. package/src/components/common/confirm-modal/index.tsx +200 -0
  10. package/src/components/filter/components/attributes-filter.tsx +26 -0
  11. package/src/components/filter/components/forms/components/Attributes-select.tsx +180 -0
  12. package/src/components/filter/components/forms/components/Date.tsx +58 -0
  13. package/src/components/filter/components/forms/components/Dropdown.tsx +62 -0
  14. package/src/components/filter/components/forms/components/Filter-criteria.tsx +164 -0
  15. package/src/components/filter/components/forms/components/Multi-Select.tsx +57 -0
  16. package/src/components/filter/components/forms/components/Select.tsx +53 -0
  17. package/src/components/filter/components/forms/components/Textfield.tsx +43 -0
  18. package/src/components/filter/components/forms/components/styles.tsx +11 -0
  19. package/src/components/filter/components/forms/index.tsx +424 -0
  20. package/src/components/filter/components/main-filter.tsx +53 -0
  21. package/src/components/filter/components/saved-edit-filter.tsx +101 -0
  22. package/src/components/filter/components/saved-filter.tsx +148 -0
  23. package/src/components/filter/components/search/index.tsx +56 -0
  24. package/src/components/filter/components/tabs/custom-tab-panel.tsx +29 -0
  25. package/src/components/filter/components/tabs/index.tsx +52 -0
  26. package/src/components/filter/index.tsx +258 -0
  27. package/src/components/index-table.tsx +20 -14
  28. package/src/components/index.scss +4 -0
  29. package/src/components/login/index.tsx +49 -0
  30. package/src/components/search/index.tsx +0 -1
  31. package/src/components/table-body-dnd-cell.tsx +3 -3
  32. package/src/components/table-body.tsx +8 -5
  33. package/src/components/table-head-popover.tsx +2 -1
  34. package/src/components/table-head.tsx +0 -10
  35. package/src/components/topbar/index.scss +6 -1
  36. package/src/components/topbar/index.tsx +59 -33
  37. package/src/components/viewmore/index.tsx +33 -17
  38. package/src/libs/hooks/useCraftTable.tsx +32 -6
  39. package/src/libs/hooks/useDefaultColumns.tsx +6 -5
  40. package/src/libs/hooks/useEntityTableAPI.tsx +183 -0
  41. package/src/libs/hooks/useEntityTableHooks.ts +25 -0
  42. package/src/libs/utils/apiColumn.ts +123 -0
  43. package/src/libs/utils/common.ts +42 -0
  44. package/src/main.tsx +6 -3
  45. package/src/types/common.ts +67 -0
  46. package/src/types/filter.ts +211 -0
  47. package/src/types/table-options.ts +15 -2
  48. package/src/types/table.ts +7 -6
  49. package/tsconfig.json +1 -1
  50. package/vite.config.ts +3 -3
@@ -0,0 +1,25 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import {
3
+ entityTableFilterMaster,
4
+ fetchDetailsByFilterId,
5
+ } from "../utils/apiColumn";
6
+
7
+ export const useDetailsQueryAPI = (value: string) => {
8
+ const detailsQuery = useQuery({
9
+ queryKey: ["details", value],
10
+ queryFn: () => fetchDetailsByFilterId(value),
11
+ enabled: !!value, // This ensures that the second query only runs if the first one has data
12
+ });
13
+
14
+ return { detailsQuery };
15
+ };
16
+
17
+ export const useFetchData = (entity_type: string) => {
18
+ // First query to get meta data
19
+ const metaQuery = useQuery({
20
+ queryKey: ["meta", entity_type],
21
+ queryFn: () => entityTableFilterMaster(entity_type),
22
+ });
23
+
24
+ return { metaQuery };
25
+ };
@@ -0,0 +1,123 @@
1
+ import { api } from "./common";
2
+ import {
3
+ createSavedFilterPaload,
4
+ deleteSavedFilterPayload,
5
+ updateSavedFilterPayload,
6
+ } from "../../types/filter";
7
+
8
+ export const entityTableMetaMaster = async (entity_type: string) => {
9
+ try {
10
+ const response = await api.post(
11
+ `/meta/get-table-data?entity_type=${entity_type}&list_type=${entity_type}`
12
+ );
13
+
14
+ const rawColumns = response.data?.data?.column_list || [];
15
+
16
+ const res = rawColumns.map((item: any) => ({
17
+ id: item.attribute_key,
18
+ accessorKey: item.attribute_key,
19
+ header: item.name,
20
+ }));
21
+ return { res };
22
+ } catch (error) {
23
+ console.error("Failed to fetch table meta:", error);
24
+ return { res: [] };
25
+ }
26
+ };
27
+
28
+ export const entityTableFilterMaster = async (entity_type: string) => {
29
+ try {
30
+ const response = await api.post(
31
+ `/meta/get-table-data?entity_type=${entity_type}&list_type=${entity_type}`
32
+ );
33
+
34
+ const filteredData = {
35
+ ...response.data.data,
36
+ column_list: response.data.data.column_list.filter(
37
+ (item: any) => item.attribute_key !== "action"
38
+ ),
39
+ };
40
+ // console.log("response", filteredData.column_list);
41
+ // return response.data.data;
42
+ return filteredData; // FOR ACTION COLUMN REMOVE
43
+ } catch (error) {
44
+ console.error("Failed to fetch filter operation list meta:", error);
45
+ }
46
+ };
47
+
48
+ export const fetchDetailsByFilterId = async (filterId: string) => {
49
+ const response = await api.get(`/filter/${filterId}`);
50
+ return response.data;
51
+ };
52
+
53
+ export const commonGetDropdownDataAPI = async (
54
+ entity_type: string,
55
+ organization_id?: string | null,
56
+ data?: any
57
+ ) => {
58
+ try {
59
+ const requestBody = {
60
+ status: "ACTIVE",
61
+ organization_id: organization_id,
62
+ ...data,
63
+ };
64
+
65
+ const response = await api.post(
66
+ `/list-master/getDropdownData/${entity_type}`,
67
+ requestBody
68
+ );
69
+
70
+ return response.data;
71
+ } catch (error) {
72
+ console.error("Failed to fetch dropdown data:", error);
73
+ throw error;
74
+ }
75
+ };
76
+
77
+ export const createSavedFilter = async (
78
+ entity_type: string,
79
+ payload: createSavedFilterPaload
80
+ ) => {
81
+ try {
82
+ const response = await api.post(
83
+ `/entity/create?entity_type=${entity_type}`,
84
+ payload
85
+ );
86
+ return response.data;
87
+ } catch (error) {
88
+ console.error("Failed to fetch saved filter list:", error);
89
+ throw error;
90
+ }
91
+ };
92
+
93
+ export const deleteSavedFilter = async (
94
+ entity_type: string,
95
+ payload: deleteSavedFilterPayload
96
+ ) => {
97
+ try {
98
+ const response = await api.post(
99
+ `/entity/update/17?entity_type=${entity_type}`,
100
+ payload
101
+ );
102
+ return response.data;
103
+ } catch (error) {
104
+ console.error("Failed to delete saved filter:", error);
105
+ throw error;
106
+ }
107
+ };
108
+
109
+ export const updateSavedFilter = async (
110
+ entity_type: string,
111
+ payload: updateSavedFilterPayload
112
+ ) => {
113
+ try {
114
+ const response = await api.post(
115
+ `/entity/update/17?entity_type=${entity_type}`,
116
+ payload
117
+ );
118
+ return response.data;
119
+ } catch (error) {
120
+ console.error("Failed to update saved filter:", error);
121
+ throw error;
122
+ }
123
+ };
@@ -1,6 +1,7 @@
1
1
  import { Column } from "@tanstack/react-table";
2
2
  import { alignProps } from "../../types/common";
3
3
  import { CSSProperties } from "react";
4
+ import axios from "axios";
4
5
 
5
6
  export const formatClassName = (className: string): string => {
6
7
  return className.replace(/\s+/g, " ").trim();
@@ -60,3 +61,44 @@ export const getColumnPinningStylesBody = <T>(
60
61
  width: column.getSize(),
61
62
  };
62
63
  };
64
+
65
+ export function customDebounce<T extends (...args: any[]) => any>(
66
+ func: T,
67
+ delay: number
68
+ ): (...args: Parameters<T>) => void {
69
+ let timerId: ReturnType<typeof setTimeout> | null = null;
70
+
71
+ return function (this: ThisParameterType<T>, ...args: Parameters<T>): void {
72
+ if (timerId) clearTimeout(timerId);
73
+ timerId = setTimeout(() => {
74
+ func.apply(this, args);
75
+ }, delay);
76
+ };
77
+ }
78
+
79
+ // uat http://13.200.182.92:9091/api
80
+ // local http://localhost:9091/api
81
+
82
+ // API INTEGRATION
83
+ export const api = axios.create({
84
+ baseURL: "http://13.200.182.92:9091/api",
85
+ timeout: 10000,
86
+ headers: {
87
+ "Content-Type": "application/json",
88
+ },
89
+ });
90
+
91
+ api.interceptors.request.use(
92
+ (config) => {
93
+ const token = localStorage.getItem("authToken");
94
+ if (token) {
95
+ config.headers.Authorization = `Bearer ${token}`;
96
+ }
97
+ return config;
98
+ },
99
+ (error) => {
100
+ return Promise.reject(error);
101
+ }
102
+ );
103
+
104
+ export const ENTITY_TYPE = "UPR";
package/src/main.tsx CHANGED
@@ -1,9 +1,12 @@
1
1
  import React from "react";
2
2
  import ReactDOM from "react-dom/client";
3
3
  import App from "./App.tsx";
4
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
5
 
5
6
  ReactDOM.createRoot(document.getElementById("root")!).render(
6
- <React.StrictMode>
7
- <App />
8
- </React.StrictMode>
7
+ <QueryClientProvider client={new QueryClient()}>
8
+ <React.StrictMode>
9
+ <App />
10
+ </React.StrictMode>
11
+ </QueryClientProvider>
9
12
  );
@@ -38,3 +38,70 @@ export const camelCaseToTitle = (str: string): string => {
38
38
  .replace(/\b\w/g, (char) => char.toUpperCase()) // Capitalize each word's first letter
39
39
  .trim();
40
40
  };
41
+
42
+ //API INTEGRATION
43
+ export interface EntityTableAPIProps {
44
+ entity_type?: string;
45
+ page: number;
46
+ size: number;
47
+ tabs?: {
48
+ columnName: string;
49
+ sortBy: "ASC" | "DSC";
50
+ value?: string;
51
+ };
52
+ sortby?: {
53
+ sortColum: string;
54
+ sortType: "ASC" | "DSC";
55
+ }[];
56
+ quickFilter?: {
57
+ filter_attribute: string;
58
+ filter_operator: string;
59
+ filter_value: string[] | string;
60
+ }[];
61
+ attributeFilter?: {
62
+ filter_attribute: string;
63
+ filter_operator: string;
64
+ filter_value: string[] | string;
65
+ }[];
66
+ }
67
+
68
+ interface EntityListTab {
69
+ tab_value: string | null;
70
+ tab_value_count: string | number;
71
+ }
72
+
73
+ interface EntityList {
74
+ id: string;
75
+ entity_type: string;
76
+ name: string;
77
+ status: string | null;
78
+ parent_type: string | null;
79
+ parent_id: string | null;
80
+ code: string;
81
+ created_by: string | null;
82
+ created_date: string | null;
83
+ modified_by: string | null;
84
+ modified_date: string | null;
85
+ enterprise_id: string | null;
86
+ organization_id: number | null;
87
+ app_code: string | null;
88
+ is_system: number | null;
89
+ description: string | null;
90
+ }
91
+
92
+ export interface EntityListingResponse {
93
+ data: {
94
+ entity_tabs: EntityListTab[];
95
+ entity_list: EntityList[];
96
+ };
97
+ }
98
+
99
+ export interface APIParamsProps {
100
+ page?: number;
101
+ size?: number;
102
+ }
103
+
104
+ export type DropdownOption = {
105
+ value: string | number;
106
+ label: string;
107
+ };
@@ -0,0 +1,211 @@
1
+ import { CraftTableOptionsProps } from "./table-options";
2
+
3
+ interface OperationProps {
4
+ label: string;
5
+ value: string;
6
+ }
7
+
8
+ type OperationMapProps = {
9
+ [key in FilterInputDataTypes]?: OperationProps[];
10
+ };
11
+
12
+ export interface FilterOperationListProps {
13
+ label: string;
14
+ value: string;
15
+ }
16
+
17
+ export type FilterInputDataTypes =
18
+ | "text"
19
+ | "select"
20
+ | "multiselect"
21
+ | "date"
22
+ | "number";
23
+
24
+ export interface FilterColumnsListProps {
25
+ created_date: string | null;
26
+ entity_type: string;
27
+ id: string;
28
+ name: string;
29
+ status: string | null;
30
+ parent_type: string;
31
+ parent_id: string;
32
+ code: string | null;
33
+ created_by: string | null;
34
+ modified_by: string | null;
35
+ modified_date: string | null;
36
+ enterprise_id: string | null;
37
+ organization_id: string | null;
38
+ app_code: string | null;
39
+ mapped_entity_type: string;
40
+ menu_code: string | null;
41
+ table_name: string | null;
42
+ col_position: number;
43
+ sortable: string | null;
44
+ searchable: string | null;
45
+ attribute_key: string;
46
+ sort_type: string | null;
47
+ data_type: FilterInputDataTypes;
48
+ data_source_type: string | null;
49
+ datasource_list: any | null;
50
+ visible: string;
51
+ }
52
+
53
+ export interface FilterColumnsDataProps {
54
+ column_list: FilterColumnsListProps[];
55
+ operation_list: OperationMapProps;
56
+ saved_filter: FilterOperationListProps[];
57
+ }
58
+
59
+ export interface FilterDropdownDataProps {
60
+ [key: string]: FilterOperationListProps[];
61
+ }
62
+
63
+ export interface FilterDrawerProps {
64
+ tableStates: CraftTableOptionsProps;
65
+ open?: boolean;
66
+ onClose?: () => void;
67
+ onDeleteFilter?: () => void;
68
+ onSaveFilter?: (name: string) => void;
69
+ onUpdateFilter?: (name: string) => void;
70
+ columnsData: FilterColumnsDataProps;
71
+ dropdownData: FilterDropdownDataProps;
72
+ defaultFilters?: Array<{
73
+ filter_attribute: string;
74
+ filter_operator: string;
75
+ filter_value: string;
76
+ }>;
77
+ savedFilters?: Array<{ label: string; value: string }>;
78
+ tableData?: {
79
+ entity_list: any[];
80
+ };
81
+ }
82
+
83
+ export interface FilterCriteria {
84
+ columnId: string;
85
+ value: string | string[];
86
+ type: FilterInputDataTypes | undefined;
87
+ operator?: string | null;
88
+ dropdown?: {
89
+ label?: string;
90
+ value?: string;
91
+ };
92
+ optionList?: {
93
+ label?: string | undefined;
94
+ value?: string | undefined;
95
+ };
96
+ attribute_key?: string | undefined;
97
+ name: string | undefined;
98
+ }
99
+
100
+ export interface FilterStateProps {
101
+ filter_attribute: string;
102
+ filter_operator: string;
103
+ filter_value: string | string[];
104
+ }
105
+
106
+ export interface UpdatedFilterStateProps extends FilterStateProps {
107
+ id: string | number;
108
+ name: string | undefined;
109
+ data_type: FilterInputDataTypes | undefined;
110
+ attribute_key?: string;
111
+ dropdown_list?: {
112
+ label?: string;
113
+ value?: string;
114
+ }[];
115
+ optionList?: {
116
+ label?: string | undefined;
117
+ value?: string | undefined;
118
+ };
119
+ }
120
+
121
+ interface FilterDetail {
122
+ filter_attribute: string;
123
+ filter_operator: string;
124
+ filter_value: string | string[];
125
+ }
126
+
127
+ export interface createSavedFilterPaload {
128
+ name: string;
129
+ organization_id?: number;
130
+ enterprise_id?: number;
131
+ user_id?: number;
132
+ is_default: boolean;
133
+ mapped_entity_type: string;
134
+ status?: string;
135
+ entity_type: string;
136
+ filterDetails: FilterDetail[];
137
+ }
138
+
139
+ export interface deleteSavedFilterPayload {
140
+ name: string;
141
+ is_default: boolean;
142
+ id: string | number;
143
+ status?: string;
144
+ entity_type: string;
145
+ mapped_entity_type: string;
146
+ }
147
+
148
+ export interface updateSavedFilterPayload {
149
+ name: string;
150
+ is_default: boolean;
151
+ id: string | number;
152
+ status?: string;
153
+ entity_type: string;
154
+ mapped_entity_type: string;
155
+ filterDetails: FilterDetail[];
156
+ }
157
+
158
+ export interface deleteSavedFilterPayload {
159
+ name: string;
160
+ is_default: boolean;
161
+ id: string | number;
162
+ status?: string;
163
+ entity_type: string;
164
+ mapped_entity_type: string;
165
+ }
166
+ interface FilterDetail {
167
+ filter_attribute: string;
168
+ filter_operator: string;
169
+ filter_value: string | string[];
170
+ }
171
+
172
+ export interface FilterFormComponentProps {
173
+ columnsData: FilterColumnsDataProps;
174
+ dropdownData: FilterDropdownDataProps;
175
+ tableStates: CraftTableOptionsProps;
176
+ selectedFilters: UpdatedFilterStateProps[];
177
+ setSelectedFilters: React.Dispatch<
178
+ React.SetStateAction<UpdatedFilterStateProps[]>
179
+ >;
180
+ editMode?: boolean;
181
+ setEditMode?: React.Dispatch<React.SetStateAction<boolean>>;
182
+ setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
183
+ setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
184
+ }
185
+
186
+ export interface FilterMasterStateProps {
187
+ attributes: {
188
+ selected: string;
189
+ radio: string;
190
+ };
191
+ saved_filters: {
192
+ selectedId: string;
193
+ selectedName: string;
194
+ };
195
+ }
196
+
197
+ export interface AttributesFilterProps {
198
+ columnsData: FilterColumnsDataProps;
199
+ tableStates: CraftTableOptionsProps;
200
+ dropdownData: FilterDropdownDataProps;
201
+ searchTerm: string;
202
+ setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
203
+ }
204
+
205
+ export interface AttributesFilterSelectProps {
206
+ columnsData: FilterColumnsDataProps;
207
+ tableStates: CraftTableOptionsProps;
208
+ dropdownData: FilterDropdownDataProps;
209
+ searchTerm: string;
210
+ setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
211
+ }
@@ -5,6 +5,11 @@ import {
5
5
  ExpandedState,
6
6
  } from "@tanstack/react-table";
7
7
  import { Dispatch, SetStateAction } from "react";
8
+ import {
9
+ FilterMasterStateProps,
10
+ FilterOperationListProps,
11
+ FilterStateProps,
12
+ } from "./filter";
8
13
 
9
14
  export interface CraftTableOptionsProps {
10
15
  sorting: SortingState;
@@ -19,8 +24,16 @@ export interface CraftTableOptionsProps {
19
24
  setExpanded: Dispatch<SetStateAction<ExpandedState>>;
20
25
  wrapColumns: Record<string, boolean>;
21
26
  setWrapColumns: Dispatch<SetStateAction<Record<string, boolean>>>;
22
- globalWrapColumns: boolean | null;
23
- setGlobalWrapColumns: Dispatch<SetStateAction<boolean | null>>;
27
+ filters: FilterStateProps[];
28
+ setFilters: Dispatch<SetStateAction<FilterStateProps[]>>;
29
+ savedFilterEditValue: string | number;
30
+ setSavedFilterEditValue: Dispatch<SetStateAction<string | number>>;
31
+ filterToDelete: FilterOperationListProps | null;
32
+ setFilterToDelete: Dispatch<SetStateAction<FilterOperationListProps | null>>;
33
+ filterSelectedAttributeValue: string;
34
+ setFilterSelectedAttributeValue: Dispatch<SetStateAction<string>>;
35
+ filterMaster: FilterMasterStateProps | null;
36
+ setFilterMaster: Dispatch<SetStateAction<FilterMasterStateProps | null>>;
24
37
  }
25
38
 
26
39
  export interface CraftTableFeatureProps {
@@ -10,6 +10,7 @@ import {
10
10
  CraftTableOptionsProps,
11
11
  } from "./table-options";
12
12
  import React from "react";
13
+ import { FilterDrawerProps } from "./filter";
13
14
 
14
15
  export interface CraftTablePaginationProps {
15
16
  totalRows?: number;
@@ -26,17 +27,19 @@ interface LoadingOptionsProps {
26
27
  }
27
28
 
28
29
  export interface TopbarOptionsProps {
30
+ tableStates: CraftTableOptionsProps;
29
31
  leftSideComponent?: React.ReactNode;
30
32
  rightSideComponent?: React.ReactNode;
31
- showFullscreenToggle?: boolean;
32
33
  showColumnToggle?: boolean;
33
34
  showCompactTableToggle?: boolean;
34
35
  showChangeLayoutToggle?: boolean;
35
36
  viewMoreToggle?: boolean;
36
- showAddNewButton?: boolean;
37
37
  showSearch?: boolean;
38
- showFilter?: boolean;
39
- showCustomizationToggle?: boolean;
38
+ showSortingToggle?: boolean;
39
+ showFilterToggle?: boolean;
40
+ searchValue?: string;
41
+ onSearchChange?: (val: string) => void;
42
+ filterOptions?: FilterDrawerProps;
40
43
  }
41
44
 
42
45
  export interface CustomRenderContext<T> {
@@ -75,8 +78,6 @@ export interface CraftTableProps<T> {
75
78
  customRenderFn?: CustomRenderFnMap<T>;
76
79
  shouldHideColumn?: (accessorKey?: string) => boolean;
77
80
  styleOptions?: CraftTableStyleProps;
78
- searchValue?: string;
79
- onSearchChange?: (val: string) => void;
80
81
  }
81
82
  export interface CraftTableComponentProps<T> {
82
83
  table: Table<T>;
package/tsconfig.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "strict": true,
19
19
  "noUnusedLocals": true,
20
20
  "noUnusedParameters": true,
21
- "noFallthroughCasesInSwitch": true
21
+ "noFallthroughCasesInSwitch": true,
22
22
  },
23
23
  "include": ["src"],
24
24
  "references": [{ "path": "./tsconfig.node.json" }]
package/vite.config.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
3
 
4
4
  // https://vitejs.dev/config/
5
5
  export default defineConfig({
6
6
  plugins: [react()],
7
- })
7
+ });