cecomponent 2.0.84 → 2.0.85
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/ce-component-lib.css +1 -1
- package/dist/ce-component-lib.js +59 -59
- package/dist/ce-component-lib.mjs +4522 -3762
- package/dist/components/Common/DataGrid/CEDataGridDynamicsTable.d.ts +71 -9
- package/dist/components/Common/DataGrid/ManageViewsModal.d.ts +13 -0
- package/dist/components/Common/DataGrid/SaveViewModal.d.ts +15 -0
- package/dist/components/Common/DataGrid/ViewPersistenceControls.d.ts +14 -0
- package/dist/components/Common/DataGrid/hooks/useViewPersistence.d.ts +31 -0
- package/dist/components/Common/DataGrid/types/ViewConfig.d.ts +44 -0
- package/dist/components/Common/DataGrid/utils/ViewManager.d.ts +53 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { CustomAction } from '../../../types/customActions';
|
|
3
3
|
export type ComponentType = "text-input" | "number-input" | "auto-suggest" | "date-picker" | "label-text" | "drop-down-input";
|
|
4
|
+
type FreezeColumnsInput = number | Array<string | number>;
|
|
4
5
|
export interface ColumnConfig {
|
|
5
6
|
id: string;
|
|
6
7
|
label?: string;
|
|
@@ -11,7 +12,27 @@ export interface ColumnConfig {
|
|
|
11
12
|
elementType?: ComponentType;
|
|
12
13
|
required?: boolean;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
export interface GridContextState {
|
|
16
|
+
currentPage: number;
|
|
17
|
+
rowsPerPage: number;
|
|
18
|
+
sortConfig: {
|
|
19
|
+
column: string;
|
|
20
|
+
direction: "asc" | "desc";
|
|
21
|
+
} | null;
|
|
22
|
+
filters: {
|
|
23
|
+
[key: string]: {
|
|
24
|
+
value: string;
|
|
25
|
+
operator: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
searchQuery: string;
|
|
29
|
+
/** Optional persisted column visibility state */
|
|
30
|
+
visibleColumns?: string[];
|
|
31
|
+
/** Optional persisted column order state */
|
|
32
|
+
columnOrder?: string[];
|
|
33
|
+
/** Optional persisted frozen column ids */
|
|
34
|
+
frozenColumnIds?: string[];
|
|
35
|
+
}
|
|
15
36
|
interface CEDataGridDynamicTableProps {
|
|
16
37
|
title?: React.ReactNode;
|
|
17
38
|
jsonData: any[];
|
|
@@ -46,6 +67,18 @@ interface CEDataGridDynamicTableProps {
|
|
|
46
67
|
handleCancelClick?: (row: any, rowIndex: number) => void;
|
|
47
68
|
handleCopyClick?: (row: any, rowIndex: number) => void;
|
|
48
69
|
handleViewClick?: (row: any, rowIndex: number) => void;
|
|
70
|
+
/** Enables inline row-level edit mode (Edit → Save/Cancel) inside the grid. */
|
|
71
|
+
enableRowLevelEdit?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Custom icon (img src URL or SVG path) to use for the inline row-edit trigger button.
|
|
74
|
+
* When omitted, the default Edit icon is used.
|
|
75
|
+
* Has no effect when enableRowLevelEdit is false.
|
|
76
|
+
*/
|
|
77
|
+
rowEditIcon?: string;
|
|
78
|
+
/** Optional explicit allow-list of columns that can be edited in row edit mode. */
|
|
79
|
+
editableColumns?: string[];
|
|
80
|
+
/** Optional predicate for fine-grained editability by row+column. Returns true to allow editing. */
|
|
81
|
+
editableCellPredicate?: (rowData: any, columnId: string) => boolean;
|
|
49
82
|
clickableColumns?: string[];
|
|
50
83
|
isExportAllToExcel?: boolean;
|
|
51
84
|
conditionalClickableColumns?: Record<string, string[]>;
|
|
@@ -87,7 +120,7 @@ interface CEDataGridDynamicTableProps {
|
|
|
87
120
|
onDataUpdate?: (updatedData: {
|
|
88
121
|
fullData: any[];
|
|
89
122
|
updatedRow: any;
|
|
90
|
-
}) => void
|
|
123
|
+
}) => void | Promise<void>;
|
|
91
124
|
isOverrideCSS?: any;
|
|
92
125
|
showPagination?: boolean;
|
|
93
126
|
shouldResetSearchOnDataChange?: boolean;
|
|
@@ -130,18 +163,47 @@ interface CEDataGridDynamicTableProps {
|
|
|
130
163
|
*/
|
|
131
164
|
customActions?: CustomAction[];
|
|
132
165
|
shouldColumnPersist?: boolean;
|
|
166
|
+
enableFreezeControls?: boolean;
|
|
133
167
|
/**
|
|
134
|
-
*
|
|
135
|
-
* - number:
|
|
136
|
-
* - (string | number)[]:
|
|
168
|
+
* Controlled freeze: freeze columns by id, label, or 1-based visible index.
|
|
169
|
+
* - number: freeze first N visible columns
|
|
170
|
+
* - (string | number)[]: freeze by column id/label or 1-based index
|
|
137
171
|
*/
|
|
138
172
|
freezeColumns?: FreezeColumnsInput;
|
|
139
|
-
/** Initial freeze config for uncontrolled mode. */
|
|
173
|
+
/** Initial freeze config for uncontrolled mode (applied once on mount). */
|
|
140
174
|
defaultFreezeColumns?: FreezeColumnsInput;
|
|
141
|
-
/**
|
|
142
|
-
enableFreezeControls?: boolean;
|
|
143
|
-
/** Emits normalized frozen column ids when users update freeze settings from UI. */
|
|
175
|
+
/** Emits the current frozen column ids whenever the user pins or unpins a column. */
|
|
144
176
|
onFreezeColumnsChange?: (frozenColumnIds: string[]) => void;
|
|
177
|
+
/**
|
|
178
|
+
* Unique identifier for this grid instance (required for view management)
|
|
179
|
+
*/
|
|
180
|
+
gridId?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Enable automatic saving of grid state (columns, pagination)
|
|
183
|
+
* @default false
|
|
184
|
+
*/
|
|
185
|
+
enableAutoSave?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Enable automatic restoration of grid state on mount
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
enableAutoRestore?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Exposes manual Save/Restore actions so external buttons can control persistence.
|
|
193
|
+
*/
|
|
194
|
+
onViewPersistenceReady?: (actions: {
|
|
195
|
+
saveView: () => void;
|
|
196
|
+
restoreView: () => void;
|
|
197
|
+
}) => void;
|
|
198
|
+
/**
|
|
199
|
+
* Optional external grid context to restore/drive page, page-size, sort, filters and search.
|
|
200
|
+
* Consumers can persist this object and pass it back after data refresh.
|
|
201
|
+
*/
|
|
202
|
+
gridContext?: Partial<GridContextState>;
|
|
203
|
+
/**
|
|
204
|
+
* Emits whenever local grid context changes.
|
|
205
|
+
*/
|
|
206
|
+
onGridContextChange?: (context: GridContextState) => void;
|
|
145
207
|
}
|
|
146
208
|
declare const CEDataGridDynamicTable: React.FC<CEDataGridDynamicTableProps>;
|
|
147
209
|
export default CEDataGridDynamicTable;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SavedView } from './types/ViewConfig';
|
|
3
|
+
interface ManageViewsModalProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
views: SavedView[];
|
|
7
|
+
onLoadView: (viewId: string) => void;
|
|
8
|
+
onDeleteView: (viewId: string) => void;
|
|
9
|
+
onRenameView: (viewId: string, newName: string) => void;
|
|
10
|
+
isLoading?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const ManageViewsModal: React.FC<ManageViewsModalProps>;
|
|
13
|
+
export default ManageViewsModal;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface SaveViewModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onSave: (payload: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
includeFilters: boolean;
|
|
9
|
+
includeSort: boolean;
|
|
10
|
+
includeSearch: boolean;
|
|
11
|
+
}) => void;
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const SaveViewModal: React.FC<SaveViewModalProps>;
|
|
15
|
+
export default SaveViewModal;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Example component demonstrating how to use useViewPersistence hook
|
|
4
|
+
* with external Save/Restore buttons outside the grid
|
|
5
|
+
*/
|
|
6
|
+
interface ViewPersistenceControlsProps {
|
|
7
|
+
gridId?: string;
|
|
8
|
+
onSave?: () => void;
|
|
9
|
+
onRestore?: () => void;
|
|
10
|
+
/** @deprecated Use onRestore instead. */
|
|
11
|
+
onLoad?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const ViewPersistenceControls: React.FC<ViewPersistenceControlsProps>;
|
|
14
|
+
export default ViewPersistenceControls;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for managing automatic view persistence
|
|
3
|
+
* Automatically saves changes and provides save/load methods
|
|
4
|
+
*/
|
|
5
|
+
export declare const useViewPersistence: (gridId: string | undefined, enabled?: boolean) => {
|
|
6
|
+
autoSave: (visibleColumns: string[], columnOrder: string[], frozenColumnIds: string[] | undefined, currentPage: number, rowsPerPage: number, sortConfig?: any, filters?: any, searchQuery?: string) => void;
|
|
7
|
+
autoRestore: () => {
|
|
8
|
+
visibleColumns: string[];
|
|
9
|
+
columnOrder: string[];
|
|
10
|
+
frozenColumnIds?: string[];
|
|
11
|
+
currentPage: number;
|
|
12
|
+
rowsPerPage: number;
|
|
13
|
+
sort?: any;
|
|
14
|
+
filters?: any;
|
|
15
|
+
searchQuery?: string;
|
|
16
|
+
} | null;
|
|
17
|
+
saveView: (visibleColumns: string[], columnOrder: string[], frozenColumnIds: string[] | undefined, currentPage: number, rowsPerPage: number, viewName?: string, sortConfig?: any, filters?: any, searchQuery?: string) => string | null;
|
|
18
|
+
loadView: (viewId?: string) => {
|
|
19
|
+
visibleColumns: string[];
|
|
20
|
+
columnOrder: string[];
|
|
21
|
+
frozenColumnIds?: string[];
|
|
22
|
+
currentPage: number;
|
|
23
|
+
rowsPerPage: number;
|
|
24
|
+
sort?: any;
|
|
25
|
+
filters?: any;
|
|
26
|
+
searchQuery?: string;
|
|
27
|
+
} | null;
|
|
28
|
+
getSavedViews: () => import('../types/ViewConfig').SavedView[];
|
|
29
|
+
clearAllViews: () => boolean;
|
|
30
|
+
};
|
|
31
|
+
export default useViewPersistence;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View Configuration Types
|
|
3
|
+
* Defines structure for saving and loading grid view states
|
|
4
|
+
*/
|
|
5
|
+
export interface PaginationState {
|
|
6
|
+
currentPage: number;
|
|
7
|
+
rowsPerPage: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ColumnState {
|
|
10
|
+
visibleColumns: string[];
|
|
11
|
+
columnOrder: string[];
|
|
12
|
+
frozenColumnIds?: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface SortState {
|
|
15
|
+
column: string;
|
|
16
|
+
direction: "asc" | "desc";
|
|
17
|
+
}
|
|
18
|
+
export interface FilterState {
|
|
19
|
+
[key: string]: {
|
|
20
|
+
value: string;
|
|
21
|
+
operator: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface ViewConfig {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
columns: ColumnState;
|
|
29
|
+
pagination: PaginationState;
|
|
30
|
+
sort?: SortState | null;
|
|
31
|
+
filters?: FilterState;
|
|
32
|
+
searchQuery?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SavedView {
|
|
35
|
+
id: string;
|
|
36
|
+
config: ViewConfig;
|
|
37
|
+
}
|
|
38
|
+
export interface ViewContextPayload {
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
includeFilters?: boolean;
|
|
42
|
+
includeSort?: boolean;
|
|
43
|
+
includeSearch?: boolean;
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ViewConfig, SavedView, ColumnState, PaginationState, ViewContextPayload } from '../types/ViewConfig';
|
|
2
|
+
export declare class ViewManager {
|
|
3
|
+
private storageKeyPrefix;
|
|
4
|
+
/**
|
|
5
|
+
* Generate unique storage key for a grid instance
|
|
6
|
+
*/
|
|
7
|
+
private getStorageKey;
|
|
8
|
+
/**
|
|
9
|
+
* Get all saved views for a grid
|
|
10
|
+
*/
|
|
11
|
+
getSavedViews(gridId: string): SavedView[];
|
|
12
|
+
/**
|
|
13
|
+
* Save a new view configuration
|
|
14
|
+
*/
|
|
15
|
+
saveView(gridId: string, payload: ViewContextPayload, columns: ColumnState, pagination: PaginationState, additionalData?: {
|
|
16
|
+
sort?: any;
|
|
17
|
+
filters?: any;
|
|
18
|
+
searchQuery?: string;
|
|
19
|
+
}): SavedView;
|
|
20
|
+
/**
|
|
21
|
+
* Update an existing view
|
|
22
|
+
*/
|
|
23
|
+
updateView(gridId: string, viewId: string, columns: ColumnState, pagination: PaginationState, additionalData?: {
|
|
24
|
+
sort?: any;
|
|
25
|
+
filters?: any;
|
|
26
|
+
searchQuery?: string;
|
|
27
|
+
}): SavedView | null;
|
|
28
|
+
/**
|
|
29
|
+
* Load a saved view configuration
|
|
30
|
+
*/
|
|
31
|
+
loadView(gridId: string, viewId: string): ViewConfig | null;
|
|
32
|
+
/**
|
|
33
|
+
* Delete a saved view
|
|
34
|
+
*/
|
|
35
|
+
deleteView(gridId: string, viewId: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Rename a saved view
|
|
38
|
+
*/
|
|
39
|
+
renameView(gridId: string, viewId: string, newName: string, description?: string): SavedView | null;
|
|
40
|
+
/**
|
|
41
|
+
* Clear all views for a grid
|
|
42
|
+
*/
|
|
43
|
+
clearAllViews(gridId: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Export views as JSON
|
|
46
|
+
*/
|
|
47
|
+
exportViews(gridId: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Import views from JSON
|
|
50
|
+
*/
|
|
51
|
+
importViews(gridId: string, jsonString: string): boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare const viewManager: ViewManager;
|
package/package.json
CHANGED